sinicum 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
[ {
|
|
2
|
+
"properties" : { },
|
|
3
|
+
"nodes" : {
|
|
4
|
+
"MetaData" : {
|
|
5
|
+
"properties" : { },
|
|
6
|
+
"nodes" : { },
|
|
7
|
+
"meta" : {
|
|
8
|
+
"name" : "MetaData",
|
|
9
|
+
"path" : "/path/subpage1/MetaData",
|
|
10
|
+
"workspace" : "website",
|
|
11
|
+
"depth" : 3,
|
|
12
|
+
"mixinNodeTypes" : [ ],
|
|
13
|
+
"superTypes" : [ "mix:referenceable", "nt:base", "nt:hierarchyNode" ],
|
|
14
|
+
"jcr:uuid" : "f7a6d0b9-e6e9-470b-881d-967bab1e7f76",
|
|
15
|
+
"jcr:primaryType" : "mgnl:metaData",
|
|
16
|
+
"jcr:created" : "2013-06-03T10:17:45.260+02:00"
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
"meta" : {
|
|
21
|
+
"name" : "subpage1",
|
|
22
|
+
"path" : "/path/subpage1",
|
|
23
|
+
"workspace" : "website",
|
|
24
|
+
"depth" : 2,
|
|
25
|
+
"mixinNodeTypes" : [ ],
|
|
26
|
+
"superTypes" : [ "mix:referenceable", "nt:base", "nt:hierarchyNode", "mgnl:content" ],
|
|
27
|
+
"jcr:uuid" : "995a776f-242e-453a-9422-d0b7e8e9c068",
|
|
28
|
+
"jcr:primaryType" : "mgnl:page",
|
|
29
|
+
"jcr:created" : "2013-06-03T10:17:45.260+02:00"
|
|
30
|
+
}
|
|
31
|
+
}, {
|
|
32
|
+
"properties" : { },
|
|
33
|
+
"nodes" : {
|
|
34
|
+
"MetaData" : {
|
|
35
|
+
"properties" : { },
|
|
36
|
+
"nodes" : { },
|
|
37
|
+
"meta" : {
|
|
38
|
+
"name" : "MetaData",
|
|
39
|
+
"path" : "/path/subpage2/MetaData",
|
|
40
|
+
"workspace" : "website",
|
|
41
|
+
"depth" : 3,
|
|
42
|
+
"mixinNodeTypes" : [ ],
|
|
43
|
+
"superTypes" : [ "mix:referenceable", "nt:base", "nt:hierarchyNode" ],
|
|
44
|
+
"jcr:uuid" : "c37083de-6a57-48fe-95d0-41fe05fb2ac5",
|
|
45
|
+
"jcr:primaryType" : "mgnl:metaData",
|
|
46
|
+
"jcr:created" : "2013-06-03T10:17:45.260+02:00"
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
"meta" : {
|
|
51
|
+
"name" : "subpage2",
|
|
52
|
+
"path" : "/path/subpage2",
|
|
53
|
+
"workspace" : "website",
|
|
54
|
+
"depth" : 2,
|
|
55
|
+
"mixinNodeTypes" : [ ],
|
|
56
|
+
"superTypes" : [ "mix:referenceable", "nt:base", "nt:hierarchyNode", "mgnl:content" ],
|
|
57
|
+
"jcr:uuid" : "bba4bfcd-8347-40d0-9bb6-504ddde1c5a1",
|
|
58
|
+
"jcr:primaryType" : "mgnl:page",
|
|
59
|
+
"jcr:created" : "2013-06-03T10:17:45.260+02:00"
|
|
60
|
+
}
|
|
61
|
+
} ]
|
|
Binary file
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
require 'spec_helper'
|
|
3
|
+
require 'rexml/document'
|
|
4
|
+
|
|
5
|
+
module Sinicum
|
|
6
|
+
describe HelperUtils do
|
|
7
|
+
describe "#object_from_key_or_object" do
|
|
8
|
+
it "should return the node if a node is given as an argument" do
|
|
9
|
+
node = Jcr::Node.new
|
|
10
|
+
helper.send(:object_from_key_or_object, node).should eq(node)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
it "should query for the node if a UUID is given" do
|
|
14
|
+
uuid = "f082dc7a-c23c-42bf-8338-60a6bd5a777b"
|
|
15
|
+
node = Jcr::Node.new
|
|
16
|
+
Jcr::Node.should_receive(:find_by_uuid).with("website", uuid).and_return(node)
|
|
17
|
+
helper.send(:object_from_key_or_object, uuid, "website").should eq(node)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
it "should return the property from the current content data if a symbol is given" do
|
|
21
|
+
begin
|
|
22
|
+
content = { title: "Title" }
|
|
23
|
+
Content::Aggregator.original_content = content
|
|
24
|
+
helper.send(:object_from_key_or_object, :title).should eq("Title")
|
|
25
|
+
ensure
|
|
26
|
+
Content::Aggregator.clean
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
describe "#fingerprint_in_asset_path" do
|
|
32
|
+
it "should return when a fingerprint is in the path" do
|
|
33
|
+
helper.send(
|
|
34
|
+
:fingerprint_in_asset_path,
|
|
35
|
+
"/damfiles/image_text_button/home_welcome-841fef0a3e62db91ea8cc9feea6d87a4.jpg"
|
|
36
|
+
).should be true
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
it "should return true when a fingerprint is in the path and the suffix is missing" do
|
|
40
|
+
helper.send(
|
|
41
|
+
:fingerprint_in_asset_path,
|
|
42
|
+
"/damfiles/image_text_button/home_welcome-841fef0a3e62db91ea8cc9feea6d87a4"
|
|
43
|
+
).should be true
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
it "should return false when a fingerprint is not in the path" do
|
|
47
|
+
helper.send(
|
|
48
|
+
:fingerprint_in_asset_path,
|
|
49
|
+
"/damfiles/image_text_button/home_welcome"
|
|
50
|
+
).should be false
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
end
|
|
55
|
+
end
|
|
@@ -0,0 +1,315 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
require 'spec_helper'
|
|
3
|
+
require 'rexml/document'
|
|
4
|
+
|
|
5
|
+
module Sinicum
|
|
6
|
+
describe MgnlHelper do
|
|
7
|
+
describe "#mgnl_path" do
|
|
8
|
+
let(:node) do
|
|
9
|
+
node = Jcr::Node.new
|
|
10
|
+
node.stub(:jcr_path).and_return("/the/path")
|
|
11
|
+
node
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
let(:document) do
|
|
15
|
+
node = Jcr::Dam::Document.new
|
|
16
|
+
node.stub(:jcr_path).and_return("/the/path")
|
|
17
|
+
doc = double("document")
|
|
18
|
+
node.stub(:[]).and_return(nil)
|
|
19
|
+
node.stub(:[]).with(:'jcr:content').and_return(doc)
|
|
20
|
+
doc.stub(:[]).and_return(nil)
|
|
21
|
+
node
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
it "should return a node's path" do
|
|
25
|
+
helper.mgnl_path(node).should eq("/the/path")
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
it "should return the right path for a UUID string" do
|
|
29
|
+
Jcr::Node.should_receive(:find_by_uuid)
|
|
30
|
+
.with("website", "900985a3-319c-41c6-b327-b46d7fb56d23")
|
|
31
|
+
.and_return(node)
|
|
32
|
+
|
|
33
|
+
helper.mgnl_path("900985a3-319c-41c6-b327-b46d7fb56d23").should eq("/the/path")
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
it "should handle other repositories than the website" do
|
|
37
|
+
Jcr::Node.should_receive(:find_by_uuid)
|
|
38
|
+
.with("dam", "900985a3-319c-41c6-b327-b46d7fb56d23")
|
|
39
|
+
.and_return(node)
|
|
40
|
+
|
|
41
|
+
helper.mgnl_path("900985a3-319c-41c6-b327-b46d7fb56d23", workspace: "dam")
|
|
42
|
+
.should eq("/the/path")
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
it "should ignore the renderer when the node is not a document" do
|
|
46
|
+
helper.mgnl_path(node, renderer: "video").should eq("/the/path")
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
it "should work with the renderer when the node is a document" do
|
|
50
|
+
helper.mgnl_path(document, renderer: "video").should eq(
|
|
51
|
+
"/damfiles/video/the/path-fc308f85a906fce1be5ff58fd2853af5")
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
it "should return a string if the path given is a string" do
|
|
55
|
+
helper.mgnl_path("/some/path").should eq("/some/path")
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
it "should return a string if the property that defines the link returns a string" do
|
|
59
|
+
Jcr::Node.should_receive(:find_by_uuid)
|
|
60
|
+
.with("website", "900985a3-319c-41c6-b327-b46d7fb56d23")
|
|
61
|
+
.and_return("/some/path")
|
|
62
|
+
helper.mgnl_path("900985a3-319c-41c6-b327-b46d7fb56d23", workspace: "website")
|
|
63
|
+
.should eq("/some/path")
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
describe "#mgnl_content_data" do
|
|
68
|
+
it "should return the current content data from the aggregator" do
|
|
69
|
+
content = double(:content)
|
|
70
|
+
Content::Aggregator.should_receive(:content_data).and_return(content)
|
|
71
|
+
helper.mgnl_content_data.should eq(content)
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
describe "#mgnl_link" do
|
|
76
|
+
it "should pass through a string as a link" do
|
|
77
|
+
doc = REXML::Document.new(helper.mgnl_link("/path/to/link"))
|
|
78
|
+
doc.elements["a"].attributes["href"].should eq("/path/to/link")
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
it "should pass through a string as a link when a block is given" do
|
|
82
|
+
doc = REXML::Document.new(helper.mgnl_link("/path/to/link") { "something" })
|
|
83
|
+
doc.elements["a"].attributes["href"].should eq("/path/to/link")
|
|
84
|
+
end
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
describe "#push" do
|
|
88
|
+
after(:each) do
|
|
89
|
+
Content::Aggregator.clean
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
it "should push content" do
|
|
93
|
+
node = Jcr::Node.new
|
|
94
|
+
block_called = false
|
|
95
|
+
helper.mgnl_push(node) do
|
|
96
|
+
block_called = true
|
|
97
|
+
Content::Aggregator.content_data.should eq(node)
|
|
98
|
+
end
|
|
99
|
+
block_called.should be true
|
|
100
|
+
Content::Aggregator.content_data.should be nil
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
it "should not yield if no content is found"
|
|
104
|
+
|
|
105
|
+
it "should resolve a UUID if a UUID is returned"
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
describe "#mgnl_original_content" do
|
|
109
|
+
it "should fetch the original content"
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
describe "#mgnl_out" do
|
|
113
|
+
let(:node) do
|
|
114
|
+
node = Jcr::Node.new
|
|
115
|
+
node.stub(:title).and_return("The title")
|
|
116
|
+
node
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
before(:each) do
|
|
120
|
+
Content::Aggregator.stub(:original_content).and_return(node)
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
it "should output a property" do
|
|
124
|
+
helper.mgnl_out(:title).should eq("The title")
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
it "should output an empty string if the property does not exist" do
|
|
128
|
+
helper.mgnl_out(:some_unknown_attribute).should eq("")
|
|
129
|
+
end
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
describe "#mgnl_meta" do
|
|
133
|
+
it "should display a title" do
|
|
134
|
+
Sinicum::Content::Aggregator.push(title: "My Headline") do
|
|
135
|
+
result = REXML::Document.new("<div>" + helper.mgnl_meta + "</div>")
|
|
136
|
+
result.root.elements['title'].size.should eq(1)
|
|
137
|
+
end
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
it "should remove tags from the title" do
|
|
141
|
+
Sinicum::Content::Aggregator.push(title: "my <b>bold</b> title") do
|
|
142
|
+
result = REXML::Document.new("<div>" + helper.mgnl_meta + "</div>")
|
|
143
|
+
result.root.elements['title'].size.should eq(1)
|
|
144
|
+
result.root.elements['title'].first.to_s.should eq("my bold title")
|
|
145
|
+
end
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
it "should prefer meta_title for the title" do
|
|
149
|
+
Sinicum::Content::Aggregator.push(meta_title: "Preferred title") do
|
|
150
|
+
result = REXML::Document.new("<div>" + helper.mgnl_meta + "</div>")
|
|
151
|
+
result.root.elements['title'].first.to_s.should eq("Preferred title")
|
|
152
|
+
end
|
|
153
|
+
end
|
|
154
|
+
|
|
155
|
+
it "should add a prefix for the title" do
|
|
156
|
+
Sinicum::Content::Aggregator.push(title: "My Headline") do
|
|
157
|
+
result = REXML::Document.new("<div>" +
|
|
158
|
+
helper.mgnl_meta(title_prefix: "The Prefix") + "</div>")
|
|
159
|
+
result.root.elements['title'].first.to_s.should eq("The Prefix – My Headline")
|
|
160
|
+
end
|
|
161
|
+
end
|
|
162
|
+
|
|
163
|
+
it "should add a suffix for the title" do
|
|
164
|
+
Sinicum::Content::Aggregator.push(title: "My Headline") do
|
|
165
|
+
result = REXML::Document.new("<div>" +
|
|
166
|
+
helper.mgnl_meta(title_suffix: "The Suffix") + "</div>")
|
|
167
|
+
result.root.elements['title'].first.to_s.should eq("My Headline – The Suffix")
|
|
168
|
+
end
|
|
169
|
+
end
|
|
170
|
+
|
|
171
|
+
it "should not add a delimiter after the prefix if no title is present" do
|
|
172
|
+
Sinicum::Content::Aggregator.push({}) do
|
|
173
|
+
result = REXML::Document.new("<div>" +
|
|
174
|
+
helper.mgnl_meta(title_prefix: "The Prefix") + "</div>")
|
|
175
|
+
result.root.elements['title'].first.to_s.should eq("The Prefix")
|
|
176
|
+
end
|
|
177
|
+
end
|
|
178
|
+
|
|
179
|
+
it "should not add a delimiter before the suffix if no title is present" do
|
|
180
|
+
Sinicum::Content::Aggregator.push({}) do
|
|
181
|
+
result = REXML::Document.new("<div>" +
|
|
182
|
+
helper.mgnl_meta(title_prefix: "The Suffix") + "</div>")
|
|
183
|
+
result.root.elements['title'].first.to_s.should eq("The Suffix")
|
|
184
|
+
end
|
|
185
|
+
end
|
|
186
|
+
|
|
187
|
+
it "should not add an emtpy title attribute if no title is defined" do
|
|
188
|
+
Sinicum::Content::Aggregator.push({}) do
|
|
189
|
+
result = REXML::Document.new("<div>" + helper.mgnl_meta + "</div>")
|
|
190
|
+
result.root.elements['title'].first.to_s.should eq("")
|
|
191
|
+
end
|
|
192
|
+
end
|
|
193
|
+
|
|
194
|
+
it "should display a desciption tag" do
|
|
195
|
+
Sinicum::Content::Aggregator.push(meta_description: "A Description") do
|
|
196
|
+
result = REXML::Document.new("<div>" + helper.mgnl_meta + "</div>")
|
|
197
|
+
result.root.elements["meta[@name = 'description']"].attributes["content"]
|
|
198
|
+
.should eq("A Description")
|
|
199
|
+
end
|
|
200
|
+
end
|
|
201
|
+
|
|
202
|
+
it "should not display a desciption tag if no description is given" do
|
|
203
|
+
result = REXML::Document.new("<div>" + helper.mgnl_meta + "</div>")
|
|
204
|
+
result.root.elements["meta[@name = 'description']"].should be nil
|
|
205
|
+
end
|
|
206
|
+
|
|
207
|
+
it "should display a keywords tag" do
|
|
208
|
+
Sinicum::Content::Aggregator.push(meta_keywords: "some keyowrds") do
|
|
209
|
+
result = REXML::Document.new("<div>" + helper.mgnl_meta + "</div>")
|
|
210
|
+
result.root.elements["meta[@name = 'keywords']"].attributes["content"]
|
|
211
|
+
.should eq("some keyowrds")
|
|
212
|
+
end
|
|
213
|
+
end
|
|
214
|
+
|
|
215
|
+
it "should not display a keywords tag if no description is given" do
|
|
216
|
+
result = REXML::Document.new("<div>" + helper.mgnl_meta + "</div>")
|
|
217
|
+
result.root.elements["meta[@name = 'keywords']"].should be nil
|
|
218
|
+
end
|
|
219
|
+
|
|
220
|
+
it "should display 'robots: noindex,nofollow' tag" do
|
|
221
|
+
Sinicum::Content::Aggregator.push(meta_noindex: true) do
|
|
222
|
+
result = REXML::Document.new("<div>" + helper.mgnl_meta + "</div>")
|
|
223
|
+
result.root.elements["meta[@name = 'robots']"].attributes["content"].should =~ /noindex/
|
|
224
|
+
result.root.elements["meta[@name = 'robots']"].attributes["content"].should =~ /nofollow/
|
|
225
|
+
end
|
|
226
|
+
end
|
|
227
|
+
|
|
228
|
+
it "should display no 'robots' tag by default" do
|
|
229
|
+
result = REXML::Document.new("<div>" + helper.mgnl_meta + "</div>")
|
|
230
|
+
result.root.elements["meta[@name = 'robots']"].should be nil
|
|
231
|
+
end
|
|
232
|
+
|
|
233
|
+
it "should display a language tag" do
|
|
234
|
+
result = REXML::Document.new("<div>" + helper.mgnl_meta + "</div>")
|
|
235
|
+
result.root.elements["meta[@name = 'language']"].attributes["content"]
|
|
236
|
+
.should eq(I18n.locale.to_s)
|
|
237
|
+
end
|
|
238
|
+
|
|
239
|
+
it "should display the content type tag" do
|
|
240
|
+
result = REXML::Document.new("<div>" + helper.mgnl_meta + "</div>")
|
|
241
|
+
result.root.elements["meta[@http-equiv = 'content-type']"].attributes["content"]
|
|
242
|
+
.should eq("text/html; charset=utf-8")
|
|
243
|
+
end
|
|
244
|
+
|
|
245
|
+
it "should be html_safe" do
|
|
246
|
+
helper.mgnl_meta.should be_html_safe
|
|
247
|
+
end
|
|
248
|
+
end
|
|
249
|
+
|
|
250
|
+
describe "#mgnl_navigation" do
|
|
251
|
+
let(:handler) { double "handler" }
|
|
252
|
+
let(:el1) { double("el1") }
|
|
253
|
+
let(:el2) { double("el2") }
|
|
254
|
+
let(:elements) { [el1, el2] }
|
|
255
|
+
|
|
256
|
+
describe "path based" do
|
|
257
|
+
before(:each) do
|
|
258
|
+
Navigation::NavigationHandler.should_receive(:children).with("/de", 3)
|
|
259
|
+
.and_return(handler)
|
|
260
|
+
handler.should_receive(:elements).and_return(elements)
|
|
261
|
+
end
|
|
262
|
+
|
|
263
|
+
it "should the children navigation handler" do
|
|
264
|
+
helper.mgnl_navigation("/de", :children, depth: 3)
|
|
265
|
+
end
|
|
266
|
+
|
|
267
|
+
it "should yield the block" do
|
|
268
|
+
expect { |arg| elements.each(&arg) }.to yield_successive_args(el1, el2)
|
|
269
|
+
helper.mgnl_navigation("/de", :children, depth: 3) { |nav| }
|
|
270
|
+
end
|
|
271
|
+
|
|
272
|
+
it "should retun the elements if no block given" do
|
|
273
|
+
result = helper.mgnl_navigation("/de", :children, depth: 3)
|
|
274
|
+
result.size.should eq(2)
|
|
275
|
+
end
|
|
276
|
+
end
|
|
277
|
+
|
|
278
|
+
describe "node based" do
|
|
279
|
+
let(:node) { double("node") }
|
|
280
|
+
|
|
281
|
+
before(:each) do
|
|
282
|
+
Navigation::NavigationHandler.should_receive(:children).with(node, 3)
|
|
283
|
+
.and_return(handler)
|
|
284
|
+
handler.should_receive(:elements).and_return(elements)
|
|
285
|
+
end
|
|
286
|
+
|
|
287
|
+
it "should the children navigation handler" do
|
|
288
|
+
helper.mgnl_navigation(node, :children, depth: 3)
|
|
289
|
+
end
|
|
290
|
+
end
|
|
291
|
+
|
|
292
|
+
describe "path based parents" do
|
|
293
|
+
before(:each) do
|
|
294
|
+
Navigation::NavigationHandler.should_receive(:parents).with("/de")
|
|
295
|
+
.and_return(handler)
|
|
296
|
+
handler.should_receive(:elements).and_return(elements)
|
|
297
|
+
end
|
|
298
|
+
|
|
299
|
+
it "should the children navigation handler" do
|
|
300
|
+
helper.mgnl_navigation("/de", :parents)
|
|
301
|
+
end
|
|
302
|
+
|
|
303
|
+
it "should yield the block" do
|
|
304
|
+
expect { |arg| elements.each(&arg) }.to yield_successive_args(el1, el2)
|
|
305
|
+
helper.mgnl_navigation("/de", :parents) { |nav| }
|
|
306
|
+
end
|
|
307
|
+
|
|
308
|
+
it "should return the elements if no block given" do
|
|
309
|
+
elements = helper.mgnl_navigation("/de", :parents)
|
|
310
|
+
elements.size.should eq(2)
|
|
311
|
+
end
|
|
312
|
+
end
|
|
313
|
+
end
|
|
314
|
+
end
|
|
315
|
+
end
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
require 'spec_helper'
|
|
3
|
+
require 'rexml/document'
|
|
4
|
+
|
|
5
|
+
module Sinicum
|
|
6
|
+
describe MgnlHelper do
|
|
7
|
+
let(:uuid) { "900985a3-319c-41c6-b327-b46d7fb56d23" }
|
|
8
|
+
let(:image_node) do
|
|
9
|
+
doc = double("document")
|
|
10
|
+
image_node = Jcr::Dam::Image.new
|
|
11
|
+
image_node.stub(:jcr_path).and_return("/the/path")
|
|
12
|
+
image_node.stub(:"[]").and_return(nil)
|
|
13
|
+
image_node.stub(:width).and_return(100)
|
|
14
|
+
image_node.stub(:height).and_return(50)
|
|
15
|
+
image_node.stub(:width).with("title").and_return(200)
|
|
16
|
+
image_node.stub(:height).with("title").and_return(100)
|
|
17
|
+
image_node.stub(:[]).with(:'jcr:content').and_return(doc)
|
|
18
|
+
doc.stub(:[]).and_return(nil)
|
|
19
|
+
image_node
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
context "when an image exists" do
|
|
23
|
+
before(:each) do
|
|
24
|
+
Jcr::Node.should_receive(:find_by_uuid).with("dam", uuid).and_return(image_node)
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
it "should return the image path" do
|
|
28
|
+
doc = REXML::Document.new(helper.mgnl_img(uuid, renderer: "title"))
|
|
29
|
+
doc.elements["img"].attributes["src"].should eq(
|
|
30
|
+
"/damfiles/title/the/path-fc308f85a906fce1be5ff58fd2853af5")
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
it "should return the image path with source url" do
|
|
34
|
+
helper.stub(:compute_asset_host).and_return("http://www.dievision.de")
|
|
35
|
+
doc = REXML::Document.new(helper.mgnl_img(uuid, renderer: "title"))
|
|
36
|
+
doc.elements["img"].attributes["src"].should eq(
|
|
37
|
+
"http://www.dievision.de/damfiles/title/the/path-fc308f85a906fce1be5ff58fd2853af5")
|
|
38
|
+
Rails.configuration.action_controller.asset_host = nil
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
it "should return a default renderer if no renderer is given" do
|
|
42
|
+
doc = REXML::Document.new(helper.mgnl_img(uuid))
|
|
43
|
+
doc.elements["img"].attributes["src"].should eq(
|
|
44
|
+
"/damfiles/default/the/path-fc308f85a906fce1be5ff58fd2853af5")
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
it "should create the right alt tag" do
|
|
48
|
+
image_node.stub(:'[]').with(:subject).and_return("alttext")
|
|
49
|
+
doc = REXML::Document.new(helper.mgnl_img(uuid, renderer: "title"))
|
|
50
|
+
doc.elements["img"].attributes["alt"].should eq("alttext")
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
it "should return an empty alt tag if no subject is given" do
|
|
54
|
+
doc = REXML::Document.new(helper.mgnl_img(uuid, renderer: "title"))
|
|
55
|
+
doc.elements["img"].attributes["alt"].should eq("")
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
it "should return the height and the width attribute" do
|
|
59
|
+
doc = REXML::Document.new(helper.mgnl_img(uuid))
|
|
60
|
+
doc.elements["img"].attributes["width"].should eq("100")
|
|
61
|
+
doc.elements["img"].attributes["height"].should eq("50")
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
it "should consider the renderer for the image size" do
|
|
65
|
+
doc = REXML::Document.new(helper.mgnl_img(uuid, renderer: "title"))
|
|
66
|
+
doc.elements["img"].attributes["width"].should eq("200")
|
|
67
|
+
doc.elements["img"].attributes["height"].should eq("100")
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
it "should not render the width if width is false" do
|
|
71
|
+
doc = REXML::Document.new(helper.mgnl_img(uuid, renderer: "title", width: false))
|
|
72
|
+
doc.elements["img"].attributes["width"].should be_nil
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
it "should not render the height if height is false" do
|
|
76
|
+
doc = REXML::Document.new(helper.mgnl_img(uuid, renderer: "title", height: false))
|
|
77
|
+
doc.elements["img"].attributes["height"].should be_nil
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
it "should allow for custom height and width attributes" do
|
|
81
|
+
doc = REXML::Document.new(helper.mgnl_img(
|
|
82
|
+
uuid, renderer: "title", width: "85%", height: "33%"))
|
|
83
|
+
doc.elements["img"].attributes["width"].should eq("85%")
|
|
84
|
+
doc.elements["img"].attributes["height"].should eq("33%")
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
it "should be possible to add a class attribute" do
|
|
88
|
+
doc = REXML::Document.new(helper.mgnl_img(uuid, class: "someclass"))
|
|
89
|
+
doc.elements["img"].attributes["class"].should eq("someclass")
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
it "should be possible to add a any random attribute attribute" do
|
|
93
|
+
doc = REXML::Document.new(helper.mgnl_img(uuid, :'data-something' => "data"))
|
|
94
|
+
doc.elements["img"].attributes["data-something"].should eq("data")
|
|
95
|
+
end
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
it "should return nil if no image is found" do
|
|
99
|
+
Jcr::Node.should_receive(:find_by_uuid).with("dam", uuid).and_return(nil)
|
|
100
|
+
helper.mgnl_img(uuid, renderer: "title").should be nil
|
|
101
|
+
end
|
|
102
|
+
end
|
|
103
|
+
end
|