locomotivecms_steam 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +4 -0
- data/CHANGELOG.md +5 -0
- data/Gemfile +7 -0
- data/Gemfile.lock +19 -30
- data/bin/publish +8 -8
- data/example/server.rb +27 -0
- data/lib/locomotive/steam/exceptions.rb +2 -2
- data/lib/locomotive/steam/initializers.rb +6 -4
- data/lib/locomotive/steam/initializers/dragonfly.rb +19 -0
- data/lib/locomotive/steam/initializers/sprockets.rb +1 -0
- data/lib/locomotive/steam/liquid.rb +1 -1
- data/lib/locomotive/steam/liquid/filters/resize.rb +2 -1
- data/lib/locomotive/steam/liquid/scopeable.rb +2 -2
- data/lib/locomotive/steam/liquid/tags/consume.rb +6 -1
- data/lib/locomotive/steam/liquid/tags/editable/short_text.rb +1 -1
- data/lib/locomotive/steam/liquid/tags/snippet.rb +1 -1
- data/lib/locomotive/steam/middlewares.rb +15 -0
- data/lib/locomotive/steam/{server/middleware.rb → middlewares/base.rb} +13 -11
- data/lib/locomotive/steam/middlewares/dynamic_assets.rb +40 -0
- data/lib/locomotive/steam/{server → middlewares}/entry_submission.rb +4 -4
- data/lib/locomotive/steam/{server → middlewares}/favicon.rb +2 -3
- data/lib/locomotive/steam/{server → middlewares}/locale.rb +4 -4
- data/lib/locomotive/steam/{server → middlewares}/logging.rb +2 -2
- data/lib/locomotive/steam/{server → middlewares}/page.rb +4 -6
- data/lib/locomotive/steam/{server → middlewares}/path.rb +4 -4
- data/lib/locomotive/steam/{server → middlewares}/renderer.rb +6 -5
- data/lib/locomotive/steam/middlewares/stack.rb +66 -0
- data/lib/locomotive/steam/middlewares/static_assets.rb +25 -0
- data/lib/locomotive/steam/{server → middlewares}/templatized_page.rb +4 -4
- data/lib/locomotive/steam/{server → middlewares}/timezone.rb +4 -4
- data/lib/locomotive/steam/misc.rb +10 -0
- data/lib/locomotive/steam/monkey_patches.rb +3 -4
- data/lib/locomotive/steam/monkey_patches/haml.rb +3 -1
- data/lib/locomotive/steam/monkey_patches/mounter.rb +22 -0
- data/lib/locomotive/steam/server.rb +33 -58
- data/lib/locomotive/steam/services.rb +1 -0
- data/lib/locomotive/steam/services/dragonfly.rb +49 -0
- data/lib/locomotive/steam/{monkey_patches/httparty.rb → services/external_api.rb} +6 -6
- data/lib/locomotive/steam/services/markdown.rb +29 -0
- data/lib/locomotive/steam/standalone_server.rb +9 -12
- data/lib/locomotive/steam/version.rb +1 -1
- data/lib/steam.rb +0 -1
- data/locomotivecms_steam.gemspec +8 -9
- data/spec/integration/integration_helper.rb +2 -13
- data/spec/integration/server/basic_spec.rb +0 -6
- data/spec/integration/server/contact_form_spec.rb +0 -4
- data/spec/integration/server/liquid_spec.rb +0 -4
- data/spec/integration/server/with_scope_spec.rb +0 -4
- data/spec/spec_helper.rb +1 -0
- data/spec/support/helpers.rb +13 -4
- metadata +47 -57
- data/lib/locomotive/steam/initializers/markdown.rb +0 -27
- data/lib/locomotive/steam/initializers/will_paginate.rb +0 -16
- data/lib/locomotive/steam/listen.rb +0 -64
- data/lib/locomotive/steam/logger.rb +0 -54
- data/lib/locomotive/steam/monkey_patches/better_errors.rb +0 -70
- data/lib/locomotive/steam/monkey_patches/dragonfly.rb +0 -79
- data/lib/locomotive/steam/server/dynamic_assets.rb +0 -33
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8893681c8f5eb7eb8d2679fd660ae4aed7e731f5
|
4
|
+
data.tar.gz: 9ee2f1cacf9d807e2194f139cabd844743cf3dc7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9090a78846cc972558e88da4dba21c6aa44b30585608467ca09e666e18022f85572f3de3861be7e7c95a13433a37410270417edf9a71095c69ad181bb08c5089
|
7
|
+
data.tar.gz: 0ef2642d9cf8fe0d28cf30621f48eabf294ce02d396e37096031455d8f3062b809f88bae38270587b09233d316d8f2580a124e04ce4e0619656b68fd9d6d757d
|
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
data/Gemfile
CHANGED
@@ -2,7 +2,14 @@ source 'https://rubygems.org'
|
|
2
2
|
|
3
3
|
gemspec
|
4
4
|
|
5
|
+
group :development do
|
6
|
+
gem 'locomotivecms_common', '~> 0.0.1', require: 'common' # path: '../common'
|
7
|
+
gem 'thin'
|
8
|
+
end
|
9
|
+
|
5
10
|
group :test do
|
6
11
|
gem 'pry'
|
7
12
|
gem 'coveralls', require: false
|
8
13
|
end
|
14
|
+
|
15
|
+
gem 'thin'
|
data/Gemfile.lock
CHANGED
@@ -1,13 +1,12 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
locomotivecms_steam (0.1.
|
5
|
-
|
6
|
-
better_errors (~> 1.0)
|
7
|
-
dragonfly (~> 0.9)
|
8
|
-
listen (~> 2.7)
|
4
|
+
locomotivecms_steam (0.1.1)
|
5
|
+
dragonfly (~> 1.0.3)
|
9
6
|
locomotivecms-solid
|
7
|
+
locomotivecms_common (~> 0.0.1)
|
10
8
|
locomotivecms_mounter
|
9
|
+
moneta (~> 0.7.20)
|
11
10
|
rack-cache (~> 1.1)
|
12
11
|
redcarpet (~> 3.1)
|
13
12
|
sprockets (~> 2.0)
|
@@ -22,14 +21,6 @@ GEM
|
|
22
21
|
i18n (~> 0.6, >= 0.6.4)
|
23
22
|
multi_json (~> 1.0)
|
24
23
|
addressable (2.3.6)
|
25
|
-
better_errors (1.1.0)
|
26
|
-
coderay (>= 1.0.0)
|
27
|
-
erubis (>= 2.6.6)
|
28
|
-
celluloid (0.15.2)
|
29
|
-
timers (~> 1.1.0)
|
30
|
-
celluloid-io (0.15.0)
|
31
|
-
celluloid (>= 0.15.0)
|
32
|
-
nio4r (>= 0.5.0)
|
33
24
|
chronic (0.10.2)
|
34
25
|
chunky_png (1.3.0)
|
35
26
|
coderay (1.1.0)
|
@@ -39,10 +30,10 @@ GEM
|
|
39
30
|
coffee-script-source (1.7.0)
|
40
31
|
colorize (0.5.8)
|
41
32
|
commonjs (0.2.7)
|
42
|
-
compass (0.12.
|
33
|
+
compass (0.12.5)
|
43
34
|
chunky_png (~> 1.2)
|
44
35
|
fssm (>= 0.2.7)
|
45
|
-
sass (~> 3.2.
|
36
|
+
sass (~> 3.2.19)
|
46
37
|
coveralls (0.7.0)
|
47
38
|
multi_json (~> 1.3)
|
48
39
|
rest-client
|
@@ -51,14 +42,14 @@ GEM
|
|
51
42
|
thor
|
52
43
|
crack (0.4.2)
|
53
44
|
safe_yaml (~> 1.0.0)
|
45
|
+
daemons (1.1.9)
|
54
46
|
diff-lcs (1.2.5)
|
55
47
|
docile (1.1.3)
|
56
|
-
dragonfly (0.
|
48
|
+
dragonfly (1.0.4)
|
57
49
|
multi_json (~> 1.0)
|
58
50
|
rack
|
59
|
-
|
51
|
+
eventmachine (1.0.3)
|
60
52
|
execjs (2.0.2)
|
61
|
-
ffi (1.9.3)
|
62
53
|
fssm (0.2.10)
|
63
54
|
haml (4.0.5)
|
64
55
|
tilt
|
@@ -66,7 +57,7 @@ GEM
|
|
66
57
|
httmultiparty (0.3.10)
|
67
58
|
httparty (>= 0.7.3)
|
68
59
|
multipart-post
|
69
|
-
httparty (0.13.
|
60
|
+
httparty (0.13.1)
|
70
61
|
json (~> 1.8)
|
71
62
|
multi_xml (>= 0.5.2)
|
72
63
|
i18n (0.6.9)
|
@@ -79,14 +70,10 @@ GEM
|
|
79
70
|
addressable (~> 2.3)
|
80
71
|
less (2.2.2)
|
81
72
|
commonjs (~> 0.2.6)
|
82
|
-
listen (2.7.1)
|
83
|
-
celluloid (>= 0.15.2)
|
84
|
-
celluloid-io (>= 0.15.0)
|
85
|
-
rb-fsevent (>= 0.9.3)
|
86
|
-
rb-inotify (>= 0.9)
|
87
73
|
locomotivecms-liquid (2.6.0)
|
88
74
|
locomotivecms-solid (0.2.2.1)
|
89
75
|
locomotivecms-liquid (~> 2.6.0)
|
76
|
+
locomotivecms_common (0.0.1)
|
90
77
|
locomotivecms_mounter (1.4.0)
|
91
78
|
RedCloth (~> 4.2.3)
|
92
79
|
activesupport (~> 3.2.15)
|
@@ -112,10 +99,10 @@ GEM
|
|
112
99
|
logger (1.2.8)
|
113
100
|
method_source (0.8.2)
|
114
101
|
mime-types (1.25.1)
|
102
|
+
moneta (0.7.20)
|
115
103
|
multi_json (1.7.9)
|
116
104
|
multi_xml (0.5.5)
|
117
105
|
multipart-post (2.0.0)
|
118
|
-
nio4r (1.0.0)
|
119
106
|
pry (0.9.12.6)
|
120
107
|
coderay (~> 1.0)
|
121
108
|
method_source (~> 0.8)
|
@@ -126,9 +113,6 @@ GEM
|
|
126
113
|
rack-test (0.6.2)
|
127
114
|
rack (>= 1.0)
|
128
115
|
rake (10.2.2)
|
129
|
-
rb-fsevent (0.9.4)
|
130
|
-
rb-inotify (0.9.3)
|
131
|
-
ffi (>= 0.5.0)
|
132
116
|
redcarpet (3.1.1)
|
133
117
|
rest-client (1.6.7)
|
134
118
|
mime-types (>= 1.16)
|
@@ -141,7 +125,7 @@ GEM
|
|
141
125
|
diff-lcs (>= 1.1.3, < 2.0)
|
142
126
|
rspec-mocks (2.14.6)
|
143
127
|
safe_yaml (1.0.1)
|
144
|
-
sass (3.2.
|
128
|
+
sass (3.2.19)
|
145
129
|
simplecov (0.8.2)
|
146
130
|
docile (~> 1.1.0)
|
147
131
|
multi_json
|
@@ -159,9 +143,12 @@ GEM
|
|
159
143
|
stringex (2.0.11)
|
160
144
|
term-ansicolor (1.3.0)
|
161
145
|
tins (~> 1.0)
|
146
|
+
thin (1.6.2)
|
147
|
+
daemons (>= 1.0.9)
|
148
|
+
eventmachine (>= 1.0.0)
|
149
|
+
rack (>= 1.0.0)
|
162
150
|
thor (0.18.1)
|
163
151
|
tilt (1.4.1)
|
164
|
-
timers (1.1.0)
|
165
152
|
tins (1.0.0)
|
166
153
|
tzinfo (0.3.39)
|
167
154
|
vcr (2.9.0)
|
@@ -179,10 +166,12 @@ DEPENDENCIES
|
|
179
166
|
coveralls
|
180
167
|
i18n-spec
|
181
168
|
launchy
|
169
|
+
locomotivecms_common (~> 0.0.1)
|
182
170
|
locomotivecms_steam!
|
183
171
|
pry
|
184
172
|
rack-test
|
185
173
|
rake (~> 10.1)
|
186
174
|
rspec (~> 2.14)
|
175
|
+
thin
|
187
176
|
vcr
|
188
177
|
webmock
|
data/bin/publish
CHANGED
@@ -6,8 +6,8 @@ require_relative '../lib/steam'
|
|
6
6
|
|
7
7
|
class Publish
|
8
8
|
|
9
|
-
def start version, rvm=false
|
10
|
-
system "rvm use #{rvm}"
|
9
|
+
def start # version, rvm=false
|
10
|
+
# system "rvm use #{rvm}"
|
11
11
|
|
12
12
|
system "bundle && bundle exec rspec"
|
13
13
|
system "gem build locomotivecms_steam.gemspec"
|
@@ -19,10 +19,10 @@ class Publish
|
|
19
19
|
|
20
20
|
end
|
21
21
|
|
22
|
-
if ARGV.length != 1 # or !ARGV[0].match(/\d{1,3}.\d{1,3}.\d{1,3}/)
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
end
|
22
|
+
# if ARGV.length != 1 # or !ARGV[0].match(/\d{1,3}.\d{1,3}.\d{1,3}/)
|
23
|
+
# puts 'HELP: '
|
24
|
+
# puts '$ bin/publish [ruby-2.1.1@steam]'
|
25
|
+
# exit 0
|
26
|
+
# end
|
27
27
|
|
28
|
-
Publish.new.start ARGV[0]
|
28
|
+
Publish.new.start # ARGV[0]
|
data/example/server.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'bundler/setup'
|
5
|
+
|
6
|
+
Bundler.require
|
7
|
+
|
8
|
+
require 'thin'
|
9
|
+
require 'common'
|
10
|
+
|
11
|
+
require_relative '../lib/steam'
|
12
|
+
require_relative '../lib/locomotive/steam/server'
|
13
|
+
require_relative '../lib/locomotive/steam/initializers'
|
14
|
+
|
15
|
+
path = ENV['SITE_PATH'] || File.join(File.expand_path(File.dirname(__FILE__)), '../spec/fixtures/default')
|
16
|
+
reader = Locomotive::Mounter::Reader::FileSystem.instance
|
17
|
+
reader.run!(path: path)
|
18
|
+
|
19
|
+
app = Locomotive::Steam::Server.new(reader, {
|
20
|
+
serve_assets: true
|
21
|
+
})
|
22
|
+
|
23
|
+
server = Thin::Server.new('localhost', '3333', app)
|
24
|
+
server.threaded = true
|
25
|
+
|
26
|
+
Locomotive::Common::Logger.info 'Server started...'
|
27
|
+
server.start
|
@@ -15,7 +15,7 @@ module Locomotive
|
|
15
15
|
full_error_message = "#{parent_exception.message}\n\t"
|
16
16
|
full_error_message += parent_exception.backtrace.join("\n\t")
|
17
17
|
full_error_message += "\n\n"
|
18
|
-
Locomotive::
|
18
|
+
Locomotive::Common::Logger.fatal full_error_message
|
19
19
|
end
|
20
20
|
|
21
21
|
end
|
@@ -40,7 +40,7 @@ module Locomotive
|
|
40
40
|
|
41
41
|
message = "#{self.template.filepath}:#{line}:in `#{self.name}'"
|
42
42
|
|
43
|
-
Locomotive::
|
43
|
+
Locomotive::Common::Logger.fatal "[ERROR] #{exception.message} - #{message}\n".red
|
44
44
|
|
45
45
|
exception.backtrace.unshift message
|
46
46
|
end
|
@@ -1,5 +1,7 @@
|
|
1
|
-
require_relative '
|
2
|
-
|
1
|
+
require_relative 'initializers/sprockets.rb'
|
3
2
|
require_relative 'initializers/i18n.rb'
|
4
|
-
require_relative 'initializers/
|
5
|
-
|
3
|
+
require_relative 'initializers/dragonfly.rb'
|
4
|
+
|
5
|
+
Locomotive::Common.configure do |config|
|
6
|
+
config.notifier = Locomotive::Common::Logger.setup
|
7
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'dragonfly'
|
2
|
+
require 'common'
|
3
|
+
|
4
|
+
# Configure
|
5
|
+
Dragonfly.app(:steam).configure do
|
6
|
+
plugin :imagemagick,
|
7
|
+
convert_command: `which convert`.strip.presence || '/usr/local/bin/convert',
|
8
|
+
identify_command: `which identify`.strip.presence || '/usr/local/bin/identify'
|
9
|
+
|
10
|
+
protect_from_dos_attacks true
|
11
|
+
|
12
|
+
url_format '/images/dynamic/:job/:basename.:ext'
|
13
|
+
|
14
|
+
fetch_file_whitelist /public/
|
15
|
+
|
16
|
+
fetch_url_whitelist /.+/
|
17
|
+
end
|
18
|
+
|
19
|
+
Dragonfly.logger = Locomotive::Common::Logger.instance
|
@@ -0,0 +1 @@
|
|
1
|
+
Sprockets::Sass.add_sass_functions = false
|
@@ -6,7 +6,7 @@ require_relative 'liquid/drops/base'
|
|
6
6
|
require_relative 'liquid/tags/hybrid'
|
7
7
|
require_relative 'liquid/tags/path_helper'
|
8
8
|
|
9
|
-
%w{. drops tags filters
|
9
|
+
%w{. drops tags filters}.each do |dir|
|
10
10
|
Dir[File.join(File.dirname(__FILE__), 'liquid', dir, '*.rb')].each { |lib| require lib }
|
11
11
|
end
|
12
12
|
|
@@ -13,7 +13,7 @@ module Locomotive
|
|
13
13
|
# build the chains of conditions
|
14
14
|
conditions = _conditions.map { |name, value| Condition.new(name, value) }
|
15
15
|
|
16
|
-
Locomotive::
|
16
|
+
Locomotive::Common::Logger.info "[with_scope] conditions: #{conditions.map(&:to_s).join(', ')}"
|
17
17
|
|
18
18
|
# get only the entries matching ALL the conditions
|
19
19
|
_entries = entries.find_all do |content|
|
@@ -38,7 +38,7 @@ module Locomotive
|
|
38
38
|
|
39
39
|
name, direction = order_by.split.map(&:to_sym)
|
40
40
|
|
41
|
-
Locomotive::
|
41
|
+
Locomotive::Common::Logger.info "[with_scope] order_by #{name} #{direction || 'asc'}"
|
42
42
|
|
43
43
|
if direction == :asc || direction.nil?
|
44
44
|
entries.sort { |a, b| a.send(name) <=> b.send(name) }
|
@@ -72,7 +72,8 @@ module Locomotive
|
|
72
72
|
def render_all_without_cache(context)
|
73
73
|
context.stack do
|
74
74
|
begin
|
75
|
-
context.scopes.last[@target.to_s] =
|
75
|
+
context.scopes.last[@target.to_s] = external_api_service(context).consume(@url, @options.symbolize_keys)
|
76
|
+
|
76
77
|
self.cached_response = context.scopes.last[@target.to_s]
|
77
78
|
rescue Timeout::Error
|
78
79
|
context.scopes.last[@target.to_s] = self.cached_response
|
@@ -88,6 +89,10 @@ module Locomotive
|
|
88
89
|
end
|
89
90
|
end
|
90
91
|
|
92
|
+
def external_api_service(context)
|
93
|
+
context.registers[:services][:external_api]
|
94
|
+
end
|
95
|
+
|
91
96
|
end
|
92
97
|
|
93
98
|
::Liquid::Template.register_tag('consume', Consume)
|
@@ -6,7 +6,7 @@ module Locomotive
|
|
6
6
|
class ShortText < Base
|
7
7
|
|
8
8
|
def render(context)
|
9
|
-
Locomotive::
|
9
|
+
Locomotive::Common::Logger.warn " [#{self.current_block_name(context)}/#{@slug}] The editable_{short|long}_text tags are deprecated. Use editable_text instead.".colorize(:orange)
|
10
10
|
super(context)
|
11
11
|
end
|
12
12
|
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require_relative 'middlewares/base'
|
2
|
+
|
3
|
+
require_relative 'middlewares/favicon'
|
4
|
+
require_relative 'middlewares/static_assets'
|
5
|
+
require_relative 'middlewares/dynamic_assets'
|
6
|
+
require_relative 'middlewares/logging'
|
7
|
+
require_relative 'middlewares/entry_submission'
|
8
|
+
require_relative 'middlewares/path'
|
9
|
+
require_relative 'middlewares/locale'
|
10
|
+
require_relative 'middlewares/page'
|
11
|
+
require_relative 'middlewares/timezone'
|
12
|
+
require_relative 'middlewares/templatized_page'
|
13
|
+
require_relative 'middlewares/renderer'
|
14
|
+
|
15
|
+
require_relative 'middlewares/stack'
|
@@ -1,10 +1,10 @@
|
|
1
1
|
module Locomotive::Steam
|
2
|
-
|
2
|
+
module Middlewares
|
3
3
|
|
4
|
-
class
|
5
|
-
|
6
|
-
attr_accessor :app, :request, :path, :liquid_assigns
|
4
|
+
class Base
|
7
5
|
|
6
|
+
attr_accessor :app, :request, :path
|
7
|
+
attr_accessor :liquid_assigns, :services
|
8
8
|
attr_accessor :mounting_point, :page, :content_entry
|
9
9
|
|
10
10
|
def initialize(app = nil)
|
@@ -12,17 +12,19 @@ module Locomotive::Steam
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def call(env)
|
15
|
-
|
15
|
+
dup._call(env) # thread-safe purpose
|
16
|
+
end
|
17
|
+
|
18
|
+
def _call(env)
|
19
|
+
self.set_accessors(env)
|
16
20
|
end
|
17
21
|
|
18
22
|
protected
|
19
23
|
|
20
24
|
def set_accessors(env)
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
self.page = env['steam.page']
|
25
|
-
self.content_entry = env['steam.content_entry']
|
25
|
+
%w(path request mounting_point page content_entry services).each do |name|
|
26
|
+
self.send(:"#{name}=", env["steam.#{name}"])
|
27
|
+
end
|
26
28
|
|
27
29
|
env['steam.liquid_assigns'] ||= {}
|
28
30
|
self.liquid_assigns = env['steam.liquid_assigns']
|
@@ -52,7 +54,7 @@ module Locomotive::Steam
|
|
52
54
|
end
|
53
55
|
|
54
56
|
def log(msg)
|
55
|
-
Locomotive::
|
57
|
+
Locomotive::Common::Logger.info msg
|
56
58
|
end
|
57
59
|
|
58
60
|
end
|