back_end widget breadcrumb finish

This commit is contained in:
Rueshyna 2013-01-31 19:20:55 +08:00 committed by chris
parent 0b88f7d1f8
commit 2a61470f8b
10 changed files with 69 additions and 1048 deletions

View File

@ -76,8 +76,8 @@ group :test, :development do
gem 'pry-remote'
gem 'pry-stack_explorer'
gem 'pry-debugger'
gem 'debugger'
gem 'faker'
gem "sunspot-rails-tester"
gem 'database_cleaner' #Strategies for cleaning databases. Can be used to ensure a clean state for testing.
gem "rspec", "~> 2.0"
@ -93,4 +93,3 @@ group :test, :development do
# gem "bluecloth"
end
gem 'debugger'

View File

@ -2,6 +2,11 @@ class FrontController < ApplicationController
layout false
def show_breadcrumb
@ancestors = Page.find(params[:menu_page_id]).ancestors_and_self.map{|m|m.title_translations[locale]}.delete_at(0) rescue []
@ancestors.delete_at(0)
end
def show_banner
@ad_banner = AdBanner.find(params[:id]) rescue nil
end

View File

@ -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?('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) %>
<% end %>

View File

@ -0,0 +1,11 @@
<% if not @ancestors.empty? %>
<div class='category_list'>
<ul class='list'>
<%= @ancestors.each do |node| %>
<li class='active'>
<%= link_to node.title, (node.class.to_s.eql?('Page') ? '/' + node.path : node.url) %>
</li>
<% end %>
</ul>
</div>
<% end %>

View File

@ -42,6 +42,7 @@ public_r_tags:
- ad_banner
- sub_menu
- sitemap
- breadcrumb
page_part_kinds:
- text

View File

@ -255,7 +255,7 @@ Orbit::Application.routes.draw do
end
end
controller_paths :front, %w[show_banner show_footer show_menu show_page_sub_menu show_site_sub_menu show_sitemap]
controller_paths :front, %w[show_breadcrumb show_banner show_footer show_menu show_page_sub_menu show_site_sub_menu show_sitemap]
# controller_paths :mobile, %w[index announcement announcement_content dialog_contact dialog_copyright dialog_language map page page_content]
# scope 'app' do

View File

@ -30,6 +30,7 @@ module ParserBackEnd
parse_images_edit(body, page)
parse_footer_edit(body, page)
parse_sub_menu_edit(body, page)
parse_breadcrumb_edit(body, page)
parse_counter_edit(body)
public_r_tags.each do |tag|
send("parse_#{tag}s_edit", body, page, true)

View File

@ -144,6 +144,31 @@ module ParserCommon
end
end
# breadcrumb
def parse_breadcrumbs_edit(body = nil, page = nil, edit=nil)
body.css('breadcrumb').each do |breadcrumb|
ancestors = Page.find(page.id).ancestors_and_self.map{|m|m.title} rescue nil
ancestors.delete_at(0)
res = ''
if ancestors
res << "<div class='category_list'>"
res << "<ul class='list'>"
ancestors.each do |node|
res << "<li class='active'>"
# root = "/"
# res << "<a href='#{edit ? root + admin_page_path(child.id) : (child.class.to_s.eql?('Page') ? root + child.path : child.url)}'>#{child.title}</a>"
res << "<a herf ='/' + node.path )}>#{node}</a>"
res << "</li>"
end
res << "</ul>"
res << "</div>"
end
fragment = Nokogiri::HTML::DocumentFragment.new(body, res)
breadcrumb.swap(fragment)
end
end
# page_footer
def parse_footer_edit(body, page)
page_footer = body.css('.page_footer').first
@ -172,6 +197,18 @@ module ParserCommon
end
end
def parse_breadcrumb_edit(body, page)
page_breadcrumb = body.css('.page_breadcrumb').first
if page_breadcrumb
res = "<div id='#{page_breadcrumb['id']}', class='#{page_breadcrumb['class']}'>"
res << @site.breadcrumb rescue nil
res << "</div>"
fragment = Nokogiri::HTML::DocumentFragment.new(body ,res)
page_breadcrumb.swap(fragment) rescue nil
else
''
end
end
# sitemap
def parse_sitemaps_edit(body = nil, page = nil, edit=nil)
sitemap = body.css('sitemap').first

View File

@ -179,4 +179,8 @@ module ParserFrontEnd
"<div class='dymanic_load' path='#{front_show_page_sub_menu_path({:menu_page_id => args[0], :page_id => args[1]})}'></div>"
end
# breadcrumb
def generate_breadcrumbs(*args)
"<div class='dymanic_load' path='#{front_show_breadcrumb_path({:menu_page_id => args[0], :page_id => args[1]})}'></div>"
end
end

1038
route

File diff suppressed because one or more lines are too long