Class: CamaleonCms::FrontendController
- Inherits:
-
CamaleonController
- Object
- ApplicationController
- CamaleonController
- CamaleonCms::FrontendController
- Includes:
- CamaleonCms::Frontend::ApplicationHelper, FrontendConcern
- Defined in:
- app/controllers/camaleon_cms/frontend_controller.rb
Overview
Camaleon CMS is a content management system
Copyright (C) 2015 by Owen Peredo Diaz
Email: [email protected]
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU Affero General Public License (GPLv3) for more details.
Direct Known Subclasses
Instance Method Summary collapse
-
#ajax ⇒ Object
ajax requests.
-
#category ⇒ Object
render category list.
-
#index ⇒ Object
home page for frontend.
-
#post ⇒ Object
render a post.
-
#post_tag ⇒ Object
render contents for the post tag.
-
#post_type ⇒ Object
render contents from post type.
-
#profile ⇒ Object
render user profile.
-
#search ⇒ Object
search contents.
Methods included from FrontendConcern
#robots, #rss, #save_comment, #sitemap
Methods inherited from CamaleonController
Methods included from EmailHelper
#cama_send_email, #send_email, #send_password_reset_email, #send_user_confirm_email
Methods included from HooksHelper
#hook_run, #hook_skip, #hooks_run
Methods included from UploaderHelper
#cama_crop_image, #cama_file_path_to_url, #cama_resize_and_crop, #cama_resize_upload, #cama_tmp_upload, #cama_uploader, #cama_uploader_generate_thumbnail, #cama_url_to_file_path, #upload_file, #uploader_verify_name
Methods included from CaptchaHelper
#cama_captcha_build, #cama_captcha_increment_attack, #cama_captcha_reset_attack, #cama_captcha_tag, #cama_captcha_tags_if_under_attack, #cama_captcha_total_attacks, #cama_captcha_under_attack?, #cama_captcha_verified?, #captcha_verify_if_under_attack
Methods included from ContentHelper
#cama_content_after_draw, #cama_content_append, #cama_content_before_draw, #cama_content_init, #cama_content_prepend
Methods included from ThemeHelper
#self_theme_key, #theme_asset_file_path, #theme_asset_path, #theme_asset_url, #theme_init, #theme_layout, #theme_view
Methods included from PluginsHelper
#current_plugin, #plugin_asset_path, #plugin_asset_url, #plugin_destroy, #plugin_install, #plugin_layout, #plugin_load_helpers, #plugin_uninstall, #plugin_upgrade, #plugin_view, #plugins_initialize, #self_plugin_key
Methods included from ShortCodeHelper
#cama_strip_shortcodes, #do_shortcode, #render_shortcode, #shortcode_add, #shortcode_change_template, #shortcode_delete, #shortcodes_init
Methods included from UserRolesHelper
Methods included from HtmlHelper
#append_asset_content, #append_pre_asset_content, #cama_assets_library_register, #cama_draw_custom_assets, #cama_draw_pre_asset_contents, #cama_get_options_html_from_items, #cama_html_helpers_init, #cama_html_tooltip, #cama_load_custom_assets, #cama_load_libraries
Methods included from SiteHelper
#cama_get_list_layouts_files, #cama_get_list_template_files, #current_locale, #current_site, #current_theme, #site_after_install, #site_install_theme, #site_uninstall_theme
Methods included from SessionHelper
#cama_authenticate, #cama_current_role, #cama_current_user, #cama_get_session_id, #cama_logout_user, #cama_on_heroku?, #cama_register_user, #cama_sign_in?, #login_user, #login_user_with_password, #session_back_to_parent, #session_switch_user
Methods included from CamaleonHelper
#cama_cache_fetch, #cama_draw_timer, #cama_edit_link, #cama_is_admin_request?, #cama_requestAction, #cama_sitemap_cats_generator, #ct
Instance Method Details
#ajax ⇒ Object
ajax requests
106 107 108 109 110 111 112 113 114 115 |
# File 'app/controllers/camaleon_cms/frontend_controller.rb', line 106 def ajax r = {render_file: nil, render_text: "", layout: (self.send :_layout) } @cama_visited_ajax = true hooks_run("on_ajax", r) if r[:render_file] render r[:render_file], layout: r[:layout] else render inline: r[:render_text] end end |
#category ⇒ Object
render category list
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'app/controllers/camaleon_cms/frontend_controller.rb', line 32 def category begin @category = current_site.the_full_categories.find(params[:category_id]).decorate @post_type = @category.the_post_type rescue return page_not_found end @cama_visited_category = @category @children = @category.children.no_empty.decorate @posts = @category.the_posts.paginate(:page => params[:page], :per_page => current_site.front_per_page).eager_load(:metas) r_file = lookup_context.template_exists?("post_types/#{@post_type.the_slug}/category_#{@category.the_slug}") ? "post_types/#{@post_type.the_slug}/category_#{@post_type.the_slug}" : nil # specific template category with specific slug within a posttype r_file = lookup_context.template_exists?("post_types/#{@post_type.the_slug}/category") ? "post_types/#{@post_type.the_slug}/category" : nil unless r_file.present? # default template category for all categories within a posttype r_file = lookup_context.template_exists?("categories/#{@category.the_slug}") ? "categories/#{@category.the_slug}" : 'category' unless r_file.present? # default template category for all categories for all posttypes layout_ = lookup_context.template_exists?("layouts/post_types/#{@post_type.the_slug}/category") ? "post_types/#{@post_type.the_slug}/category" : nil unless layout_.present? # layout for all categories within a posttype layout_ = lookup_context.template_exists?("layouts/categories/#{@category.the_slug}") ? "categories/#{@category.the_slug}" : (self.send :_layout) unless layout_.present? # layout for categories for all post types r = {category: @category, layout: layout_, render: r_file}; hooks_run("on_render_category", r) render r[:render], layout: r[:layout] end |
#index ⇒ Object
home page for frontend
20 21 22 23 24 25 26 27 28 29 |
# File 'app/controllers/camaleon_cms/frontend_controller.rb', line 20 def index @cama_visited_home = true if @_site_options[:home_page].present? render_post(@_site_options[:home_page].to_i) else r = {layout: (self.send :_layout), render: "index"} hooks_run("on_render_index", r) render r[:render], layout: r[:layout] end end |
#post ⇒ Object
render a post
118 119 120 121 122 123 124 |
# File 'app/controllers/camaleon_cms/frontend_controller.rb', line 118 def post if params[:draft_id].present? draft_render else render_post(@post || params[:slug].to_s.split("/").last, true) end end |
#post_tag ⇒ Object
render contents for the post tag
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'app/controllers/camaleon_cms/frontend_controller.rb', line 70 def post_tag begin if params[:post_tag_slug].present? @post_tag = current_site..find_by_slug(params[:post_tag_id]).decorate else @post_tag = current_site..find(params[:post_tag_id]).decorate end @post_type = @post_tag.the_post_type rescue return page_not_found end @cama_visited_tag = @post_tag @posts = @post_tag.the_posts.paginate(:page => params[:page], :per_page => current_site.front_per_page).eager_load(:metas) r_file = lookup_context.template_exists?("post_types/#{@post_type.the_slug}/post_tag_#{@post_tag.the_slug}") ? "post_types/#{@post_type.the_slug}/post_tag_#{@post_tag.the_slug}" : nil r_file = lookup_context.template_exists?("post_types/#{@post_type.the_slug}/post_tag") ? "post_types/#{@post_type.the_slug}/post_tag" : nil unless r_file.present? r_file = lookup_context.template_exists?("post_tags/#{@post_tag.the_slug}") ? "post_tags/#{@post_tag.the_slug}" : "post_tag" unless r_file.present? layout_ = lookup_context.template_exists?("layouts/post_tags/#{@post_tag.the_slug}") ? "post_tags/#{@post_tag.the_slug}" : (self.send :_layout) r = {post_tag: @post_tag, layout: layout_, render: r_file}; hooks_run("on_render_post_tag", r) render r[:render], layout: r[:layout] end |
#post_type ⇒ Object
render contents from post type
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'app/controllers/camaleon_cms/frontend_controller.rb', line 53 def post_type begin @post_type = current_site.post_types.find(params[:post_type_id]).decorate rescue return page_not_found end @cama_visited_post_type = @post_type @posts = @post_type.the_posts.paginate(:page => params[:page], :per_page => current_site.front_per_page).eager_load(:metas) @categories = @post_type.categories.no_empty.eager_load(:metas).decorate @post_tags = @post_type..eager_load(:metas) r_file = lookup_context.template_exists?("post_types/#{@post_type.the_slug}") ? "post_types/#{@post_type.the_slug}" : "post_type" layout_ = lookup_context.template_exists?("layouts/post_types/#{@post_type.the_slug}") ? "post_types/#{@post_type.the_slug}" : (self.send :_layout) r = {post_type: @post_type, layout: layout_, render: r_file}; hooks_run("on_render_post_type", r) render r[:render], layout: r[:layout] end |
#profile ⇒ Object
render user profile
127 128 129 130 131 132 133 134 135 136 137 |
# File 'app/controllers/camaleon_cms/frontend_controller.rb', line 127 def profile begin @user = current_site.users.find(params[:user_id]).decorate rescue return page_not_found end @cama_visited_profile = true layout_ = lookup_context.template_exists?("layouts/profile") ? "profile" : (self.send :_layout) r = {user: @user, layout: layout_, render: "profile"}; hooks_run("on_render_profile", r) render r[:render], layout: r[:layout] end |
#search ⇒ Object
search contents
92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'app/controllers/camaleon_cms/frontend_controller.rb', line 92 def search (ct("search")) @cama_visited_search = true @param_search = params[:q] layout_ = lookup_context.template_exists?("layouts/search") ? "search" : (self.send :_layout) r = {layout: layout_, render: "search", posts: nil}; hooks_run("on_render_search", r) params[:q] = (params[:q] || '').downcase @posts = r[:posts] != nil ? r[:posts] : current_site.the_posts.where("LOWER(title) LIKE ? OR LOWER(content_filtered) LIKE ?", "%#{params[:q]}%", "%#{params[:q]}%") @posts_size = @posts.size @posts = @posts.paginate(:page => params[:page], :per_page => current_site.front_per_page) render r[:render], layout: r[:layout] end |