Changes into page_part edition.

Can choose between 'text', 'public_r_tag' and 'widget'
This commit is contained in:
Christophe Vilayphiou committed 2012-02-16 13:09:09 +08:00
1 parent 7ea1745f73
commit e0accbecaa
25 files changed
+119 -179

No files matched your search

+5 -7
View File
@@ -18,19 +18,17 @@
<!-- example -->
<div id="header_top" class="header">
This is the first level of header
<r:adbanner name='banner_1'>
</r:adbanner>
<r:content name='content_2'>
</r:content>
</div>
<div id="header_bottom" class="header">
This is the second level of header
</div>
<div id="main_content" class="content">
<r:content name='content_1' main='true'>
</r:content>
<div class="dymanic_load" path="/panel/new_blog/widget/latest_post"></div>
<div class="dymanic_load" path="/panel/new_blog/widget/"></div>
<div class="dymanic_load" path="/panel/announcement/widget/"></div>
<r:content name='content_1' main='true'/>
<r:content name='content_3'/>
<r:content name='content_4'/>
</div>
<div id="footer" class="footer">
+32 -31
View File
@@ -31,12 +31,6 @@ module ParserBackEnd
end
}.join(' | ')
end
c.define_tag 'multi_lang' do |tag|
tag.expand
end
c.define_tag 'multi_lang:lang' do |tag|
tag.expand if tag.attr['name'].eql?(I18n.locale.to_s)
end
c.define_tag 'css' do |tag|
assets = Asset.any_in(:filename => tag.attr['name'].split(',').map(&:strip))
res = ''
@@ -75,26 +69,24 @@ module ParserBackEnd
end
res
end
c.define_tag 'adbanner' do |tag|
c.define_tag 'ad_banner' do |tag|
res = ''
ad_banner = AdBanner.first(conditions:{title: tag.attr["name"]})
res << "<script type='text/javascript'>
$(document).ready(function(){ $('#slideshow-#{ad_banner.title}').cycle({after: onAfter,timeout:1 ,fx: '#{ad_banner.ad_fx.nil?? 'fade': ad_banner.ad_fx}' }); });
</script>"
res << "<div id='#{tag.attr['name']}' ad_banner_id='#{ad_banner.id}' class='editable' style='border:solid 1px; margin:5px; padding:5px;'>"
res << "<div class='edit_link' style='display:none'>"
res << " <a href='#{edit_admin_ad_banner_path(ad_banner.id)}' class='nav'>#{t(:edit)}</a>"
res << '</div>'
#==================================
res << "<div id='slideshow-#{ad_banner.title}'>"
ad_banner.ad_images.each do |ad_image|
res << "<img src='#{ad_image.file}' />"
ad_banner = AdBanner.find(tag.attr["id"]) rescue nil
if ad_banner
res << "<script type='text/javascript'>
$(document).ready(function(){ $('#slideshow-#{ad_banner.title.dehumanize}').cycle({after: onAfter,timeout:1 ,fx: '#{ad_banner.ad_fx.nil?? 'fade': ad_banner.ad_fx}' }); });
</script>"
res << "<div id='slideshow-#{ad_banner.title.dehumanize}'>"
ad_banner.ad_images.each do |ad_image|
res << "<img src='#{ad_image.file}' "
res << "alt='#{ad_image.picture_intro || ' '}' "
res << "time_to_next='#{ad_image.get_delay_time}' "
res << "link_open='#{ad_image.link_open}' "
res << "link_url='#{(ad_banner.direct_to_after_click?? ad_image.out_link : ad_banner.context) || ' '}' "
res << "/>"
end
res << "</div>"
#==================================
res << "</div>"
res << "</div>"
end
end
c.define_tag 'layout_part' do |tag|
part = page.page_parts.detect{ |p| p.name.to_s == tag.attr['name'].to_s }
@@ -108,13 +100,22 @@ module ParserBackEnd
if (tag.attributes["main"] == "true" && !page.module_app.nil?)
ret << "<div id='appfrontend' class='dymanic_load' path='/panel/#{page.module_app.key}/front_end/#{page.app_frontend_url}?inner=true'></div>"
else
part = page.page_parts.detect{ |p| p.name.to_s == tag.attr['name'].to_s }
ret << "<div id='#{tag.attr['name']}' part_id='#{part.id}' class='editable' style='border:solid 1px; margin:5px; padding:5px;'>"
ret << "<div class='edit_link' style='display:none'>"
ret << " <a href='#{edit_admin_page_part_path(part.id)}' class='nav'>#{t(:edit)}</a>"
ret << '</div>'
ret << part.i18n_variable[I18n.locale.to_s] rescue ''
ret << '</div>'
part = page.page_parts.detect{ |p| p.name.to_s == tag.attr['name'].to_s }
ret << "<div id='#{tag.attr['name']}' part_id='#{part.id}' class='editable' style='border:solid 1px; margin:5px; padding:5px;'>"
ret << "<div class='edit_link' style='display:none'>"
ret << " <a href='#{edit_admin_page_part_path(part.id)}' class='nav'>#{t(:edit)}</a>"
ret << '</div>'
case part.kind
when 'text'
ret << part.i18n_variable[I18n.locale] rescue ''
when 'module_widget'
ret << "<div class='dymanic_load' path='/panel/#{part.module_app.key}/widget/#{part.widget_path}'></div>"
when 'public_r_tag'
ret << "<r:#{part.public_r_tag} id='#{part.public_r_tag_object_id}'/>"
else
''
end
ret << '</div>'
end
end
c.define_tag 'link' do |tag|
+15 -13
View File
@@ -51,12 +51,6 @@ module ParserFrontEnd
var.destroy
end
end
c.define_tag 'multi_lang' do |tag|
tag.expand
end
c.define_tag 'multi_lang:lang' do |tag|
tag.expand if tag.attr['name'].eql?(I18n.locale.to_s)
end
c.define_tag 'css' do |tag|
assets = Asset.any_in(:filename => tag.attr['name'].split(',').map(&:strip))
res = ''
@@ -83,15 +77,14 @@ module ParserFrontEnd
end
res
end
c.define_tag 'adbanner' do |tag|
c.define_tag 'ad_banner' do |tag|
res = ''
ad_banner = AdBanner.first(conditions:{title: tag.attr["name"]})
if ad_banner.display?
ad_banner = AdBanner.find(tag.attr["id"]) rescue nil
if ad_banner && ad_banner.display?
res << "<script type='text/javascript'>
$(document).ready(function(){ $('#slideshow-#{ad_banner.title}').cycle({after: onAfter,timeout:1 ,fx: '#{ad_banner.ad_fx.nil?? 'fade': ad_banner.ad_fx}' }); });
$(document).ready(function(){ $('#slideshow-#{ad_banner.title.dehumanize}').cycle({after: onAfter,timeout:1 ,fx: '#{ad_banner.ad_fx.nil?? 'fade': ad_banner.ad_fx}' }); });
</script>"
res << "<div id='slideshow-#{ad_banner.title}'>"
res << "<div id='slideshow-#{ad_banner.title.dehumanize}'>"
ad_banner.ad_images.each do |ad_image|
res << "<img src='#{ad_image.file}' "
res << "alt='#{ad_image.picture_intro || ' '}' "
@@ -128,7 +121,16 @@ module ParserFrontEnd
ret << "?inner=true'></div>"
else
part = page.page_parts.detect{ |p| p.name.to_s == tag.attr['name'].to_s } rescue nil
ret << part.content rescue nil
case part.kind
when 'text'
ret << part.i18n_variable[I18n.locale] rescue ''
when 'module_widget'
ret << "<div class='dymanic_load' path='/panel/#{part.module_app.key}/widget/#{part.widget_path}?inner=true'></div>"
when 'public_r_tag'
ret << "<r:#{part.public_r_tag} id='#{part.public_r_tag_object_id}'/>"
else
''
end
end
ret
end
+1 -1
View File
@@ -15,7 +15,7 @@ module ParserLayout
end
c.define_tag 'stylesheets' do |tag|
end
c.define_tag 'adbanner' do |tag|
c.define_tag 'ad_banner' do |tag|
end
c.define_tag 'menu' do |tag|
layout.build_menu(:levels => 0, :values => {}) unless layout.menu
+5 -2
View File
@@ -103,8 +103,11 @@ namespace :dev do
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 )
home = Page.create!( :i18n_variable => var_10, :design_id => design_1.id, :name => 'home', :is_published => true, :theme_id => theme.id )
home.page_parts.create!( :name => 'content_1', :content => nil, :kind => nil )
home.page_parts.create!( :name => 'content_2', :content => nil, :kind => nil )
home.page_parts.create!( :name => 'content_3', :content => nil, :kind => 'text', :i18n_variable => var_13 )
home.page_parts.create!( :name => 'content_4', :content => nil, :kind => 'text', :i18n_variable => nil )
ModuleApp.new.from_json(File.open("#{Rails.root}/vendor/built_in_modules/new_blog/new_blog.json").read).save
ModuleApp.new.from_json(File.open("#{Rails.root}/vendor/built_in_modules/announcement/announcement.json").read).save
Post.create(:title=>"1st post",:body=>"Long long time ago.....")
+2 -8
View File
@@ -1,8 +1,2 @@
<r:multi_lang>
<r:lang name='en'>
<p>This is the homepage</p>
</r:lang>
<r:lang name='zh_tw'>
<p>t這是首頁</p>
</r:lang>
</r:multi_lang>
<r:ad_banner name='banner_1'>
</r:ad_banner>