From 55fa1cef4f0f945efeb7894824508afbb0fde0d0 Mon Sep 17 00:00:00 2001 From: saurabhbhatia Date: Fri, 11 Oct 2013 13:08:22 +0000 Subject: [PATCH] Added Enable and disable terms of use, sitemap --- app/controllers/front_controller.rb | 26 ++++++++++++- app/controllers/pages_controller.rb | 3 +- app/models/site.rb | 4 +- .../admin/page_parts/_public_r_tag.html.erb | 1 + app/views/admin/sites/site_info.html.erb | 38 +++++++++++++------ app/views/admin/sites/sitemap.html.erb | 19 +++++----- app/views/front/show_terms_of_use.html.erb | 1 + config/list.yml | 1 + config/routes.rb | 2 +- lib/parsers/parser_common.rb | 10 +++++ lib/parsers/parser_front_end.rb | 5 +++ 11 files changed, 84 insertions(+), 26 deletions(-) create mode 100644 app/views/front/show_terms_of_use.html.erb diff --git a/app/controllers/front_controller.rb b/app/controllers/front_controller.rb index da608297..fa866b87 100644 --- a/app/controllers/front_controller.rb +++ b/app/controllers/front_controller.rb @@ -12,7 +12,16 @@ class FrontController < ApplicationController end def show_footer - render :text => @site.footer + @page = Page.find(:all, :conditions => {:name => /terms/i}) + @name = @page.first.name + @url = "/#{@name}" + + if @site.enable_terms_of_use + render :text => (@site.footer + "Terms of Use") + else + render :text => @site.footer + end + end def show_menu @@ -21,7 +30,15 @@ class FrontController < ApplicationController end def show_site_sub_menu - render :text => @site.sub_menu + @page = Page.find(:all, :conditions => {:name => /sitemap/i}) + @name = @page.first.name + @url = "/#{@name}" + + if @site.sitemap_menu_in_header + render :text => (@site.sub_menu + "Sitemap") + else + render :text => @site.sub_menu + end end def show_sitemap @@ -43,6 +60,11 @@ class FrontController < ApplicationController @tags = module_app.sorted_tags_for_cloud end + def show_terms_of_use + @site = Site.first rescue nil + @terms = @site.terms_of_use + end + private def menu_level(page, current_page, current, menu) diff --git a/app/controllers/pages_controller.rb b/app/controllers/pages_controller.rb index be166daf..69a011d9 100644 --- a/app/controllers/pages_controller.rb +++ b/app/controllers/pages_controller.rb @@ -9,7 +9,7 @@ class PagesController < ApplicationController if @item delayed_impressionist(@item) - render_page + render_page else redirect_to '/admin/dashboards',:notice=>t(:need_home) # render :text => t(:need_home) @@ -19,6 +19,7 @@ class PagesController < ApplicationController def show #begin @item = Item.first(:conditions => {:path => params[:page_name]}) + if @item && @item.is_published && (@item.enabled_for.nil? ? true : @item.enabled_for.include?(I18n.locale.to_s)) delayed_impressionist(@item) case @item.class.to_s diff --git a/app/models/site.rb b/app/models/site.rb index 331f3179..ccaab840 100644 --- a/app/models/site.rb +++ b/app/models/site.rb @@ -15,6 +15,8 @@ class Site field :frontend_closed, :type => Boolean, :default => false field :backend_openness_on, :type => Boolean, :default => false field :desktop_closed, :type => Boolean, :default => false + field :sitemap_menu_in_header, :type => Boolean, :default => false + field :enable_terms_of_use, :type => Boolean, :default => true field :title_always_on, :type => Boolean, :default => false field :dashbroad_allow_visitor, :type => Boolean, :default => false @@ -34,7 +36,7 @@ class Site field :title, localize: true field :footer, localize: true field :sub_menu, localize: true - field :terms_of_user, localize: true + field :terms_of_use, localize: true field :google_analytics field :default_locale diff --git a/app/views/admin/page_parts/_public_r_tag.html.erb b/app/views/admin/page_parts/_public_r_tag.html.erb index 3ceed4ca..88057f13 100644 --- a/app/views/admin/page_parts/_public_r_tag.html.erb +++ b/app/views/admin/page_parts/_public_r_tag.html.erb @@ -7,6 +7,7 @@ <%= f.hidden_field :public_r_tag_object_id, :value => @part.page.id %> <%#= f.select :public_r_tag_object_id, options_for_select([t(:horizontal), t(:vertical)], t(:horizontal)) %> <% elsif @r_tag.eql?('sitemap') %> + <% elsif @r_tag.eql?('terms_of_use') %> <% elsif @r_tag.eql?('breadcrumb') %> <% else %> <%= f.select :public_r_tag_object_id, options_from_collection_for_select(@tag_objects, :id, :title, :selected => @part.public_r_tag_object_id) %> diff --git a/app/views/admin/sites/site_info.html.erb b/app/views/admin/sites/site_info.html.erb index 7a7f1cdc..b2919cfa 100644 --- a/app/views/admin/sites/site_info.html.erb +++ b/app/views/admin/sites/site_info.html.erb @@ -47,7 +47,7 @@
-
+ <%end%> <%end%> + -
<%= f.submit t("submit"), :class => "btn btn-primary" %> diff --git a/app/views/admin/sites/sitemap.html.erb b/app/views/admin/sites/sitemap.html.erb index 7ccb84e1..4adf90e0 100644 --- a/app/views/admin/sites/sitemap.html.erb +++ b/app/views/admin/sites/sitemap.html.erb @@ -21,16 +21,17 @@
<% @site_valid_locales.each_with_index do |temp_locale, i| %> -
    +
      <%= render :partial => 'sitemap_block', :collection => @items, :locals => {:temp_locale => temp_locale} %> -
    +
