Revert "Revert "Clean code and add 'name' in theme.rb""
This reverts commit 00813c9060.
This commit is contained in:
1 parent
00813c9060
commit
1d214bedec
16 files changed
+59
-177
No files matched your search
@@ -0,0 +1 @@
|
||||
/* Some css */
|
||||
+1
-103
@@ -105,12 +105,6 @@ module Parser
|
||||
end
|
||||
end
|
||||
|
||||
def parse_content(page_content, attributes = {})
|
||||
context = parser_context(page_content, attributes)
|
||||
parser = Radius::Parser.new(context, :tag_prefix => 'r')
|
||||
parser.parse(page_content)
|
||||
end
|
||||
|
||||
def parse_page(page)
|
||||
if page._type == 'Page'
|
||||
layout_content = page.design.layout.content
|
||||
@@ -214,33 +208,6 @@ module Parser
|
||||
end
|
||||
end
|
||||
|
||||
def parse_page_code(page)
|
||||
layout_content = page.design.layout.content
|
||||
context = parser_context_code(page)
|
||||
parser = Radius::Parser.new(context, :tag_prefix => 'r')
|
||||
parser.parse(layout_content)
|
||||
end
|
||||
|
||||
def parser_context_code(page) #context should be interpretd as the orginally one
|
||||
Radius::Context.new do |c|
|
||||
c.define_tag 'stylesheets' do |tag|
|
||||
res << "<r:layout_part>"
|
||||
res << tag.expand.to_s
|
||||
res << "</r:layout_part>"
|
||||
end
|
||||
c.define_tag 'layout_part' do |tag|
|
||||
part = page.page_parts.detect{ |p| p.name.to_s == tag.attr['name'].to_s }
|
||||
res = ''
|
||||
res << "<r:layout_part"
|
||||
tag.attr.each do |l|
|
||||
res << " #{l[0]}='#{l[1]}'"
|
||||
end
|
||||
res << ">"
|
||||
res << part.content if part
|
||||
res << "</r:layout_part>"
|
||||
end
|
||||
end
|
||||
end
|
||||
#=============
|
||||
def parse_layout_layout_part(layout)
|
||||
content = layout.content
|
||||
@@ -265,76 +232,7 @@ module Parser
|
||||
end
|
||||
end
|
||||
end
|
||||
#============
|
||||
def parse_content_update_code(page, page_content)
|
||||
context = parser_context_update_code(page, page_content)
|
||||
parser = Radius::Parser.new(context, :tag_prefix => 'r')
|
||||
parser.parse(page_content)
|
||||
end
|
||||
|
||||
def parser_context_update_code(page, page_content)
|
||||
Radius::Context.new do |c|
|
||||
c.define_tag 'layout_part' do |tag|
|
||||
@part = page.page_parts.detect{ |p| p.name.to_s == tag.attr['name'].to_s }
|
||||
tag.locals.name = tag.attr['name'].to_s
|
||||
if @part
|
||||
part_update = tag.expand
|
||||
if part_update
|
||||
if !part_update.eql?(@part.content)
|
||||
@part.content = tag.expand
|
||||
@part.save
|
||||
tag.locals.action = 'update'
|
||||
end
|
||||
else
|
||||
tag.locals.action = 'destroy'
|
||||
end
|
||||
else
|
||||
tag.locals.action = 'new'
|
||||
end
|
||||
res = ''
|
||||
res << "<r:layout_part"
|
||||
tag.attr.each do |l|
|
||||
res << " #{l[0]}='#{l[1]}'"
|
||||
end
|
||||
res << ">"
|
||||
res << tag.expand
|
||||
res << "</r:layout_part>"
|
||||
end
|
||||
c.define_tag 'multi_lang' do |tag|
|
||||
case tag.locals.action
|
||||
when 'new', 'update'
|
||||
@h = {}
|
||||
tag.expand
|
||||
@part.i18n_variable = @h
|
||||
when 'destroy'
|
||||
else
|
||||
res = ''
|
||||
res << "<r:multi_lang"
|
||||
tag.attr.each do |l|
|
||||
res << " #{l[0]}='#{l[1]}'"
|
||||
end
|
||||
res << ">"
|
||||
res << tag.expand
|
||||
res << "</r:multi_lang>"
|
||||
end
|
||||
end
|
||||
c.define_tag 'multi_lang:lang' do |tag|
|
||||
if tag.locals.action
|
||||
@h.merge!(tag.attr['name'] => "#{tag.expand}")
|
||||
else
|
||||
res = ''
|
||||
res << "<r:lang"
|
||||
tag.attr.each do |l|
|
||||
res << " #{l[0]}='#{l[1]}'"
|
||||
end
|
||||
res << ">"
|
||||
res << tag.expand
|
||||
res << "</r:lang>"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def self.included(base)
|
||||
base.send :helper_method, :parse_page if base.respond_to? :helper_method
|
||||
base.send :helper_method, :parse_page_edit if base.respond_to? :helper_method
|
||||
|
||||
+29
-7
@@ -75,25 +75,47 @@ namespace :dev do
|
||||
#
|
||||
# js = design.javascripts.build(:file => File.open("#{Rails.root}/lib/fraisier/inettuts.js"))
|
||||
#
|
||||
# theme = design.themes.build(:file => File.open("#{Rails.root}/lib/fraisier/inettuts.js.css"))
|
||||
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.save
|
||||
theme_1.save
|
||||
# image.save
|
||||
# js.save
|
||||
|
||||
design.save
|
||||
|
||||
design.layout.layout_parts.create!( :name => 'header_1')
|
||||
design.layout.layout_parts.create!( :name => 'header_2')
|
||||
design.layout.layout_parts.create!( :name => 'block_1')
|
||||
design.layout.layout_parts.create!( :name => 'footer_1')
|
||||
|
||||
|
||||
design_1 = Design.new(:title => "Bob", :author => "Me", :intro => "Moran")
|
||||
|
||||
design_1.structure_css = File.open("#{Rails.root}/lib/fraisier/structure.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.id, :name => 'home', :is_published => true )
|
||||
home.page_parts.create!( :name => 'header_1', :kind => 'text')
|
||||
home.page_parts.create!( :name => 'header_1', :content => File.open("#{Rails.root}/lib/template/home.page").read, :kind => 'text', :i18n_variable_id => var_13.id )
|
||||
|
||||
end
|
||||
|
||||
|
||||
Reference in new issue
Block a user