Module: Gluttonberg::Public
- Includes:
- Assets, CmsStylesheets, HtmlTruncate, MetaTags, NavTree, PageInfo
- Included in:
- Admin::Membership::MembersController, ApplicationHelper
- Defined in:
- app/helpers/gluttonberg/public.rb,
app/helpers/gluttonberg/public/assets.rb,
app/helpers/gluttonberg/public/nav_tree.rb,
app/helpers/gluttonberg/public/meta_tags.rb,
app/helpers/gluttonberg/public/page_info.rb,
app/helpers/gluttonberg/public/html_truncate.rb,
app/helpers/gluttonberg/public/cms_stylesheets.rb,
app/controllers/gluttonberg/public/base_controller.rb,
app/controllers/gluttonberg/public/flag_controller.rb,
app/controllers/gluttonberg/public/pages_controller.rb,
app/controllers/gluttonberg/public/members_controller.rb,
app/controllers/gluttonberg/public/public_assets_controller.rb,
app/controllers/gluttonberg/public/member_sessions_controller.rb,
app/controllers/gluttonberg/public/member_password_resets_controller.rb
Overview
This Class is intended to be used to integrate an arbitrary controller into the Gluttonberg front end. It provides access to the locale/dialect processing, templating, page collections for generating navigations and injects a bunch of other useful helpers.
Defined Under Namespace
Modules: Assets, CmsStylesheets, HtmlTruncate, MetaTags, NavTree, PageInfo Classes: BaseController, FlagController, MemberPasswordResetsController, MemberSessionsController, MembersController, PagesController, PublicAssetsController
Instance Method Summary collapse
- #clean_public_query(string) ⇒ Object
- #clean_public_query_for_sphinx(string) ⇒ Object
- #embed_shortcode(embed_obj) ⇒ Object
-
#google_analytics_js_tag ⇒ Object
Returns the code for google analytics.
- #link_to_inappropriate(obj) ⇒ Object
- #render_match_partial(result) ⇒ Object
-
#shortcode_safe(str) ⇒ Object
process shortcodes and returns processed string with all shortcode replaced to actual content.
Methods included from Assets
Methods included from HtmlTruncate
Methods included from CmsStylesheets
#cms_managed_stylesheets_link_tag
Methods included from NavTree
#build_page, #children_active?, #find_children, #navigation_tree, #page_url
Methods included from MetaTags
#description_meta_tag, #keywords_meta_tag
Methods included from PageInfo
#body_class, #og_image, #og_site_name, #og_title, #og_type, #page_description, #page_keywords, #page_title
Instance Method Details
#clean_public_query(string) ⇒ Object
51 52 53 54 55 56 57 58 59 |
# File 'app/helpers/gluttonberg/public.rb', line 51 def clean_public_query(string) unless string.blank? string = string.gsub("'", "\\\\'") string = string.gsub("\"", "\\\"") string = string.gsub(/\${2,}/, "$") else string end end |
#clean_public_query_for_sphinx(string) ⇒ Object
61 62 63 64 65 66 67 68 69 70 |
# File 'app/helpers/gluttonberg/public.rb', line 61 def clean_public_query_for_sphinx(string) unless string.blank? string = clean_public_query(string) string = string.gsub("$", "") string = string.gsub(/[\!\*'"″′‟‘’‛„‚”“”˝\\\(\)\;\:\.\@\&\=\+\-\$\,\/?\%\#\[\]]/,'') string else string end end |
#embed_shortcode(embed_obj) ⇒ Object
97 98 99 100 101 |
# File 'app/helpers/gluttonberg/public.rb', line 97 def () unless .blank? || .body.blank? .body.html_safe end end |
#google_analytics_js_tag ⇒ Object
Returns the code for google analytics
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'app/helpers/gluttonberg/public.rb', line 14 def google_analytics_js_tag code = Gluttonberg::Setting.get_setting("google_analytics", current_site_config_name) unless code.blank? javascript_tag do %{ var _gaq = _gaq || []; _gaq.push(['_setAccount', '#{code}']); _gaq.push(['_trackPageview']); (function() { var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); })(); }.html_safe end end end |
#link_to_inappropriate(obj) ⇒ Object
43 44 45 46 47 48 49 |
# File 'app/helpers/gluttonberg/public.rb', line 43 def link_to_inappropriate(obj) if current_user and current_user.flagged?(obj) content_tag(:p, "You have already flagged this item.") else link_to "Inappropriate" , mark_as_flag_path(obj.class.name , obj.id) end end |
#render_match_partial(result) ⇒ Object
32 33 34 35 36 37 38 39 40 41 |
# File 'app/helpers/gluttonberg/public.rb', line 32 def render_match_partial(result) begin klass = result.class.name.demodulize.underscore render :partial => "search/#{klass}", :locals => { :result => result } rescue ActionView::MissingTemplate => e "Missing search template for model #{klass}. Create a search/_#{klass}.html.erb partial in the correct plugin and try again." rescue RuntimeError => e "Unable to find the class name of the following match #{debug result}" end end |
#shortcode_safe(str) ⇒ Object
process shortcodes and returns processed string with all shortcode replaced to actual content
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'app/helpers/gluttonberg/public.rb', line 73 def shortcode_safe(str) unless str.blank? || str.nil? temp_string = str temp_string = temp_string.gsub(/\[(\w|\s|-|_)*\]/) do |match| shortcode = match.gsub("[","").gsub("]","") shortcode_tokens = shortcode.split(" ") shortcode_method = "#{shortcode_tokens.first}_shortcode" shortcode_args = shortcode_tokens.length > 1 ? shortcode_tokens[1..-1] : [] = Gluttonberg::Embed.where(:shortcode => shortcode_tokens.first).first if !.blank? () elsif respond_to?(shortcode_method) send(shortcode_method, shortcode_args) else match end end temp_string.html_safe else str end end |