Sitemap done for backend and fronted

This commit is contained in:
Christophe Vilayphiou 2012-07-27 16:53:12 +08:00
parent 934b515914
commit a8cc581279
11 changed files with 54 additions and 9 deletions

View File

@ -1,8 +1,8 @@
class Admin::SitesController < ApplicationController
layout "new_admin"
before_filter :authenticate_user!
before_filter :is_admin?
before_filter :authenticate_user!, :except => [:sitemap_frontend]
before_filter :is_admin?, :except => [:sitemap_frontend]
before_filter :get_site
# def index
@ -31,6 +31,11 @@ class Admin::SitesController < ApplicationController
@items = get_homepage.children rescue []
end
def sitemap_frontend
@items = get_homepage.children.excludes(sitemap_enabled: false) rescue []
render :layout => false
end
def sitemap_toggle
@item = Item.find(params[:id])
@item.sitemap_enabled = !@item.sitemap_enabled

View File

@ -21,7 +21,7 @@ class Item
validates_associated :parent, :children
before_destroy :destroy_children
after_rearrange :rebuild_path
after_rearrange :rebuild_path, :if => "parent_id_changed?"
def self.find_by_name(item_name)

View File

@ -6,6 +6,7 @@
<% if @r_tag.eql?('sub_menu') %>
<%= 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') %>
<% else %>
<%= f.select :public_r_tag_object_id, options_from_collection_for_select(@tag_objects, :id, :title, :selected => @part.public_r_tag_object_id) %>
<% end %>

View File

@ -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.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('site_map'), admin_site_sitemap_path(@site)), :class => active_for_action('sites', 'sitemap') %>
<% end -%>
<% end -%>

View File

@ -1,13 +1,15 @@
<div class="map-block <%= 'disabled' if !sitemap_block.sitemap_enabled %>">
<h4>
<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>
<ul>
<% sitemap_block.children.each do |child| %>
<% sitemap_block.children.each_with_index do |child, i| %>
<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>
<span><%= child.i18n_variable[I18n.locale] %></span>
<%= content_tag :button, :id => child.id, :class => "onoff pull-right", :disabled => !sitemap_block.sitemap_enabled do %>
<%= child.sitemap_enabled ? t('on_upcase') : t('off_upcase') %>
<% end %>
<span><%= "#{sitemap_block_counter + 1}-#{i + 1}" %> <%= child.title %></span>
</li>
<% end if sitemap_block.children %>
</ul>

View File

@ -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>

View File

@ -10,6 +10,7 @@ markups:
public_r_tags:
- ad_banner
- sub_menu
- sitemap
page_part_kinds:
- text

View File

@ -68,6 +68,7 @@ en:
role: Role
site_info: Site Info
site_name: Site Name
sitemap: Sitemap
statistics: Statistics
title: Title
total_visitors: Total Visitors

View File

@ -66,6 +66,7 @@ zh_tw:
role: 角色
site_info: 網站資訊
site_name: 網站名稱
sitemap: 網站地圖
statistics: 統計
title: 標題
total_visitors: 造訪次數

View File

@ -117,6 +117,7 @@ Orbit::Application.routes.draw do
get 'mail_setting'
get 'site_info'
get 'sitemap'
get 'sitemap_frontend'
get 'sitemap_toggle', :on => :member
get 'system_info'
get 'ui_theme'

View File

@ -161,6 +161,15 @@ module ParserCommon
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
def parse_contents(body, page, edit=nil)
public_r_tags = []