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,32 @@
|
|
1
|
+
module Locomotive::Steam
|
2
|
+
class Server
|
3
|
+
|
4
|
+
# Track the request into the current logger
|
5
|
+
#
|
6
|
+
class Logging < Middleware
|
7
|
+
|
8
|
+
def call(env)
|
9
|
+
now = Time.now
|
10
|
+
|
11
|
+
log "Started #{env['REQUEST_METHOD'].upcase} \"#{env['PATH_INFO']}\" at #{now}".light_white
|
12
|
+
|
13
|
+
app.call(env).tap do |response|
|
14
|
+
done_in_ms = ((Time.now - now) * 10000).truncate / 10.0
|
15
|
+
log "Completed #{code_to_human(response.first)} in #{done_in_ms}ms\n\n".green
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
protected
|
20
|
+
|
21
|
+
def code_to_human(code)
|
22
|
+
case code.to_i
|
23
|
+
when 200 then '200 OK'
|
24
|
+
when 301 then '301 Found'
|
25
|
+
when 302 then '302 Found'
|
26
|
+
when 404 then '404 Not Found'
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
module Locomotive::Steam
|
2
|
+
class Server
|
3
|
+
|
4
|
+
class Middleware
|
5
|
+
|
6
|
+
attr_accessor :app, :request, :path, :liquid_assigns
|
7
|
+
|
8
|
+
attr_accessor :mounting_point, :page, :content_entry
|
9
|
+
|
10
|
+
def initialize(app = nil)
|
11
|
+
@app = app
|
12
|
+
end
|
13
|
+
|
14
|
+
def call(env)
|
15
|
+
app.call(env)
|
16
|
+
end
|
17
|
+
|
18
|
+
protected
|
19
|
+
|
20
|
+
def set_accessors(env)
|
21
|
+
self.path = env['steam.path']
|
22
|
+
self.request = Rack::Request.new(env)
|
23
|
+
self.mounting_point = env['steam.mounting_point']
|
24
|
+
self.page = env['steam.page']
|
25
|
+
self.content_entry = env['steam.content_entry']
|
26
|
+
|
27
|
+
env['steam.liquid_assigns'] ||= {}
|
28
|
+
self.liquid_assigns = env['steam.liquid_assigns']
|
29
|
+
end
|
30
|
+
|
31
|
+
def site
|
32
|
+
self.mounting_point.site
|
33
|
+
end
|
34
|
+
|
35
|
+
def params
|
36
|
+
self.request.params.deep_symbolize_keys
|
37
|
+
end
|
38
|
+
|
39
|
+
def html?
|
40
|
+
['text/html', 'application/x-www-form-urlencoded'].include?(self.request.media_type) &&
|
41
|
+
!self.request.xhr? &&
|
42
|
+
!self.json?
|
43
|
+
end
|
44
|
+
|
45
|
+
def json?
|
46
|
+
self.request.content_type == 'application/json' || File.extname(self.request.path) == '.json'
|
47
|
+
end
|
48
|
+
|
49
|
+
def redirect_to(location, type = 301)
|
50
|
+
self.log "Redirected to #{location}"
|
51
|
+
[type, { 'Content-Type' => 'text/html', 'Location' => location }, []]
|
52
|
+
end
|
53
|
+
|
54
|
+
def log(msg)
|
55
|
+
Locomotive::Steam::Logger.info msg
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
module Locomotive::Steam
|
2
|
+
class Server
|
3
|
+
|
4
|
+
# Sanitize the path from the previous middleware in order
|
5
|
+
# to make it work for the renderer.
|
6
|
+
#
|
7
|
+
class Page < Middleware
|
8
|
+
|
9
|
+
def call(env)
|
10
|
+
self.set_accessors(env)
|
11
|
+
|
12
|
+
self.set_page!(env)
|
13
|
+
|
14
|
+
app.call(env)
|
15
|
+
end
|
16
|
+
|
17
|
+
protected
|
18
|
+
|
19
|
+
def set_page!(env)
|
20
|
+
page = self.fetch_page
|
21
|
+
|
22
|
+
if page
|
23
|
+
self.log "Found page \"#{page.title}\" [#{page.safe_fullpath}]"
|
24
|
+
end
|
25
|
+
|
26
|
+
env['steam.page'] = page
|
27
|
+
end
|
28
|
+
|
29
|
+
def fetch_page
|
30
|
+
|
31
|
+
|
32
|
+
matchers = self.path_combinations(self.path)
|
33
|
+
|
34
|
+
pages = self.mounting_point.pages.values.find_all do |_page|
|
35
|
+
matchers.include?(_page.safe_fullpath) ||
|
36
|
+
matchers.include?(_page.safe_fullpath.try(:underscore))
|
37
|
+
end.sort_by { |p| p.position || Float::INFINITY }
|
38
|
+
|
39
|
+
if pages.size > 1
|
40
|
+
self.log "Found multiple pages: #{pages.collect(&:title).join(', ')}"
|
41
|
+
end
|
42
|
+
|
43
|
+
pages.first
|
44
|
+
end
|
45
|
+
|
46
|
+
def path_combinations(path)
|
47
|
+
self._path_combinations(path.split('/'))
|
48
|
+
end
|
49
|
+
|
50
|
+
def _path_combinations(segments, can_include_template = true)
|
51
|
+
return nil if segments.empty?
|
52
|
+
|
53
|
+
segment = segments.shift
|
54
|
+
|
55
|
+
(can_include_template ? [segment, '*'] : [segment]).map do |_segment|
|
56
|
+
if (_combinations = _path_combinations(segments.clone, can_include_template && _segment != '*'))
|
57
|
+
[*_combinations].map do |_combination|
|
58
|
+
File.join(_segment, _combination)
|
59
|
+
end
|
60
|
+
else
|
61
|
+
[_segment]
|
62
|
+
end
|
63
|
+
end.flatten
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|
67
|
+
|
68
|
+
end
|
69
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module Locomotive::Steam
|
2
|
+
class Server
|
3
|
+
|
4
|
+
# Sanitize the path from the previous middleware in order
|
5
|
+
# to make it work for the renderer.
|
6
|
+
#
|
7
|
+
class Path < Middleware
|
8
|
+
|
9
|
+
def call(env)
|
10
|
+
self.set_accessors(env)
|
11
|
+
|
12
|
+
self.set_path!(env)
|
13
|
+
|
14
|
+
app.call(env)
|
15
|
+
end
|
16
|
+
|
17
|
+
protected
|
18
|
+
|
19
|
+
def set_path!(env)
|
20
|
+
path = env['PATH_INFO'].clone
|
21
|
+
|
22
|
+
path.gsub!(/\.[a-zA-Z][a-zA-Z0-9]{2,}$/, '')
|
23
|
+
path.gsub!(/^\//, '')
|
24
|
+
path.gsub!(/^[A-Z]:\//, '')
|
25
|
+
|
26
|
+
path = 'index' if path.blank?
|
27
|
+
|
28
|
+
env['steam.path'] = path
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,118 @@
|
|
1
|
+
module Locomotive::Steam
|
2
|
+
class Server
|
3
|
+
|
4
|
+
class Renderer < Middleware
|
5
|
+
|
6
|
+
def call(env)
|
7
|
+
self.set_accessors(env)
|
8
|
+
|
9
|
+
if self.page
|
10
|
+
if self.page.redirect?
|
11
|
+
self.redirect_to(self.page.redirect_url, self.page.redirect_type)
|
12
|
+
else
|
13
|
+
type = self.page.response_type || 'text/html'
|
14
|
+
html = self.render_page
|
15
|
+
|
16
|
+
self.log 'Rendered liquid page template'
|
17
|
+
|
18
|
+
[200, { 'Content-Type' => type }, [html]]
|
19
|
+
end
|
20
|
+
else
|
21
|
+
[404, { 'Content-Type' => 'text/html' }, [self.render_404]]
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
protected
|
26
|
+
|
27
|
+
def render_page
|
28
|
+
context = self.locomotive_context
|
29
|
+
begin
|
30
|
+
self.page.render(context)
|
31
|
+
rescue Exception => e
|
32
|
+
raise RendererException.new(e, self.page.title, self.page.template, context)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def render_404
|
37
|
+
if self.page = self.mounting_point.pages['404']
|
38
|
+
self.render_page
|
39
|
+
else
|
40
|
+
'Page not found'
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
# Build the Liquid context used to render the Locomotive page. It
|
45
|
+
# stores both assigns and registers.
|
46
|
+
#
|
47
|
+
# @param [ Hash ] other_assigns Assigns coming for instance from the controler (optional)
|
48
|
+
#
|
49
|
+
# @return [ Object ] A new instance of the Liquid::Context class.
|
50
|
+
#
|
51
|
+
def locomotive_context(other_assigns = {})
|
52
|
+
assigns = self.locomotive_default_assigns
|
53
|
+
|
54
|
+
# assigns from other middlewares
|
55
|
+
assigns.merge!(self.liquid_assigns)
|
56
|
+
|
57
|
+
assigns.merge!(other_assigns)
|
58
|
+
|
59
|
+
# templatized page
|
60
|
+
if self.page && self.content_entry
|
61
|
+
['content_entry', 'entry', self.page.content_type.slug.singularize].each do |key|
|
62
|
+
assigns[key] = self.content_entry
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
# Tip: switch from false to true to enable the re-thrown exception flag
|
67
|
+
::Liquid::Context.new({}, assigns, self.locomotive_default_registers, true)
|
68
|
+
end
|
69
|
+
|
70
|
+
# Return the default Liquid assigns used inside the Locomotive Liquid context
|
71
|
+
#
|
72
|
+
# @return [ Hash ] The default liquid assigns object
|
73
|
+
#
|
74
|
+
def locomotive_default_assigns
|
75
|
+
{
|
76
|
+
'site' => self.site.to_liquid,
|
77
|
+
'page' => self.page,
|
78
|
+
'models' => Locomotive::Steam::Liquid::Drops::ContentTypes.new,
|
79
|
+
'contents' => Locomotive::Steam::Liquid::Drops::ContentTypes.new,
|
80
|
+
'current_page' => self.params[:page],
|
81
|
+
'params' => self.params.stringify_keys,
|
82
|
+
'path' => self.request.path,
|
83
|
+
'fullpath' => self.request.fullpath,
|
84
|
+
'url' => self.request.url,
|
85
|
+
'ip_address' => self.request.ip,
|
86
|
+
'post?' => self.request.post?,
|
87
|
+
'host' => self.request.host_with_port,
|
88
|
+
'now' => Time.zone.now,
|
89
|
+
'today' => Date.today,
|
90
|
+
'locale' => I18n.locale.to_s,
|
91
|
+
'default_locale' => self.mounting_point.default_locale.to_s,
|
92
|
+
'locales' => self.mounting_point.locales.map(&:to_s),
|
93
|
+
'current_user' => {},
|
94
|
+
'session' => Locomotive::Steam::Liquid::Drops::SessionProxy.new,
|
95
|
+
'steam' => true,
|
96
|
+
'editing' => false
|
97
|
+
}
|
98
|
+
end
|
99
|
+
|
100
|
+
# Return the default Liquid registers used inside the Locomotive Liquid context
|
101
|
+
#
|
102
|
+
# @return [ Hash ] The default liquid registers object
|
103
|
+
#
|
104
|
+
def locomotive_default_registers
|
105
|
+
{
|
106
|
+
request: self.request,
|
107
|
+
site: self.site,
|
108
|
+
page: self.page,
|
109
|
+
mounting_point: self.mounting_point,
|
110
|
+
inline_editor: false,
|
111
|
+
logger: Locomotive::Steam::Logger
|
112
|
+
}
|
113
|
+
end
|
114
|
+
|
115
|
+
end
|
116
|
+
|
117
|
+
end
|
118
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module Locomotive::Steam
|
2
|
+
class Server
|
3
|
+
|
4
|
+
class TemplatizedPage < Middleware
|
5
|
+
|
6
|
+
def call(env)
|
7
|
+
self.set_accessors(env)
|
8
|
+
|
9
|
+
if self.page && self.page.templatized?
|
10
|
+
self.set_content_entry!(env)
|
11
|
+
end
|
12
|
+
|
13
|
+
app.call(env)
|
14
|
+
end
|
15
|
+
|
16
|
+
protected
|
17
|
+
|
18
|
+
def set_content_entry!(env)
|
19
|
+
%r(^#{self.page.safe_fullpath.gsub('*', '([^\/]+)')}$) =~ self.path
|
20
|
+
|
21
|
+
permalink = $1
|
22
|
+
|
23
|
+
if content_entry = self.page.content_type.find_entry(permalink)
|
24
|
+
env['steam.content_entry'] = content_entry
|
25
|
+
else
|
26
|
+
env['steam.page'] = nil
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Locomotive::Steam
|
2
|
+
class Server
|
3
|
+
|
4
|
+
# Set the timezone according to the settings of the site
|
5
|
+
#
|
6
|
+
class Timezone < Middleware
|
7
|
+
|
8
|
+
def call(env)
|
9
|
+
self.set_accessors(env)
|
10
|
+
|
11
|
+
Time.use_zone(site.try(:timezone) || 'UTC') do
|
12
|
+
app.call(env)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
$:.unshift(File.expand_path(File.dirname(__FILE__) + '/../..'))
|
2
|
+
|
3
|
+
require_relative 'logger'
|
4
|
+
require_relative 'version'
|
5
|
+
require_relative 'exceptions'
|
6
|
+
require_relative 'server'
|
7
|
+
|
8
|
+
require 'locomotive/mounter'
|
9
|
+
|
10
|
+
module Locomotive
|
11
|
+
module Steam
|
12
|
+
class StandaloneServer < Server
|
13
|
+
|
14
|
+
def initialize(path, options={})
|
15
|
+
options.fetch(:logger) do
|
16
|
+
Locomotive::Steam::Logger.setup(path, false)
|
17
|
+
end
|
18
|
+
|
19
|
+
reader = options.fetch(:reader) do
|
20
|
+
_reader = Locomotive::Mounter::Reader::FileSystem.instance
|
21
|
+
Proc.new { |_path| _reader.run!(path: _path) }
|
22
|
+
end
|
23
|
+
reader.call path
|
24
|
+
|
25
|
+
Bundler.require 'monkey_patches'
|
26
|
+
Bundler.require 'initializers'
|
27
|
+
|
28
|
+
# run the rack app
|
29
|
+
super(reader, disable_listen: true)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
data/lib/steam.rb
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
require_relative 'lib/steam'
|
2
|
+
|
3
|
+
Gem::Specification.new do |spec|
|
4
|
+
spec.name = 'locomotivecms_steam'
|
5
|
+
spec.version = Locomotive::Steam::VERSION
|
6
|
+
spec.authors = ['Didier Lafforgue', 'Rodrigo Alvarez', 'Arnaud Sellenet', 'Joel Azemar']
|
7
|
+
spec.email = ['did@locomotivecms.com', 'papipo@gmail.com', 'arnaud@sellenet.fr', 'joel.azemar@gmail.com']
|
8
|
+
spec.description = %q{The LocomotiveCMS steam is a front end server LocomotiveCMS libraries}
|
9
|
+
spec.summary = %q{The LocomotiveCMS steam is a technical piece for compiled and steam front end stuff for LocomotiveCMS libraries}
|
10
|
+
spec.homepage = 'http://www.locomotivecms.com'
|
11
|
+
spec.homepage = 'https://github.com/locomotivecms/steam'
|
12
|
+
spec.license = 'MIT'
|
13
|
+
|
14
|
+
spec.files = `git ls-files`.split($/)
|
15
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
16
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
17
|
+
spec.require_paths = ['lib']
|
18
|
+
|
19
|
+
spec.add_development_dependency 'bundler', '~> 1.5'
|
20
|
+
spec.add_development_dependency 'rake', '~> 10.1'
|
21
|
+
spec.add_development_dependency 'rspec', '~> 2.14'
|
22
|
+
spec.add_development_dependency 'launchy'
|
23
|
+
spec.add_development_dependency 'vcr'
|
24
|
+
spec.add_development_dependency 'webmock'
|
25
|
+
spec.add_development_dependency 'rack-test'
|
26
|
+
spec.add_development_dependency 'i18n-spec'
|
27
|
+
|
28
|
+
spec.add_dependency 'rack-cache', '~> 1.1'
|
29
|
+
spec.add_dependency 'sprockets', '~> 2.0'
|
30
|
+
spec.add_dependency 'sprockets-sass', '~> 1.0'
|
31
|
+
spec.add_dependency 'better_errors', '~> 1.0'
|
32
|
+
spec.add_dependency 'dragonfly', '~> 0.9'
|
33
|
+
spec.add_dependency 'activesupport', '~> 3.2'
|
34
|
+
spec.add_dependency 'listen', '~> 2.7'
|
35
|
+
spec.add_dependency 'will_paginate', '~> 3.0'
|
36
|
+
spec.add_dependency 'redcarpet', '~> 3.1'
|
37
|
+
|
38
|
+
spec.add_dependency 'locomotivecms_mounter'
|
39
|
+
spec.add_dependency 'locomotivecms-solid'
|
40
|
+
|
41
|
+
spec.required_ruby_version = '~> 2.0'
|
42
|
+
end
|