<% end %>
@@ -61,18 +62,18 @@ } $.getScript('<%= admin_sites_path %>' + '/' + $(this).attr('id') + '/sitemap_toggle?temp_locale=' + $(this).attr('temp_locale')); }); - $(document).on('click', 'h4 .onoff', function () { + $(document).on('click', 'h6 .onoff', function () { $(this).parents(".map-block").toggleClass("disabled"); - if($(this).parents("h4").parents("li").attr("class").indexOf("disabled") > 0){ + if($(this).parents("h6").parents("li").attr("class").indexOf("disabled") > 0){ $(this).text("<%= t('off_upcase') %>") $(this).parents(".map-block").find('li').addClass('disabled') - $(this).parents(".map-block").find('button').text("<%= t('off_upcase') %>") - $(this).parents(".map-block").find('li button').attr('disabled', 'disabled') + $(this).parents(".map-block").find('checkbox').text("<%= t('off_upcase') %>") + // $(this).parents(".map-block").find('li checkbox').attr('disabled', 'disabled') } else { $(this).text("<%= t('on_upcase') %>") $(this).parents(".map-block").find('li').removeClass('disabled') - $(this).parents(".map-block").find('button').text("<%= t('on_upcase') %>") - $(this).parents(".map-block").find('li button').removeAttr("disabled") + $(this).parents(".map-block").find('checkbox').text("<%= t('on_upcase') %>") + // $(this).parents(".map-block").find('li checkbox').removeAttr("disabled") } $.getScript('<%= admin_sites_path %>' + '/' + $(this).attr('id') + '/sitemap_toggle?parent=true&temp_locale=' + $(this).attr('temp_locale')); }); diff --git a/app/views/front/show_terms_of_use.html.erb b/app/views/front/show_terms_of_use.html.erb new file mode 100644 index 00000000..1e8bfd27 --- /dev/null +++ b/app/views/front/show_terms_of_use.html.erb @@ -0,0 +1 @@ +<%= @terms.html_safe %> \ No newline at end of file diff --git a/config/list.yml b/config/list.yml index c49de9f4..b9722e7c 100644 --- a/config/list.yml +++ b/config/list.yml @@ -44,6 +44,7 @@ public_r_tags: - sitemap - breadcrumb - tag_cloud + - terms_of_use page_part_kinds: - text diff --git a/config/routes.rb b/config/routes.rb index dce9252d..16cad4cf 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -328,7 +328,7 @@ Orbit::Application.routes.draw do end end - controller_paths :front, %w[show_breadcrumb show_banner show_footer show_menu show_page_sub_menu show_site_sub_menu show_sitemap show_tag_cloud] + controller_paths :front, %w[show_breadcrumb show_banner show_footer show_menu show_page_sub_menu show_site_sub_menu show_sitemap show_tag_cloud show_terms_of_use] # controller_paths :mobile, %w[index announcement announcement_content dialog_contact dialog_copyright dialog_language map page page_content] # scope 'app' do diff --git a/lib/parsers/parser_common.rb b/lib/parsers/parser_common.rb index e8d86989..749664dc 100644 --- a/lib/parsers/parser_common.rb +++ b/lib/parsers/parser_common.rb @@ -125,6 +125,7 @@ module ParserCommon def parse_sub_menus_edit(body = nil, page = nil, edit=nil) body.css('sub_menu').each do |sub_menu| menu_page = Page.find(sub_menu['id']) rescue nil + res = '' if menu_page && menu_page.visible_children.size > 0 res << "
" @@ -245,6 +246,15 @@ module ParserCommon sitemap.swap(fragment) end + # terms_of_use + def parse_terms_of_uses_edit(body = nil, page = nil, edit=nil) + terms_of_use = body.css('terms_of_use').first + url = front_show_terms_of_use_path + options = "?inner=true" + fragment = Nokogiri::HTML::DocumentFragment.new(body, "
") + terms_of_use.swap(fragment) + end + # page_contents def parse_contents_edit(body, page, edit=nil) public_r_tags = [] diff --git a/lib/parsers/parser_front_end.rb b/lib/parsers/parser_front_end.rb index 46b5066d..f56a0c93 100644 --- a/lib/parsers/parser_front_end.rb +++ b/lib/parsers/parser_front_end.rb @@ -222,4 +222,9 @@ module ParserFrontEnd def generate_tag_clouds(*args) "
" end + + # tag_cloud + def generate_terms_of_uses(*args) + "
" + end end