Module: CamaleonCms::FrontendConcern
- Extended by:
- ActiveSupport::Concern
- Included in:
- FrontendController
- Defined in:
- app/controllers/concerns/camaleon_cms/frontend_concern.rb
Instance Method Summary collapse
-
#robots ⇒ Object
accessing for robots.txt.
-
#rss ⇒ Object
rss for current site.
-
#save_comment ⇒ Object
save comment from a post.
-
#sitemap ⇒ Object
visiting sitemap.xml With hook “on_render_sitemap” you can skip post_types, categories, tags or posts you can change render file and layout you can add custom sitemap elements in the attr “custom”, like: github.com/owen2345/camaleon-cms/issues/106#issuecomment-146232211 you can customize your content for html or xml format.
Instance Method Details
#robots ⇒ Object
accessing for robots.txt
18 19 20 21 22 |
# File 'app/controllers/concerns/camaleon_cms/frontend_concern.rb', line 18 def robots r = { layout: false, render: 'robots' } hooks_run('on_render_robots', r) render r[:render], layout: r[:layout] end |
#rss ⇒ Object
rss for current site
25 26 27 28 29 |
# File 'app/controllers/concerns/camaleon_cms/frontend_concern.rb', line 25 def rss r = { layout: false, render: 'rss' } hooks_run('on_render_rss', r) render r[:render], layout: r[:layout], formats: [:rss] end |
#save_comment ⇒ Object
save comment from a post
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'app/controllers/concerns/camaleon_cms/frontend_concern.rb', line 32 def save_comment flash[:comment_submit] = {} @post = current_site.posts.find_by_id(params[:post_id]).decorate user = cama_current_user comment_data = {} unless @post.can_commented? flash[:comment_submit][:error] = t('.comments_not_enabled', default: 'This post can not be commented') end if user.present? comment_data[:author] = user.fullname comment_data[:author_email] = user.email elsif current_site.get_option('permit_anonimos_comment', false) user = current_site.get_anonymous_user comment_data[:is_anonymous] = true comment_data[:author] = params[:post_comment][:name] comment_data[:author_email] = params[:post_comment][:email] if current_site.is_enable_captcha_for_comments? && !cama_captcha_verified? flash[:comment_submit][:error] = t('camaleon_cms.admin.users.message.error_captcha', default: 'Invalid captcha value') end end unless flash[:comment_submit][:error] if user.present? comment_data[:user_id] = user.id comment_data[:author_url] = params[:post_comment][:url] || '' comment_data[:author_IP] = request.remote_ip.to_s comment_data[:approved] = current_site.front_comment_status comment_data[:agent] = request.user_agent.force_encoding('ISO-8859-1').encode('UTF-8') comment_data[:content] = params[:post_comment][:content] @comment = params[:post_comment][:parent_id].present? ? @post.comments.find_by_id(params[:post_comment][:parent_id]).children.new(comment_data) : @post.comments.main.new(comment_data) if @comment.save flash[:comment_submit][:notice] = t('camaleon_cms.admin.comments.message.created') else flash[:comment_submit][:error] = "#{t('camaleon_cms.common.comment_error', default: 'An error was occurred on save comment')}:<br> #{@comment.errors..join(', ')}" end else flash[:comment_submit][:error] = t('camaleon_cms.admin.message.unauthorized') end end params[:format] == 'json' ? render(json: flash.discard(:comment_submit).to_hash) : redirect_to(request.referer || @post.the_url(as_path: true)) end |
#sitemap ⇒ Object
visiting sitemap.xml With hook “on_render_sitemap” you can skip post_types, categories, tags or posts
you can change render file and layout
you can add custom sitemap elements in the attr "custom", like: https://github.com/owen2345/camaleon-cms/issues/106#issuecomment-146232211
you can customize your content for html or xml format
9 10 11 12 13 14 15 |
# File 'app/controllers/concerns/camaleon_cms/frontend_concern.rb', line 9 def sitemap r = { layout: (params[:format] == 'html' ? nil : false), render: 'sitemap', custom: {}, format: params[:format], skip_post_ids: [], skip_posttype_ids: [], skip_cat_ids: [], skip_tag_ids: [] } hooks_run('on_render_sitemap', r) @r = r render r[:render], (!r[:layout].nil? ? { layout: r[:layout] } : {}) end |