locomotivecms_steam 1.4.1 → 1.5.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -1
- data/Gemfile.lock +31 -25
- data/Rakefile +2 -2
- data/config/locales/pt-BR.yml +43 -13
- data/lib/locomotive/steam.rb +9 -4
- data/lib/locomotive/steam/adapters/filesystem.rb +2 -7
- data/lib/locomotive/steam/adapters/filesystem/sanitizer.rb +0 -2
- data/lib/locomotive/steam/adapters/filesystem/sanitizers/page.rb +11 -0
- data/lib/locomotive/steam/adapters/filesystem/sanitizers/section.rb +37 -0
- data/lib/locomotive/steam/adapters/filesystem/sanitizers/site.rb +18 -0
- data/lib/locomotive/steam/adapters/filesystem/yaml_loaders/content_entry.rb +4 -3
- data/lib/locomotive/steam/adapters/filesystem/yaml_loaders/content_type.rb +4 -3
- data/lib/locomotive/steam/adapters/filesystem/yaml_loaders/section.rb +40 -0
- data/lib/locomotive/steam/adapters/filesystem/yaml_loaders/snippet.rb +0 -1
- data/lib/locomotive/steam/adapters/memory.rb +1 -1
- data/lib/locomotive/steam/entities/content_entry.rb +15 -3
- data/lib/locomotive/steam/entities/content_type.rb +2 -1
- data/lib/locomotive/steam/entities/page.rb +21 -19
- data/lib/locomotive/steam/entities/section.rb +24 -0
- data/lib/locomotive/steam/entities/site.rb +3 -1
- data/lib/locomotive/steam/liquid.rb +2 -0
- data/lib/locomotive/steam/liquid/drops/page.rb +4 -2
- data/lib/locomotive/steam/liquid/drops/params.rb +51 -0
- data/lib/locomotive/steam/liquid/drops/section.rb +56 -0
- data/lib/locomotive/steam/liquid/drops/section_block.rb +47 -0
- data/lib/locomotive/steam/liquid/drops/section_content_proxy.rb +97 -0
- data/lib/locomotive/steam/liquid/drops/section_editor_setting_data.rb +65 -0
- data/lib/locomotive/steam/liquid/drops/site.rb +2 -1
- data/lib/locomotive/steam/liquid/errors.rb +2 -0
- data/lib/locomotive/steam/liquid/filters/base.rb +3 -3
- data/lib/locomotive/steam/liquid/filters/date.rb +1 -1
- data/lib/locomotive/steam/liquid/filters/html.rb +7 -2
- data/lib/locomotive/steam/liquid/filters/json.rb +3 -1
- data/lib/locomotive/steam/liquid/tags/action.rb +2 -2
- data/lib/locomotive/steam/liquid/tags/alt_page_links.rb +63 -0
- data/lib/locomotive/steam/liquid/tags/concerns/i18n_page.rb +1 -1
- data/lib/locomotive/steam/liquid/tags/concerns/section.rb +117 -0
- data/lib/locomotive/steam/liquid/tags/global_section.rb +32 -0
- data/lib/locomotive/steam/liquid/tags/model_form.rb +1 -1
- data/lib/locomotive/steam/liquid/tags/section.rb +87 -0
- data/lib/locomotive/steam/liquid/tags/sections_dropzone.rb +56 -0
- data/lib/locomotive/steam/liquid/tags/snippet.rb +3 -2
- data/lib/locomotive/steam/liquid/template.rb +0 -5
- data/lib/locomotive/steam/middlewares.rb +1 -1
- data/lib/locomotive/steam/middlewares/auth.rb +29 -13
- data/lib/locomotive/steam/middlewares/concerns/helpers.rb +59 -0
- data/lib/locomotive/steam/middlewares/concerns/liquid_context.rb +94 -0
- data/lib/locomotive/steam/middlewares/encoded_link_redirection.rb +45 -0
- data/lib/locomotive/steam/middlewares/entry_submission.rb +1 -1
- data/lib/locomotive/steam/middlewares/favicon.rb +1 -1
- data/lib/locomotive/steam/middlewares/locale.rb +63 -15
- data/lib/locomotive/steam/middlewares/locale_redirection.rb +18 -6
- data/lib/locomotive/steam/middlewares/logging.rb +1 -1
- data/lib/locomotive/steam/middlewares/page.rb +35 -6
- data/lib/locomotive/steam/middlewares/path.rb +1 -1
- data/lib/locomotive/steam/middlewares/private_access.rb +1 -1
- data/lib/locomotive/steam/middlewares/redirection.rb +1 -1
- data/lib/locomotive/steam/middlewares/renderer.rb +2 -82
- data/lib/locomotive/steam/middlewares/robots.rb +1 -1
- data/lib/locomotive/steam/middlewares/section.rb +56 -0
- data/lib/locomotive/steam/middlewares/site.rb +1 -1
- data/lib/locomotive/steam/middlewares/sitemap.rb +58 -45
- data/lib/locomotive/steam/middlewares/templatized_page.rb +1 -1
- data/lib/locomotive/steam/middlewares/thread_safe.rb +85 -2
- data/lib/locomotive/steam/middlewares/timezone.rb +1 -1
- data/lib/locomotive/steam/middlewares/url_redirection.rb +1 -1
- data/lib/locomotive/steam/models/entity.rb +0 -2
- data/lib/locomotive/steam/models/mapper.rb +5 -3
- data/lib/locomotive/steam/models/scope.rb +8 -0
- data/lib/locomotive/steam/repositories.rb +4 -0
- data/lib/locomotive/steam/repositories/content_entry_repository.rb +6 -2
- data/lib/locomotive/steam/repositories/page_repository.rb +4 -1
- data/lib/locomotive/steam/repositories/section_repository.rb +14 -0
- data/lib/locomotive/steam/repositories/site_repository.rb +1 -1
- data/lib/locomotive/steam/repositories/snippet_repository.rb +0 -3
- data/lib/locomotive/steam/server.rb +3 -1
- data/lib/locomotive/steam/services.rb +17 -1
- data/lib/locomotive/steam/services/action_service.rb +10 -0
- data/lib/locomotive/steam/services/concerns/decorator.rb +0 -2
- data/lib/locomotive/steam/services/image_resizer_service.rb +1 -1
- data/lib/locomotive/steam/services/page_finder_service.rb +6 -0
- data/lib/locomotive/steam/services/section_finder_service.rb +17 -0
- data/lib/locomotive/steam/services/url_builder_service.rb +31 -17
- data/lib/locomotive/steam/services/url_finder_service.rb +87 -0
- data/lib/locomotive/steam/version.rb +2 -2
- data/locomotivecms_steam.gemspec +1 -1
- data/spec/fixtures/default/app/views/pages/tags/section.liquid.haml +11 -0
- data/spec/fixtures/default/app/views/sections/carousel.liquid +20 -0
- data/spec/fixtures/default/app/views/sections/footer.liquid +48 -0
- data/spec/fixtures/default/app/views/sections/header.liquid +54 -0
- data/spec/fixtures/default/config/deploy.yml +1 -1
- data/spec/fixtures/errors/section_bad_json_content.liquid +9 -0
- data/spec/fixtures/errors/section_bad_json_header.liquid +8 -0
- data/spec/fixtures/mongodb/locomotive_accounts.bson +0 -0
- data/spec/fixtures/mongodb/locomotive_accounts.metadata.json +1 -1
- data/spec/fixtures/mongodb/locomotive_activities.bson +0 -0
- data/spec/fixtures/mongodb/locomotive_activities.metadata.json +1 -1
- data/spec/fixtures/mongodb/locomotive_content_assets.bson +0 -0
- data/spec/fixtures/mongodb/locomotive_content_assets.metadata.json +1 -1
- data/spec/fixtures/mongodb/locomotive_content_entries.bson +0 -0
- data/spec/fixtures/mongodb/locomotive_content_entries.metadata.json +1 -1
- data/spec/fixtures/mongodb/locomotive_content_types.bson +0 -0
- data/spec/fixtures/mongodb/locomotive_content_types.metadata.json +1 -1
- data/spec/fixtures/mongodb/locomotive_pages.bson +0 -0
- data/spec/fixtures/mongodb/locomotive_pages.metadata.json +1 -1
- data/spec/fixtures/mongodb/locomotive_sections.bson +0 -0
- data/spec/fixtures/mongodb/{sessions.metadata.json → locomotive_sections.metadata.json} +1 -1
- data/spec/fixtures/mongodb/locomotive_sites.bson +0 -0
- data/spec/fixtures/mongodb/locomotive_sites.metadata.json +1 -1
- data/spec/fixtures/mongodb/locomotive_snippets.bson +0 -0
- data/spec/fixtures/mongodb/locomotive_snippets.metadata.json +1 -1
- data/spec/fixtures/mongodb/locomotive_theme_assets.bson +0 -0
- data/spec/fixtures/mongodb/locomotive_theme_assets.metadata.json +1 -1
- data/spec/fixtures/mongodb/locomotive_translations.bson +0 -0
- data/spec/fixtures/mongodb/locomotive_translations.metadata.json +1 -1
- data/spec/integration/repositories/content_entry_repository_spec.rb +1 -1
- data/spec/integration/repositories/page_repository_spec.rb +1 -1
- data/spec/integration/repositories/theme_asset_repository_spec.rb +1 -1
- data/spec/integration/server/auth_spec.rb +0 -4
- data/spec/integration/server/basic_spec.rb +8 -0
- data/spec/integration/server/contact_form_spec.rb +15 -2
- data/spec/integration/server/sitemap_spec.rb +5 -3
- data/spec/integration/services/content_entry_service_spec.rb +1 -1
- data/spec/support/helpers.rb +3 -3
- data/spec/unit/adapters/filesystem/sanitizers/section_spec.rb +65 -0
- data/spec/unit/adapters/filesystem/sanitizers/site_spec.rb +28 -2
- data/spec/unit/adapters/filesystem/yaml_loaders/content_entry_spec.rb +8 -4
- data/spec/unit/adapters/filesystem/yaml_loaders/content_type_spec.rb +2 -2
- data/spec/unit/adapters/filesystem/yaml_loaders/page_spec.rb +1 -1
- data/spec/unit/adapters/filesystem/yaml_loaders/section_spec.rb +27 -0
- data/spec/unit/entities/section_spec.rb +29 -0
- data/spec/unit/liquid/drops/params_spec.rb +38 -0
- data/spec/unit/liquid/drops/section_content_proxy_spec.rb +88 -0
- data/spec/unit/liquid/drops/section_spec.rb +26 -0
- data/spec/unit/liquid/filters/html_spec.rb +198 -170
- data/spec/unit/liquid/filters/json_spec.rb +7 -0
- data/spec/unit/liquid/tags/action_spec.rb +12 -2
- data/spec/unit/liquid/tags/alt_page_links_spec.rb +58 -0
- data/spec/unit/liquid/tags/global_section_spec.rb +130 -0
- data/spec/unit/liquid/tags/link_to_spec.rb +1 -1
- data/spec/unit/liquid/tags/locale_switcher_spec.rb +1 -1
- data/spec/unit/liquid/tags/model_form_spec.rb +8 -0
- data/spec/unit/liquid/tags/path_to_spec.rb +26 -3
- data/spec/unit/liquid/tags/section_spec.rb +231 -0
- data/spec/unit/liquid/tags/sections_dropzone_spec.rb +107 -0
- data/spec/unit/middlewares/auth_spec.rb +9 -2
- data/spec/unit/middlewares/encoded_link_redirection_spec.rb +73 -0
- data/spec/unit/middlewares/entry_submission_spec.rb +1 -1
- data/spec/unit/middlewares/helpers_spec.rb +3 -64
- data/spec/unit/middlewares/locale_redirection_spec.rb +13 -2
- data/spec/unit/middlewares/locale_spec.rb +52 -10
- data/spec/unit/middlewares/page_spec.rb +57 -16
- data/spec/unit/middlewares/private_access_spec.rb +1 -1
- data/spec/unit/middlewares/redirection_spec.rb +1 -1
- data/spec/unit/middlewares/renderer_spec.rb +2 -1
- data/spec/unit/middlewares/section_spec.rb +70 -0
- data/spec/unit/middlewares/site_spec.rb +1 -1
- data/spec/unit/middlewares/sitemap_spec.rb +4 -42
- data/spec/unit/middlewares/url_redirection_spec.rb +1 -1
- data/spec/unit/repositories/content_entry_repository_spec.rb +13 -13
- data/spec/unit/repositories/section_repository_spec.rb +38 -0
- data/spec/unit/repositories/snippet_repository_spec.rb +0 -3
- data/spec/unit/services/action_service_spec.rb +19 -1
- data/spec/unit/services/asset_host_service_spec.rb +8 -0
- data/spec/unit/services/parent_finder_service_spec.rb +1 -2
- data/spec/unit/services/section_finder_service_spec.rb +28 -0
- data/spec/unit/services/url_builder_service_spec.rb +14 -4
- data/spec/unit/services/url_finder_service_spec.rb +100 -0
- data/spec/unit/services_spec.rb +34 -20
- metadata +72 -11
- data/lib/locomotive/steam/middlewares/helpers.rb +0 -140
- data/spec/fixtures/mongodb/sessions.bson +0 -0
@@ -1,140 +0,0 @@
|
|
1
|
-
module Locomotive::Steam
|
2
|
-
module Middlewares
|
3
|
-
|
4
|
-
module Helpers
|
5
|
-
|
6
|
-
#= Shortcuts =
|
7
|
-
|
8
|
-
def services
|
9
|
-
@services ||= env.fetch('steam.services')
|
10
|
-
end
|
11
|
-
|
12
|
-
def repositories
|
13
|
-
@repositories ||= services.repositories
|
14
|
-
end
|
15
|
-
|
16
|
-
def request
|
17
|
-
@request ||= env.fetch('steam.request')
|
18
|
-
end
|
19
|
-
|
20
|
-
def site
|
21
|
-
@site ||= env.fetch('steam.site')
|
22
|
-
end
|
23
|
-
|
24
|
-
def page
|
25
|
-
@page ||= env.fetch('steam.page')
|
26
|
-
end
|
27
|
-
|
28
|
-
def path
|
29
|
-
@path ||= env.fetch('steam.path')
|
30
|
-
end
|
31
|
-
|
32
|
-
def locale
|
33
|
-
@locale ||= env.fetch('steam.locale')
|
34
|
-
end
|
35
|
-
|
36
|
-
def liquid_assigns
|
37
|
-
@liquid_assigns ||= env.fetch('steam.liquid_assigns')
|
38
|
-
end
|
39
|
-
|
40
|
-
def locales
|
41
|
-
site.locales
|
42
|
-
end
|
43
|
-
|
44
|
-
def default_locale
|
45
|
-
site.default_locale
|
46
|
-
end
|
47
|
-
|
48
|
-
def live_editing?
|
49
|
-
!!env['steam.live_editing']
|
50
|
-
end
|
51
|
-
|
52
|
-
def mounted_on
|
53
|
-
env['steam.mounted_on']
|
54
|
-
end
|
55
|
-
|
56
|
-
# if this is a JSON request with a JSON body, try to parse it
|
57
|
-
# if we are unable to parse it, fallback to the original params
|
58
|
-
def params
|
59
|
-
@params = env['steam.params']
|
60
|
-
|
61
|
-
return @params if @params.present?
|
62
|
-
|
63
|
-
if json? && (request.post? || request.put?)
|
64
|
-
@params = JSON.parse(request.body.read) rescue nil
|
65
|
-
|
66
|
-
request.body.rewind # leave the body as it was before we touched it
|
67
|
-
end
|
68
|
-
|
69
|
-
@params = env['steam.params'] = (@params || request.params).with_indifferent_access
|
70
|
-
end
|
71
|
-
|
72
|
-
#= Useful getters =
|
73
|
-
|
74
|
-
def html?
|
75
|
-
['text/html', 'application/x-www-form-urlencoded', 'multipart/form-data'].include?(self.request.media_type) &&
|
76
|
-
!self.request.xhr? &&
|
77
|
-
!self.json?
|
78
|
-
end
|
79
|
-
|
80
|
-
def json?
|
81
|
-
self.request.content_type == 'application/json' || File.extname(self.request.path) == '.json'
|
82
|
-
end
|
83
|
-
|
84
|
-
#= Helper methods
|
85
|
-
|
86
|
-
def render_response(content, code = 200, type = nil)
|
87
|
-
@next_response = [code, { 'Content-Type' => type || 'text/html' }, [content]]
|
88
|
-
end
|
89
|
-
|
90
|
-
def redirect_to(location, type = 301)
|
91
|
-
_location = mounted_on && !location.starts_with?(mounted_on) && (location =~ Locomotive::Steam::IsHTTP).nil? ? "#{mounted_on}#{location}" : location
|
92
|
-
|
93
|
-
self.log "Redirected to #{_location}".blue
|
94
|
-
|
95
|
-
@next_response = [type, { 'Content-Type' => 'text/html', 'Location' => _location }, []]
|
96
|
-
end
|
97
|
-
|
98
|
-
def modify_path(path = nil, &block)
|
99
|
-
path ||= env['steam.path']
|
100
|
-
|
101
|
-
segments = path.split('/')
|
102
|
-
yield(segments)
|
103
|
-
path = segments.join('/')
|
104
|
-
|
105
|
-
path = '/' if path.blank?
|
106
|
-
path += "?#{request.query_string}" unless request.query_string.empty?
|
107
|
-
path
|
108
|
-
end
|
109
|
-
|
110
|
-
# make sure the location passed in parameter doesn't
|
111
|
-
# include the "mounted_on" parameter.
|
112
|
-
# If so, returns the location without the "mounted_on" string.
|
113
|
-
def make_local_path(location)
|
114
|
-
return location if mounted_on.blank?
|
115
|
-
location.gsub(Regexp.new('^' + mounted_on), '')
|
116
|
-
end
|
117
|
-
|
118
|
-
def decorate_entry(entry)
|
119
|
-
return nil if entry.nil?
|
120
|
-
Locomotive::Steam::Decorators::I18nDecorator.new(entry, locale, default_locale)
|
121
|
-
end
|
122
|
-
|
123
|
-
def default_liquid_context
|
124
|
-
::Liquid::Context.new({ 'site' => site.to_liquid }, {}, {
|
125
|
-
request: request,
|
126
|
-
locale: locale,
|
127
|
-
site: site,
|
128
|
-
services: services,
|
129
|
-
repositories: services.repositories
|
130
|
-
}, true)
|
131
|
-
end
|
132
|
-
|
133
|
-
def log(msg, offset = 2)
|
134
|
-
Locomotive::Common::Logger.info (' ' * offset) + msg
|
135
|
-
end
|
136
|
-
|
137
|
-
end
|
138
|
-
|
139
|
-
end
|
140
|
-
end
|
Binary file
|