infopark_fiona_connector 7.0.1.5.2.3.rc7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.yardopts +5 -0
- data/app/assets/images/admin/minus.gif +0 -0
- data/app/assets/images/bg80.png +0 -0
- data/app/assets/images/edit.png +0 -0
- data/app/assets/images/icons/mm_generic.png +0 -0
- data/app/assets/images/icons/mm_menu.png +0 -0
- data/app/assets/javascripts/editmarker.js +240 -0
- data/app/assets/javascripts/infopark_rails_connector.js.erb +0 -0
- data/app/assets/stylesheets/editmarker.css +70 -0
- data/app/assets/stylesheets/infopark_rails_connector.css.erb +0 -0
- data/app/controllers/cms_controller.rb +7 -0
- data/app/controllers/rails_connector/default_cms_controller.rb +41 -0
- data/app/helpers/cms_helper.rb +7 -0
- data/app/helpers/cms_routing_helper.rb +7 -0
- data/app/helpers/rails_connector/cms_asset_helper.rb +54 -0
- data/app/helpers/rails_connector/cms_tag_helper.rb +4 -0
- data/app/helpers/rails_connector/default_cms_helper.rb +21 -0
- data/app/helpers/rails_connector/default_cms_routing_helper.rb +119 -0
- data/app/helpers/rails_connector/display_helper.rb +124 -0
- data/app/helpers/rails_connector/editing_helper.rb +7 -0
- data/app/helpers/rails_connector/layout_helper.rb +26 -0
- data/app/helpers/rails_connector/marker_helper.rb +371 -0
- data/app/helpers/rails_connector/table_of_contents_helper.rb +20 -0
- data/app/models/named_link.rb +2 -0
- data/app/views/cms/_index.html.erb +7 -0
- data/app/views/cms/index.html.erb +1 -0
- data/app/views/errors/403_forbidden.html.erb +3 -0
- data/app/views/errors/410_gone.html.erb +7 -0
- data/config/cms_routes.rb +17 -0
- data/config/locales/de.rails_connector.errors.yml +11 -0
- data/config/locales/de.rails_connector.lib.yml +6 -0
- data/config/locales/de.rails_connector.views.yml +9 -0
- data/config/locales/en.rails_connector.errors.yml +10 -0
- data/config/locales/en.rails_connector.lib.yml +6 -0
- data/config/locales/en.rails_connector.views.yml +9 -0
- data/lib/gem_dependencies.rb +68 -0
- data/lib/generators/rails_connector/install/install_generator.rb +37 -0
- data/lib/generators/rails_connector/install/templates/app/models/obj.rb.erb +5 -0
- data/lib/generators/rails_connector/install/templates/initializers/rails_connector.rb +2 -0
- data/lib/generators/rails_connector/install/templates/local/configuration.rb +2 -0
- data/lib/infopark_fiona_connector.rb +44 -0
- data/lib/meta_eager_loader.rb +1 -0
- data/lib/obj.rb +3 -0
- data/lib/rails_connector/attr_dict.rb +169 -0
- data/lib/rails_connector/attr_value_provider.bundle +0 -0
- data/lib/rails_connector/attr_value_provider.so +0 -0
- data/lib/rails_connector/attr_value_provider64.so +0 -0
- data/lib/rails_connector/attribute.rb +93 -0
- data/lib/rails_connector/authenticable.rb +37 -0
- data/lib/rails_connector/basic_obj.rb +571 -0
- data/lib/rails_connector/blob.rb +75 -0
- data/lib/rails_connector/blob_mapping.rb +15 -0
- data/lib/rails_connector/blob_mysql.rb +30 -0
- data/lib/rails_connector/blob_oracle.rb +37 -0
- data/lib/rails_connector/cache_middleware.rb +13 -0
- data/lib/rails_connector/channel.rb +18 -0
- data/lib/rails_connector/cms_accessible.rb +111 -0
- data/lib/rails_connector/cms_base_model.rb +62 -0
- data/lib/rails_connector/cms_dispatch_controller.rb +43 -0
- data/lib/rails_connector/cms_env.rb +65 -0
- data/lib/rails_connector/cms_test_request.rb +8 -0
- data/lib/rails_connector/configuration.rb +174 -0
- data/lib/rails_connector/content.rb +7 -0
- data/lib/rails_connector/core_extensions.rb +1 -0
- data/lib/rails_connector/core_extensions/time.rb +17 -0
- data/lib/rails_connector/date_attribute.rb +26 -0
- data/lib/rails_connector/default_search_request.rb +6 -0
- data/lib/rails_connector/engine.rb +65 -0
- data/lib/rails_connector/errors.rb +6 -0
- data/lib/rails_connector/fiona_datetime.rb +14 -0
- data/lib/rails_connector/fiona_engine.rb +8 -0
- data/lib/rails_connector/html_string.rb +17 -0
- data/lib/rails_connector/job.rb +10 -0
- data/lib/rails_connector/link.rb +148 -0
- data/lib/rails_connector/link_list.rb +28 -0
- data/lib/rails_connector/link_resolvable.rb +5 -0
- data/lib/rails_connector/lucene_search_request.rb +102 -0
- data/lib/rails_connector/markdown_string.rb +17 -0
- data/lib/rails_connector/meta.rb +143 -0
- data/lib/rails_connector/meta/eager_loader.rb +84 -0
- data/lib/rails_connector/named_link.rb +90 -0
- data/lib/rails_connector/news.rb +20 -0
- data/lib/rails_connector/obj_class.rb +138 -0
- data/lib/rails_connector/obj_class_attr.rb +5 -0
- data/lib/rails_connector/object_with_meta_data.rb +13 -0
- data/lib/rails_connector/permission.rb +37 -0
- data/lib/rails_connector/rack_middlewares.rb +5 -0
- data/lib/rails_connector/ses.rb +78 -0
- data/lib/rails_connector/ses/verity_accessor.rb +127 -0
- data/lib/rails_connector/string_tagging.rb +26 -0
- data/lib/rails_connector/verity_search_request.rb +86 -0
- data/lib/search_request.rb +2 -0
- data/lib/version.rb +7 -0
- metadata +277 -0
@@ -0,0 +1,75 @@
|
|
1
|
+
module RailsConnector
|
2
|
+
# A binary containing the blob data of a Content or CMS management
|
3
|
+
# data of Attribute (fields), ObjClass (object classes), for example.
|
4
|
+
class Blob < CmsBaseModel
|
5
|
+
self.primary_key = "blob_name"
|
6
|
+
|
7
|
+
class << self
|
8
|
+
# Does not retrieve the column blob_data.
|
9
|
+
def find_with_excluded_blob_data(primary_key)
|
10
|
+
select(:blob_name, :blob_length).find(primary_key)
|
11
|
+
end
|
12
|
+
|
13
|
+
alias_method :find_without_excluded_blob_data, :find
|
14
|
+
alias_method :find, :find_with_excluded_blob_data
|
15
|
+
end
|
16
|
+
|
17
|
+
def length
|
18
|
+
blob_length
|
19
|
+
end
|
20
|
+
|
21
|
+
def data
|
22
|
+
@data ||= self.class.find_without_excluded_blob_data(id).blob_data
|
23
|
+
end
|
24
|
+
|
25
|
+
def path_of_stored_data(use_cached_file_if_older_than = Time.now)
|
26
|
+
store_data if !File.exist?(path) || file_size_differs? || stale?(use_cached_file_if_older_than)
|
27
|
+
path
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.cache_dir
|
31
|
+
Configuration.blob_cache_dir || File.join(Rails.root, %w(tmp cache))
|
32
|
+
end
|
33
|
+
|
34
|
+
def self.initialize_blob_streaming_for(adapter_name)
|
35
|
+
# Redefines store_data:
|
36
|
+
case adapter_name
|
37
|
+
when /mysql$/i
|
38
|
+
raise "Adapter 'mysql' no longer supported. " +
|
39
|
+
"Please change adapter in your database.yml to 'mysql2'."
|
40
|
+
when /mysql2/i
|
41
|
+
require "rails_connector/blob_mysql"
|
42
|
+
include BlobMysql
|
43
|
+
when /oracle/i
|
44
|
+
require "rails_connector/blob_oracle"
|
45
|
+
include BlobOracle
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
private
|
50
|
+
|
51
|
+
def path
|
52
|
+
"#{Blob.cache_dir}/#{id}"
|
53
|
+
end
|
54
|
+
|
55
|
+
def store_data
|
56
|
+
store_data_atomically do |f|
|
57
|
+
f << data
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
def store_data_atomically(&block)
|
62
|
+
tmp_file = "#{path}.#{Process.pid}"
|
63
|
+
File.open(tmp_file, "wb", &block)
|
64
|
+
File.rename(tmp_file, path)
|
65
|
+
end
|
66
|
+
|
67
|
+
def stale?(time)
|
68
|
+
time > File.mtime(path)
|
69
|
+
end
|
70
|
+
|
71
|
+
def file_size_differs?
|
72
|
+
blob_length != File.stat(path).size
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module RailsConnector
|
2
|
+
class BlobMapping < CmsBaseModel
|
3
|
+
def self.exists?
|
4
|
+
table_exists?
|
5
|
+
end
|
6
|
+
|
7
|
+
def self.get_fingerprint(name)
|
8
|
+
find_by_blob_name(name).fingerprint
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.get_fingerprint_map(blob_names)
|
12
|
+
Hash[where(blob_name: blob_names).select(%i(blob_name fingerprint)).map { |b| [b.blob_name, b.fingerprint] }]
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require "mysql2"
|
2
|
+
require "mysql_blob_streaming"
|
3
|
+
|
4
|
+
module RailsConnector
|
5
|
+
module BlobMysql
|
6
|
+
def self.included(base)
|
7
|
+
base.instance_eval do
|
8
|
+
define_method :store_data do
|
9
|
+
store_data_atomically { |f| fetch_into_file(f) }
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def fetch_into_file(file)
|
15
|
+
mysql2_client = self.class.connection.raw_connection
|
16
|
+
ActiveRecord::Base.logger.debug "Streaming blob from MySQL2 into #{file.path}"
|
17
|
+
|
18
|
+
table_name = mysql2_client.escape(self.class.table_name)
|
19
|
+
primary_key = mysql2_client.escape(self.class.primary_key)
|
20
|
+
escaped_id = mysql2_client.escape(id)
|
21
|
+
query = "SELECT `blob_data` FROM `#{table_name}` WHERE `#{primary_key}`='#{escaped_id}'"
|
22
|
+
|
23
|
+
MysqlBlobStreaming.stream(mysql2_client, query, 1.megabyte) do |chunk|
|
24
|
+
file << chunk
|
25
|
+
chunk = nil
|
26
|
+
GC.start
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module RailsConnector
|
2
|
+
module BlobOracle
|
3
|
+
def self.included(base)
|
4
|
+
base.instance_eval do
|
5
|
+
define_method :store_data do
|
6
|
+
store_data_atomically { |f| fetch_into_file(f) }
|
7
|
+
end
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
def fetch_into_file(file)
|
12
|
+
blob = blob_handle
|
13
|
+
while data = blob.read(buff_size ||= 1.megabyte)
|
14
|
+
file << data
|
15
|
+
data = nil
|
16
|
+
GC.start
|
17
|
+
end
|
18
|
+
ensure
|
19
|
+
blob&.close
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def sql
|
25
|
+
%(
|
26
|
+
SELECT blob_data
|
27
|
+
FROM #{self.class.table_name}
|
28
|
+
WHERE #{self.class.primary_key} = :1
|
29
|
+
)
|
30
|
+
end
|
31
|
+
|
32
|
+
def blob_handle
|
33
|
+
con = self.class.connection.raw_connection
|
34
|
+
con.exec(sql, id).fetch.first
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module RailsConnector
|
2
|
+
class Channel < CmsBaseModel
|
3
|
+
self.primary_key = "channel_name"
|
4
|
+
|
5
|
+
def self.table_name
|
6
|
+
"#{table_name_prefix}" "channels"
|
7
|
+
end
|
8
|
+
|
9
|
+
has_many :news, class_name: "RailsConnector::News", foreign_key: "channel_name"
|
10
|
+
has_many :active_news,
|
11
|
+
-> { where(["valid_from <= :now AND valid_until >= :now", { now: Time.now.to_s(:number) }]) },
|
12
|
+
class_name: "RailsConnector::News", foreign_key: "channel_name"
|
13
|
+
|
14
|
+
has_many :objects, through: :news
|
15
|
+
|
16
|
+
scope :with_prefix, ->(prefix) { where(["channel_name LIKE ?", "#{prefix}%"]) }
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,111 @@
|
|
1
|
+
module RailsConnector
|
2
|
+
# @api public
|
3
|
+
module CmsAccessible
|
4
|
+
protected
|
5
|
+
|
6
|
+
# Filter method to load a CMS object.
|
7
|
+
#
|
8
|
+
# To require the loading for all actions, use this in your controllers:
|
9
|
+
# before_action :load_object
|
10
|
+
def load_object
|
11
|
+
CmsEnv.new(request.env).load
|
12
|
+
loaded_obj = request.env[CmsEnv::OBJ_ENV_KEY]
|
13
|
+
raise loaded_obj if loaded_obj.is_a?(StandardError)
|
14
|
+
|
15
|
+
@obj = loaded_obj
|
16
|
+
end
|
17
|
+
|
18
|
+
# Filter method to check if the already loaded object is active. If it is
|
19
|
+
# not, a 410 Gone error message will be generate (by calling render_obj_error).
|
20
|
+
#
|
21
|
+
# To require the check for all actions, use this in your controllers:
|
22
|
+
# before_action :load_object
|
23
|
+
# before_action :ensure_object_is_active
|
24
|
+
def ensure_object_is_active
|
25
|
+
unless @obj.active?
|
26
|
+
@valid_from = @obj.valid_from
|
27
|
+
@valid_until = @obj.valid_until
|
28
|
+
@obj = nil
|
29
|
+
render_obj_error(410, "gone")
|
30
|
+
end
|
31
|
+
true
|
32
|
+
end
|
33
|
+
|
34
|
+
# Filter method to check if access to the loaded object is permitted. If it is
|
35
|
+
# not, a 403 Forbidden error message will be generated (by calling render_obj_error)
|
36
|
+
#
|
37
|
+
# To require the check for all actions, use this in your controllers:
|
38
|
+
# before_action :load_object
|
39
|
+
# before_action :ensure_object_is_permitted
|
40
|
+
def ensure_object_is_permitted
|
41
|
+
unless is_permitted(@obj)
|
42
|
+
@obj = nil
|
43
|
+
render_obj_error(403, "forbidden")
|
44
|
+
end
|
45
|
+
true
|
46
|
+
end
|
47
|
+
|
48
|
+
# This method is called when rendering an error caused by either {ensure_object_is_permitted}
|
49
|
+
# or {ensure_object_is_active} before filter. It renders an error template located in
|
50
|
+
# "errors/*.html.erb" with given HTTP status and content type "text/html" and with no layout.
|
51
|
+
# Overwrite this method to change the error page.
|
52
|
+
# @api public
|
53
|
+
def render_obj_error(status, name)
|
54
|
+
force_html_format
|
55
|
+
render(
|
56
|
+
template: "errors/#{status}_#{name}",
|
57
|
+
layout: false,
|
58
|
+
status: status,
|
59
|
+
content_type: Mime[:html]
|
60
|
+
)
|
61
|
+
end
|
62
|
+
|
63
|
+
# Enforce "html" as template format.
|
64
|
+
# @api public
|
65
|
+
def force_html_format
|
66
|
+
request.format = :html
|
67
|
+
end
|
68
|
+
|
69
|
+
# Inclusion hook to make is_permitted available as helper method.
|
70
|
+
def self.included(base)
|
71
|
+
base.__send__ :helper_method, :is_permitted
|
72
|
+
end
|
73
|
+
|
74
|
+
# Helper method to check live permissions
|
75
|
+
def is_permitted(obj)
|
76
|
+
obj.permitted_for_user?(current_user)
|
77
|
+
end
|
78
|
+
|
79
|
+
# Filter method which sets the header 'X-Robots-Tag: unavailable_after'
|
80
|
+
# to the valid_until date of the current object.
|
81
|
+
def set_google_expire_header
|
82
|
+
if @obj && (date = @obj.valid_until)
|
83
|
+
headers["X-Robots-Tag: unavailable_after"] = date.rfc822
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
# Deliver the obj's body as response by file or data.
|
88
|
+
# May respond with status 304 if a If-Modified-Since header is found.
|
89
|
+
# @api public
|
90
|
+
def deliver_file
|
91
|
+
if @obj.body_data_url
|
92
|
+
redirect_to enforce_protocol_from_request(@obj.body_data_url)
|
93
|
+
elsif stale?(last_modified: @obj.last_changed.utc)
|
94
|
+
mime_type = @obj.mime_type
|
95
|
+
mime_type += "; charset=utf-8" if %r{^text/}.match?(mime_type)
|
96
|
+
|
97
|
+
if (filepath = @obj.body_data_path).present?
|
98
|
+
send_file(File.expand_path(filepath), {
|
99
|
+
type: mime_type,
|
100
|
+
filename: @obj.filename,
|
101
|
+
disposition: "inline"
|
102
|
+
})
|
103
|
+
else
|
104
|
+
# generics should send its body, empty files should be delivered as
|
105
|
+
# empty files - and not lead to an application error
|
106
|
+
send_data @obj.body || "", type: mime_type, filename: @obj.filename, disposition: "inline"
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
module RailsConnector
|
2
|
+
# This is the abstract class from which all CMS models derive.
|
3
|
+
# The database connection is set to "infopark_rails_connector_${RAILS_ENV}" and the table prefix is
|
4
|
+
# determined from the instance_name.
|
5
|
+
#
|
6
|
+
# [instance_name] the name of the CMS instance
|
7
|
+
class CmsBaseModel < ActiveRecord::Base
|
8
|
+
@@instance_name = "default"
|
9
|
+
cattr_accessor :instance_name
|
10
|
+
self.abstract_class = true
|
11
|
+
|
12
|
+
def self.configure_database(db_connection_spec)
|
13
|
+
establish_connection(db_connection_spec)
|
14
|
+
Blob.initialize_blob_streaming_for(connection.adapter_name)
|
15
|
+
end
|
16
|
+
|
17
|
+
# Returns :table_name_with_underscore. All CMS models use this kind of primary key naming.
|
18
|
+
def self.primary_key_prefix_type
|
19
|
+
:table_name_with_underscore
|
20
|
+
end
|
21
|
+
|
22
|
+
# CmsBaseModel and all of its descendants are model classes that can access CMS contents.
|
23
|
+
def self.cms_model?
|
24
|
+
true
|
25
|
+
end
|
26
|
+
|
27
|
+
# FIXME: Find a more stable solution for this
|
28
|
+
#
|
29
|
+
# Since ActiveRecord 4.2 finding Objs by name is no longer consistent when
|
30
|
+
# switching between edited and released content at runtime. As long as we
|
31
|
+
# find a better solution this mitigates the behaviour.
|
32
|
+
def self.find_by(arg, *args)
|
33
|
+
where(arg, *args).take
|
34
|
+
end
|
35
|
+
|
36
|
+
def readonly?
|
37
|
+
true
|
38
|
+
end
|
39
|
+
|
40
|
+
def attribute_for_inspect(attr_name)
|
41
|
+
value = read_attribute(attr_name)
|
42
|
+
|
43
|
+
if value.is_a?(RailsConnector::LinkList)
|
44
|
+
value.destination_objects.map(&:to_s)
|
45
|
+
else
|
46
|
+
super
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
class << self
|
51
|
+
# The prefix of the table name is determined by using the instance name followed by an underscore.
|
52
|
+
# Set the instance_name in your environment to the CMS instance name (defaults to 'default').
|
53
|
+
#
|
54
|
+
# CmsBaseModel.instance_name = 'default'
|
55
|
+
#
|
56
|
+
# ActiveRecord::Base::primary_key_prefix_type has no effect here.
|
57
|
+
def table_name_prefix
|
58
|
+
@@instance_name.blank? ? "" : (@@instance_name + "_")
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
module RailsConnector
|
2
|
+
class CmsDispatchController < ActionController::Metal
|
3
|
+
def process(action)
|
4
|
+
CmsEnv.new(request.env).load
|
5
|
+
controller = target_controller(request.env)
|
6
|
+
request.env["action_dispatch.request.path_parameters"][:controller] = controller.controller_path
|
7
|
+
|
8
|
+
action = loaded_obj.controller_action_name if !obj_not_found? && action == "index"
|
9
|
+
|
10
|
+
request.env["action_dispatch.request.path_parameters"][:action] = action
|
11
|
+
|
12
|
+
self.response = controller.action(action).call(request.env)
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
def target_controller(_env)
|
18
|
+
return default_controller if obj_not_found?
|
19
|
+
|
20
|
+
controller = "#{loaded_obj.controller_name}Controller".constantize
|
21
|
+
|
22
|
+
if controller.respond_to?(:use_for_obj_dispatch?) && controller.use_for_obj_dispatch?
|
23
|
+
controller
|
24
|
+
else
|
25
|
+
default_controller
|
26
|
+
end
|
27
|
+
rescue NameError
|
28
|
+
default_controller
|
29
|
+
end
|
30
|
+
|
31
|
+
def loaded_obj
|
32
|
+
request.env[CmsEnv::OBJ_ENV_KEY]
|
33
|
+
end
|
34
|
+
|
35
|
+
def obj_not_found?
|
36
|
+
loaded_obj.is_a?(StandardError)
|
37
|
+
end
|
38
|
+
|
39
|
+
def default_controller
|
40
|
+
CmsController
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
module RailsConnector
|
2
|
+
class CmsEnv
|
3
|
+
OBJ_ENV_KEY = "INFOPARK_OBJ".freeze
|
4
|
+
|
5
|
+
def initialize(env)
|
6
|
+
@env = env
|
7
|
+
end
|
8
|
+
|
9
|
+
def load
|
10
|
+
return if env[OBJ_ENV_KEY]
|
11
|
+
|
12
|
+
load_object
|
13
|
+
end
|
14
|
+
|
15
|
+
protected
|
16
|
+
|
17
|
+
attr_reader :env
|
18
|
+
|
19
|
+
def load_object
|
20
|
+
env[OBJ_ENV_KEY] =
|
21
|
+
begin
|
22
|
+
find_obj
|
23
|
+
rescue StandardError => e
|
24
|
+
e
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def find_obj
|
29
|
+
found_obj =
|
30
|
+
if params[:id]
|
31
|
+
Obj.find(params[:id])
|
32
|
+
elsif params[:permalink].present?
|
33
|
+
self.class.find_permalink_by_param(params[:permalink])
|
34
|
+
else
|
35
|
+
if callback = RailsConnector::Configuration.choose_homepage_callback
|
36
|
+
callback_result = callback.call(env)
|
37
|
+
if callback_result.is_a?(Obj)
|
38
|
+
callback_result
|
39
|
+
else
|
40
|
+
raise "choose_homepage callback did not return an Obj. "\
|
41
|
+
"Instead saw #{callback_result.class}."
|
42
|
+
end
|
43
|
+
else
|
44
|
+
Obj.homepage
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
if found_obj.suppressed?
|
49
|
+
raise RailsConnector::ResourceNotFound,
|
50
|
+
"Tried to access Obj #{found_obj.inspect}, but it is suppressed (suppress_export is set)!"
|
51
|
+
end
|
52
|
+
|
53
|
+
found_obj
|
54
|
+
end
|
55
|
+
|
56
|
+
def params
|
57
|
+
env["action_dispatch.request.path_parameters"]
|
58
|
+
end
|
59
|
+
|
60
|
+
def self.find_permalink_by_param(permalink_param)
|
61
|
+
permalink = Array(permalink_param).join("/")
|
62
|
+
Obj.find_by_permalink!(permalink)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|