infopark_rails_connector 6.8.0.beta.200.621.4c8e1b0
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.
- 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
@@ -0,0 +1,12 @@
|
|
1
|
+
# Renders a search engine optimized sitemap.xml
|
2
|
+
# Enable via <tt>RailsConnector::Configuration.enable(:seo_sitemap)</tt>
|
3
|
+
class SeoSitemapController < ApplicationController
|
4
|
+
layout nil
|
5
|
+
|
6
|
+
# Finds all objects which are to be shown in the SEO sitemap. Responds to xml only.
|
7
|
+
def show
|
8
|
+
@objects = Obj.find_all_for_sitemap
|
9
|
+
respond_to { |format| format.xml }
|
10
|
+
end
|
11
|
+
|
12
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
module RailsConnector
|
2
|
+
|
3
|
+
# This module contains helpers that can be used to reference images and other assets stored in the CMS.
|
4
|
+
#
|
5
|
+
# Use this helper to take advantage of rails' asset host mechanism.
|
6
|
+
# (See http://api.rubyonrails.com/classes/ActionView/Helpers/AssetTagHelper.html for details about asset hosts.)
|
7
|
+
# If your application does not use any asset hosts, the helper will generate regular (=non asset host) pathes.
|
8
|
+
module CmsAssetHelper
|
9
|
+
|
10
|
+
# Returns an html image tag for an image stored in the CMS.
|
11
|
+
#
|
12
|
+
# +target+ is the image from the cms to be referenced in the image tag.
|
13
|
+
# +target+ can be an +Obj+ or a +Link+ or a +LinkList+.
|
14
|
+
# +options+ can be used to specify additional html attributes for the tag.
|
15
|
+
# If you do not specify an html alt attribute, the helper method will use
|
16
|
+
# +target+'s +display_title+ as the html alt attribute.
|
17
|
+
# If your application is configured to use asset hosts, the images tag will reference
|
18
|
+
# the image using one of your asset hosts.
|
19
|
+
def cms_image_tag(target, options = {})
|
20
|
+
options.symbolize_keys!
|
21
|
+
|
22
|
+
options[:src] = cms_asset_path(target)
|
23
|
+
options[:alt] ||= display_title(target)
|
24
|
+
|
25
|
+
tag("img", options)
|
26
|
+
end
|
27
|
+
|
28
|
+
# Calculate the path to an asset stored in the CMS.
|
29
|
+
#
|
30
|
+
# The path can be used to reference a cms object inside an html page.
|
31
|
+
# +target+ can be an +Obj+ or a +Link+ or a +LinkList+.
|
32
|
+
# If your application is configured to use asset hosts, the path will reference
|
33
|
+
# the object using one of your asset hosts.
|
34
|
+
def cms_asset_path(target)
|
35
|
+
regular_path = cms_path(target)
|
36
|
+
return regular_path if regular_path.first == "#"
|
37
|
+
asset_paths.compute_public_path(regular_path, nil)
|
38
|
+
end
|
39
|
+
|
40
|
+
private
|
41
|
+
|
42
|
+
def display_title(target)
|
43
|
+
if target.respond_to?(:display_title)
|
44
|
+
return target.display_title
|
45
|
+
elsif target.respond_to?(:first) && target.first.respond_to?(:display_title)
|
46
|
+
return target.first.display_title
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module RailsConnector
|
2
|
+
|
3
|
+
# This is a wrapper module for the default set of Rails Connector helper modules.
|
4
|
+
#
|
5
|
+
# To make autoloading from +CmsController+ work, this module must be wrapped
|
6
|
+
# by a module named +CmsHelper+:
|
7
|
+
#
|
8
|
+
# module CmsHelper
|
9
|
+
# include RailsConnector::DefaultCmsHelper
|
10
|
+
# end
|
11
|
+
|
12
|
+
module DefaultCmsHelper
|
13
|
+
include DisplayHelper
|
14
|
+
include MarkerHelper
|
15
|
+
include CmsAssetHelper
|
16
|
+
include SeoHelper
|
17
|
+
include RailsConnector::MenuHelper
|
18
|
+
include RailsConnector::MicronavHelper
|
19
|
+
include RailsConnector::TimeMachineHelper
|
20
|
+
include RailsConnector::LinkHelper
|
21
|
+
include RailsConnector::CmsAssetHelper
|
22
|
+
include RailsConnector::TableOfContentsHelper
|
23
|
+
include RatingsHelper
|
24
|
+
include RailsConnector::LayoutHelper
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
@@ -0,0 +1,93 @@
|
|
1
|
+
module RailsConnector
|
2
|
+
|
3
|
+
module DefaultCmsRoutingHelper
|
4
|
+
# Returns the path for +target+ using the +CmsController+ routes.
|
5
|
+
# +target+ can be an +Obj+ or a +Link+ or a +LinkList+.
|
6
|
+
# If +target+ is a +Linklist+, it must be non-empty. The first +Link+ from the +LinkList+ will be used.
|
7
|
+
# +options+ are optional and include url settings such as path parameters or protocol
|
8
|
+
# +options+ are only passed on if +target+ is an +Obj+.
|
9
|
+
def cms_path(target, options = {})
|
10
|
+
cms_path_or_url(target, "path", options)
|
11
|
+
end
|
12
|
+
|
13
|
+
# Returns the absolute URL for target using the +CmsController+ routes.
|
14
|
+
# +target+ can be an +Obj+ or a +Link+ or a +LinkList+.
|
15
|
+
# If +target+ is a +Linklist+, it must be non-empty. The first +Link+ from the +LinkList+ will be used.
|
16
|
+
# +options+ are optional and include url settings such as path parameters or protocol
|
17
|
+
# +options+ are only passed on if +target+ is an +Obj+.
|
18
|
+
def cms_url(target, options = {})
|
19
|
+
cms_path_or_url(target, "url", options)
|
20
|
+
end
|
21
|
+
|
22
|
+
LINK_TO_UNRELEASED = "#__target_object_not_released" #:nodoc:
|
23
|
+
LINK_TO_EMPTY_LINKLIST = "#__empty_linklist" #:nodoc:
|
24
|
+
|
25
|
+
def cms_path_or_url(target, path_or_url, options = {}) #:nodoc:
|
26
|
+
if target.is_a?(Link)
|
27
|
+
cms_path_or_url_for_links(target, path_or_url)
|
28
|
+
elsif target.is_a?(Obj)
|
29
|
+
cms_path_or_url_for_objs(target, path_or_url, options)
|
30
|
+
elsif target.respond_to?(:first)
|
31
|
+
if target.first.is_a?(Link)
|
32
|
+
cms_path_or_url_for_links(target.first, path_or_url)
|
33
|
+
else
|
34
|
+
return LINK_TO_EMPTY_LINKLIST
|
35
|
+
end
|
36
|
+
else
|
37
|
+
raise "cms_path or cms_url was called with an instance of #{target.class}. "+
|
38
|
+
"It must only be called with an Obj or a Link or a non-empty LinkList."
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def cms_path_or_url_for_links(link, path_or_url) #:nodoc:
|
43
|
+
return LINK_TO_UNRELEASED if link.internal? && link.destination_object.nil?
|
44
|
+
append_search_and_fragment(
|
45
|
+
basic_url_or_path_for_link(link, path_or_url), link
|
46
|
+
)
|
47
|
+
end
|
48
|
+
|
49
|
+
def cms_path_or_url_for_objs(obj, path_or_url, options = {}) #:nodoc:
|
50
|
+
permalink = obj.permalink
|
51
|
+
if permalink && !Configuration.editor_interface_enabled?
|
52
|
+
__send__("cms_permalink_#{path_or_url}", options.merge(:permalink => permalink))
|
53
|
+
elsif obj.homepage? && !Configuration.editor_interface_enabled?
|
54
|
+
__send__("root_#{path_or_url}", options)
|
55
|
+
else
|
56
|
+
if obj.body_data_url
|
57
|
+
obj.body_data_url
|
58
|
+
elsif obj.binary? && !obj.file_extension.blank?
|
59
|
+
__send__("cms_id_#{path_or_url}",
|
60
|
+
options.merge(:id => obj.id, :name => obj.name, :format => obj.file_extension))
|
61
|
+
else
|
62
|
+
routing_options = options.merge(:id => obj.id, :name => obj.name.presence)
|
63
|
+
__send__("cms_id_#{path_or_url}", routing_options)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
private
|
69
|
+
|
70
|
+
def basic_url_or_path_for_link(link, path_or_url)
|
71
|
+
if link.internal?
|
72
|
+
__send__("cms_#{path_or_url}", link.destination_object)
|
73
|
+
else
|
74
|
+
if link.external_prefix?
|
75
|
+
remove_external_prefix(link.url)
|
76
|
+
else
|
77
|
+
link.url
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
def remove_external_prefix(link)
|
83
|
+
link.gsub(/external:/, "").strip
|
84
|
+
end
|
85
|
+
|
86
|
+
def append_search_and_fragment(url,link)
|
87
|
+
result = url
|
88
|
+
result += "?#{link.search}" unless link.search.blank?
|
89
|
+
result += "##{link.fragment}" unless link.fragment.blank?
|
90
|
+
result
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
module RailsConnector
|
2
|
+
|
3
|
+
module DefaultCrmFormHelper
|
4
|
+
|
5
|
+
include ::RailsConnector::DefaultUserHelper
|
6
|
+
include ::RailsConnector::MandatoryLabelHelper
|
7
|
+
include ::RailsConnector::ErrorMessagesHelper
|
8
|
+
|
9
|
+
def custom_fields_for(form)
|
10
|
+
activity = instance_variable_get("@#{form.object_name}")
|
11
|
+
custom_attribute_defs = Infopark::Crm::CustomType.find(activity.kind).custom_attributes
|
12
|
+
content = "".html_safe
|
13
|
+
custom_attribute_defs.each do |attribute|
|
14
|
+
custom_attr = "custom_#{attribute.name}"
|
15
|
+
next unless allow_custom_attribute?(custom_attr)
|
16
|
+
value = activity.__send__(custom_attr).to_s
|
17
|
+
input_field =
|
18
|
+
case attribute.type
|
19
|
+
when 'enum'
|
20
|
+
form.select(custom_attr, [''] + attribute.valid_values, :value => value)
|
21
|
+
when 'text'
|
22
|
+
form.text_area(custom_attr, :value => value, :cols => 50, :rows => 5)
|
23
|
+
else
|
24
|
+
form.text_field(custom_attr, :value => value, :size => "40")
|
25
|
+
end
|
26
|
+
content << content_tag(:div, :class => 'label') do
|
27
|
+
if attribute.mandatory
|
28
|
+
mandatory_label_for(form, custom_attr, h(attribute.title))
|
29
|
+
else
|
30
|
+
form.label(custom_attr, h(attribute.title))
|
31
|
+
end
|
32
|
+
end
|
33
|
+
content << content_tag(:div, input_field, :class => 'field')
|
34
|
+
end
|
35
|
+
content
|
36
|
+
end
|
37
|
+
|
38
|
+
def title_field_for(form)
|
39
|
+
content = "".html_safe
|
40
|
+
if has_title_input_field?
|
41
|
+
content << content_tag(:div, :class => 'label') do
|
42
|
+
mandatory_label_for(form, :title, t(:"rails_connector.views.crm_form.title"))
|
43
|
+
end
|
44
|
+
content << content_tag(:div, :class => 'field') do
|
45
|
+
form.text_field :title
|
46
|
+
end
|
47
|
+
end
|
48
|
+
content
|
49
|
+
end
|
50
|
+
|
51
|
+
def logged_in_as(user)
|
52
|
+
content_tag(:em) do
|
53
|
+
t('rails_connector.views.crm_form.logged_in_as',
|
54
|
+
:user => content_tag(:strong, user)).html_safe
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module RailsConnector
|
2
|
+
#
|
3
|
+
# This helper provides methods for use with ratings.
|
4
|
+
module DefaultRatingsHelper
|
5
|
+
# Determines whether the current user has rated a CMS object.
|
6
|
+
def rated_by_current_user?(obj)
|
7
|
+
session[:rated_objs] && session[:rated_objs][obj.id]
|
8
|
+
end
|
9
|
+
|
10
|
+
# Builds the HTML markup for the ratings section.
|
11
|
+
def stars_for_rating(obj)
|
12
|
+
stars = "".html_safe
|
13
|
+
(Rating::MINIMUM..Rating::MAXIMUM).collect do |score|
|
14
|
+
stars << content_tag(:li, link_a_star(score, obj))
|
15
|
+
end
|
16
|
+
stars
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def link_a_star(score, obj)
|
22
|
+
css_classes = ["", "one-star", "two-stars", "three-stars", "four-stars", "five-stars"]
|
23
|
+
descriptions = ["",
|
24
|
+
t(:"rails_connector.helpers.ratings.bad"),
|
25
|
+
t(:"rails_connector.helpers.ratings.mediocre"),
|
26
|
+
t(:"rails_connector.helpers.ratings.average"),
|
27
|
+
t(:"rails_connector.helpers.ratings.good"),
|
28
|
+
t(:"rails_connector.helpers.ratings.very_good")
|
29
|
+
]
|
30
|
+
html_options = {
|
31
|
+
:title => "#{score} von #{Rating::MAXIMUM} Sternen",
|
32
|
+
:class => css_classes[score],
|
33
|
+
"data-description" => descriptions[score]
|
34
|
+
}
|
35
|
+
link_to(score.to_s, ratings_url(:action => :rate, :id => obj.id, :score => score), html_options)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,90 @@
|
|
1
|
+
require "recaptcha"
|
2
|
+
|
3
|
+
module RailsConnector
|
4
|
+
|
5
|
+
# This module contains helpers for the +UserController+ and +DefaultUserController+
|
6
|
+
module DefaultUserHelper
|
7
|
+
|
8
|
+
include ::ReCaptcha::ViewHelper
|
9
|
+
include ::RailsConnector::MandatoryLabelHelper
|
10
|
+
include ::RailsConnector::ErrorMessagesHelper
|
11
|
+
|
12
|
+
# Returns mandatory user fields as array of symbols.
|
13
|
+
def mandatory_user_fields
|
14
|
+
[:email, :gender, :language, :last_name]
|
15
|
+
end
|
16
|
+
|
17
|
+
# Generates part of a form for the given attributes:
|
18
|
+
#
|
19
|
+
# In your view, use:
|
20
|
+
#
|
21
|
+
# <%= form_for @user, :as => :user do |f| -%>
|
22
|
+
# <%= user_fields_for(f, 'contact', :first_name, :last_name) %>
|
23
|
+
# <% end -%>
|
24
|
+
#
|
25
|
+
# to generate labels and fields for the contact:
|
26
|
+
#
|
27
|
+
# <form>
|
28
|
+
# <div class="label"><label for="user_first_name">First name</label></div>
|
29
|
+
# <div class="field"><input id="user_first_name" name="user[first_name]" size="30" type="text" /></div>
|
30
|
+
# <div class="label"><label for="user_last_name">Last name</label></div>
|
31
|
+
# <div class="field"><input id="user_last_name" name="user[last_name]" size="30" type="text" /></div>
|
32
|
+
# </form>
|
33
|
+
#
|
34
|
+
# Labels are localized automatically, using the scope views.contact and views.location,
|
35
|
+
# respectively. For example:
|
36
|
+
#
|
37
|
+
# views:
|
38
|
+
# user:
|
39
|
+
# first_name: First name
|
40
|
+
# last_name: Last name
|
41
|
+
def user_fields_for(form, model_name, *attributes)
|
42
|
+
output = "".html_safe
|
43
|
+
attributes.flatten.each do |attr|
|
44
|
+
output += content_tag(:div, :class => 'label') do
|
45
|
+
if mandatory_user_fields.include?(attr)
|
46
|
+
mandatory_label_for(form, attr, t("rails_connector.views.user.#{model_name}.#{attr}"))
|
47
|
+
else
|
48
|
+
form.label(attr, t("rails_connector.views.user.#{model_name}.#{attr}"))
|
49
|
+
end
|
50
|
+
end
|
51
|
+
form_field = case attr
|
52
|
+
when :gender
|
53
|
+
form.select(:gender, genders_for_select)
|
54
|
+
when :language
|
55
|
+
languages = Infopark::Crm::CustomType.find('contact').languages
|
56
|
+
form.select(:language, languages_for_select_for(languages),
|
57
|
+
:selected => (@user ? @user.language : I18n.locale.to_s) )
|
58
|
+
else
|
59
|
+
form.text_field(attr)
|
60
|
+
end
|
61
|
+
output += content_tag(:div, form_field, :class => 'field')
|
62
|
+
end
|
63
|
+
output
|
64
|
+
end
|
65
|
+
|
66
|
+
def genders_for_select
|
67
|
+
[
|
68
|
+
['', 'N'],
|
69
|
+
[t('rails_connector.views.user.gender_female'),'F'],
|
70
|
+
[t('rails_connector.views.user.gender_male'), 'M']
|
71
|
+
]
|
72
|
+
end
|
73
|
+
|
74
|
+
def languages_for_select_for(*languages)
|
75
|
+
options = []
|
76
|
+
languages.flatten.each do |lang|
|
77
|
+
options << [t(:"rails_connector.views.user.languages.#{lang}"), lang]
|
78
|
+
end
|
79
|
+
options
|
80
|
+
end
|
81
|
+
|
82
|
+
def profile_fields_for(form, editable_attributes={})
|
83
|
+
output = "".html_safe
|
84
|
+
output += user_fields_for(form, "contact", editable_attributes[:contact])
|
85
|
+
output
|
86
|
+
end
|
87
|
+
|
88
|
+
end
|
89
|
+
|
90
|
+
end
|
@@ -0,0 +1,117 @@
|
|
1
|
+
module RailsConnector
|
2
|
+
|
3
|
+
# This module contains a helper that can be used to render attributes of the CMS models.
|
4
|
+
module DisplayHelper
|
5
|
+
|
6
|
+
# For a consistent look of your site and easy maintenance, only the display helpers
|
7
|
+
# should be used to render an attribute <em>value</em> of a CMS model.
|
8
|
+
#
|
9
|
+
# <%= display_value @obj.title %>
|
10
|
+
# Renders the value, taking its type into account.
|
11
|
+
# * An HtmlString will be exported by converting its links
|
12
|
+
# * A Time will be exported in an international form: Year-Mounth-Day Hour:Minutes
|
13
|
+
# * A non-HTML String will be quoted
|
14
|
+
# * other values will be rendered unchanged
|
15
|
+
#
|
16
|
+
def display_value(value)
|
17
|
+
case value
|
18
|
+
when MarkdownString then markdown(convert_links(value)).html_safe
|
19
|
+
when HtmlString then convert_links(value).html_safe
|
20
|
+
when String then h(value)
|
21
|
+
when Time then h(l(value))
|
22
|
+
else value
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
# Renders a field from the CMS, including an edit marker for the preview
|
27
|
+
# If the option :marker is false, no edit marker will be rendered.
|
28
|
+
#
|
29
|
+
# <%= display_field @obj, :title %>
|
30
|
+
#
|
31
|
+
# When creating an edit marker, all options except :marker are passed to MarkerHelper::edit_marker.
|
32
|
+
#
|
33
|
+
def display_field(obj, attr, options = {})
|
34
|
+
options.reverse_merge!({
|
35
|
+
:marker => ![:id, :path, :created, :last_changed, :version].include?(attr.to_sym)
|
36
|
+
})
|
37
|
+
if options.delete :marker
|
38
|
+
edit_marker(obj, attr, options) do |obj, attr|
|
39
|
+
display_value obj[attr]
|
40
|
+
end
|
41
|
+
else
|
42
|
+
display_value obj[attr]
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
# Legacy method - deprecated
|
47
|
+
#
|
48
|
+
# Use display_value and display_field instead
|
49
|
+
#
|
50
|
+
def display(*args) #:nodoc:
|
51
|
+
if args.last.kind_of? Hash
|
52
|
+
options = args.pop
|
53
|
+
else
|
54
|
+
options = {}
|
55
|
+
end
|
56
|
+
return display_value(args.first) if args.size == 1
|
57
|
+
display_field(args[0], args[1], options)
|
58
|
+
end
|
59
|
+
|
60
|
+
private
|
61
|
+
|
62
|
+
def markdown(string)
|
63
|
+
require 'maruku'
|
64
|
+
Maruku.new(string).to_html
|
65
|
+
end
|
66
|
+
|
67
|
+
LINK_PATTERN = '<?\binternallink:(\d+)\b>?'
|
68
|
+
LINK_EXPRESSION = %r(#{LINK_PATTERN})
|
69
|
+
|
70
|
+
def convert_links(content_attribute)
|
71
|
+
return content_attribute unless content_attribute =~ LINK_EXPRESSION
|
72
|
+
link_map = content_attribute.source.text_links.each_with_object({}) do |link, map|
|
73
|
+
map[link.id.to_s] = link
|
74
|
+
end
|
75
|
+
content_attribute.gsub(%r(#{LINK_PATTERN}(['"]?))) do
|
76
|
+
link = link_map[$1.to_s]
|
77
|
+
if link.blank?
|
78
|
+
"#{CmsRoutingHelper::LINK_TO_UNRELEASED}#{$2}"
|
79
|
+
else
|
80
|
+
uri = "#{cms_path(link)}#{$2}"
|
81
|
+
if link.markdown?
|
82
|
+
markdown_link(link, uri)
|
83
|
+
else
|
84
|
+
html_link(link, uri)
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
def html_link(link, uri)
|
91
|
+
subst = uri
|
92
|
+
name, value =
|
93
|
+
case link.tag_name
|
94
|
+
when 'img', 'input'
|
95
|
+
['alt', link.title || ""]
|
96
|
+
when 'a', 'link'
|
97
|
+
['title', begin link.title unless link.title.blank? end]
|
98
|
+
end
|
99
|
+
if value
|
100
|
+
subst << %( #{name}="#{h(value)}")
|
101
|
+
end
|
102
|
+
subst << %( target="#{h(link.target)}") unless link.target.blank?
|
103
|
+
subst
|
104
|
+
end
|
105
|
+
|
106
|
+
def markdown_link(link, uri)
|
107
|
+
subst = "<#{uri}>"
|
108
|
+
unless link.title.blank?
|
109
|
+
case link.markdown_type
|
110
|
+
when 'inline', 'reference'
|
111
|
+
subst << %( "#{h(link.title)}")
|
112
|
+
end
|
113
|
+
end
|
114
|
+
subst
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module RailsConnector
|
2
|
+
module ErrorMessagesHelper
|
3
|
+
# Shortened error_messages_for from git://github.com/rails/dynamic_form.git
|
4
|
+
def error_messages(*objects)
|
5
|
+
objects.compact!
|
6
|
+
count = objects.inject(0) {|sum, object| sum + object.errors.count }
|
7
|
+
return '' if count.zero?
|
8
|
+
|
9
|
+
content_tag(:div, :class => 'errorExplanation') do
|
10
|
+
c = ''.html_safe
|
11
|
+
c << content_tag(:ul) do
|
12
|
+
li = ''.html_safe
|
13
|
+
objects.each do |object|
|
14
|
+
object.errors.full_messages.each do |msg|
|
15
|
+
li << content_tag(:li, msg)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
li
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module RailsConnector
|
2
|
+
|
3
|
+
# This module contains helpers that render tags for the html head
|
4
|
+
# and the end of the html body.
|
5
|
+
module LayoutHelper
|
6
|
+
include TrackingHelper
|
7
|
+
|
8
|
+
# Renders all tags needed in the html head for the enabled features.
|
9
|
+
def rails_connector_header_tags
|
10
|
+
html = "".html_safe
|
11
|
+
html += tag('meta', :name => 'generator',
|
12
|
+
:content => "Rails Connector for Infopark CMS Fiona by Infopark AG (www.infopark.de); "\
|
13
|
+
"Version #{Gem.loaded_specs['infopark_rails_connector'].version}")
|
14
|
+
if Configuration.enabled?(:rss)
|
15
|
+
html += auto_discovery_link_tag(:rss, rss_url, :title => 'RSS Feed')
|
16
|
+
end
|
17
|
+
html += include_edit_marker_support
|
18
|
+
html
|
19
|
+
end
|
20
|
+
|
21
|
+
# Renders all tags needed at the end of the body tag for the enabled features.
|
22
|
+
def rails_connector_after_content_tags
|
23
|
+
html = "".html_safe
|
24
|
+
html += render_marker_code
|
25
|
+
html += google_analytics if Configuration.enabled?(:google_analytics)
|
26
|
+
html
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
@@ -0,0 +1,88 @@
|
|
1
|
+
require "uri"
|
2
|
+
|
3
|
+
module RailsConnector
|
4
|
+
|
5
|
+
# This module contains a helper that can be used to build markup for a link, e.g. a download link.
|
6
|
+
module LinkHelper
|
7
|
+
# Generates a link by producing the corresponding HTML markup.
|
8
|
+
# <em>link</em> is the Link to be rendered, you may specify the following <em>options</em>:
|
9
|
+
#
|
10
|
+
# [:file_extension] specifies the file extension if the link object is an internal link.
|
11
|
+
# An external link has no file extension since there is no destination object from which
|
12
|
+
# the file extension could be taken. File extensions are, for example, 'pdf', 'zip', or 'doc'.
|
13
|
+
#
|
14
|
+
# The HTML text generated depends on the kind of Link passed to the helper:
|
15
|
+
#
|
16
|
+
# <%= link(@myLinkObject) %>
|
17
|
+
#
|
18
|
+
# [With an internal Link] The helper will produce the following HTML where path is
|
19
|
+
# the path created by the PageHelper, file extension is the file_extension of the
|
20
|
+
# destination object. For a Content, the display title is the Link's display_title and
|
21
|
+
# size is the size of its body (in KB or MB):
|
22
|
+
# <a href='path' class='link'>
|
23
|
+
# <span class='file extension'>
|
24
|
+
# display title
|
25
|
+
# <span class='link_size'> (size)</span>
|
26
|
+
# </span>
|
27
|
+
# </a></tt>
|
28
|
+
#
|
29
|
+
# [With an external Link] The helper will produce the following HTML where url
|
30
|
+
# is the external url of the link and display title is the display_title of the Link:
|
31
|
+
#
|
32
|
+
# <a class='link' href='url'>
|
33
|
+
# <span>display title</span>
|
34
|
+
# </a>
|
35
|
+
#
|
36
|
+
# Normally, you do not know the file extension of the external source, so by default
|
37
|
+
# there will be no CSS class generated for the nested <tt><span></tt> tag. In the case
|
38
|
+
# that you do know it or want some external links to have a special style, you can
|
39
|
+
# specify the file extension with the :file_extension option:
|
40
|
+
#
|
41
|
+
# <%= link(@myLinkObject, :file_extension => 'file_extension' %>
|
42
|
+
#
|
43
|
+
# The helper would then produce the following:
|
44
|
+
#
|
45
|
+
# <a class='link' href='destination'>
|
46
|
+
# <span class='file_extension'>title</span>
|
47
|
+
# </a>
|
48
|
+
def link(link, options = {})
|
49
|
+
link_attributes = {
|
50
|
+
:href => cms_path(link),
|
51
|
+
:class => 'link'
|
52
|
+
}
|
53
|
+
link_attributes[:target] = link.target unless link.target.blank?
|
54
|
+
content_tag(:a,
|
55
|
+
content_tag(:span,
|
56
|
+
display_value(link.display_title) + size_content(link),
|
57
|
+
:class => options[:file_extension] || link.file_extension
|
58
|
+
),
|
59
|
+
link_attributes
|
60
|
+
)
|
61
|
+
end
|
62
|
+
|
63
|
+
# Displays a link list as an HTML list.
|
64
|
+
# <em>link_list</em> is the link list to be rendered. For each link #link is called.
|
65
|
+
# For a list of valid <em>options</em> see #link.
|
66
|
+
#
|
67
|
+
# The generated list element has the CSS class 'linklist'.
|
68
|
+
def link_list(link_list, options = {})
|
69
|
+
return if link_list.blank?
|
70
|
+
markup = "<ul class='linklist'>"
|
71
|
+
link_list.each do |l|
|
72
|
+
markup << "<li>#{link l, options}</li>"
|
73
|
+
end
|
74
|
+
markup << "</ul>"
|
75
|
+
end
|
76
|
+
|
77
|
+
private
|
78
|
+
|
79
|
+
def size_content(link)
|
80
|
+
return "" unless link.internal? && link.destination_object && link.destination_object.binary?
|
81
|
+
size = ' (' + number_to_human_size(link.destination_object.body_length) + ')'
|
82
|
+
content_tag(:span, size, :class => 'link_size')
|
83
|
+
end
|
84
|
+
|
85
|
+
include DisplayHelper
|
86
|
+
end
|
87
|
+
|
88
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
module RailsConnector
|
2
|
+
module MandatoryLabelHelper
|
3
|
+
def mandatory_label_for(form, object, label)
|
4
|
+
html = "".html_safe
|
5
|
+
html += label
|
6
|
+
html += content_tag(:span, " *", :class => "mandatory_star")
|
7
|
+
form.label(object, html, :class => "mandatory")
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|