infopark_rails_connector 6.8.0.beta.200.621.4c8e1b0
Sign up to get free protection for your applications and to get access to all the features.
- data/README +59 -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/images/ratings/star.gif +0 -0
- data/app/assets/images/time_machine/calendar-menuarrow.gif +0 -0
- data/app/assets/images/time_machine/calendar_bg.png +0 -0
- data/app/assets/images/time_machine/icon.png +0 -0
- data/app/assets/images/time_machine/slider_bg.png +0 -0
- data/app/assets/images/time_machine/slider_handle.png +0 -0
- data/app/assets/images/time_machine/timemachine_bg.png +0 -0
- data/app/assets/javascripts/comments.js +29 -0
- data/app/assets/javascripts/editmarker.js +240 -0
- data/app/assets/javascripts/infopark_rails_connector.js.erb +3 -0
- data/app/assets/javascripts/initializer.js +9 -0
- data/app/assets/javascripts/ratings.js +26 -0
- data/app/assets/javascripts/time_machine/calendar-setup.js +200 -0
- data/app/assets/javascripts/time_machine/calendar.js +1806 -0
- data/app/assets/javascripts/time_machine/lang/calendar-de.js +127 -0
- data/app/assets/javascripts/time_machine/lang/calendar-en.js +127 -0
- data/app/assets/javascripts/time_machine/lang/calendar-es.js +129 -0
- data/app/assets/javascripts/time_machine/lang/calendar-fr.js +125 -0
- data/app/assets/javascripts/time_machine/lang/calendar-it.js +124 -0
- data/app/assets/javascripts/time_machine/slider.js +278 -0
- data/app/assets/javascripts/time_machine.js +8 -0
- data/app/assets/stylesheets/editmarker.css +70 -0
- data/app/assets/stylesheets/infopark_rails_connector.css.erb +4 -0
- data/app/assets/stylesheets/ratings.css +97 -0
- data/app/assets/stylesheets/time_machine/time_machine.css +292 -0
- data/app/assets/stylesheets/time_machine.css +6 -0
- data/app/controllers/cms_controller.rb +6 -0
- data/app/controllers/comments_controller.rb +6 -0
- data/app/controllers/crm_form_controller.rb +2 -0
- data/app/controllers/pdf_controller.rb +6 -0
- data/app/controllers/rails_connector/default_cms_controller.rb +40 -0
- data/app/controllers/rails_connector/default_comments_controller.rb +71 -0
- data/app/controllers/rails_connector/default_crm_form_controller.rb +167 -0
- data/app/controllers/rails_connector/default_pdf_controller.rb +136 -0
- data/app/controllers/rails_connector/default_ratings_controller.rb +84 -0
- data/app/controllers/rails_connector/default_rss_controller.rb +29 -0
- data/app/controllers/rails_connector/default_search_controller.rb +60 -0
- data/app/controllers/rails_connector/default_user_controller.rb +267 -0
- data/app/controllers/rails_connector/pdf_external_controller.rb +54 -0
- data/app/controllers/rails_connector/time_machine_controller.rb +48 -0
- data/app/controllers/ratings_controller.rb +6 -0
- data/app/controllers/rss_controller.rb +6 -0
- data/app/controllers/search_controller.rb +2 -0
- data/app/controllers/seo_sitemap_controller.rb +12 -0
- data/app/controllers/user_controller.rb +2 -0
- data/app/helpers/cms_helper.rb +6 -0
- data/app/helpers/cms_routing_helper.rb +6 -0
- data/app/helpers/crm_form_helper.rb +3 -0
- data/app/helpers/rails_connector/cms_asset_helper.rb +51 -0
- data/app/helpers/rails_connector/default_cms_helper.rb +27 -0
- data/app/helpers/rails_connector/default_cms_routing_helper.rb +93 -0
- data/app/helpers/rails_connector/default_crm_form_helper.rb +58 -0
- data/app/helpers/rails_connector/default_ratings_helper.rb +38 -0
- data/app/helpers/rails_connector/default_user_helper.rb +90 -0
- data/app/helpers/rails_connector/display_helper.rb +117 -0
- data/app/helpers/rails_connector/error_messages_helper.rb +23 -0
- data/app/helpers/rails_connector/layout_helper.rb +30 -0
- data/app/helpers/rails_connector/link_helper.rb +88 -0
- data/app/helpers/rails_connector/mandatory_label_helper.rb +10 -0
- data/app/helpers/rails_connector/marker_helper.rb +363 -0
- data/app/helpers/rails_connector/menu_helper.rb +72 -0
- data/app/helpers/rails_connector/micronav_helper.rb +107 -0
- data/app/helpers/rails_connector/seo_helper.rb +44 -0
- data/app/helpers/rails_connector/table_of_contents_helper.rb +20 -0
- data/app/helpers/rails_connector/time_machine_helper.rb +24 -0
- data/app/helpers/rails_connector/tracking_helper.rb +32 -0
- data/app/helpers/ratings_helper.rb +4 -0
- data/app/helpers/user_helper.rb +3 -0
- data/app/mailers/confirmation_mailer.rb +13 -0
- data/app/models/crm_form.rb +2 -0
- data/app/models/named_link.rb +2 -0
- data/app/models/obj.rb +9 -0
- data/app/models/rails_connector/default_comment.rb +28 -0
- data/app/models/rails_connector/default_rating.rb +20 -0
- data/app/models/rails_connector/link_list.rb +30 -0
- data/app/views/cms/_comments.html.erb +44 -0
- data/app/views/cms/_index.html.erb +7 -0
- data/app/views/cms/_rating.html.erb +31 -0
- data/app/views/cms/index.html.erb +3 -0
- data/app/views/comments/_comment.html.erb +28 -0
- data/app/views/confirmation_mailer/register_confirmation.erb +5 -0
- data/app/views/confirmation_mailer/reset_password.erb +5 -0
- data/app/views/crm_form/_flash_messages.html.erb +11 -0
- data/app/views/crm_form/_form.html.erb +17 -0
- data/app/views/crm_form/confirmation.html.erb +3 -0
- data/app/views/crm_form/index.html.erb +5 -0
- data/app/views/crm_form/not_logged_in.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/app/views/layouts/rails_connector/time_machine.html.erb +12 -0
- data/app/views/pdf/index.html.erb +7 -0
- data/app/views/pdf/index.xsl +1240 -0
- data/app/views/rails_connector/time_machine/index.html.erb +88 -0
- data/app/views/rss/_item.rss.builder +11 -0
- data/app/views/rss/index.rss.builder +11 -0
- data/app/views/search/_hit.html.erb +12 -0
- data/app/views/search/_hits.html.erb +11 -0
- data/app/views/search/_mini_panel.html.erb +4 -0
- data/app/views/search/_pagination.html.erb +5 -0
- data/app/views/search/_panel.html.erb +4 -0
- data/app/views/search/search.html.erb +12 -0
- data/app/views/seo_sitemap/show.xml.builder +16 -0
- data/app/views/user/_flash_messages.html.erb +11 -0
- data/app/views/user/edit.html.erb +6 -0
- data/app/views/user/edit_password.html.erb +11 -0
- data/app/views/user/forgot_password.html.erb +7 -0
- data/app/views/user/login.html.erb +15 -0
- data/app/views/user/new.html.erb +11 -0
- data/app/views/user/profile.html.erb +8 -0
- data/app/views/user/register_pending.html.erb +1 -0
- data/app/views/user/set_password.html.erb +14 -0
- data/config/cms_routes.rb +13 -0
- data/config/locales/de.rails_connector.controllers.yml +30 -0
- data/config/locales/de.rails_connector.errors.yml +11 -0
- data/config/locales/de.rails_connector.helpers.yml +9 -0
- data/config/locales/de.rails_connector.lib.yml +6 -0
- data/config/locales/de.rails_connector.models.yml +8 -0
- data/config/locales/de.rails_connector.views.yml +87 -0
- data/config/locales/en.rails_connector.controllers.yml +30 -0
- data/config/locales/en.rails_connector.errors.yml +10 -0
- data/config/locales/en.rails_connector.helpers.yml +9 -0
- data/config/locales/en.rails_connector.lib.yml +6 -0
- data/config/locales/en.rails_connector.models.yml +8 -0
- data/config/locales/en.rails_connector.views.yml +87 -0
- data/config/routes.rb +37 -0
- data/lib/generators/rails_connector/comments/comments_generator.rb +21 -0
- data/lib/generators/rails_connector/comments/templates/migration.rb +17 -0
- data/lib/generators/rails_connector/install/install_generator.rb +38 -0
- data/lib/generators/rails_connector/install/templates/initializers/rails_connector.rb +58 -0
- data/lib/generators/rails_connector/install/templates/local/configuration.rb +2 -0
- data/lib/generators/rails_connector/install/templates/obj_extensions.rb +25 -0
- data/lib/generators/rails_connector/ratings/ratings_generator.rb +21 -0
- data/lib/generators/rails_connector/ratings/templates/migration.rb +15 -0
- data/lib/infopark_rails_connector.rb +31 -0
- data/lib/obj_extensions.rb +6 -0
- data/lib/rails_connector/authenticable.rb +30 -0
- data/lib/rails_connector/cms_accessible.rb +114 -0
- data/lib/rails_connector/cms_dispatch_controller.rb +47 -0
- data/lib/rails_connector/cms_env.rb +55 -0
- data/lib/rails_connector/cms_test_request.rb +23 -0
- data/lib/rails_connector/commentable.rb +23 -0
- data/lib/rails_connector/configuration/google_analytics.rb +29 -0
- data/lib/rails_connector/configuration/pdf_generator.rb +15 -0
- data/lib/rails_connector/configuration/rss.rb +46 -0
- data/lib/rails_connector/configuration.rb +235 -0
- data/lib/rails_connector/core_extensions/time.rb +18 -0
- data/lib/rails_connector/core_extensions.rb +1 -0
- data/lib/rails_connector/crm.rb +282 -0
- data/lib/rails_connector/engine.rb +78 -0
- data/lib/rails_connector/fop.rb +18 -0
- data/lib/rails_connector/fop_on_rails/document/dom_tree.rb +42 -0
- data/lib/rails_connector/fop_on_rails/document/images.rb +34 -0
- data/lib/rails_connector/fop_on_rails/document/tables.rb +67 -0
- data/lib/rails_connector/fop_on_rails/document.rb +25 -0
- data/lib/rails_connector/fop_on_rails.rb +92 -0
- data/lib/rails_connector/googlebot_checker.rb +47 -0
- data/lib/rails_connector/html_string.rb +19 -0
- data/lib/rails_connector/infopark_base.rb +2 -0
- data/lib/rails_connector/link_resolvable.rb +9 -0
- data/lib/rails_connector/liquid_support/action_marker.rb +69 -0
- data/lib/rails_connector/liquid_support/field_value_drop.rb +22 -0
- data/lib/rails_connector/liquid_support/general_helper_tag.rb +44 -0
- data/lib/rails_connector/liquid_support/link_drop.rb +22 -0
- data/lib/rails_connector/liquid_support/liquid_template_handler.rb +162 -0
- data/lib/rails_connector/liquid_support/named_object_drop.rb +14 -0
- data/lib/rails_connector/liquid_support/obj_drop.rb +43 -0
- data/lib/rails_connector/liquid_support/obj_filters.rb +77 -0
- data/lib/rails_connector/liquid_support.rb +23 -0
- data/lib/rails_connector/markdown_string.rb +19 -0
- data/lib/rails_connector/rateable.rb +57 -0
- data/lib/rails_connector/seo.rb +52 -0
- data/lib/rails_connector/ses.rb +72 -0
- data/lib/rails_connector/string_tagging.rb +29 -0
- data/lib/rails_connector/syndicateable.rb +11 -0
- data/lib/search_request.rb +2 -0
- data/lib/tasks/check.rake +25 -0
- data/lib/tasks/cms_license_check.rake +17 -0
- metadata +489 -0
data/config/routes.rb
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
Rails.application.routes.draw do
|
2
|
+
if RailsConnector::Configuration.enabled?(:search)
|
3
|
+
match 'search', :to => 'search#search'
|
4
|
+
end
|
5
|
+
|
6
|
+
if RailsConnector::Configuration.enabled?(:crm)
|
7
|
+
match 'login', :to => 'user#login'
|
8
|
+
match 'logout', :to => 'user#logout'
|
9
|
+
match 'user/:action', :to => 'user', :as => "user"
|
10
|
+
end
|
11
|
+
|
12
|
+
if RailsConnector::Configuration.enabled?(:time_machine) && RailsConnector::Configuration.editor_interface_enabled?
|
13
|
+
match 'time_machine/:action', :to => 'rails_connector/time_machine', :as => "time_machine"
|
14
|
+
end
|
15
|
+
|
16
|
+
if RailsConnector::Configuration.enabled?(:pdf_generator)
|
17
|
+
match 'pdf/external', :to => 'rails_connector/pdf_external#index', :as => "pdf_external"
|
18
|
+
match 'pdf/:id', :to => 'pdf#index', :as => "pdf"
|
19
|
+
match 'pdf/:action/:id', :to => 'pdf', :as => "pdf_with_action"
|
20
|
+
end
|
21
|
+
|
22
|
+
if RailsConnector::Configuration.enabled?(:rss)
|
23
|
+
match 'rss', :to => 'rss#index', :format => "rss"
|
24
|
+
end
|
25
|
+
|
26
|
+
if RailsConnector::Configuration.enabled?(:comments)
|
27
|
+
match 'comments/:action(/:id)', :to => 'comments', :as => "comment"
|
28
|
+
end
|
29
|
+
|
30
|
+
if RailsConnector::Configuration.enabled?(:ratings)
|
31
|
+
match 'ratings/:action/:id(/:score)', :to => 'ratings', :as => "ratings"
|
32
|
+
end
|
33
|
+
|
34
|
+
if RailsConnector::Configuration.enabled?(:seo_sitemap)
|
35
|
+
match 'sitemap.xml', :to => 'seo_sitemap#show', :format => 'xml'
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
#:stopdoc:
|
2
|
+
require "rails/generators/active_record"
|
3
|
+
|
4
|
+
module RailsConnector
|
5
|
+
module Generators
|
6
|
+
class CommentsGenerator < Rails::Generators::Base
|
7
|
+
include Rails::Generators::Migration
|
8
|
+
|
9
|
+
source_root File.expand_path('../templates', __FILE__)
|
10
|
+
|
11
|
+
def self.next_migration_number(dirname)
|
12
|
+
ActiveRecord::Generators::Base.next_migration_number(dirname)
|
13
|
+
end
|
14
|
+
|
15
|
+
desc "Create a migration to create comments in your application."
|
16
|
+
def generate_migration
|
17
|
+
migration_template 'migration.rb', 'db/migrate/create_comments.rb'
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# :stopdoc:
|
2
|
+
class CreateComments < ActiveRecord::Migration
|
3
|
+
def self.up
|
4
|
+
create_table :comments do |t|
|
5
|
+
t.string :obj_id
|
6
|
+
t.string :name
|
7
|
+
t.string :email
|
8
|
+
t.string :subject
|
9
|
+
t.text :body
|
10
|
+
t.datetime :created_at
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.down
|
15
|
+
drop_table :comments
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
#:stopdoc:
|
2
|
+
module RailsConnector
|
3
|
+
module Generators
|
4
|
+
class InstallGenerator < Rails::Generators::Base
|
5
|
+
desc "Copy Infopark Rails Connector files to your application."
|
6
|
+
|
7
|
+
# Normally, you'd just call 'source_root' as a class method from here,
|
8
|
+
# but we need to glob the dir ourselves. Hence our own method.
|
9
|
+
def self.source_root
|
10
|
+
@source_root ||= File.expand_path('../templates', __FILE__)
|
11
|
+
end
|
12
|
+
|
13
|
+
def install_configuration
|
14
|
+
copy_file "initializers/rails_connector.rb", "config/initializers/rails_connector.rb"
|
15
|
+
copy_file "obj_extensions.rb", "lib/obj_extensions.rb"
|
16
|
+
copy_file "local/configuration.rb", "config/local/configuration.rb"
|
17
|
+
end
|
18
|
+
|
19
|
+
def append_asset_manifests
|
20
|
+
append_file("app/assets/javascripts/application.js", "//= require infopark_rails_connector")
|
21
|
+
gsub_file("app/assets/stylesheets/application.css", "*= require_tree .",
|
22
|
+
"*= require_tree .\n *= require infopark_rails_connector")
|
23
|
+
end
|
24
|
+
|
25
|
+
def remove_public_index_html
|
26
|
+
remove_file "public/index.html"
|
27
|
+
remove_file "app/assets/images/rails.png"
|
28
|
+
end
|
29
|
+
|
30
|
+
def patch_default_application_layout
|
31
|
+
gsub_file("app/views/layouts/application.html.erb", %r{</head>},
|
32
|
+
"<%= rails_connector_header_tags %>\n</head>")
|
33
|
+
gsub_file("app/views/layouts/application.html.erb", %r{</body>},
|
34
|
+
"<%= rails_connector_after_content_tags %>\n</body>")
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
# Name of the CMS Fiona Instance to access
|
2
|
+
RailsConnector::Configuration.instance_name = 'default'
|
3
|
+
|
4
|
+
# Enable Rails Connector Addons.
|
5
|
+
# Please refer to the Infopark Knowledge Base for more information on addons.
|
6
|
+
RailsConnector::Configuration.enable(
|
7
|
+
# :comments,
|
8
|
+
# :google_analytics,
|
9
|
+
# :crm,
|
10
|
+
# :pdf_generator,
|
11
|
+
# :ratings,
|
12
|
+
# :rss,
|
13
|
+
:search,
|
14
|
+
# :seo_sitemap,
|
15
|
+
:time_machine
|
16
|
+
)
|
17
|
+
|
18
|
+
# Search should be configured in config/rails_connector.yml
|
19
|
+
|
20
|
+
# RSS-Feed:
|
21
|
+
#
|
22
|
+
# Specify which Object should be used for the RSS feed's parent folder
|
23
|
+
# RailsConnector::Configuration::Rss.root = lambda { NamedLink.get_object('news') }
|
24
|
+
|
25
|
+
|
26
|
+
# PDF-Generator:
|
27
|
+
#
|
28
|
+
# Set a list of approved hosts which the PdfGenerator is allowed to use
|
29
|
+
RailsConnector::Configuration::PdfGenerator.host_whitelist('localhost')
|
30
|
+
|
31
|
+
|
32
|
+
# Google Analytics:
|
33
|
+
#
|
34
|
+
# RailsConnector::Configuration::GoogleAnalytics.domains(
|
35
|
+
# '<your.domain.com>' => '<your-ga-code-1>',
|
36
|
+
# '<your.domain.de>' => '<your-ga-code-2>'
|
37
|
+
# )
|
38
|
+
|
39
|
+
# OMC:
|
40
|
+
#
|
41
|
+
# Infopark::Crm.configure do |config|
|
42
|
+
# config.url = "http://<crm-domain>:<port>"
|
43
|
+
# config.login = 'webservice'
|
44
|
+
# config.api_key = '<password>'
|
45
|
+
# # config.live_server_groups_callback = lambda {|contact|
|
46
|
+
# # case contact.account.name
|
47
|
+
# # when "My Company"
|
48
|
+
# # %w(internal)
|
49
|
+
# # else
|
50
|
+
# # []
|
51
|
+
# # end
|
52
|
+
# # }
|
53
|
+
# end
|
54
|
+
#
|
55
|
+
# Re-captcha public/private key pair (used for creating a new user)
|
56
|
+
# You can get those by signing up at http://recaptcha.net/
|
57
|
+
# RCC_PUB=""
|
58
|
+
# RCC_PRIV=""
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module ObjExtensions
|
2
|
+
|
3
|
+
# Infopark Rails Connector enables the developer to define specific behavior for Fiona CMS
|
4
|
+
# classes by using Single Table Inheritance (http://www.martinfowler.com/eaaCatalog/singleTableInheritance.html).
|
5
|
+
#
|
6
|
+
# If you wish to decorate the Obj model with extra behavior, you will need to add it here.
|
7
|
+
#
|
8
|
+
# Be careful only to use methods and classes that are part of the documented api.
|
9
|
+
# Other methods and classes may change without warning.
|
10
|
+
|
11
|
+
def self.enable
|
12
|
+
return if Obj.respond_to? :obj_extensions_enabled
|
13
|
+
|
14
|
+
Obj.class_eval do
|
15
|
+
|
16
|
+
def self.obj_extensions_enabled
|
17
|
+
end
|
18
|
+
|
19
|
+
# Add custom extensions to the Obj model below
|
20
|
+
#
|
21
|
+
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
#:stopdoc:
|
2
|
+
require "rails/generators/active_record"
|
3
|
+
|
4
|
+
module RailsConnector
|
5
|
+
module Generators
|
6
|
+
class RatingsGenerator < Rails::Generators::Base
|
7
|
+
include Rails::Generators::Migration
|
8
|
+
|
9
|
+
source_root File.expand_path('../templates', __FILE__)
|
10
|
+
|
11
|
+
def self.next_migration_number(dirname)
|
12
|
+
ActiveRecord::Generators::Base.next_migration_number(dirname)
|
13
|
+
end
|
14
|
+
|
15
|
+
desc "Copy files to your application and create a migration to create ratings."
|
16
|
+
def generate_migration
|
17
|
+
migration_template 'migration.rb', 'db/migrate/create_ratings.rb'
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# :stopdoc:
|
2
|
+
class CreateRatings < ActiveRecord::Migration
|
3
|
+
def self.up
|
4
|
+
create_table :ratings do |t|
|
5
|
+
t.timestamps
|
6
|
+
t.column :obj_id, :string
|
7
|
+
t.column :score, :integer
|
8
|
+
t.column :count, :integer, :default => 0
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.down
|
13
|
+
drop_table :ratings
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module ::RailsConnector
|
2
|
+
def self.load_platform_gem_if_present(name) # :nodoc:
|
3
|
+
if Gem.loaded_specs["infopark_#{name}_connector"]
|
4
|
+
gem_name = "infopark_#{name}_connector"
|
5
|
+
|
6
|
+
# ensure the other connector is present in exactly the same version
|
7
|
+
gem gem_name, Gem.loaded_specs["infopark_rails_connector"].version
|
8
|
+
|
9
|
+
require gem_name
|
10
|
+
|
11
|
+
@platform = name
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
# return either :fiona or :cloud depending on the app's configuration.
|
16
|
+
def self.platform
|
17
|
+
@platform
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
RailsConnector::load_platform_gem_if_present(:cloud)
|
22
|
+
RailsConnector::load_platform_gem_if_present(:fiona)
|
23
|
+
|
24
|
+
unless RailsConnector::platform
|
25
|
+
raise "The infopark_rails_connector gem requires "\
|
26
|
+
"either the infopark_cloud_connector gem (for use with Infopark Cloud Express) or "\
|
27
|
+
"the infopark_fiona_connector gem (for use with Infopark CMS Fiona). "\
|
28
|
+
"Add either gem to your Gemfile."
|
29
|
+
end
|
30
|
+
|
31
|
+
require "rails_connector/engine" if defined?(Rails)
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module RailsConnector
|
2
|
+
module Authenticable #:nodoc:
|
3
|
+
def self.included(mod)
|
4
|
+
%w(logged_in? admin? current_user).each do |method_name|
|
5
|
+
unless instance_method_defined?(mod, method_name)
|
6
|
+
mod.class_eval do
|
7
|
+
private
|
8
|
+
define_method(method_name, InstanceMethods.method(method_name).to_proc)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
mod.send(:helper_method, method_name)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
module InstanceMethods #:nodoc:
|
17
|
+
def self.logged_in?; false; end
|
18
|
+
def self.admin?; false; end
|
19
|
+
def self.current_user; nil; end
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def self.instance_method_defined?(mod, method_name)
|
25
|
+
mod.instance_methods.include?(method_name) or
|
26
|
+
mod.protected_instance_methods.include?(method_name) or
|
27
|
+
mod.private_instance_methods.include?(method_name)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,114 @@
|
|
1
|
+
module RailsConnector
|
2
|
+
|
3
|
+
module CmsAccessible
|
4
|
+
|
5
|
+
protected
|
6
|
+
|
7
|
+
def set_preview_time # :nodoc:
|
8
|
+
Obj.preview_time = session[:preview_time]
|
9
|
+
end
|
10
|
+
|
11
|
+
# Filter method to load a CMS object.
|
12
|
+
#
|
13
|
+
# To require the loading for all actions, use this in your controllers:
|
14
|
+
# before_filter :load_object
|
15
|
+
def load_object # :nodoc:
|
16
|
+
CmsEnv.new(request.env).load
|
17
|
+
loaded_obj = request.env[CmsEnv::OBJ_ENV_KEY]
|
18
|
+
raise loaded_obj if loaded_obj.is_a?(RailsConnector::ResourceNotFound)
|
19
|
+
@obj = loaded_obj
|
20
|
+
end
|
21
|
+
|
22
|
+
# Filter method to check if the already loaded object is active. If it is
|
23
|
+
# not, a 410 Gone error message will be generate (by calling render_obj_error).
|
24
|
+
#
|
25
|
+
# To require the check for all actions, use this in your controllers:
|
26
|
+
# before_filter :load_object
|
27
|
+
# before_filter :ensure_object_is_active
|
28
|
+
def ensure_object_is_active # :nodoc:
|
29
|
+
unless @obj.active?
|
30
|
+
@valid_from = @obj.valid_from
|
31
|
+
@valid_until = @obj.valid_until
|
32
|
+
@obj = nil
|
33
|
+
render_obj_error(410, "gone")
|
34
|
+
return false
|
35
|
+
end
|
36
|
+
return true
|
37
|
+
end
|
38
|
+
|
39
|
+
# Filter method to check if access to the loaded object is permitted. If it is
|
40
|
+
# not, a 403 Forbidden error message will be generated (by calling render_obj_error)
|
41
|
+
#
|
42
|
+
# To require the check for all actions, use this in your controllers:
|
43
|
+
# before_filter :load_object
|
44
|
+
# before_filter :ensure_object_is_permitted
|
45
|
+
def ensure_object_is_permitted # :nodoc:
|
46
|
+
unless is_permitted(@obj)
|
47
|
+
@obj = nil
|
48
|
+
render_obj_error(403, "forbidden")
|
49
|
+
return false
|
50
|
+
end
|
51
|
+
return true
|
52
|
+
end
|
53
|
+
|
54
|
+
# This method is called when rendering an error caused by either ensure_object_is_permitted
|
55
|
+
# or ensure_object_is_active before filter. It renders an error template located in
|
56
|
+
# "errors/*.html.erb" with given HTTP status and content type "text/html" and with no layout.
|
57
|
+
# Overwrite this method to change the error page.
|
58
|
+
def render_obj_error(status, name)
|
59
|
+
force_html_format
|
60
|
+
render(
|
61
|
+
:template => "errors/#{status}_#{name}",
|
62
|
+
:layout => false,
|
63
|
+
:status => status,
|
64
|
+
:content_type => Mime::HTML
|
65
|
+
)
|
66
|
+
end
|
67
|
+
|
68
|
+
# Enforce "html" as template format.
|
69
|
+
def force_html_format # :doc:
|
70
|
+
request.format = :html
|
71
|
+
end
|
72
|
+
|
73
|
+
# Inclusion hook to make is_permitted available as helper method.
|
74
|
+
def self.included(base) # :nodoc:
|
75
|
+
base.__send__ :helper_method, :is_permitted
|
76
|
+
end
|
77
|
+
|
78
|
+
# Helper method to check live permissions
|
79
|
+
def is_permitted(obj) # :nodoc:
|
80
|
+
obj.permitted_for_user?(current_user)
|
81
|
+
end
|
82
|
+
|
83
|
+
# Filter method which sets the header 'X-Robots-Tag: unavailable_after'
|
84
|
+
# to the valid_until date of the current object.
|
85
|
+
def set_google_expire_header # :nodoc:
|
86
|
+
if @obj && (date = @obj.valid_until)
|
87
|
+
headers['X-Robots-Tag: unavailable_after'] = date.rfc822
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
# Deliver the obj's body as response by file or data.
|
92
|
+
# May respond with status 304 if a If-Modified-Since header is found.
|
93
|
+
def deliver_file
|
94
|
+
if @obj.body_data_url
|
95
|
+
redirect_to @obj.body_data_url
|
96
|
+
elsif stale?(:last_modified => @obj.last_changed.utc)
|
97
|
+
mime_type = @obj.mime_type
|
98
|
+
mime_type += '; charset=utf-8' if mime_type =~ /^text\//
|
99
|
+
|
100
|
+
if (filepath = @obj.body_data_path).present?
|
101
|
+
send_file(File.expand_path(filepath), {
|
102
|
+
:type => mime_type,
|
103
|
+
:filename => @obj.filename,
|
104
|
+
:disposition => 'inline',
|
105
|
+
})
|
106
|
+
else
|
107
|
+
# generics should send its body, empty files should be delivered as
|
108
|
+
# empty files - and not lead to an application error
|
109
|
+
send_data @obj.body || '', :type => mime_type, :filename => @obj.filename, :disposition => 'inline'
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
#:enddoc:
|
2
|
+
module RailsConnector
|
3
|
+
|
4
|
+
class CmsDispatchController < ActionController::Metal
|
5
|
+
def process(action)
|
6
|
+
CmsEnv.new(env).load
|
7
|
+
controller = target_controller(env)
|
8
|
+
env["action_dispatch.request.path_parameters"]["controller"] = controller.controller_path
|
9
|
+
|
10
|
+
if !obj_not_found? && action == 'index'
|
11
|
+
action = loaded_obj.controller_action_name
|
12
|
+
end
|
13
|
+
|
14
|
+
env["action_dispatch.request.path_parameters"]["action"] = action
|
15
|
+
|
16
|
+
self.response = controller.action(action).call(env)
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def target_controller(env)
|
22
|
+
return default_controller if obj_not_found?
|
23
|
+
controller = "#{loaded_obj.controller_name}Controller".constantize
|
24
|
+
|
25
|
+
if controller.respond_to?(:use_for_obj_dispatch?) && controller.use_for_obj_dispatch?
|
26
|
+
controller
|
27
|
+
else
|
28
|
+
default_controller
|
29
|
+
end
|
30
|
+
rescue NameError
|
31
|
+
default_controller
|
32
|
+
end
|
33
|
+
|
34
|
+
def loaded_obj
|
35
|
+
env[CmsEnv::OBJ_ENV_KEY]
|
36
|
+
end
|
37
|
+
|
38
|
+
def obj_not_found?
|
39
|
+
loaded_obj.is_a?(RailsConnector::ResourceNotFound)
|
40
|
+
end
|
41
|
+
|
42
|
+
def default_controller
|
43
|
+
CmsController
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
#:enddoc:
|
2
|
+
module RailsConnector
|
3
|
+
|
4
|
+
class CmsEnv
|
5
|
+
|
6
|
+
OBJ_ENV_KEY = "INFOPARK_OBJ"
|
7
|
+
|
8
|
+
def initialize(env)
|
9
|
+
@env = env
|
10
|
+
end
|
11
|
+
|
12
|
+
def load
|
13
|
+
return if env[OBJ_ENV_KEY]
|
14
|
+
load_object
|
15
|
+
end
|
16
|
+
|
17
|
+
protected
|
18
|
+
|
19
|
+
attr_reader :env
|
20
|
+
|
21
|
+
def load_object
|
22
|
+
env[OBJ_ENV_KEY] =
|
23
|
+
begin
|
24
|
+
find_obj
|
25
|
+
rescue RailsConnector::ResourceNotFound => e
|
26
|
+
e
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def find_obj
|
31
|
+
found_obj =
|
32
|
+
if params[:id]
|
33
|
+
Obj.find(params[:id])
|
34
|
+
elsif params[:permalink].present?
|
35
|
+
permalink = params[:permalink].to_a.join("/")
|
36
|
+
Obj.find_by_permalink!(permalink)
|
37
|
+
else
|
38
|
+
Obj.homepage
|
39
|
+
end
|
40
|
+
|
41
|
+
if found_obj.suppressed?
|
42
|
+
raise RailsConnector::ResourceNotFound,
|
43
|
+
"Tried to access Obj #{found_obj.inspect}, but it is suppressed (suppress_export is set)!"
|
44
|
+
end
|
45
|
+
|
46
|
+
found_obj
|
47
|
+
end
|
48
|
+
|
49
|
+
def params
|
50
|
+
env["action_dispatch.request.path_parameters"]
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module RailsConnector
|
2
|
+
module CmsTestRequest # :nodoc:
|
3
|
+
def for_cms_object(test_obj=nil)
|
4
|
+
# prepare the env as if the given obj was loaded by CmsEnv
|
5
|
+
env[RailsConnector::CmsEnv::OBJ_ENV_KEY] = test_obj if test_obj
|
6
|
+
class << self
|
7
|
+
# This special behaviour is necessary for testing controllers that descend from DefaultCmsController.
|
8
|
+
# These controllers do not have explicit routes by default.
|
9
|
+
# Instead, they are reached via the CmsDispatchController.
|
10
|
+
# The TestRequest must therefore use CmsDispatchController as a fallback route.
|
11
|
+
def assign_parameters(routes, controller_path, action, parameters = {})
|
12
|
+
super(routes, controller_path, action, parameters)
|
13
|
+
rescue ActionController::RoutingError=> e
|
14
|
+
begin
|
15
|
+
super(routes, "rails_connector/cms_dispatch", action, parameters)
|
16
|
+
rescue ActionController::RoutingError
|
17
|
+
raise e
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module RailsConnector
|
2
|
+
# This module is included if the <tt>:comments</tt> addon is
|
3
|
+
# enabled:
|
4
|
+
# RailsConnector::Configuration.enable(:comments)
|
5
|
+
module Commentable
|
6
|
+
# returns all Comments for this Obj.
|
7
|
+
def comments
|
8
|
+
Comment.where(:obj_id => id).order("created_at")
|
9
|
+
end
|
10
|
+
|
11
|
+
# Returns +true+ by default.
|
12
|
+
# Implement your own conditions by overwriting this method in your +ObjExtensions+.
|
13
|
+
def allow_comments?
|
14
|
+
true
|
15
|
+
end
|
16
|
+
|
17
|
+
# Returns +true+ by default.
|
18
|
+
# Implement your own conditions by overwriting this method in your +ObjExtensions+.
|
19
|
+
def allow_anonymous_comments?
|
20
|
+
true
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module RailsConnector
|
2
|
+
class Configuration
|
3
|
+
|
4
|
+
# This module is an extension to the rails connector configuration.
|
5
|
+
#
|
6
|
+
# Configuration example:
|
7
|
+
#
|
8
|
+
# RailsConnector::Configuration::GoogleAnalytics.domains(
|
9
|
+
# 'www.example.de' => 'UA-example-1',
|
10
|
+
# 'www.example.com' => 'UA-example-2'
|
11
|
+
# )
|
12
|
+
module GoogleAnalytics
|
13
|
+
@@domains = {}
|
14
|
+
|
15
|
+
def self.domains=(domains_and_codes)
|
16
|
+
@@domains = @@domains.merge(domains_and_codes)
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.domains(domains_and_codes)
|
20
|
+
self.domains = domains_and_codes
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.domain_code(domain)
|
24
|
+
@@domains[domain]
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
module RailsConnector
|
2
|
+
class Configuration
|
3
|
+
|
4
|
+
# This module adds configuration options for the RSS feature.
|
5
|
+
#
|
6
|
+
# Specify the RSS root in
|
7
|
+
# <code><em>RAILS_ROOT</em>/config/initializers/rails_connector.rb</code>:
|
8
|
+
# RailsConnector::Configuration::Rss.root = lambda { NamedLink.get_object('news') }
|
9
|
+
module Rss
|
10
|
+
|
11
|
+
# Raised if no RSS root object has been specified.
|
12
|
+
class RootUndefined < StandardError; end
|
13
|
+
# Raised if the root is missing when accessing it
|
14
|
+
# Inherits from RootUndefined for compatibility reasons
|
15
|
+
class RootNotFound < RootUndefined; end
|
16
|
+
|
17
|
+
@root_provider = nil
|
18
|
+
|
19
|
+
# Stores the obj providing lambda for later use
|
20
|
+
def self.root=(obj_provider)
|
21
|
+
case obj_provider
|
22
|
+
when Obj
|
23
|
+
Rails.logger.warn("Rss.root= called with an Obj. Use an Obj returning lambda instead.")
|
24
|
+
root_id = obj_provider.id
|
25
|
+
@root_provider = lambda { Obj.find(root_id) }
|
26
|
+
when Proc
|
27
|
+
@root_provider = obj_provider
|
28
|
+
else
|
29
|
+
raise ArgumentError.new("Rss.root= called with '#{obj_provider.class.name}' instead of a lambda.")
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
# Returns the RSS root object.
|
34
|
+
# If no RSS root has been specified then Rss::RootUndefined is raised.
|
35
|
+
def self.root
|
36
|
+
raise RootUndefined unless @root_provider
|
37
|
+
begin
|
38
|
+
@root_provider.call
|
39
|
+
rescue RailsConnector::ResourceNotFound
|
40
|
+
raise RootNotFound
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
end
|