Skip to content

Commit 4e82ec5

Browse files
committed
Merge remote-tracking branch 'upstream/master' into add-starred-feature
Merge most updated upstream source.
2 parents 8875aaa + 62ddf65 commit 4e82ec5

25 files changed

Lines changed: 1219 additions & 830 deletions

‎.gitignore‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,4 @@ bin/
2020

2121
db/*.sqlite
2222
.DS_Store
23+
.localeapp

‎Gemfile‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ gem "sinatra"
44
gem "sinatra-activerecord"
55
gem "sinatra-flash"
66
gem "sinatra-contrib", github: "sinatra/sinatra-contrib"
7+
gem "sinatra-assetpack", :require => "sinatra/assetpack"
78
gem "i18n"
89

910
gem "rake"
@@ -15,8 +16,8 @@ gem "feedzirra", github: "swanson/feedzirra"
1516
gem "loofah"
1617
gem "nokogiri"
1718
gem "feedbag", github: "dwillis/feedbag"
18-
1919
gem "coveralls", require: false
20+
gem "uglifier"
2021

2122
group :production do
2223
gem "unicorn"

‎Gemfile.lock‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,15 @@ GEM
6262
diff-lcs (1.2.4)
6363
dotenv (0.7.0)
6464
eventmachine (1.0.3)
65+
execjs (1.4.0)
66+
multi_json (~> 1.0)
6567
faker (1.1.2)
6668
i18n (~> 0.5)
6769
foreman (0.63.0)
6870
dotenv (>= 0.7)
6971
thor (>= 0.13.6)
7072
i18n (0.6.4)
73+
jsmin (1.0.1)
7174
kgio (2.8.0)
7275
loofah (1.2.1)
7376
nokogiri (>= 1.4.4)
@@ -118,13 +121,22 @@ GEM
118121
sinatra-activerecord (1.2.2)
119122
activerecord (~> 3.0)
120123
sinatra (~> 1.0)
124+
sinatra-assetpack (0.2.2)
125+
backports
126+
jsmin
127+
rack-test
128+
sinatra
129+
tilt (>= 1.3.0)
121130
sinatra-flash (0.3.0)
122131
sinatra (>= 1.0.0)
123132
slop (3.4.4)
124133
sqlite3 (1.3.7)
125134
thor (0.18.1)
126135
tilt (1.4.1)
127136
tzinfo (0.3.37)
137+
uglifier (2.1.0)
138+
execjs (>= 0.3.0)
139+
multi_json (~> 1.0, >= 1.0.2)
128140
unicorn (4.6.2)
129141
kgio (~> 2.6)
130142
rack
@@ -155,8 +167,10 @@ DEPENDENCIES
155167
shotgun
156168
sinatra
157169
sinatra-activerecord
170+
sinatra-assetpack
158171
sinatra-contrib!
159172
sinatra-flash
160173
sqlite3
174+
uglifier
161175
unicorn
162176
will_paginate

‎README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ Stringer has been translated to [several other languages](config/locales). Your
7676

7777
To set your locale on Heroku, run `heroku config:set LOCALE=en`.
7878

79-
If you would like to translate Stringer to your preferred language, please open a pull request.
79+
If you would like to translate Stringer to your preferred language, please use [LocaleApp](http://www.localeapp.com/projects/4637).
8080

8181
# Development
8282

‎app.rb‎

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
require "sinatra/activerecord"
33
require "sinatra/flash"
44
require "sinatra/contrib/all"
5+
require "sinatra/assetpack"
56
require "json"
67
require "i18n"
78
require "will_paginate"
@@ -17,6 +18,7 @@ class Stringer < Sinatra::Base
1718
set :database_file, "config/database.yml"
1819
set :views, "app/views"
1920
set :public_dir, "app/public"
21+
set :root, File.dirname(__FILE__)
2022

2123
enable :sessions
2224
set :session_secret, ENV["SECRET_TOKEN"] || "secret!"
@@ -25,6 +27,7 @@ class Stringer < Sinatra::Base
2527
register Sinatra::ActiveRecordExtension
2628
register Sinatra::Flash
2729
register Sinatra::Contrib
30+
register Sinatra::AssetPack
2831

2932
ActiveRecord::Base.include_root_in_json = false
3033
end
@@ -49,6 +52,36 @@ def t(*args)
4952
end
5053
end
5154

55+
assets {
56+
serve "/js", from: "app/public/js"
57+
serve "/css", from: "app/public/css"
58+
serve "/images", from: "app/public/img"
59+
60+
js :application, "/js/application.js", [
61+
"/js/jquery-min.js",
62+
"/js/bootstrap-min.js",
63+
"/js/bootstrap.file-input.js",
64+
"/js/mousetrap-min.js",
65+
"/js/jquery-visible-min.js",
66+
"/js/underscore-min.js",
67+
"/js/backbone-min.js",
68+
"/js/app.js"
69+
]
70+
71+
css :application, "/css/application.css", [
72+
"/css/bootstrap-min.css",
73+
"/css/flat-ui-no-icons.css",
74+
"/css/font-awesome-min.css",
75+
"/css/styles.css"
76+
]
77+
78+
js_compression :uglify
79+
css_compression :simple
80+
81+
prebuild true
82+
cache_dynamic_assets true
83+
}
84+
5285
before do
5386
I18n.locale = ENV["LOCALE"].blank? ? :en : ENV["LOCALE"].to_sym
5487

‎app/models/story.rb‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def source
2020
end
2121

2222
def pretty_date
23-
self.published.strftime("%A, %B %d")
23+
I18n.l(self.published)
2424
end
2525

2626
def as_json(options = {})

‎app/public/js/app.js‎

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,25 +87,35 @@ var StoryView = Backbone.View.extend({
8787

8888
initialize: function() {
8989
this.template = _.template($(this.template).html());
90-
this.listenTo(this.model, 'change', this.render);
90+
this.listenTo(this.model, 'add', this.render);
91+
this.listenTo(this.model, 'change:selected', this.itemSelected);
92+
this.listenTo(this.model, 'change:open', this.itemOpened);
93+
this.listenTo(this.model, 'change:is_read', this.itemRead);
9194
},
9295

9396
render: function() {
9497
this.$el.html(this.template(this.model.toJSON()));
98+
return this;
99+
},
95100

101+
itemRead: function() {
96102
this.$el.toggleClass("read", this.model.get("is_read"));
103+
},
97104

105+
itemOpened: function() {
98106
if (this.model.get("open")) {
99107
this.$el.addClass("open");
100108
$(".story-lead", this.$el).fadeOut(1000);
109+
window.scrollTo(0, this.$el.offset().top);
101110
} else {
102111
this.$el.removeClass("open");
103112
$(".story-lead", this.$el).show();
104113
}
114+
},
105115

116+
itemSelected: function() {
106117
this.$el.toggleClass("cursor", this.model.get("selected"));
107-
108-
return this;
118+
if (!this.$el.visible()) window.scrollTo(0, this.$el.offset().top);
109119
},
110120

111121
storyClicked: function() {
@@ -166,6 +176,8 @@ var StoryList = Backbone.Collection.extend({
166176
moveCursorDown: function() {
167177
if (this.cursorPosition < this.max_position()) {
168178
this.cursorPosition++;
179+
} else {
180+
this.cursorPosition = 0;
169181
}
170182

171183
this.at(this.cursorPosition).select();

‎app/public/js/jquery-visible-min.js‎

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎app/views/js/templates/_story.js.erb‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
</div>
3131
<div class="pull-right story-actions">
3232
<div class="story-keep-unread">
33-
<i class="icon-check{{ if(!keep_unread) { }}-empty{{ } }}"></i> Keep unread
33+
<i class="icon-check{{ if(!keep_unread) { }}-empty{{ } }}"></i> <%= t('stories.keep_unread') %>
3434
</div>
3535
<a class="story-permalink" href="{{= permalink }}">
3636
<i class="icon-external-link"></i>

‎app/views/layout.erb‎

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,9 @@
88
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
99
<link rel="shortcut icon" href="/img/favicon.png">
1010
<link href="http://fonts.googleapis.com/css?family=Lato:300,400,700,900,400italic" rel="stylesheet" type="text/css">
11-
12-
<link rel="stylesheet" type="text/css" href="/css/bootstrap-min.css">
13-
<link rel="stylesheet" type="text/css" href="/css/flat-ui-no-icons.css">
14-
<link rel="stylesheet" type="text/css" href="/css/font-awesome-min.css">
15-
<link rel="stylesheet" type="text/css" href="/css/styles.css">
1611

17-
<script type="text/javascript" src="/js/jquery-min.js"></script>
18-
<script type="text/javascript" src="/js/mousetrap-min.js"></script>
19-
<script type="text/javascript" src="/js/bootstrap-min.js"></script>
20-
<script type="text/javascript" src="/js/underscore-min.js"></script>
21-
<script type="text/javascript" src="/js/backbone-min.js"></script>
22-
<script type="text/javascript" src="/js/app.js"></script>
12+
<%= css :application %>
13+
<%= js :application %>
2314

2415
<%= yield_content :head %>
2516
</head>
@@ -43,7 +34,7 @@
4334
<div id="footer">
4435
<%= render_partial :footer %>
4536
</div>
46-
37+
4738
<script>
4839
window.i18n = {};
4940
window.i18n.titleName = "<%= t('layout.title') %>";

0 commit comments

Comments
 (0)