sinicum 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.cane +19 -0
- data/.gitignore +14 -0
- data/.rubocop.yml +30 -0
- data/.travis.yml +14 -0
- data/Gemfile +4 -0
- data/LICENSE +24 -0
- data/README.md +327 -0
- data/Rakefile +37 -0
- data/app/assets/javascripts/sinicum/magnolia_client.js.coffee +233 -0
- data/app/controllers/sinicum/controller_base.rb +173 -0
- data/app/controllers/sinicum/controllers/cache_aware.rb +16 -0
- data/app/controllers/sinicum/controllers/global_state_cache.rb +83 -0
- data/app/helpers/sinicum/helper_utils.rb +152 -0
- data/app/helpers/sinicum/mgnl_helper.rb +145 -0
- data/app/helpers/sinicum/mgnl_helper5.rb +7 -0
- data/app/helpers/sinicum/mgnl_image_helper.rb +26 -0
- data/app/helpers/sinicum/taglib_helper5.rb +166 -0
- data/gemfiles/Gemfile-3.2 +6 -0
- data/gemfiles/Gemfile-4.0 +6 -0
- data/lib/generators/sinicum/install_generator.rb +162 -0
- data/lib/generators/sinicum/templates/VersionHandler.java +18 -0
- data/lib/generators/sinicum/templates/config/default/log4j-development.xml +203 -0
- data/lib/generators/sinicum/templates/config/default/log4j.xml +200 -0
- data/lib/generators/sinicum/templates/config/default/magnolia-author.properties +63 -0
- data/lib/generators/sinicum/templates/config/default/magnolia-public01.properties +63 -0
- data/lib/generators/sinicum/templates/config/default/magnolia.properties +63 -0
- data/lib/generators/sinicum/templates/config/repo-conf/jackrabbit-bundle-postgres-search-author.xml +73 -0
- data/lib/generators/sinicum/templates/config/repo-conf/jackrabbit-bundle-postgres-search-public01.xml +73 -0
- data/lib/generators/sinicum/templates/config/repo-conf/jackrabbit-bundle-postgres-search.xml +70 -0
- data/lib/generators/sinicum/templates/magnolia/config.modules.myproject.dialogs.xml +1625 -0
- data/lib/generators/sinicum/templates/magnolia/config.modules.myproject.templates.xml +247 -0
- data/lib/generators/sinicum/templates/module-config.xml +13 -0
- data/lib/generators/sinicum/templates/module-pom.xml +67 -0
- data/lib/generators/sinicum/templates/project-pom.xml +104 -0
- data/lib/generators/sinicum/templates/rails/_article.html.haml +15 -0
- data/lib/generators/sinicum/templates/rails/_content.html.haml +2 -0
- data/lib/generators/sinicum/templates/rails/_meta.html.haml +9 -0
- data/lib/generators/sinicum/templates/rails/application.html.haml +11 -0
- data/lib/generators/sinicum/templates/rails/content_controller.rb +5 -0
- data/lib/generators/sinicum/templates/rails/imaging.yml +8 -0
- data/lib/generators/sinicum/templates/rails/sinicum_server.yml +15 -0
- data/lib/sinicum.rb +53 -0
- data/lib/sinicum/content/aggregator.rb +173 -0
- data/lib/sinicum/content/website_content_resolver.rb +10 -0
- data/lib/sinicum/engine.rb +23 -0
- data/lib/sinicum/imaging.rb +29 -0
- data/lib/sinicum/imaging/config.rb +133 -0
- data/lib/sinicum/imaging/converter.rb +81 -0
- data/lib/sinicum/imaging/default_converter.rb +20 -0
- data/lib/sinicum/imaging/image_size_converter.rb +52 -0
- data/lib/sinicum/imaging/imaging.rb +171 -0
- data/lib/sinicum/imaging/imaging_file.rb +115 -0
- data/lib/sinicum/imaging/imaging_middleware.rb +56 -0
- data/lib/sinicum/imaging/max_size_converter.rb +39 -0
- data/lib/sinicum/imaging/resize_crop_converter.rb +35 -0
- data/lib/sinicum/jcr/api_client.rb +50 -0
- data/lib/sinicum/jcr/api_queries.rb +37 -0
- data/lib/sinicum/jcr/cache/global_cache.rb +26 -0
- data/lib/sinicum/jcr/dam/document.rb +57 -0
- data/lib/sinicum/jcr/dam/image.rb +40 -0
- data/lib/sinicum/jcr/jcr_configuration.rb +67 -0
- data/lib/sinicum/jcr/mgnl4_compatibility.rb +11 -0
- data/lib/sinicum/jcr/node.rb +268 -0
- data/lib/sinicum/jcr/node_initializer.rb +16 -0
- data/lib/sinicum/jcr/node_queries.rb +101 -0
- data/lib/sinicum/jcr/query_sanitizer.rb +24 -0
- data/lib/sinicum/jcr/type_translator.rb +38 -0
- data/lib/sinicum/jcr/type_translators/component_translator.rb +28 -0
- data/lib/sinicum/jcr/type_translators/dam_translator.rb +33 -0
- data/lib/sinicum/jcr/type_translators/data_translator.rb +31 -0
- data/lib/sinicum/jcr/type_translators/default_translator.rb +13 -0
- data/lib/sinicum/jcr/type_translators/translator_base.rb +40 -0
- data/lib/sinicum/logger.rb +28 -0
- data/lib/sinicum/navigation/default_navigation_element.rb +30 -0
- data/lib/sinicum/navigation/navigation_element.rb +39 -0
- data/lib/sinicum/navigation/navigation_element_list.rb +33 -0
- data/lib/sinicum/navigation/navigation_handler.rb +95 -0
- data/lib/sinicum/navigation/navigation_status.rb +27 -0
- data/lib/sinicum/templating/area_handler.rb +33 -0
- data/lib/sinicum/templating/dialog_resolver.rb +26 -0
- data/lib/sinicum/templating/templating_utils.rb +24 -0
- data/lib/sinicum/util.rb +12 -0
- data/lib/sinicum/version.rb +3 -0
- data/script/cibuild +31 -0
- data/sinicum.gemspec +29 -0
- data/spec/controllers/sinicum/controller_base_spec.rb +53 -0
- data/spec/controllers/sinicum/controllers/global_state_cache_spec.rb +35 -0
- data/spec/dummy/REVISION +1 -0
- data/spec/dummy/Rakefile +7 -0
- data/spec/dummy/app/controllers/application_controller.rb +5 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/views/application/index.html.erb +1 -0
- data/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy/app/views/layouts/layout_name.html.erb +0 -0
- data/spec/dummy/app/views/layouts/my-module/test.html.erb +0 -0
- data/spec/dummy/app/views/layouts/my_module/test.html.erb +0 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/config/application.rb +45 -0
- data/spec/dummy/config/boot.rb +10 -0
- data/spec/dummy/config/database.yml +22 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +24 -0
- data/spec/dummy/config/environments/production.rb +51 -0
- data/spec/dummy/config/environments/test.rb +34 -0
- data/spec/dummy/config/imaging.yml +7 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/inflections.rb +10 -0
- data/spec/dummy/config/initializers/mime_types.rb +5 -0
- data/spec/dummy/config/initializers/secret_token.rb +11 -0
- data/spec/dummy/config/initializers/session_store.rb +8 -0
- data/spec/dummy/config/locales/en.yml +5 -0
- data/spec/dummy/config/routes.rb +59 -0
- data/spec/dummy/config/sinicum_server.yml +13 -0
- data/spec/dummy/public/404.html +26 -0
- data/spec/dummy/public/422.html +26 -0
- data/spec/dummy/public/500.html +26 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/public/javascripts/application.js +2 -0
- data/spec/dummy/public/javascripts/controls.js +965 -0
- data/spec/dummy/public/javascripts/dragdrop.js +974 -0
- data/spec/dummy/public/javascripts/effects.js +1123 -0
- data/spec/dummy/public/javascripts/prototype.js +6001 -0
- data/spec/dummy/public/javascripts/rails.js +191 -0
- data/spec/dummy/public/stylesheets/.gitkeep +0 -0
- data/spec/dummy/script/rails +6 -0
- data/spec/fixtures/api/cache_global.json +3 -0
- data/spec/fixtures/api/content_mgnl5.json +22 -0
- data/spec/fixtures/api/default_json.json.erb +47 -0
- data/spec/fixtures/api/default_json_mgnl5.json.erb +27 -0
- data/spec/fixtures/api/file.json +73 -0
- data/spec/fixtures/api/file_mgnl5.json +51 -0
- data/spec/fixtures/api/homepage.json +1497 -0
- data/spec/fixtures/api/homepage_parent.json +483 -0
- data/spec/fixtures/api/image.json +73 -0
- data/spec/fixtures/api/image_mgnl5.json +50 -0
- data/spec/fixtures/api/navigation_children.json +3107 -0
- data/spec/fixtures/api/navigation_parents.json +25 -0
- data/spec/fixtures/api/product.json +2084 -0
- data/spec/fixtures/api/query_result.json +61 -0
- data/spec/fixtures/mock_content.rb +6 -0
- data/spec/fixtures/mock_image.gif +0 -0
- data/spec/helpers/sinicum/helper_utils_spec.rb +55 -0
- data/spec/helpers/sinicum/mgnl_helper_spec.rb +315 -0
- data/spec/helpers/sinicum/mgnl_image_helper_spec.rb +103 -0
- data/spec/sinicum/content/aggregator_spec.rb +91 -0
- data/spec/sinicum/content/website_content_resolver_spec.rb +14 -0
- data/spec/sinicum/imaging/config_spec.rb +50 -0
- data/spec/sinicum/imaging/converter_spec.rb +41 -0
- data/spec/sinicum/imaging/image_size_converter_spec.rb +27 -0
- data/spec/sinicum/imaging/imaging.yml +15 -0
- data/spec/sinicum/imaging/imaging_file_spec.rb +125 -0
- data/spec/sinicum/imaging/imaging_middleware_spec.rb +79 -0
- data/spec/sinicum/imaging/max_size_converter_spec.rb +52 -0
- data/spec/sinicum/imaging/resize_crop_converter_spec.rb +18 -0
- data/spec/sinicum/imaging_spec.rb +13 -0
- data/spec/sinicum/jcr/api_client_spec.rb +69 -0
- data/spec/sinicum/jcr/cache/global_cache_spec.rb +29 -0
- data/spec/sinicum/jcr/dam/document_spec.rb +81 -0
- data/spec/sinicum/jcr/dam/image_spec.rb +46 -0
- data/spec/sinicum/jcr/jcr_configuration_spec.rb +57 -0
- data/spec/sinicum/jcr/mgnl4_compatibility_spec.rb +10 -0
- data/spec/sinicum/jcr/node_queries_spec.rb +113 -0
- data/spec/sinicum/jcr/node_spec.rb +261 -0
- data/spec/sinicum/jcr/query_sanitizer_spec.rb +26 -0
- data/spec/sinicum/jcr/type_translator_spec.rb +42 -0
- data/spec/sinicum/jcr/type_translators/component_translator_spec.rb +71 -0
- data/spec/sinicum/jcr/type_translators/data_translator_spec.rb +38 -0
- data/spec/sinicum/jcr/type_translators/default_translator_spec.rb +19 -0
- data/spec/sinicum/navigation/default_navigation_element_spec.rb +45 -0
- data/spec/sinicum/navigation/navigation_handler_spec.rb +71 -0
- data/spec/sinicum/templating/dialog_resolver_spec.rb +13 -0
- data/spec/sinicum/util_spec.rb +34 -0
- data/spec/spec_helper.rb +42 -0
- data/spec/support/default_node_reader.rb +40 -0
- metadata +434 -0
data/Rakefile
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
begin
|
2
|
+
require 'bundler/setup'
|
3
|
+
rescue LoadError
|
4
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
5
|
+
end
|
6
|
+
Bundler::GemHelper.install_tasks
|
7
|
+
|
8
|
+
require 'rake'
|
9
|
+
require 'rdoc/task'
|
10
|
+
|
11
|
+
require 'rspec/core/rake_task'
|
12
|
+
RSpec::Core::RakeTask.new(:spec)
|
13
|
+
|
14
|
+
require 'rubocop/rake_task'
|
15
|
+
Rubocop::RakeTask.new(:rubocop) do |task|
|
16
|
+
# don't abort rake on failure
|
17
|
+
task.fail_on_error = false
|
18
|
+
end
|
19
|
+
|
20
|
+
task default: [:spec, :rubocop]
|
21
|
+
|
22
|
+
desc "Create Sinicum plugin documentation"
|
23
|
+
task :doc do |doc|
|
24
|
+
|
25
|
+
require 'yard'
|
26
|
+
|
27
|
+
gem_root = File.dirname(__FILE__)
|
28
|
+
|
29
|
+
docdir = ENV['docdir'] || File.join(gem_root, "doc")
|
30
|
+
rm_r Dir.glob(docdir + "/*") if File.exists?(docdir)
|
31
|
+
YARD::Rake::YardocTask.new do |t|
|
32
|
+
t.files = [File.join(gem_root, "lib", "**", "*.rb")] # optional
|
33
|
+
t.options = ['-m', 'markdown', '--protected', '-o', docdir,
|
34
|
+
'-r', File.join(gem_root, "README.md")]
|
35
|
+
end
|
36
|
+
Rake::Task[:yard].invoke
|
37
|
+
end
|
@@ -0,0 +1,233 @@
|
|
1
|
+
sinicum = sinicum ? { }
|
2
|
+
|
3
|
+
sinicum.renderDocumentReady = true
|
4
|
+
|
5
|
+
|
6
|
+
class sinicum.MagnoliaClient
|
7
|
+
setMainBar: (elements) ->
|
8
|
+
jQuery.each(elements, (index, value) ->
|
9
|
+
element = jQuery(value)
|
10
|
+
config = {}
|
11
|
+
config['dialog'] = element.data("dialog")
|
12
|
+
config['label'] = element.data("label")
|
13
|
+
config['adminButtonVisible'] = element.data("admin-button-visible")
|
14
|
+
config['repository'] = element.data("repository")
|
15
|
+
config['nodePath'] = element.data("node-path")
|
16
|
+
element.wrapInner(new sinicum.MainBar(config).render())
|
17
|
+
)
|
18
|
+
|
19
|
+
setMainBarPreview: (elements) ->
|
20
|
+
jQuery.each(elements, (index, value) ->
|
21
|
+
element = jQuery(value)
|
22
|
+
element.wrapInner(new sinicum.MainBarPreview().render())
|
23
|
+
)
|
24
|
+
|
25
|
+
setNewBar: (elements) ->
|
26
|
+
jQuery.each(elements, (index, value) ->
|
27
|
+
element = jQuery(value)
|
28
|
+
config = {}
|
29
|
+
config['contentNodeCollectionName'] = element.data("content-node-collection-name")
|
30
|
+
config['contentNodeName'] = element.data("content-node-name")
|
31
|
+
config['label'] = element.data("label")
|
32
|
+
config['paragraph'] = element.data("paragraph")
|
33
|
+
config['repository'] = element.data("repository")
|
34
|
+
config['nodePath'] = element.data("node-path")
|
35
|
+
element.wrapInner(new sinicum.NewBar(config).render())
|
36
|
+
)
|
37
|
+
|
38
|
+
setEditBar: (elements) ->
|
39
|
+
jQuery.each(elements, (index, value) ->
|
40
|
+
element = jQuery(value)
|
41
|
+
config = {}
|
42
|
+
config['repository'] = element.data("repository")
|
43
|
+
config['nodePath'] = element.data("node-path")
|
44
|
+
config['paragraph'] = element.data("paragraph")
|
45
|
+
config['contentNodeCollectionName'] = element.data("content-node-collection-name")
|
46
|
+
config['contentNodeIteratorIndex'] = element.attr("data-content-node-iterator-index")
|
47
|
+
config['contentNodeIteratorPath'] = element.data("content-node-iterator-path")
|
48
|
+
config['deleteLabel'] = element.data("delete-label")
|
49
|
+
config['editLabel'] = element.data("edit-label")
|
50
|
+
config['moveLabel'] = element.data("move-label")
|
51
|
+
element.wrapInner(new sinicum.EditBar(config).render())
|
52
|
+
)
|
53
|
+
|
54
|
+
|
55
|
+
class sinicum.MainBar
|
56
|
+
constructor: (options) ->
|
57
|
+
@label = "Properties"
|
58
|
+
@adminButtonVisible = true
|
59
|
+
if options
|
60
|
+
@dialog = options['dialog']
|
61
|
+
@repository = options['repository']
|
62
|
+
@nodePath = options['nodePath']
|
63
|
+
if options['label']
|
64
|
+
@label = options['label']
|
65
|
+
if options['adminButtonVisible'] == false || options['adminButtonVisible'] == 'false'
|
66
|
+
@adminButtonVisible = false
|
67
|
+
|
68
|
+
render: ->
|
69
|
+
wrapper = jQuery("<div class\"mgnlMainBar\" style=\"top:0px;left:0px;width:100%;\"></div>")
|
70
|
+
wrapper.append(this.renderControlBarTable())
|
71
|
+
|
72
|
+
renderControlBarTable: ->
|
73
|
+
# left
|
74
|
+
leftColumn = jQuery("<td class=\"mgnlBtnsLeft\"></td>")
|
75
|
+
leftColumn.append(btn.render()) for btn in this.leftButtons()
|
76
|
+
# right
|
77
|
+
rightColumn = jQuery("<td class=\"mgnlBtnsRight\"></td>")
|
78
|
+
rightColumn.append(btn.render()) for btn in this.rightButtons()
|
79
|
+
# table structure
|
80
|
+
row = jQuery("<tr></tr>").append(leftColumn).append(rightColumn)
|
81
|
+
body = jQuery("<tbody></tbody>").append(row)
|
82
|
+
table = jQuery("<table class=\"mgnlControlBar\"></table>").append(body)
|
83
|
+
table
|
84
|
+
|
85
|
+
leftButtons: ->
|
86
|
+
buttons = []
|
87
|
+
buttons.push(new sinicum.MgnlButton("« Preview", "mgnlPreview(true)"))
|
88
|
+
if @adminButtonVisible
|
89
|
+
buttons.push(new sinicum.MgnlButton("AdminCentral",
|
90
|
+
"MgnlAdminCentral.showTree(\'#{this.escJs(@repository)}\'," +
|
91
|
+
"\'#{this.escJs(@nodePath)}\')"))
|
92
|
+
buttons
|
93
|
+
|
94
|
+
rightButtons: ->
|
95
|
+
[
|
96
|
+
new sinicum.MgnlButton(@label,
|
97
|
+
"mgnlOpenDialog(\'#{this.escJs(@nodePath)}\',\'\',\'\',\'#{this.escJs(@dialog)}\'," +
|
98
|
+
"\'#{this.escJs(@repository)}\',null, null, null)")
|
99
|
+
]
|
100
|
+
|
101
|
+
escJs: (string) ->
|
102
|
+
if string
|
103
|
+
string.replace(/\'/g, "\\'")
|
104
|
+
|
105
|
+
class sinicum.MainBarPreview
|
106
|
+
render: ->
|
107
|
+
html = "<div class=\"mgnlMainbarPreview\" style=\"top:4px;left:4px;\">" +
|
108
|
+
"<span onmousedown=\"mgnlShiftPushButtonDown(this);\" " +
|
109
|
+
"onmouseout=\"mgnlShiftPushButtonOut(this);\" " +
|
110
|
+
"onclick=\"mgnlShiftPushButtonClick(this);mgnlPreview(false);\" " +
|
111
|
+
"class=\"mgnlControlButton\" style=\"\">»</span>" +
|
112
|
+
"</div>"
|
113
|
+
jQuery(html)
|
114
|
+
|
115
|
+
|
116
|
+
class sinicum.NewBar
|
117
|
+
constructor: (options) ->
|
118
|
+
@contentNodeCollectionName = options['contentNodeCollectionName']
|
119
|
+
@contentNodeName = options['contentNodeName']
|
120
|
+
@label = "New" || options['label']
|
121
|
+
@paragraph = options['paragraph']
|
122
|
+
@repository = options['repository']
|
123
|
+
@nodePath = options['nodePath']
|
124
|
+
|
125
|
+
render: ->
|
126
|
+
html = "<table onmousedown=\"mgnlMoveNodeEnd(this,'#{@nodePath}');\" " +
|
127
|
+
"onmouseout=\"mgnlMoveNodeReset(this);\" onmouseover=\"mgnlMoveNodeHigh(this);\" " +
|
128
|
+
"class=\"mgnlControlBarSmall\" id=\"#{@contentNodeCollectionName}__mgnlNew\" cellspacing=\"0\">" +
|
129
|
+
"<tbody><tr><td class=\"mgnlBtnsLeft\">" +
|
130
|
+
"<span onmousedown=\"mgnlShiftPushButtonDown(this);\" " +
|
131
|
+
"onmouseout=\"mgnlShiftPushButtonOut(this);\" " +
|
132
|
+
"onclick=\"mgnlShiftPushButtonClick(this);" +
|
133
|
+
"mgnlOpenDialog('#{@nodePath}',"
|
134
|
+
if @contentNodeCollectionName
|
135
|
+
html += "'#{@contentNodeCollectionName}','mgnlNew',"
|
136
|
+
else if @contentNodeName
|
137
|
+
html += "'','#{@contentNodeName}',"
|
138
|
+
html += "'#{@paragraph}','#{@repository}'," +
|
139
|
+
"'.magnolia/dialogs/#{this.editPageName()}', null, null);\" " +
|
140
|
+
"class=\"mgnlControlButtonSmall\" style=\"background-color: transparent; " +
|
141
|
+
"background-position: initial initial; background-repeat: initial initial; \">" +
|
142
|
+
"New</span></td></tr></tbody></table>"
|
143
|
+
wrapper = jQuery(html)
|
144
|
+
wrapper
|
145
|
+
|
146
|
+
editPageName: ->
|
147
|
+
pageName = "editParagraph.html"
|
148
|
+
if @paragraph && @paragraph.indexOf(",") > 0
|
149
|
+
pageName = "selectParagraph.html"
|
150
|
+
pageName
|
151
|
+
|
152
|
+
|
153
|
+
class sinicum.EditBar
|
154
|
+
constructor: (options) ->
|
155
|
+
@repository = options['repository']
|
156
|
+
@nodePath = options['nodePath']
|
157
|
+
@paragraph = options['paragraph']
|
158
|
+
@deleteLabel = options['deleteLabel'] || "Delete"
|
159
|
+
@editLabel = options['editLabel'] || "Edit"
|
160
|
+
@moveLabel = options['moveLabel'] || "Move"
|
161
|
+
@contentNodeCollectionName = options['contentNodeCollectionName']
|
162
|
+
@contentNodeIteratorIndex = options['contentNodeIteratorIndex']
|
163
|
+
@contentNodeIteratorPath = options['contentNodeIteratorPath']
|
164
|
+
|
165
|
+
render: ->
|
166
|
+
html = "<table onmousedown=\"mgnlMoveNodeEnd(this,'#{@nodePath}');\" " +
|
167
|
+
"onmouseout=\"mgnlMoveNodeReset(this);\" onmouseover=\"mgnlMoveNodeHigh(this);\" " +
|
168
|
+
"class=\"mgnlControlBarSmall\" id=\"__#{@contentNodeIteratorIndex || 0}\" cellspacing=\"0\">" +
|
169
|
+
"<tbody><tr><td class=\"mgnlBtnsLeft\">" +
|
170
|
+
|
171
|
+
"<span onmousedown=\"mgnlShiftPushButtonDown(this);\" " +
|
172
|
+
"onmouseout=\"mgnlShiftPushButtonOut(this);\" " +
|
173
|
+
"onclick=\"mgnlShiftPushButtonClick(this);mgnlOpenDialog("
|
174
|
+
if @contentNodeCollectionName
|
175
|
+
html += "'#{@nodePath}','','#{@contentNodeIteratorIndex}',"
|
176
|
+
else
|
177
|
+
html += "'#{@nodePath}','','',"
|
178
|
+
html += "'#{@paragraph}','#{@repository}'," +
|
179
|
+
"'.magnolia/dialogs/#{this.editPageName()}', null, null);\" " +
|
180
|
+
"class=\"mgnlControlButtonSmall\" style=\"background:transparent;\">#{@editLabel}</span>"
|
181
|
+
|
182
|
+
if @contentNodeCollectionName
|
183
|
+
html += "<span onmousedown=\"mgnlShiftPushButtonDown(this);\" " +
|
184
|
+
"onmouseout=\"mgnlShiftPushButtonOut(this);\" " +
|
185
|
+
"onclick=\"mgnlShiftPushButtonClick(this);mgnlMoveNodeStart('','#{@contentNodeIteratorIndex}','__#{@contentNodeIteratorIndex}');\" " +
|
186
|
+
"class=\"mgnlControlButtonSmall\" style=\"background:transparent;\">#{@moveLabel}</span></td>"
|
187
|
+
|
188
|
+
html += "<td class=\"mgnlBtnsRight\"><span onmousedown=\"mgnlShiftPushButtonDown(this);\" " +
|
189
|
+
"onmouseout=\"mgnlShiftPushButtonOut(this);\" onclick=\"mgnlShiftPushButtonClick(this);"
|
190
|
+
if @contentNodeCollectionName
|
191
|
+
html += "mgnlDeleteNode('#{@nodePath}','','#{@contentNodeIteratorIndex}');\" "
|
192
|
+
else
|
193
|
+
html += "mgnlDeleteNode('#{@nodePath}');\" "
|
194
|
+
html += "class=\"mgnlControlButtonSmall\" style=\"background:transparent;\">#{@deleteLabel}" +
|
195
|
+
"</span></td></tr></tbody></table>"
|
196
|
+
wrapper = jQuery(html)
|
197
|
+
wrapper
|
198
|
+
|
199
|
+
editPageName: ->
|
200
|
+
pageName = "editParagraph.html"
|
201
|
+
if @paragraph && @paragraph.indexOf(",") > 0
|
202
|
+
pageName = "selectParagraph.html"
|
203
|
+
pageName
|
204
|
+
|
205
|
+
|
206
|
+
class sinicum.MgnlButton
|
207
|
+
constructor: (@text, @onclickAction) ->
|
208
|
+
|
209
|
+
render: ->
|
210
|
+
button = jQuery("<span></span>")
|
211
|
+
button.addClass("mgnlControlButton")
|
212
|
+
button = button.attr("onmousedown", "mgnlShiftPushButtonDown(this);")
|
213
|
+
button = button.attr("onmouseout", "mgnlShiftPushButtonOut(this);")
|
214
|
+
button = button.attr("onclick", "mgnlShiftPushButtonClick(this);#{@onclickAction};")
|
215
|
+
button = button.css("background", "transparent")
|
216
|
+
button = button.text(@text)
|
217
|
+
button
|
218
|
+
|
219
|
+
sinicum.renderBars = ->
|
220
|
+
client = new sinicum.MagnoliaClient()
|
221
|
+
client.setMainBar(jQuery(".sinicum-mgnl-main-bar"))
|
222
|
+
client.setMainBarPreview(jQuery(".sinicum-mgnl-main-bar-preview"))
|
223
|
+
client.setEditBar(jQuery(".sinicum-mgnl-edit-bar"))
|
224
|
+
client.setNewBar(jQuery(".sinicum-mgnl-new-bar"))
|
225
|
+
|
226
|
+
sinicum.preventDefaultRender = ->
|
227
|
+
sinicum.renderDocumentReady = false
|
228
|
+
|
229
|
+
window.sinicum = sinicum
|
230
|
+
|
231
|
+
jQuery ->
|
232
|
+
if sinicum.renderDocumentReady
|
233
|
+
sinicum.renderBars()
|
@@ -0,0 +1,173 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module Sinicum
|
4
|
+
module ControllerBase
|
5
|
+
HTML_SUFFIX = ".html"
|
6
|
+
extend ActiveSupport::Concern
|
7
|
+
include Controllers::CacheAware
|
8
|
+
|
9
|
+
included do
|
10
|
+
prepend_before_filter ::Sinicum::Controllers::GlobalStateCache
|
11
|
+
prepend_before_filter :remove_html_suffix
|
12
|
+
after_filter ::Sinicum::Controllers::GlobalStateCache
|
13
|
+
end
|
14
|
+
|
15
|
+
def index
|
16
|
+
cms_render
|
17
|
+
end
|
18
|
+
|
19
|
+
def render(options = {}, locals = {}, &block)
|
20
|
+
find_original_content_for_path(content_path)
|
21
|
+
unless redirect_redirect_page
|
22
|
+
check_for_content!
|
23
|
+
options[:layout] = layout_file_name_or_fallback
|
24
|
+
block_given? ? super(options, locals, block) : super(options, locals)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
# Deprecated!
|
29
|
+
def cms_render
|
30
|
+
client_cache_control
|
31
|
+
render inline: "", use_sinicum_template_layout: true
|
32
|
+
end
|
33
|
+
|
34
|
+
protected
|
35
|
+
|
36
|
+
def content_path
|
37
|
+
request.path
|
38
|
+
end
|
39
|
+
|
40
|
+
def find_original_content_for_path(path = nil)
|
41
|
+
path ||= content_path
|
42
|
+
original_content = Content::WebsiteContentResolver.find_for_path(path)
|
43
|
+
Content::Aggregator.original_content = original_content
|
44
|
+
end
|
45
|
+
|
46
|
+
# Constructs the name of the layout file. Per default: Name of the template without special
|
47
|
+
# characters and spaces. Override in subclasses.
|
48
|
+
#
|
49
|
+
# @return [String] the layout filename (without 'html.erb')
|
50
|
+
def layout_file_name
|
51
|
+
layout = "application"
|
52
|
+
fail unless Content::Aggregator.original_content
|
53
|
+
prepare_layout(layout)
|
54
|
+
end
|
55
|
+
|
56
|
+
private
|
57
|
+
|
58
|
+
def prepare_layout(layout)
|
59
|
+
if Content::Aggregator.original_content &&
|
60
|
+
Content::Aggregator.original_content.mgnl_template
|
61
|
+
layout = Content::Aggregator.original_content.mgnl_template.dup
|
62
|
+
end
|
63
|
+
layout = handle_mgnl45_names(layout)
|
64
|
+
layout = handle_umlauts(layout)
|
65
|
+
layout.downcase!
|
66
|
+
layout.gsub!(/\s/, '_')
|
67
|
+
layout.gsub!(/[^\w\/-]/, '')
|
68
|
+
add_sinicum_layout_prefix(layout)
|
69
|
+
end
|
70
|
+
|
71
|
+
def add_sinicum_layout_prefix(layout)
|
72
|
+
if self.class.sinicum_layout_prefix.present?
|
73
|
+
layout = self.class.sinicum_layout_prefix + "/" + layout
|
74
|
+
end
|
75
|
+
layout
|
76
|
+
end
|
77
|
+
|
78
|
+
def check_for_content!
|
79
|
+
unless Sinicum::Content::Aggregator.content_data
|
80
|
+
fail ActionController::RoutingError.new("Page not found.")
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
def handle_mgnl45_names(layout_name)
|
85
|
+
result = layout_name
|
86
|
+
if result.index(":pages/")
|
87
|
+
parts = layout_name.split(":")
|
88
|
+
result = parts[0] + "/"
|
89
|
+
result << parts[1][":pages/".size - 1, parts[1].size]
|
90
|
+
end
|
91
|
+
result
|
92
|
+
end
|
93
|
+
|
94
|
+
def redirect_redirect_page
|
95
|
+
return false if request.headers["HTTP_X_MGNL_ADMIN"].present?
|
96
|
+
page = ::Sinicum::Content::Aggregator.content_data
|
97
|
+
if redirect_page_45?(page) || redirect_page_44?(page)
|
98
|
+
redirect_target = page[:redirect_link]
|
99
|
+
if Sinicum::Util.is_a_uuid?(redirect_target)
|
100
|
+
redirect_target = Sinicum::Jcr::Node.find_by_uuid("website", redirect_target).try(:path)
|
101
|
+
end
|
102
|
+
redirect_to redirect_target
|
103
|
+
true
|
104
|
+
end
|
105
|
+
false
|
106
|
+
end
|
107
|
+
|
108
|
+
def redirect_page_44?(page)
|
109
|
+
template_exists?(page) && page.mgnl_template == "redirect" && page[:redirect_link]
|
110
|
+
end
|
111
|
+
|
112
|
+
def redirect_page_45?(page)
|
113
|
+
template_exists?(page) && page.mgnl_template.index("pages/redirect") && page[:redirect_link]
|
114
|
+
end
|
115
|
+
|
116
|
+
def template_exists?(page)
|
117
|
+
page && page.mgnl_template
|
118
|
+
end
|
119
|
+
|
120
|
+
# Determines the name of the layout file that is _actually_ used by the controller.
|
121
|
+
# By default it's the result of `layout_file_name`. If this file cannot be found, a
|
122
|
+
# default replacement (`application`) is used
|
123
|
+
#
|
124
|
+
# @return [String] the name of the layout file actually used
|
125
|
+
def layout_file_name_or_fallback
|
126
|
+
ActionController::Base.view_paths.each do |path|
|
127
|
+
ActionView::Template::Handlers.extensions.each do |engine_suffix|
|
128
|
+
format = params[:format].presence || "html"
|
129
|
+
file_in_path = File.join(
|
130
|
+
path.to_s, "layouts", "#{layout_file_name}.#{format}.#{engine_suffix}"
|
131
|
+
)
|
132
|
+
return layout_file_name if File.exist?(file_in_path)
|
133
|
+
end
|
134
|
+
end
|
135
|
+
fallback = "application"
|
136
|
+
if self.class.sinicum_layout_prefix.present?
|
137
|
+
fallback = self.class.sinicum_layout_prefix + "/" + fallback
|
138
|
+
end
|
139
|
+
fallback
|
140
|
+
end
|
141
|
+
|
142
|
+
def remove_html_suffix
|
143
|
+
if request.get? && request.path =~ /#{HTML_SUFFIX}$/i
|
144
|
+
new_path = request.path[0, request.path.length - HTML_SUFFIX.length]
|
145
|
+
if request.query_string && !request.query_string.blank?
|
146
|
+
new_path << "?#{request.query_string}"
|
147
|
+
end
|
148
|
+
redirect_to new_path
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
152
|
+
def find_content_for_request
|
153
|
+
find_original_content_for_path(content_path)
|
154
|
+
yield
|
155
|
+
end
|
156
|
+
|
157
|
+
def handle_umlauts(layout)
|
158
|
+
if !layout.respond_to?(:encode)
|
159
|
+
@_iconv ||= Iconv.new("US-ASCII//IGNORE", "UTF-8")
|
160
|
+
layout = @_iconv.iconv(layout)
|
161
|
+
elsif layout
|
162
|
+
layout = layout.encode(
|
163
|
+
"US-ASCII", undef: :replace, invalid: :replace, replace: '-'
|
164
|
+
)
|
165
|
+
end
|
166
|
+
layout
|
167
|
+
end
|
168
|
+
|
169
|
+
module ClassMethods
|
170
|
+
attr_accessor :sinicum_layout_prefix
|
171
|
+
end
|
172
|
+
end
|
173
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Sinicum
|
2
|
+
module Controllers
|
3
|
+
module CacheAware
|
4
|
+
DEFAULT_CACHE_EXPIRATION_TIME = 10.minutes
|
5
|
+
TIMESTAMP_ASSET_EXPIRATION_TIME = 30.days
|
6
|
+
|
7
|
+
# Sets the HTTP cache parameters. By default, an expiration time of 10 minutes and a
|
8
|
+
# public cache is used when `Rails.env` is `production`
|
9
|
+
def client_cache_control
|
10
|
+
if Rails.application.config.action_controller.perform_caching
|
11
|
+
expires_in(DEFAULT_CACHE_EXPIRATION_TIME, public: true)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|