Sitemap done for backend and fronted
This commit is contained in:
parent
934b515914
commit
a8cc581279
|
@ -1,8 +1,8 @@
|
||||||
class Admin::SitesController < ApplicationController
|
class Admin::SitesController < ApplicationController
|
||||||
|
|
||||||
layout "new_admin"
|
layout "new_admin"
|
||||||
before_filter :authenticate_user!
|
before_filter :authenticate_user!, :except => [:sitemap_frontend]
|
||||||
before_filter :is_admin?
|
before_filter :is_admin?, :except => [:sitemap_frontend]
|
||||||
before_filter :get_site
|
before_filter :get_site
|
||||||
|
|
||||||
# def index
|
# def index
|
||||||
|
@ -31,6 +31,11 @@ class Admin::SitesController < ApplicationController
|
||||||
@items = get_homepage.children rescue []
|
@items = get_homepage.children rescue []
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def sitemap_frontend
|
||||||
|
@items = get_homepage.children.excludes(sitemap_enabled: false) rescue []
|
||||||
|
render :layout => false
|
||||||
|
end
|
||||||
|
|
||||||
def sitemap_toggle
|
def sitemap_toggle
|
||||||
@item = Item.find(params[:id])
|
@item = Item.find(params[:id])
|
||||||
@item.sitemap_enabled = !@item.sitemap_enabled
|
@item.sitemap_enabled = !@item.sitemap_enabled
|
||||||
|
|
|
@ -21,7 +21,7 @@ class Item
|
||||||
validates_associated :parent, :children
|
validates_associated :parent, :children
|
||||||
|
|
||||||
before_destroy :destroy_children
|
before_destroy :destroy_children
|
||||||
after_rearrange :rebuild_path
|
after_rearrange :rebuild_path, :if => "parent_id_changed?"
|
||||||
|
|
||||||
|
|
||||||
def self.find_by_name(item_name)
|
def self.find_by_name(item_name)
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
<% if @r_tag.eql?('sub_menu') %>
|
<% if @r_tag.eql?('sub_menu') %>
|
||||||
<%= f.hidden_field :public_r_tag_object_id, :value => @part.page.id %>
|
<%= 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)) %>
|
<%#= f.select :public_r_tag_object_id, options_for_select([t(:horizontal), t(:vertical)], t(:horizontal)) %>
|
||||||
|
<% elsif @r_tag.eql?('sitemap') %>
|
||||||
<% else %>
|
<% else %>
|
||||||
<%= f.select :public_r_tag_object_id, options_from_collection_for_select(@tag_objects, :id, :title, :selected => @part.public_r_tag_object_id) %>
|
<%= f.select :public_r_tag_object_id, options_from_collection_for_select(@tag_objects, :id, :title, :selected => @part.public_r_tag_object_id) %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
<%#= content_tag :li, link_to(t('admin.site_language'), admin_site_language_path(@site)), :class => active_for_action('sites', 'language') %>
|
<%#= content_tag :li, link_to(t('admin.site_language'), admin_site_language_path(@site)), :class => active_for_action('sites', 'language') %>
|
||||||
<%= content_tag :li, link_to(t('admin.mail_setting'), admin_site_mail_setting_path(@site)), :class => active_for_action('sites', 'mail_setting') %>
|
<%= content_tag :li, link_to(t('admin.mail_setting'), admin_site_mail_setting_path(@site)), :class => active_for_action('sites', 'mail_setting') %>
|
||||||
<%#= content_tag :li, link_to(t('admin.ui_theme'), admin_site_ui_theme_path(@site)), :class => active_for_action('sites', 'ui_theme') %>
|
<%#= content_tag :li, link_to(t('admin.ui_theme'), admin_site_ui_theme_path(@site)), :class => active_for_action('sites', 'ui_theme') %>
|
||||||
|
<%= content_tag :li, link_to(t('site_map'), admin_site_sitemap_path(@site)), :class => active_for_action('sites', 'sitemap') %>
|
||||||
<% end -%>
|
<% end -%>
|
||||||
|
|
||||||
<% end -%>
|
<% end -%>
|
||||||
|
|
|
@ -1,13 +1,15 @@
|
||||||
<div class="map-block <%= 'disabled' if !sitemap_block.sitemap_enabled %>">
|
<div class="map-block <%= 'disabled' if !sitemap_block.sitemap_enabled %>">
|
||||||
<h4>
|
<h4>
|
||||||
<button id="<%= sitemap_block.id %>" class="onoff pull-right"><%= sitemap_block.sitemap_enabled ? t('on_upcase') : t('off_upcase') %></button>
|
<button id="<%= sitemap_block.id %>" class="onoff pull-right"><%= sitemap_block.sitemap_enabled ? t('on_upcase') : t('off_upcase') %></button>
|
||||||
<span><%= sitemap_block.i18n_variable[I18n.locale] %></span>
|
<span><%= sitemap_block_counter + 1 %> <%= sitemap_block.title %></span>
|
||||||
</h4>
|
</h4>
|
||||||
<ul>
|
<ul>
|
||||||
<% sitemap_block.children.each do |child| %>
|
<% sitemap_block.children.each_with_index do |child, i| %>
|
||||||
<li class="clear <%= 'disabled' if !child.sitemap_enabled %>">
|
<li class="clear <%= 'disabled' if !child.sitemap_enabled %>">
|
||||||
<button id="<%= child.id %>" class="onoff pull-right" disabled="<%= 'disabled' if !sitemap_block.sitemap_enabled %>" ><%= child.sitemap_enabled ? t('on_upcase') : t('off_upcase') %></button>
|
<%= content_tag :button, :id => child.id, :class => "onoff pull-right", :disabled => !sitemap_block.sitemap_enabled do %>
|
||||||
<span><%= child.i18n_variable[I18n.locale] %></span>
|
<%= child.sitemap_enabled ? t('on_upcase') : t('off_upcase') %>
|
||||||
|
<% end %>
|
||||||
|
<span><%= "#{sitemap_block_counter + 1}-#{i + 1}" %> <%= child.title %></span>
|
||||||
</li>
|
</li>
|
||||||
<% end if sitemap_block.children %>
|
<% end if sitemap_block.children %>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
<div class="site-map">
|
||||||
|
<% @items.each_with_index do |item, i| %>
|
||||||
|
<div class="map-block">
|
||||||
|
<h4><%= i+1 %> <%= item.title %></h4>
|
||||||
|
<ul>
|
||||||
|
<% item.children.each_with_index do |child, ii| %>
|
||||||
|
<li class="clear"><%= "#{i+1}-#{ii+1}" %> <%= child.title %></span></li>
|
||||||
|
<% end if item.children %>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<%= javascript_include_tag "lib/jquery.masonry.min.js" %>
|
||||||
|
<script>
|
||||||
|
$(document).ready(function(){
|
||||||
|
$('.site-map').masonry({
|
||||||
|
itemSelector: '.map-block',
|
||||||
|
columnWidth: 260,
|
||||||
|
isAnimated: true
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
|
@ -10,6 +10,7 @@ markups:
|
||||||
public_r_tags:
|
public_r_tags:
|
||||||
- ad_banner
|
- ad_banner
|
||||||
- sub_menu
|
- sub_menu
|
||||||
|
- sitemap
|
||||||
|
|
||||||
page_part_kinds:
|
page_part_kinds:
|
||||||
- text
|
- text
|
||||||
|
|
|
@ -68,6 +68,7 @@ en:
|
||||||
role: Role
|
role: Role
|
||||||
site_info: Site Info
|
site_info: Site Info
|
||||||
site_name: Site Name
|
site_name: Site Name
|
||||||
|
sitemap: Sitemap
|
||||||
statistics: Statistics
|
statistics: Statistics
|
||||||
title: Title
|
title: Title
|
||||||
total_visitors: Total Visitors
|
total_visitors: Total Visitors
|
||||||
|
|
|
@ -66,6 +66,7 @@ zh_tw:
|
||||||
role: 角色
|
role: 角色
|
||||||
site_info: 網站資訊
|
site_info: 網站資訊
|
||||||
site_name: 網站名稱
|
site_name: 網站名稱
|
||||||
|
sitemap: 網站地圖
|
||||||
statistics: 統計
|
statistics: 統計
|
||||||
title: 標題
|
title: 標題
|
||||||
total_visitors: 造訪次數
|
total_visitors: 造訪次數
|
||||||
|
|
|
@ -117,6 +117,7 @@ Orbit::Application.routes.draw do
|
||||||
get 'mail_setting'
|
get 'mail_setting'
|
||||||
get 'site_info'
|
get 'site_info'
|
||||||
get 'sitemap'
|
get 'sitemap'
|
||||||
|
get 'sitemap_frontend'
|
||||||
get 'sitemap_toggle', :on => :member
|
get 'sitemap_toggle', :on => :member
|
||||||
get 'system_info'
|
get 'system_info'
|
||||||
get 'ui_theme'
|
get 'ui_theme'
|
||||||
|
|
|
@ -161,6 +161,15 @@ module ParserCommon
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# sitemap
|
||||||
|
def parse_sitemaps(body = nil, page = nil, edit=nil)
|
||||||
|
sitemap = body.css('sitemap').first
|
||||||
|
url = admin_site_sitemap_frontend_path(@site)
|
||||||
|
options = "?inner=true"
|
||||||
|
fragment = Nokogiri::HTML::DocumentFragment.new(body, "<div class='dymanic_load' path='#{url + options}'></div>")
|
||||||
|
sitemap.swap(fragment)
|
||||||
|
end
|
||||||
|
|
||||||
# page_contents
|
# page_contents
|
||||||
def parse_contents(body, page, edit=nil)
|
def parse_contents(body, page, edit=nil)
|
||||||
public_r_tags = []
|
public_r_tags = []
|
||||||
|
|
Reference in New Issue