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
@@ -0,0 +1,95 @@
|
|
1
|
+
module Sinicum
|
2
|
+
module Navigation
|
3
|
+
# Public: Handles the API communication and initializes the
|
4
|
+
# NavigationElement instances.
|
5
|
+
class NavigationHandler
|
6
|
+
include Jcr::ApiClient
|
7
|
+
|
8
|
+
def initialize(axis, base_node_or_path, navigation_element_class, options = {})
|
9
|
+
@navigation_element_class = navigation_element_class
|
10
|
+
if axis == :children
|
11
|
+
@elements = fetch_children(base_node_or_path, options[:depth])
|
12
|
+
elsif axis == :parents
|
13
|
+
@elements = fetch_parents(base_node_or_path)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def elements
|
18
|
+
NavigationElementList.new(@elements)
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.children(base_node_or_path, depth,
|
22
|
+
navigation_element_class = DefaultNavigationElement)
|
23
|
+
new(:children, base_node_or_path, navigation_element_class, depth: depth)
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.parents(base_node_or_path, navigation_element_class = DefaultNavigationElement)
|
27
|
+
new(:parents, base_node_or_path, navigation_element_class)
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
def fetch_children(base_node, depth)
|
33
|
+
url = "/_navigation/children#{base_node_url_part(base_node)}"
|
34
|
+
result = api_get(
|
35
|
+
url,
|
36
|
+
"depth" => depth,
|
37
|
+
"properties" => @navigation_element_class.navigation_properties.join(";"))
|
38
|
+
if result.ok?
|
39
|
+
json = MultiJson.load(result.body)
|
40
|
+
initialize_from_json(json)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def fetch_parents(base_node)
|
45
|
+
url = "/_navigation/parents#{base_node_url_part(base_node)}"
|
46
|
+
result = api_get(
|
47
|
+
url, "properties" => @navigation_element_class.navigation_properties.join(";"))
|
48
|
+
if result.ok?
|
49
|
+
json = MultiJson.load(result.body)
|
50
|
+
initialize_from_json(json)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def initialize_from_json(json)
|
55
|
+
result = []
|
56
|
+
json.each do |el|
|
57
|
+
element = initialize_element(el)
|
58
|
+
result << element if element
|
59
|
+
end
|
60
|
+
@elements = result
|
61
|
+
end
|
62
|
+
|
63
|
+
def initialize_element(el)
|
64
|
+
result = nil
|
65
|
+
unless @navigation_element_class.filter_node(el)
|
66
|
+
children = resolve_children(el)
|
67
|
+
element = @navigation_element_class.new(
|
68
|
+
el["uuid"], el["path"], el["depth"], el["properties"], children)
|
69
|
+
result = element
|
70
|
+
end
|
71
|
+
result
|
72
|
+
end
|
73
|
+
|
74
|
+
def resolve_children(el)
|
75
|
+
children = []
|
76
|
+
if el["children"]
|
77
|
+
el["children"].each do |child_el|
|
78
|
+
child = initialize_element(child_el)
|
79
|
+
children << child if child
|
80
|
+
end
|
81
|
+
end
|
82
|
+
children.size > 0 ? children : nil
|
83
|
+
end
|
84
|
+
|
85
|
+
def base_node_url_part(base_node)
|
86
|
+
if base_node.respond_to?(:uuid)
|
87
|
+
url_part = "/" + base_node.uuid
|
88
|
+
else
|
89
|
+
url_part = base_node
|
90
|
+
end
|
91
|
+
url_part
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Sinicum
|
2
|
+
module Navigation
|
3
|
+
# Public: Provides meta-information about the status of a NavigationElement
|
4
|
+
# in the iteration.
|
5
|
+
class NavigationStatus
|
6
|
+
attr_reader :size, :count
|
7
|
+
|
8
|
+
def initialize(size, count)
|
9
|
+
@size = size
|
10
|
+
@count = count
|
11
|
+
end
|
12
|
+
|
13
|
+
def first?
|
14
|
+
count == 0
|
15
|
+
end
|
16
|
+
|
17
|
+
def last?
|
18
|
+
count == size - 1
|
19
|
+
end
|
20
|
+
|
21
|
+
def to_s
|
22
|
+
self.class.to_s + ": " +
|
23
|
+
{ size: @size, count: @count, :first? => first?, :last? => last? }.inspect
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module Sinicum
|
2
|
+
module Templating
|
3
|
+
# Private: Handles the lookup and creation of Areas on the server.
|
4
|
+
#
|
5
|
+
# Returns an Array of Strings with the available components or nil if no
|
6
|
+
# area could be identified.
|
7
|
+
class AreaHandler
|
8
|
+
include Jcr::ApiClient
|
9
|
+
|
10
|
+
def lookup_or_create_area(base_node, area_name)
|
11
|
+
result = nil
|
12
|
+
if base_node && area_name.present?
|
13
|
+
path = "/_templating/areas/initialize"
|
14
|
+
response = api_post(
|
15
|
+
path, body: {
|
16
|
+
workspace: base_node.jcr_workspace,
|
17
|
+
baseNodeUuid: base_node.uuid,
|
18
|
+
areaName: area_name })
|
19
|
+
if response.ok?
|
20
|
+
begin
|
21
|
+
json = MultiJson.load(response.body)
|
22
|
+
result = json["availableComponents"]
|
23
|
+
rescue => e
|
24
|
+
Rails.logger.error("Could not lookup area: " + e.to_s)
|
25
|
+
nil
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
result
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Sinicum
|
2
|
+
module Templating
|
3
|
+
# Private: Provides information about Magnolia dialogs.
|
4
|
+
class DialogResolver
|
5
|
+
include TemplatingUtils
|
6
|
+
include Jcr::ApiClient
|
7
|
+
|
8
|
+
def dialog_for_node(node)
|
9
|
+
result = nil
|
10
|
+
template = split_template_path(node.mgnl_template)
|
11
|
+
path = "/_templating/dialogs/#{template[:type]}" \
|
12
|
+
"/#{template[:module]}/#{template[:name]}"
|
13
|
+
response = api_get(path)
|
14
|
+
if response.ok?
|
15
|
+
begin
|
16
|
+
json = MultiJson.load(response.body)
|
17
|
+
result = json["dialog"]
|
18
|
+
rescue
|
19
|
+
# nothing
|
20
|
+
end
|
21
|
+
end
|
22
|
+
result
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Sinicum
|
2
|
+
module Templating
|
3
|
+
module TemplatingUtils
|
4
|
+
private
|
5
|
+
|
6
|
+
def split_template_path(path)
|
7
|
+
result = {}
|
8
|
+
parts = path.split(":")
|
9
|
+
result[:module] = parts[0]
|
10
|
+
result[:type] = result_type(parts)
|
11
|
+
result[:name] = parts[1][parts[1].index("/") + 1, parts[1].length]
|
12
|
+
result
|
13
|
+
end
|
14
|
+
|
15
|
+
def result_type(parts)
|
16
|
+
if parts[1].index("pages/") == 0
|
17
|
+
:page
|
18
|
+
elsif parts[1].index("components/") == 0
|
19
|
+
:component
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
data/lib/sinicum/util.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
module Sinicum
|
2
|
+
# Public: Collection of various utility methods.
|
3
|
+
class Util
|
4
|
+
UUID_REGEXP = /^[abcdef0-9]{8}-[abcdef0-9]{4}-[abcdef0-9]{4}-[abcdef0-9]{4}-[abcdef0-9]{12}$/i
|
5
|
+
|
6
|
+
def self.is_a_uuid?(value)
|
7
|
+
return false if value.nil? || !value.respond_to?('match')
|
8
|
+
result = value.match(UUID_REGEXP)
|
9
|
+
!!result
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
data/script/cibuild
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
|
3
|
+
set -e
|
4
|
+
|
5
|
+
eval "$(rbenv init -)"
|
6
|
+
|
7
|
+
run_tests () {
|
8
|
+
if [ $BUNDLE_GEMFILE ]; then
|
9
|
+
rm -f "${BUNDLE_GEMFILE}.lock"
|
10
|
+
echo "Testing with Gemfile ${BUNDLE_GEMFILE}"
|
11
|
+
else
|
12
|
+
rm -f "Gemfile.lock"
|
13
|
+
echo "Testing with default Gemfile"
|
14
|
+
fi
|
15
|
+
bundle install --path vendor/bundle
|
16
|
+
bundle exec rake
|
17
|
+
}
|
18
|
+
|
19
|
+
# run tests
|
20
|
+
for rbenv_version in "1.9.3-p545" "2.0.0-p247" "2.1.1"; do
|
21
|
+
rbenv shell $rbenv_version
|
22
|
+
echo "Using Ruby ${rbenv_version}"
|
23
|
+
|
24
|
+
# Run with Rails 3.2
|
25
|
+
export BUNDLE_GEMFILE=gemfiles/Gemfile-3.2
|
26
|
+
run_tests
|
27
|
+
|
28
|
+
# Run with Rails 4
|
29
|
+
unset BUNDLE_GEMFILE
|
30
|
+
run_tests
|
31
|
+
done
|
data/sinicum.gemspec
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "sinicum/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "sinicum"
|
7
|
+
s.version = Sinicum::VERSION
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.authors = ["Dievision GmbH"]
|
10
|
+
s.email = ["info@dievision.de"]
|
11
|
+
s.homepage = "http://github.com/dievision/sinicum"
|
12
|
+
s.summary = %q{Use Magnolia as a CMS backend in a Rails application}
|
13
|
+
s.description = %q{Provides the necessary functionality to work with Magnolia-managed content in a Rails application.}
|
14
|
+
|
15
|
+
s.add_dependency('rails', '>= 3.2')
|
16
|
+
s.add_dependency('httpclient', '~> 2.3')
|
17
|
+
s.add_dependency('multi_json', '~> 1.3')
|
18
|
+
s.add_development_dependency('rspec-rails', '~> 2.14')
|
19
|
+
s.add_development_dependency('yard')
|
20
|
+
s.add_development_dependency('webmock', '~> 1.8')
|
21
|
+
s.add_development_dependency('rubocop', '~> 0.20')
|
22
|
+
s.add_development_dependency('cane', '~> 2.5.2')
|
23
|
+
s.add_development_dependency('codeclimate-test-reporter')
|
24
|
+
|
25
|
+
s.files = `git ls-files`.split("\n")
|
26
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
27
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
28
|
+
s.require_paths = ["lib"]
|
29
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Sinicum
|
4
|
+
describe ApplicationController do
|
5
|
+
let(:node) { Jcr::Node.new }
|
6
|
+
|
7
|
+
before(:each) do
|
8
|
+
Content::Aggregator.stub(:original_content).and_return(node)
|
9
|
+
Content::WebsiteContentResolver.stub(:find_for_path).and_return(node)
|
10
|
+
node.stub(:mgnl_template).and_return("something")
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should remove the html_ending" do
|
14
|
+
get :index, format: "html"
|
15
|
+
response.should redirect_to("/home")
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should ignore and conserve query strings" do
|
19
|
+
get :index, format: "html", key: "value"
|
20
|
+
response.should redirect_to("/home?key=value")
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should ignore post requests" do
|
24
|
+
post :index, format: "html"
|
25
|
+
response.status.should eq(200)
|
26
|
+
end
|
27
|
+
|
28
|
+
describe "layout" do
|
29
|
+
it "should render with the application layout if no matching file is found" do
|
30
|
+
get :index
|
31
|
+
response.should render_template("application")
|
32
|
+
end
|
33
|
+
|
34
|
+
it "should render with the application layout if no matching file is found" do
|
35
|
+
node.stub(:mgnl_template).and_return("layout_name")
|
36
|
+
get :index
|
37
|
+
response.should render_template("layout_name")
|
38
|
+
end
|
39
|
+
|
40
|
+
it "should handle Magnolia 4.5-style layouts" do
|
41
|
+
node.stub(:mgnl_template).and_return("my_module:pages/test")
|
42
|
+
get :index
|
43
|
+
response.should render_template("my_module/test")
|
44
|
+
end
|
45
|
+
|
46
|
+
it "should handle Magnolia 4.5-style layouts with dashes" do
|
47
|
+
node.stub(:mgnl_template).and_return("my-module:pages/test")
|
48
|
+
get :index
|
49
|
+
response.should render_template("my-module/test")
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Sinicum
|
4
|
+
module Controllers
|
5
|
+
describe GlobalStateCache do
|
6
|
+
let(:controller) do
|
7
|
+
controller = double(:controller)
|
8
|
+
request = double(:request)
|
9
|
+
controller.stub(:request).and_return(request)
|
10
|
+
request.stub(:base_url).and_return("base")
|
11
|
+
request.stub(:fullpath).and_return("fullpath")
|
12
|
+
controller
|
13
|
+
end
|
14
|
+
|
15
|
+
before(:each) do
|
16
|
+
Sinicum::Jcr::Cache::GlobalCache.any_instance
|
17
|
+
.stub(:current_key).and_return("a11cd0d31248427cbadfd8a7bc51e04e96e4de98")
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should return Rails' deployment revision" do
|
21
|
+
GlobalStateCache.send(:deploy_revision)
|
22
|
+
.should eq("d18187f9016c71e82993c867a90ff9a0554519c9")
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should return the cache key" do
|
26
|
+
cache = GlobalStateCache.new(controller)
|
27
|
+
cache.send(:cache_key).should eq(%w(
|
28
|
+
basefullpath
|
29
|
+
a11cd0d31248427cbadfd8a7bc51e04e96e4de98
|
30
|
+
d18187f9016c71e82993c867a90ff9a0554519c9
|
31
|
+
))
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
data/spec/dummy/REVISION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
d18187f9016c71e82993c867a90ff9a0554519c9
|
data/spec/dummy/Rakefile
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
# Add your own tasks in files placed in lib/tasks ending in .rake,
|
2
|
+
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
|
3
|
+
|
4
|
+
require File.expand_path('../config/application', __FILE__)
|
5
|
+
require 'rake'
|
6
|
+
|
7
|
+
Dummy::Application.load_tasks
|
@@ -0,0 +1 @@
|
|
1
|
+
<h1>Sinicum</h1>
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require File.expand_path('../boot', __FILE__)
|
2
|
+
|
3
|
+
require "active_model/railtie"
|
4
|
+
# require "active_record/railtie"
|
5
|
+
require "action_controller/railtie"
|
6
|
+
require "action_view/railtie"
|
7
|
+
require "action_mailer/railtie"
|
8
|
+
|
9
|
+
Bundler.require
|
10
|
+
require "sinicum"
|
11
|
+
|
12
|
+
module Dummy
|
13
|
+
class Application < Rails::Application
|
14
|
+
# Settings in config/environments/* take precedence over those specified here.
|
15
|
+
# Application configuration should go into files in config/initializers
|
16
|
+
# -- all .rb files in that directory are automatically loaded.
|
17
|
+
|
18
|
+
# Custom directories with classes and modules you want to be autoloadable.
|
19
|
+
# config.autoload_paths += %W(#{config.root}/extras)
|
20
|
+
|
21
|
+
# Only load the plugins named here, in the order given (default is alphabetical).
|
22
|
+
# :all can be used as a placeholder for all plugins not explicitly named.
|
23
|
+
# config.plugins = [ :exception_notification, :ssl_requirement, :all ]
|
24
|
+
|
25
|
+
# Activate observers that should always be running.
|
26
|
+
# config.active_record.observers = :cacher, :garbage_collector, :forum_observer
|
27
|
+
|
28
|
+
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
|
29
|
+
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
|
30
|
+
# config.time_zone = 'Central Time (US & Canada)'
|
31
|
+
|
32
|
+
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
|
33
|
+
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
|
34
|
+
# config.i18n.default_locale = :de
|
35
|
+
|
36
|
+
# JavaScript files you want as :defaults (application.js is always included).
|
37
|
+
# config.action_view.javascript_expansions[:defaults] = %w(jquery rails)
|
38
|
+
|
39
|
+
# Configure the default encoding used in templates for Ruby 1.9.
|
40
|
+
config.encoding = "utf-8"
|
41
|
+
|
42
|
+
# Configure sensitive parameters which will be filtered from the log file.
|
43
|
+
config.filter_parameters += [:password]
|
44
|
+
end
|
45
|
+
end
|