Ray's modification before redesign
This commit is contained in:
1 parent
bfd55277d7
commit
5518ae362d
21 files changed
+1000
-578
No files matched your search
@@ -107,7 +107,7 @@ module ParserBackEnd
|
||||
c.define_tag 'menu' do |tag|
|
||||
home = get_homepage
|
||||
menu = page.design.layout.menu
|
||||
menu_level(home, 1, menu, true)
|
||||
menu_level(home, 0, menu, true)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,23 +1,33 @@
|
||||
module ParserCommon
|
||||
|
||||
def menu_level(page, current, menu, edit = false)
|
||||
res = ''
|
||||
if current <= menu.levels
|
||||
res = "<ul id="
|
||||
res << menu.values["id_#{current}"]
|
||||
res << " class="
|
||||
res << menu.values["class_#{current}"]
|
||||
res << ">"
|
||||
i = nil
|
||||
i = 1 if menu.values["li_incremental_#{current}"]
|
||||
if current == 1 && menu.values['home'].eql?('true')
|
||||
res << menu_li(page, current, menu, i, edit)
|
||||
i += 1 if i
|
||||
if current != 0
|
||||
res << "<div class='rc_dm'>"
|
||||
item = rand(100000)
|
||||
res << "<a href='#{edit ? admin_page_path(page.id) : page.full_name}' class='dm_ctrl' rel='#{item}'>#{page.name}<span class='down'></span></a>"
|
||||
if page.children.size > 0
|
||||
res << "<div id='#{item}' class='dm_list #{menu.values['class_#{current}']}'>"
|
||||
res << "<ul class='ini_list'>"
|
||||
i = nil
|
||||
i = 1 if menu.values["li_incremental_#{current}"]
|
||||
page.children.each do |child|
|
||||
res << menu_li(child, current, menu, i, edit)
|
||||
i += 1 if i
|
||||
end
|
||||
res << "</ul>"
|
||||
res << "</div>"
|
||||
end
|
||||
res << "</div>"
|
||||
else
|
||||
res << '<ul>'
|
||||
res << "<li>" + "<a href='#{edit ? admin_page_path(page.id) : page.full_name}' class='dm_ctrl'>#{page.name}</a>" + "</li>"
|
||||
page.children.each do |child|
|
||||
res << "<li>" + menu_level(child, current + 1, menu, edit) + "</li>"
|
||||
end
|
||||
res << '</ul>'
|
||||
end
|
||||
page.children.each do |child|
|
||||
res << menu_li(child, current, menu, i, edit)
|
||||
i += 1 if i
|
||||
end
|
||||
res << "</ul>"
|
||||
end
|
||||
end
|
||||
|
||||
@@ -26,8 +36,11 @@ module ParserCommon
|
||||
res << menu.values["li_class_#{current}"]
|
||||
res << "_#{i}" if i
|
||||
res << ">"
|
||||
res << "<a href='#{edit ? admin_page_path(page.id) : page.full_name}'>#{page.name}</a>"
|
||||
res << menu_level(page, current + 1, menu, edit) if page.children.size > 0 && !page.is_home?
|
||||
if page.children.size > 0
|
||||
res << menu_level(page, current + 1, menu, edit)
|
||||
else
|
||||
res << "<a href='#{edit ? admin_page_path(page.id) : page.full_name}' class='nav dm_ctrl'>#{page.name}</a>"
|
||||
end
|
||||
res << "</li>"
|
||||
end
|
||||
|
||||
|
||||
@@ -104,7 +104,7 @@ module ParserFrontEnd
|
||||
ret << "<div id='appfrontend' class='dymanic_load' path='#{appfront_url.nil?? page.app_frontend_url : appfront_url}'></div>"
|
||||
else
|
||||
part = page.page_parts.detect{ |p| p.name.to_s == tag.attr['name'].to_s } rescue nil
|
||||
ret << part.content
|
||||
ret << part.content rescue nil
|
||||
end
|
||||
ret
|
||||
end
|
||||
@@ -118,7 +118,7 @@ module ParserFrontEnd
|
||||
c.define_tag 'menu' do |tag|
|
||||
home = get_homepage
|
||||
menu = page.design.layout.menu
|
||||
menu_level(home, 1, menu)
|
||||
menu_level(home, 0, menu)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
# encoding: utf-8
|
||||
|
||||
namespace :pages do
|
||||
|
||||
task :build => :environment do
|
||||
|
||||
Item.delete_all
|
||||
|
||||
|
||||
var_10 = I18nVariable.create!( :document_class => 'Home', :key => 'home', :en => 'Homepage', :zh_tw => '首頁')
|
||||
var_13 = I18nVariable.create!( :document_class => 'PagePart', :key => 'main_content', :en => 'This is the homepage', :zh_tw => '這是首頁', :parent_id => var_10.id )
|
||||
|
||||
|
||||
design = Design.new(:title => "Fraisier", :author => "Paul", :intro => "Strawberry cake")
|
||||
|
||||
design.build_default_css(:file => File.open("#{Rails.root}/lib/fraisier/default.css"))
|
||||
|
||||
# image = design.images.build(:file => File.open("#{Rails.root}/lib/fraisier/img/buttons.gif"))
|
||||
#
|
||||
# js = design.javascripts.build(:file => File.open("#{Rails.root}/lib/fraisier/inettuts.js"))
|
||||
#
|
||||
theme = design.themes.build(:file => File.open("#{Rails.root}/lib/fraisier/themes/default.css"))
|
||||
theme_1 = design.themes.build(:file => File.open("#{Rails.root}/lib/fraisier/themes/red.css"))
|
||||
|
||||
design.build_layout
|
||||
design.layout.file = File.open("#{Rails.root}/lib/fraisier/layout.html")
|
||||
|
||||
design.layout.save
|
||||
theme.save
|
||||
theme_1.save
|
||||
# image.save
|
||||
# js.save
|
||||
|
||||
design.save
|
||||
|
||||
|
||||
|
||||
design_1 = Design.new(:title => "Bob", :author => "Me", :intro => "Moran")
|
||||
|
||||
design_1.build_default_css(:file => File.open("#{Rails.root}/lib/fraisier/default.css"))
|
||||
|
||||
# image = design.images.build(:file => File.open("#{Rails.root}/lib/fraisier/img/buttons.gif"))
|
||||
#
|
||||
# js = design.javascripts.build(:file => File.open("#{Rails.root}/lib/fraisier/inettuts.js"))
|
||||
#
|
||||
theme = design_1.themes.build(:file => File.open("#{Rails.root}/lib/fraisier/themes/default.css"))
|
||||
theme_1 = design_1.themes.build(:file => File.open("#{Rails.root}/lib/fraisier/themes/red.css"))
|
||||
|
||||
design_1.build_layout
|
||||
design_1.layout.file = File.open("#{Rails.root}/lib/fraisier/layout.html")
|
||||
|
||||
design_1.layout.save
|
||||
theme.save
|
||||
theme_1.save
|
||||
# image.save
|
||||
# js.save
|
||||
|
||||
design_1.save
|
||||
|
||||
|
||||
home = Page.create!( :i18n_variable_id => var_10.id, :design_id => design_1.id, :name => 'home', :is_published => true, :theme_id => theme.id )
|
||||
home.page_parts.create!( :name => 'content_1', :content => File.open("#{Rails.root}/lib/template/home.page").read, :kind => 'text', :i18n_variable_id => var_13.id )
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
Reference in new issue
Block a user