locomotivecms_steam 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +21 -0
- data/.travis.yml +4 -0
- data/CHANGELOG.md +19 -0
- data/Gemfile +8 -0
- data/Gemfile.lock +188 -0
- data/LICENSE +20 -0
- data/README.md +36 -0
- data/Rakefile +17 -0
- data/bin/publish +28 -0
- data/config/locales/de.yml +157 -0
- data/config/locales/en.yml +189 -0
- data/config/locales/es.yml +133 -0
- data/config/locales/et.yml +154 -0
- data/config/locales/fr.yml +148 -0
- data/config/locales/it.yml +155 -0
- data/config/locales/nb.yml +191 -0
- data/config/locales/nl.yml +160 -0
- data/config/locales/pl.yml +203 -0
- data/config/locales/pt-BR.yml +139 -0
- data/config/locales/ru.yml +224 -0
- data/lib/locomotive/steam/core_ext.rb +5 -0
- data/lib/locomotive/steam/core_ext/array.rb +3 -0
- data/lib/locomotive/steam/core_ext/boolean/false.rb +3 -0
- data/lib/locomotive/steam/core_ext/boolean/true.rb +3 -0
- data/lib/locomotive/steam/core_ext/hash.rb +27 -0
- data/lib/locomotive/steam/core_ext/string.rb +8 -0
- data/lib/locomotive/steam/exceptions.rb +62 -0
- data/lib/locomotive/steam/initializers.rb +5 -0
- data/lib/locomotive/steam/initializers/i18n.rb +3 -0
- data/lib/locomotive/steam/initializers/markdown.rb +27 -0
- data/lib/locomotive/steam/initializers/will_paginate.rb +16 -0
- data/lib/locomotive/steam/liquid.rb +22 -0
- data/lib/locomotive/steam/liquid/drops/base.rb +46 -0
- data/lib/locomotive/steam/liquid/drops/content_entry.rb +48 -0
- data/lib/locomotive/steam/liquid/drops/content_types.rb +117 -0
- data/lib/locomotive/steam/liquid/drops/page.rb +28 -0
- data/lib/locomotive/steam/liquid/drops/session_proxy.rb +18 -0
- data/lib/locomotive/steam/liquid/drops/site.rb +26 -0
- data/lib/locomotive/steam/liquid/errors.rb +17 -0
- data/lib/locomotive/steam/liquid/filters/date.rb +136 -0
- data/lib/locomotive/steam/liquid/filters/html.rb +188 -0
- data/lib/locomotive/steam/liquid/filters/misc.rb +49 -0
- data/lib/locomotive/steam/liquid/filters/resize.rb +18 -0
- data/lib/locomotive/steam/liquid/filters/text.rb +55 -0
- data/lib/locomotive/steam/liquid/filters/translate.rb +28 -0
- data/lib/locomotive/steam/liquid/patches.rb +47 -0
- data/lib/locomotive/steam/liquid/scopeable.rb +149 -0
- data/lib/locomotive/steam/liquid/tags/consume.rb +97 -0
- data/lib/locomotive/steam/liquid/tags/csrf.rb +34 -0
- data/lib/locomotive/steam/liquid/tags/editable.rb +6 -0
- data/lib/locomotive/steam/liquid/tags/editable/base.rb +50 -0
- data/lib/locomotive/steam/liquid/tags/editable/control.rb +19 -0
- data/lib/locomotive/steam/liquid/tags/editable/file.rb +15 -0
- data/lib/locomotive/steam/liquid/tags/editable/long_text.rb +15 -0
- data/lib/locomotive/steam/liquid/tags/editable/short_text.rb +20 -0
- data/lib/locomotive/steam/liquid/tags/editable/text.rb +15 -0
- data/lib/locomotive/steam/liquid/tags/extends.rb +25 -0
- data/lib/locomotive/steam/liquid/tags/google_analytics.rb +28 -0
- data/lib/locomotive/steam/liquid/tags/hybrid.rb +27 -0
- data/lib/locomotive/steam/liquid/tags/inline_editor.rb +16 -0
- data/lib/locomotive/steam/liquid/tags/link_to.rb +56 -0
- data/lib/locomotive/steam/liquid/tags/locale_switcher.rb +106 -0
- data/lib/locomotive/steam/liquid/tags/nav.rb +287 -0
- data/lib/locomotive/steam/liquid/tags/paginate.rb +105 -0
- data/lib/locomotive/steam/liquid/tags/path_helper.rb +98 -0
- data/lib/locomotive/steam/liquid/tags/path_to.rb +36 -0
- data/lib/locomotive/steam/liquid/tags/seo.rb +74 -0
- data/lib/locomotive/steam/liquid/tags/session_assign.rb +41 -0
- data/lib/locomotive/steam/liquid/tags/snippet.rb +63 -0
- data/lib/locomotive/steam/liquid/tags/with_scope.rb +44 -0
- data/lib/locomotive/steam/listen.rb +64 -0
- data/lib/locomotive/steam/logger.rb +54 -0
- data/lib/locomotive/steam/monkey_patches.rb +5 -0
- data/lib/locomotive/steam/monkey_patches/better_errors.rb +70 -0
- data/lib/locomotive/steam/monkey_patches/dragonfly.rb +79 -0
- data/lib/locomotive/steam/monkey_patches/haml.rb +15 -0
- data/lib/locomotive/steam/monkey_patches/httparty.rb +46 -0
- data/lib/locomotive/steam/monkey_patches/mounter.rb +32 -0
- data/lib/locomotive/steam/server.rb +81 -0
- data/lib/locomotive/steam/server/dynamic_assets.rb +33 -0
- data/lib/locomotive/steam/server/entry_submission.rb +120 -0
- data/lib/locomotive/steam/server/favicon.rb +18 -0
- data/lib/locomotive/steam/server/locale.rb +42 -0
- data/lib/locomotive/steam/server/logging.rb +32 -0
- data/lib/locomotive/steam/server/middleware.rb +61 -0
- data/lib/locomotive/steam/server/page.rb +69 -0
- data/lib/locomotive/steam/server/path.rb +34 -0
- data/lib/locomotive/steam/server/renderer.rb +118 -0
- data/lib/locomotive/steam/server/templatized_page.rb +32 -0
- data/lib/locomotive/steam/server/timezone.rb +18 -0
- data/lib/locomotive/steam/standalone_server.rb +33 -0
- data/lib/locomotive/steam/version.rb +5 -0
- data/lib/steam.rb +4 -0
- data/locomotivecms_steam.gemspec +42 -0
- data/spec/fixtures/default/README +0 -0
- data/spec/fixtures/default/app/content_types/bands.yml +19 -0
- data/spec/fixtures/default/app/content_types/events.yml +25 -0
- data/spec/fixtures/default/app/content_types/messages.yml +17 -0
- data/spec/fixtures/default/app/content_types/songs.yml +25 -0
- data/spec/fixtures/default/app/content_types/updates.yml +33 -0
- data/spec/fixtures/default/app/views/pages/404.liquid.haml +10 -0
- data/spec/fixtures/default/app/views/pages/about_us.fr.liquid.haml +7 -0
- data/spec/fixtures/default/app/views/pages/about_us.liquid.haml +21 -0
- data/spec/fixtures/default/app/views/pages/about_us.nb.liquid.haml +4 -0
- data/spec/fixtures/default/app/views/pages/about_us/jane_doe.liquid.haml +4 -0
- data/spec/fixtures/default/app/views/pages/about_us/john_doe.fr.liquid.haml +5 -0
- data/spec/fixtures/default/app/views/pages/about_us/john_doe.liquid.haml +6 -0
- data/spec/fixtures/default/app/views/pages/all.liquid.haml +13 -0
- data/spec/fixtures/default/app/views/pages/archives/news.liquid.haml +10 -0
- data/spec/fixtures/default/app/views/pages/contact.liquid.haml +54 -0
- data/spec/fixtures/default/app/views/pages/contest.liquid.haml +18 -0
- data/spec/fixtures/default/app/views/pages/events.liquid.haml +42 -0
- data/spec/fixtures/default/app/views/pages/filtered.liquid.haml +10 -0
- data/spec/fixtures/default/app/views/pages/grunge_bands.liquid.haml +8 -0
- data/spec/fixtures/default/app/views/pages/index.fr.liquid.haml +3 -0
- data/spec/fixtures/default/app/views/pages/index.liquid.haml +100 -0
- data/spec/fixtures/default/app/views/pages/music.fr.liquid.haml +4 -0
- data/spec/fixtures/default/app/views/pages/music.liquid.haml +42 -0
- data/spec/fixtures/default/app/views/pages/songs/template.fr.liquid.haml +16 -0
- data/spec/fixtures/default/app/views/pages/songs/template.liquid.haml +18 -0
- data/spec/fixtures/default/app/views/pages/songs/template/band.liquid.haml +16 -0
- data/spec/fixtures/default/app/views/pages/store.fr.liquid.haml +5 -0
- data/spec/fixtures/default/app/views/pages/store.liquid +5 -0
- data/spec/fixtures/default/app/views/pages/tags/nav.liquid.haml +6 -0
- data/spec/fixtures/default/app/views/pages/tags/nav_in_deep.liquid.haml +6 -0
- data/spec/fixtures/default/app/views/pages/unlisted_pages.liquid.haml +9 -0
- data/spec/fixtures/default/app/views/snippets/A_Complicated-one.liquid.haml +1 -0
- data/spec/fixtures/default/app/views/snippets/footer.liquid.haml +6 -0
- data/spec/fixtures/default/app/views/snippets/header.liquid.haml +1 -0
- data/spec/fixtures/default/app/views/snippets/song.fr.liquid.haml +8 -0
- data/spec/fixtures/default/app/views/snippets/song.liquid +12 -0
- data/spec/fixtures/default/config/deploy.yml +12 -0
- data/spec/fixtures/default/config/deploy_example.yml +12 -0
- data/spec/fixtures/default/config/site.yml +15 -0
- data/spec/fixtures/default/config/translations.yml +3 -0
- data/spec/fixtures/default/data/bands.yml +10 -0
- data/spec/fixtures/default/data/events.yml +53 -0
- data/spec/fixtures/default/data/songs.yml +46 -0
- data/spec/fixtures/default/data/updates.yml +48 -0
- data/spec/fixtures/default/public/fonts/chunkfive-webfont.eot +0 -0
- data/spec/fixtures/default/public/fonts/chunkfive-webfont.svg +213 -0
- data/spec/fixtures/default/public/fonts/chunkfive-webfont.ttf +0 -0
- data/spec/fixtures/default/public/fonts/chunkfive-webfont.woff +0 -0
- data/spec/fixtures/default/public/fonts/chunkfive.css +8 -0
- data/spec/fixtures/default/public/fonts/chunkfive.otf +0 -0
- data/spec/fixtures/default/public/images/nav_on.png +0 -0
- data/spec/fixtures/default/public/images/photo_frame.png +0 -0
- data/spec/fixtures/default/public/images/sep.png +0 -0
- data/spec/fixtures/default/public/images/top.jpg +0 -0
- data/spec/fixtures/default/public/javascripts/application.js.coffee +2 -0
- data/spec/fixtures/default/public/javascripts/common.js +1 -0
- data/spec/fixtures/default/public/samples/asset_collections/cover.jpg +0 -0
- data/spec/fixtures/default/public/samples/photo.jpg +0 -0
- data/spec/fixtures/default/public/samples/photo_2.jpg +0 -0
- data/spec/fixtures/default/public/stylesheets/application.css +64 -0
- data/spec/fixtures/default/public/stylesheets/other/extra.css.less +8 -0
- data/spec/fixtures/default/public/stylesheets/other/style.css.scss +13 -0
- data/spec/fixtures/default/public/stylesheets/reboot.css +82 -0
- data/spec/integration/integration_helper.rb +15 -0
- data/spec/integration/server/basic_spec.rb +170 -0
- data/spec/integration/server/contact_form_spec.rb +111 -0
- data/spec/integration/server/liquid_spec.rb +91 -0
- data/spec/integration/server/with_scope_spec.rb +20 -0
- data/spec/locales/locales_spec.rb +22 -0
- data/spec/spec_helper.rb +21 -0
- data/spec/support.rb +4 -0
- data/spec/support/examples/locale_file.rb +14 -0
- data/spec/support/examples/matching_locale.rb +8 -0
- data/spec/support/helpers.rb +22 -0
- data/spec/support/matchers/hash.rb +5 -0
- metadata +564 -0
@@ -0,0 +1,224 @@
|
|
1
|
+
ru:
|
2
|
+
locomotive:
|
3
|
+
locales:
|
4
|
+
en: Английский
|
5
|
+
de: Немецкий
|
6
|
+
fr: Французский
|
7
|
+
pl: Польский
|
8
|
+
pt-BR: "Браз. - Португальский"
|
9
|
+
it: Итальянский
|
10
|
+
nl: Голландский
|
11
|
+
nb: Норвежский
|
12
|
+
es: Испанский
|
13
|
+
ru: Русский
|
14
|
+
et: Эстонский
|
15
|
+
|
16
|
+
errors:
|
17
|
+
messages:
|
18
|
+
blank: "can not be blank"
|
19
|
+
|
20
|
+
pagination:
|
21
|
+
previous: "« Предыдущая"
|
22
|
+
next: "Следующая »"
|
23
|
+
|
24
|
+
date:
|
25
|
+
formats:
|
26
|
+
# Форматы указываются в виде, поддерживаемом strftime.
|
27
|
+
# По умолчанию используется default.
|
28
|
+
# Можно добавлять собственные форматы
|
29
|
+
#
|
30
|
+
#
|
31
|
+
# Use the strftime parameters for formats.
|
32
|
+
# When no format has been given, it uses default.
|
33
|
+
# You can provide other formats here if you like!
|
34
|
+
default: "%d.%m.%Y"
|
35
|
+
short: "%d %b"
|
36
|
+
long: "%d %B %Y"
|
37
|
+
|
38
|
+
# Названия дней недели -- контекстные и отдельностоящие
|
39
|
+
day_names: [воскресенье, понедельник, вторник, среда, четверг, пятница, суббота]
|
40
|
+
standalone_day_names: [Воскресенье, Понедельник, Вторник, Среда, Четверг, Пятница, Суббота]
|
41
|
+
abbr_day_names: [Вс, Пн, Вт, Ср, Чт, Пт, Сб]
|
42
|
+
|
43
|
+
# Названия месяцев -- сокращенные и полные, плюс отдельностоящие.
|
44
|
+
# Не забудьте nil в начале массиве (~)
|
45
|
+
#
|
46
|
+
#
|
47
|
+
# Don't forget the nil at the beginning; there's no such thing as a 0th month
|
48
|
+
month_names: [~, января, февраля, марта, апреля, мая, июня, июля, августа, сентября, октября, ноября, декабря]
|
49
|
+
standalone_month_names: [~, Январь, Февраль, Март, Апрель, Май, Июнь, Июль, Август, Сентябрь, Октябрь, Ноябрь, Декабрь]
|
50
|
+
abbr_month_names: [~, янв., февр., марта, апр., мая, июня, июля, авг., сент., окт., нояб., дек.]
|
51
|
+
standalone_abbr_month_names: [~, янв., февр., март, апр., май, июнь, июль, авг., сент., окт., нояб., дек.]
|
52
|
+
|
53
|
+
# Порядок компонентов даты для хелперов
|
54
|
+
#
|
55
|
+
#
|
56
|
+
# Used in date_select and datime_select.
|
57
|
+
order:
|
58
|
+
- :day
|
59
|
+
- :month
|
60
|
+
- :year
|
61
|
+
|
62
|
+
time:
|
63
|
+
# Форматы времени
|
64
|
+
formats:
|
65
|
+
default: "%a, %d %b %Y, %H:%M:%S %z"
|
66
|
+
short: "%d %b, %H:%M"
|
67
|
+
long: "%d %B %Y, %H:%M"
|
68
|
+
|
69
|
+
# am/pm решено перевести как "утра/вечера" :)
|
70
|
+
am: "утра"
|
71
|
+
pm: "вечера"
|
72
|
+
|
73
|
+
number:
|
74
|
+
# Используется в number_with_delimiter()
|
75
|
+
# Также является установками по умолчанию для 'currency', 'percentage', 'precision', 'human'
|
76
|
+
#
|
77
|
+
# Used in number_with_delimiter()
|
78
|
+
# These are also the defaults for 'currency', 'percentage', 'precision', and 'human'
|
79
|
+
format:
|
80
|
+
# Sets the separator between the units, for more precision (e.g. 1.0 / 2.0 == 0.5)
|
81
|
+
separator: "."
|
82
|
+
# Delimets thousands (e.g. 1,000,000 is a million) (always in groups of three)
|
83
|
+
delimiter: " "
|
84
|
+
# Number of decimals, behind the separator (the number 1 with a precision of 2 gives: 1.00)
|
85
|
+
precision: 3
|
86
|
+
|
87
|
+
# Used in number_to_currency()
|
88
|
+
currency:
|
89
|
+
format:
|
90
|
+
# Формат отображения валюты и обозначение самой валюты
|
91
|
+
#
|
92
|
+
#
|
93
|
+
# Where is the currency sign? %u is the currency unit, %n the number (default: $5.00)
|
94
|
+
format: "%n %u"
|
95
|
+
unit: "руб."
|
96
|
+
# These three are to override number.format and are optional
|
97
|
+
separator: "."
|
98
|
+
delimiter: " "
|
99
|
+
precision: 2
|
100
|
+
|
101
|
+
# Used in number_to_percentage()
|
102
|
+
percentage:
|
103
|
+
format:
|
104
|
+
# These three are to override number.format and are optional
|
105
|
+
# separator:
|
106
|
+
delimiter: ""
|
107
|
+
|
108
|
+
# Used in number_to_precision()
|
109
|
+
precision:
|
110
|
+
format:
|
111
|
+
# These three are to override number.format and are optional
|
112
|
+
# separator:
|
113
|
+
delimiter: ""
|
114
|
+
# precision:
|
115
|
+
|
116
|
+
# Used in number_to_human_size()
|
117
|
+
human:
|
118
|
+
format:
|
119
|
+
# These three are to override number.format and are optional
|
120
|
+
# separator:
|
121
|
+
delimiter: ""
|
122
|
+
precision: 1
|
123
|
+
|
124
|
+
# Rails 2.2
|
125
|
+
# storage_units: [байт, КБ, МБ, ГБ, ТБ]
|
126
|
+
|
127
|
+
# Rails 2.3
|
128
|
+
storage_units:
|
129
|
+
# Storage units output formatting.
|
130
|
+
# %u is the storage unit, %n is the number (default: 2 MB)
|
131
|
+
format: "%n %u"
|
132
|
+
units:
|
133
|
+
byte:
|
134
|
+
one: "байт"
|
135
|
+
few: "байта"
|
136
|
+
many: "байт"
|
137
|
+
other: "байта"
|
138
|
+
kb: "КБ"
|
139
|
+
mb: "МБ"
|
140
|
+
gb: "ГБ"
|
141
|
+
tb: "ТБ"
|
142
|
+
|
143
|
+
# Используется в хелперах distance_of_time_in_words(), distance_of_time_in_words_to_now(), time_ago_in_words()
|
144
|
+
#
|
145
|
+
#
|
146
|
+
# Used in distance_of_time_in_words(), distance_of_time_in_words_to_now(), time_ago_in_words()
|
147
|
+
datetime:
|
148
|
+
distance_in_words:
|
149
|
+
half_a_minute: "меньше минуты"
|
150
|
+
less_than_x_seconds:
|
151
|
+
one: "меньше %{count} секунды"
|
152
|
+
few: "меньше %{count} секунд"
|
153
|
+
many: "меньше %{count} секунд"
|
154
|
+
other: "меньше %{count} секунды"
|
155
|
+
x_seconds:
|
156
|
+
one: "%{count} секунда"
|
157
|
+
few: "%{count} секунды"
|
158
|
+
many: "%{count} секунд"
|
159
|
+
other: "%{count} секунды"
|
160
|
+
less_than_x_minutes:
|
161
|
+
one: "меньше %{count} минуты"
|
162
|
+
few: "меньше %{count} минут"
|
163
|
+
many: "меньше %{count} минут"
|
164
|
+
other: "меньше %{count} минуты"
|
165
|
+
x_minutes:
|
166
|
+
one: "%{count} минуту"
|
167
|
+
few: "%{count} минуты"
|
168
|
+
many: "%{count} минут"
|
169
|
+
other: "%{count} минуты"
|
170
|
+
about_x_hours:
|
171
|
+
one: "около %{count} часа"
|
172
|
+
few: "около %{count} часов"
|
173
|
+
many: "около %{count} часов"
|
174
|
+
other: "около %{count} часа"
|
175
|
+
x_days:
|
176
|
+
one: "%{count} день"
|
177
|
+
few: "%{count} дня"
|
178
|
+
many: "%{count} дней"
|
179
|
+
other: "%{count} дня"
|
180
|
+
about_x_months:
|
181
|
+
one: "около %{count} месяца"
|
182
|
+
few: "около %{count} месяцев"
|
183
|
+
many: "около %{count} месяцев"
|
184
|
+
other: "около %{count} месяца"
|
185
|
+
x_months:
|
186
|
+
one: "%{count} месяц"
|
187
|
+
few: "%{count} месяца"
|
188
|
+
many: "%{count} месяцев"
|
189
|
+
other: "%{count} месяца"
|
190
|
+
about_x_years:
|
191
|
+
one: "около %{count} года"
|
192
|
+
few: "около %{count} лет"
|
193
|
+
many: "около %{count} лет"
|
194
|
+
other: "около %{count} лет"
|
195
|
+
over_x_years:
|
196
|
+
one: "больше %{count} года"
|
197
|
+
few: "больше %{count} лет"
|
198
|
+
many: "больше %{count} лет"
|
199
|
+
other: "больше %{count} лет"
|
200
|
+
almost_x_years:
|
201
|
+
one: "почти %{count} год"
|
202
|
+
few: "почти %{count} года"
|
203
|
+
many: "почти %{count} лет"
|
204
|
+
other: "почти %{count} лет"
|
205
|
+
prompts:
|
206
|
+
year: "Год"
|
207
|
+
month: "Месяц"
|
208
|
+
day: "День"
|
209
|
+
hour: "Часов"
|
210
|
+
minute: "Минут"
|
211
|
+
second: "Секунд"
|
212
|
+
|
213
|
+
|
214
|
+
# Used in array.to_sentence.
|
215
|
+
support:
|
216
|
+
array:
|
217
|
+
# Rails 2.2
|
218
|
+
sentence_connector: "и"
|
219
|
+
skip_last_comma: true
|
220
|
+
|
221
|
+
# Rails 2.3
|
222
|
+
words_connector: ", "
|
223
|
+
two_words_connector: " и "
|
224
|
+
last_word_connector: " и "
|
@@ -0,0 +1,27 @@
|
|
1
|
+
class Hash
|
2
|
+
|
3
|
+
def underscore_keys
|
4
|
+
new_hash = {}
|
5
|
+
|
6
|
+
self.each_pair do |key, value|
|
7
|
+
if value.respond_to?(:collect!) # Array
|
8
|
+
value.collect do |item|
|
9
|
+
if item.respond_to?(:each_pair) # Hash item within
|
10
|
+
item.underscore_keys
|
11
|
+
else
|
12
|
+
item
|
13
|
+
end
|
14
|
+
end
|
15
|
+
elsif value.respond_to?(:each_pair) # Hash
|
16
|
+
value = value.underscore_keys
|
17
|
+
end
|
18
|
+
|
19
|
+
new_key = key.is_a?(String) ? key.underscore : key # only String keys
|
20
|
+
|
21
|
+
new_hash[new_key] = value
|
22
|
+
end
|
23
|
+
|
24
|
+
self.replace(new_hash)
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
module Locomotive
|
2
|
+
module Steam
|
3
|
+
|
4
|
+
class DefaultException < ::Exception
|
5
|
+
|
6
|
+
def initialize(message = nil, parent_exception = nil)
|
7
|
+
self.log_backtrace(parent_exception) if parent_exception
|
8
|
+
|
9
|
+
super(message)
|
10
|
+
end
|
11
|
+
|
12
|
+
protected
|
13
|
+
|
14
|
+
def log_backtrace(parent_exception)
|
15
|
+
full_error_message = "#{parent_exception.message}\n\t"
|
16
|
+
full_error_message += parent_exception.backtrace.join("\n\t")
|
17
|
+
full_error_message += "\n\n"
|
18
|
+
Locomotive::Steam::Logger.fatal full_error_message
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
|
23
|
+
class RendererException < DefaultException
|
24
|
+
|
25
|
+
attr_accessor :name, :template, :liquid_context
|
26
|
+
|
27
|
+
def initialize(exception, name, template, liquid_context)
|
28
|
+
self.name, self.template, self.liquid_context = name, template, liquid_context
|
29
|
+
|
30
|
+
self.log_page_into_backtrace(exception)
|
31
|
+
|
32
|
+
super(exception.message)
|
33
|
+
|
34
|
+
self.set_backtrace(exception.backtrace)
|
35
|
+
end
|
36
|
+
|
37
|
+
def log_page_into_backtrace(exception)
|
38
|
+
line = self.template.line_offset
|
39
|
+
line += (exception.respond_to?(:line) ? exception.line || 0 : 0) + 1
|
40
|
+
|
41
|
+
message = "#{self.template.filepath}:#{line}:in `#{self.name}'"
|
42
|
+
|
43
|
+
Locomotive::Steam::Logger.fatal "[ERROR] #{exception.message} - #{message}\n".red
|
44
|
+
|
45
|
+
exception.backtrace.unshift message
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
49
|
+
|
50
|
+
class MounterException < DefaultException
|
51
|
+
end
|
52
|
+
|
53
|
+
class GeneratorException < DefaultException
|
54
|
+
|
55
|
+
def log_backtrace(parent_exception)
|
56
|
+
# Logger not initialized at this step
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
60
|
+
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'redcarpet'
|
2
|
+
|
3
|
+
module Locomotive
|
4
|
+
module Steam
|
5
|
+
module Markdown
|
6
|
+
|
7
|
+
def self.render(text)
|
8
|
+
self.parser.render(text)
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.parser
|
12
|
+
@@markdown ||= Redcarpet::Markdown.new Redcarpet::Steam::HTML, {
|
13
|
+
autolink: true,
|
14
|
+
fenced_code: true,
|
15
|
+
generate_toc: true,
|
16
|
+
gh_blockcode: true,
|
17
|
+
hard_wrap: true,
|
18
|
+
no_intraemphasis: true,
|
19
|
+
strikethrough: true,
|
20
|
+
tables: true,
|
21
|
+
xhtml: true
|
22
|
+
}
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'will_paginate'
|
2
|
+
require 'will_paginate/collection'
|
3
|
+
|
4
|
+
Array.class_eval do
|
5
|
+
def paginate(options = {})
|
6
|
+
raise ArgumentError, "parameter hash expected (got #{options.inspect})" unless Hash === options
|
7
|
+
|
8
|
+
WillPaginate::Collection.create(
|
9
|
+
options[:page] || 1,
|
10
|
+
options[:per_page] || 30,
|
11
|
+
options[:total_entries] || self.length
|
12
|
+
) { |pager|
|
13
|
+
pager.replace self[pager.offset, pager.per_page].to_a
|
14
|
+
}
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'solid'
|
2
|
+
require 'locomotive/mounter'
|
3
|
+
|
4
|
+
require_relative 'liquid/scopeable'
|
5
|
+
require_relative 'liquid/drops/base'
|
6
|
+
require_relative 'liquid/tags/hybrid'
|
7
|
+
require_relative 'liquid/tags/path_helper'
|
8
|
+
|
9
|
+
%w{. drops tags filters }.each do |dir|
|
10
|
+
Dir[File.join(File.dirname(__FILE__), 'liquid', dir, '*.rb')].each { |lib| require lib }
|
11
|
+
end
|
12
|
+
|
13
|
+
# add to_liquid methods to main models from the mounter
|
14
|
+
%w{site page content_entry}.each do |name|
|
15
|
+
klass = "Locomotive::Mounter::Models::#{name.classify}".constantize
|
16
|
+
|
17
|
+
klass.class_eval <<-EOV
|
18
|
+
def to_liquid
|
19
|
+
::Locomotive::Steam::Liquid::Drops::#{name.classify}.new(self)
|
20
|
+
end
|
21
|
+
EOV
|
22
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
# Code taken from Mephisto sources (http://mephistoblog.com/)
|
2
|
+
module Locomotive
|
3
|
+
module Steam
|
4
|
+
module Liquid
|
5
|
+
module Drops
|
6
|
+
class Base < ::Liquid::Drop
|
7
|
+
|
8
|
+
@@forbidden_attributes = %w{_id _version _index}
|
9
|
+
|
10
|
+
def initialize(source)
|
11
|
+
@_source = source
|
12
|
+
end
|
13
|
+
|
14
|
+
def id
|
15
|
+
(@_source.respond_to?(:id) ? @_source.id : nil) || 'new'
|
16
|
+
end
|
17
|
+
|
18
|
+
# converts an array of records to an array of liquid drops
|
19
|
+
def self.liquify(*records, &block)
|
20
|
+
i = -1
|
21
|
+
records =
|
22
|
+
records.inject [] do |all, r|
|
23
|
+
i+=1
|
24
|
+
attrs = (block && block.arity == 1) ? [r] : [r, i]
|
25
|
+
all << (block ? block.call(*attrs) : r.to_liquid)
|
26
|
+
all
|
27
|
+
end
|
28
|
+
records.compact!
|
29
|
+
records
|
30
|
+
end
|
31
|
+
|
32
|
+
protected
|
33
|
+
|
34
|
+
def liquify(*records, &block)
|
35
|
+
self.class.liquify(*records, &block)
|
36
|
+
end
|
37
|
+
|
38
|
+
def _source
|
39
|
+
@_source
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|