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,77 @@
|
|
1
|
+
module RailsConnector::LiquidSupport #:nodoc:
|
2
|
+
|
3
|
+
# Filters in general are methods used in Liquid templates.
|
4
|
+
# ObjFilters are filters specifically for dealing with CMS objects.
|
5
|
+
module ObjFilters
|
6
|
+
|
7
|
+
# Generates a link for the +target+.
|
8
|
+
# +target+ can be an Obj, a Link or a Linklist.
|
9
|
+
# If +target+ is a Linklist, the first element of the list will be used.
|
10
|
+
#
|
11
|
+
# Example:
|
12
|
+
# {{ "Click me" | link_to: obj }}
|
13
|
+
#
|
14
|
+
def link_to(a, b = nil)
|
15
|
+
if b
|
16
|
+
title = a || ""
|
17
|
+
target = b
|
18
|
+
else
|
19
|
+
target = a
|
20
|
+
end
|
21
|
+
target = first_link_if_linklist(target)
|
22
|
+
if target
|
23
|
+
action_view.link_to(title || target.display_title, drop_cms_path(target))
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
# Generates an IMG tag for +target+.
|
28
|
+
# +target+ can be an Obj, a Link or a Linklist.
|
29
|
+
# If +target+ is a Linklist, the first element of the list will be used.
|
30
|
+
#
|
31
|
+
# Example:
|
32
|
+
# {{ @obj | image_tag }}
|
33
|
+
def image_tag(target, title = nil)
|
34
|
+
action_view.cms_image_tag(unwrap_drop(target), :alt => title)
|
35
|
+
end
|
36
|
+
|
37
|
+
# Generates the URL where +target+ can be reached.
|
38
|
+
# +target+ can be an Obj, a Link or a Linklist.
|
39
|
+
# If +target+ is a Linklist, the first element of the list will be used.
|
40
|
+
#
|
41
|
+
# Example:
|
42
|
+
# This document can be found at {{ obj | url }}
|
43
|
+
def url(target)
|
44
|
+
target = first_link_if_linklist(target)
|
45
|
+
drop_cms_path(target) if target
|
46
|
+
end
|
47
|
+
|
48
|
+
# Generates an editmarker for +field_value_drop+
|
49
|
+
def editmarker(field_value_drop, visible=true)
|
50
|
+
drop = field_value_drop.dup
|
51
|
+
drop.__marker = visible
|
52
|
+
drop
|
53
|
+
end
|
54
|
+
|
55
|
+
private
|
56
|
+
|
57
|
+
def drop_cms_path(possible_drop)
|
58
|
+
action_view.cms_path(unwrap_drop(possible_drop))
|
59
|
+
end
|
60
|
+
|
61
|
+
def unwrap_drop(possible_drop)
|
62
|
+
possible_drop.respond_to?(:__drop_content) ? possible_drop.__drop_content : possible_drop
|
63
|
+
end
|
64
|
+
|
65
|
+
def action_view
|
66
|
+
@context.registers[:action_view]
|
67
|
+
end
|
68
|
+
|
69
|
+
def first_link_if_linklist(target)
|
70
|
+
return target if target.is_a?(LinkDrop) || target.is_a?(ObjDrop)
|
71
|
+
if target.respond_to?(:first)
|
72
|
+
first_element = target.first.to_liquid
|
73
|
+
return first_element if first_element.is_a?(LinkDrop)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'liquid'
|
2
|
+
|
3
|
+
# A collection of modules and classes needed to enable Liquid templates with Rails Connector
|
4
|
+
|
5
|
+
module RailsConnector::LiquidSupport
|
6
|
+
|
7
|
+
# Helpers can be made available in Liquid templates by enabling them in the
|
8
|
+
# app initialization like this:
|
9
|
+
#
|
10
|
+
# RailsConnector::LiquidSupport.enable_helpers(
|
11
|
+
# :helper_a,
|
12
|
+
# :helper_b
|
13
|
+
# )
|
14
|
+
def self.enable_helpers(*helpers)
|
15
|
+
helpers.each do |helper|
|
16
|
+
GeneralHelperTag << helper
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
# set to true if an error in a liquid template should lead to an 500 server error
|
21
|
+
mattr_accessor :raise_template_errors
|
22
|
+
|
23
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module RailsConnector
|
2
|
+
|
3
|
+
# Include this module in order to tag the string as one with Markdown content
|
4
|
+
module MarkdownString #:nodoc:
|
5
|
+
include LinkResolvable
|
6
|
+
# Returns whether the String contains Markdown (default to true, overrides String.markdown?).
|
7
|
+
def markdown?
|
8
|
+
true
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
end
|
13
|
+
|
14
|
+
class String #:nodoc:
|
15
|
+
# Returns whether the String contains Markdown (default to false).
|
16
|
+
def markdown?
|
17
|
+
false
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
module RailsConnector
|
2
|
+
#
|
3
|
+
# This module provides a mixin for the CMS object model. It provides a +ratings+ association and well as several helper methods.
|
4
|
+
module Rateable
|
5
|
+
|
6
|
+
# returns all Ratings for this Obj.
|
7
|
+
def ratings
|
8
|
+
Rating.where(:obj_id => id)
|
9
|
+
end
|
10
|
+
|
11
|
+
# Creates/updates the rating for a CMS object.
|
12
|
+
def rate(score)
|
13
|
+
rating = ratings.find_by_score(score) || ratings.build(:score => score)
|
14
|
+
rating.count += 1
|
15
|
+
rating.save
|
16
|
+
end
|
17
|
+
|
18
|
+
# Returns a count for the particular score for a CMS object.
|
19
|
+
def count_for_score(score)
|
20
|
+
rating = ratings.find_by_score(score)
|
21
|
+
rating ? rating.count : 0
|
22
|
+
end
|
23
|
+
|
24
|
+
# Determines if a CMS object has already been rated.
|
25
|
+
def rated?
|
26
|
+
!ratings.empty?
|
27
|
+
end
|
28
|
+
|
29
|
+
# Calculates the average rating for a CMS object.
|
30
|
+
def average_rating
|
31
|
+
raise TypeError unless rated?
|
32
|
+
sum, count = ratings.inject([0, 0]) do |(sum, count), rating|
|
33
|
+
[sum + rating.score * rating.count, count + rating.count]
|
34
|
+
end
|
35
|
+
sum.to_f / count.to_f
|
36
|
+
end
|
37
|
+
|
38
|
+
# Calculates the average rating for a CMS object in per cent.
|
39
|
+
def average_rating_in_percent
|
40
|
+
if rated?
|
41
|
+
(100 * average_rating / Rating::MAXIMUM).to_i
|
42
|
+
else
|
43
|
+
0
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
# Resets the ratings for a CMS object.
|
48
|
+
def reset_rating
|
49
|
+
ratings.destroy_all
|
50
|
+
end
|
51
|
+
|
52
|
+
# Redefine this method in your application's <tt>obj_extensions.rb</tt> in order to define conditions for allowing a CMS object to be rated.
|
53
|
+
def allow_rating?; true; end
|
54
|
+
# Redefine this method in your application's <tt>obj_extensions.rb</tt> in order to define conditions for allowing a CMS object to be rated anonymously.
|
55
|
+
def allow_anonymous_rating?; true; end
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
module RailsConnector
|
2
|
+
# Search Engine Optimization methods
|
3
|
+
module SEO
|
4
|
+
|
5
|
+
# The methods contained herein are attached to the Obj model class.
|
6
|
+
module ClassMethods
|
7
|
+
# Finds all objects that shall be included in the SEO <tt>sitemap.xml</tt>.
|
8
|
+
# On each exportable none-image object, <tt>included_in_seo_sitemap?</tt> is called.
|
9
|
+
# Overwrite <tt>included_in_seo_sitemap?</tt> in your +ObjExtensions+ to adjust the criteria.
|
10
|
+
def find_all_for_sitemap
|
11
|
+
start = Obj.homepage
|
12
|
+
children = start.toclist
|
13
|
+
grandchildren = children.map(&:toclist).flatten
|
14
|
+
|
15
|
+
([start] + children + grandchildren).select(&:included_in_seo_sitemap?)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
# The methods contained herein are included in the Obj model.
|
20
|
+
module InstanceMethods
|
21
|
+
|
22
|
+
# Returns +true+ by default. Overwrite in your +ObjExtensions+ as you like.
|
23
|
+
def readable_for_googlebots?
|
24
|
+
true
|
25
|
+
end
|
26
|
+
|
27
|
+
# Default implementation: objects have to be <tt>active?</tt> and at least of one of: permitted for anyone (<tt>permitted_groups = []</tt>), <tt>readable_for_googlebots?</tt>.
|
28
|
+
# Overwrite in your +ObjExtensions+ as you like.
|
29
|
+
def included_in_seo_sitemap?
|
30
|
+
(permitted_groups.empty? || readable_for_googlebots?) && active?
|
31
|
+
end
|
32
|
+
|
33
|
+
# Returns an html-stripped <tt>Obj#body</tt>, truncated to 300 chars.
|
34
|
+
# Overwrite in your +ObjExtensions+ as you like. For example, point to a CMS field.
|
35
|
+
def seo_description
|
36
|
+
HTML::FullSanitizer.new.sanitize(body.strip.gsub(%r{[\n|\r]}, " ")).mb_chars[0,300] if body
|
37
|
+
end
|
38
|
+
|
39
|
+
# Returns +nil+ by default. Overwrite in your +ObjExtensions+ as you like.
|
40
|
+
# For example, point to a CMS field of your objects.
|
41
|
+
def seo_keywords
|
42
|
+
nil
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def self.included(receiver) # :nodoc:
|
47
|
+
receiver.extend ClassMethods
|
48
|
+
receiver.send :include, InstanceMethods
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
module RailsConnector
|
2
|
+
|
3
|
+
# This module accesses the Infopark Search Engine Server.
|
4
|
+
module SES
|
5
|
+
|
6
|
+
autoload :VerityAccessor, "rails_connector/ses/verity_accessor"
|
7
|
+
|
8
|
+
# This method enables Obj to perform searches using the SES Search Engine Server.
|
9
|
+
def self.enable #:nodoc:
|
10
|
+
::Obj.extend Obj::ClassMethods
|
11
|
+
end
|
12
|
+
|
13
|
+
module Obj #:nodoc:
|
14
|
+
# Extends the model class Obj with the class method find_with_ses.
|
15
|
+
module ClassMethods
|
16
|
+
# Queries the search engine and returns a SearchResult. The parameters
|
17
|
+
# are passed on to a SearchRequest (a kind of DefaultSearchRequest by default).
|
18
|
+
#
|
19
|
+
# Exceptions:
|
20
|
+
# * SearchError - The search engine reported an error.
|
21
|
+
#
|
22
|
+
def find_with_ses(query_string, options = {})
|
23
|
+
SearchRequest.new(query_string, options).fetch_hits
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
class SearchError < StandardError # :nodoc:
|
29
|
+
end
|
30
|
+
|
31
|
+
# SearchResult is the list of hits in response to a search query. Since the
|
32
|
+
# maximum number of hits to return has been specified, there might be more
|
33
|
+
# hits available in the search engine.
|
34
|
+
class SearchResult < Array
|
35
|
+
# The total number of hits.
|
36
|
+
attr_reader :total_hits
|
37
|
+
|
38
|
+
def initialize(total_hits) # :nodoc:
|
39
|
+
super()
|
40
|
+
@total_hits = total_hits
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
# A hit represents a found document for a particular search query.
|
45
|
+
class Hit
|
46
|
+
# The ID of the found Obj.
|
47
|
+
attr_reader :id
|
48
|
+
|
49
|
+
# The score of the hit.
|
50
|
+
attr_reader :score
|
51
|
+
|
52
|
+
# The raw result hash returned by the search engine, for a low-level access.
|
53
|
+
# Don't use this unless you know what you're doing.
|
54
|
+
# Be aware that this is not migration safe.
|
55
|
+
attr_reader :doc
|
56
|
+
|
57
|
+
def initialize(id, score, doc={}) # :nodoc:
|
58
|
+
@id = id
|
59
|
+
@score = score
|
60
|
+
@doc = doc
|
61
|
+
end
|
62
|
+
|
63
|
+
# Returns the hit's corresponding Obj (or nil if none found in the database).
|
64
|
+
def obj
|
65
|
+
@obj ||= ::Obj.find(@id)
|
66
|
+
rescue RailsConnector::ResourceNotFound
|
67
|
+
nil
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module RailsConnector
|
2
|
+
|
3
|
+
# adds flavour to strings
|
4
|
+
module StringTagging #:nodoc: all
|
5
|
+
|
6
|
+
# html flavour
|
7
|
+
def self.tag_as_html(string, source)
|
8
|
+
unless string.blank?
|
9
|
+
class << string
|
10
|
+
include RailsConnector::HtmlString
|
11
|
+
end
|
12
|
+
string.source = source
|
13
|
+
end
|
14
|
+
string
|
15
|
+
end
|
16
|
+
|
17
|
+
# markdown flavour
|
18
|
+
def self.tag_as_markdown(string, source)
|
19
|
+
unless string.blank?
|
20
|
+
class << string
|
21
|
+
include RailsConnector::MarkdownString
|
22
|
+
end
|
23
|
+
string.source = source
|
24
|
+
end
|
25
|
+
string
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
module RailsConnector
|
2
|
+
# This module is included if the <tt>:rss</tt> addon is
|
3
|
+
# enabled:
|
4
|
+
# RailsConnector::Configuration.enable(:rss)
|
5
|
+
module Syndicateable
|
6
|
+
# Overwrite this method in your +ObjExtensions+ in order to display another field in your feed.
|
7
|
+
def rss_description
|
8
|
+
body
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
namespace :db do
|
2
|
+
|
3
|
+
namespace :cms do
|
4
|
+
|
5
|
+
desc "Checks if the infopark CMS object classes are valid ruby class names"
|
6
|
+
task :check_obj_classes => :environment do
|
7
|
+
all_obj_classes = Obj.select("distinct(obj_class)").collect(&:obj_class)
|
8
|
+
invalid_names = all_obj_classes.reject { |obj_class|
|
9
|
+
begin
|
10
|
+
obj_class.constantize
|
11
|
+
rescue NameError => e
|
12
|
+
e.message !~ /not a valid constant name/
|
13
|
+
end
|
14
|
+
}
|
15
|
+
if invalid_names.empty?
|
16
|
+
puts "\nAll object class names are valid Ruby class names."
|
17
|
+
else
|
18
|
+
puts "\nThe following object class names are invalid Ruby class names:"
|
19
|
+
y invalid_names
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
namespace :cms do
|
2
|
+
namespace :license do
|
3
|
+
desc "Check if a license file is valid (options: FILE=/path/to/license.xml, default: currently installed license)"
|
4
|
+
task :check => :environment do
|
5
|
+
RailsConnector::Configuration.license_file = ENV['FILE']
|
6
|
+
puts "Checking license #{RailsConnector::Configuration.license_file}"
|
7
|
+
begin
|
8
|
+
Obj.root.fetch_attr_values
|
9
|
+
puts "OK, license is valid."
|
10
|
+
exit 0
|
11
|
+
rescue RailsConnector::InvalidLicenseError => e
|
12
|
+
puts e
|
13
|
+
exit 1
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|