uploading is ok,checking parsing result is needed
This commit is contained in:
parent
d75dd4f936
commit
d2c2e174ac
|
@ -31,27 +31,28 @@ class Admin::DesignsController < ApplicationController
|
||||||
themes_entries = []
|
themes_entries = []
|
||||||
javascripts_entries = []
|
javascripts_entries = []
|
||||||
images_entries = []
|
images_entries = []
|
||||||
temp_file4layout = File.new(dir + '/' + zip_name+'-1', 'w+')
|
|
||||||
temp_file4layout.binmode
|
|
||||||
#dir/zip_name
|
#dir/zip_name
|
||||||
temp_file4structure = File.new(dir + '/' + zip_name+'-2', 'w+')
|
|
||||||
temp_file4structure.binmode
|
|
||||||
#dir/zip_name
|
#dir/zip_name
|
||||||
|
|
||||||
zip_file.entries.each do |entry|
|
zip_file.entries.each do |entry|
|
||||||
case (path = entry.to_s)
|
case (path = entry.to_s)
|
||||||
when /\A(#{zip_name})\/[^\/]*(\.css)\z/ #for structure css
|
when /\A(#{zip_name})\/[^\/]*(\.css)\z/ #for structure css
|
||||||
# struct_css_entry = entry
|
filename = File.basename(entry.to_s,".css")
|
||||||
|
temp_file4structure = File.new(dir + '/' + filename, 'w+')
|
||||||
|
temp_file4structure.binmode
|
||||||
temp_file4structure.write (zip_file.read entry )
|
temp_file4structure.write (zip_file.read entry )
|
||||||
design.structure_css = temp_file4structure
|
design.structure_css = temp_file4structure
|
||||||
when /\A(#{zip_name})\/[^\/]*(\.html)\z/ #for layout html
|
when /\A(#{zip_name})\/[^\/]*(\.html)\z/ #for layout html
|
||||||
# layout_entry = entry
|
filename = File.basename(entry.to_s,".css")
|
||||||
|
temp_file4layout = File.new(dir + '/' + filename, 'w+')
|
||||||
|
temp_file4layout.binmode
|
||||||
temp_file4layout.write (zip_file.read entry )
|
temp_file4layout.write (zip_file.read entry )
|
||||||
design.layout.file = temp_file4structure
|
design.layout.file = temp_file4layout
|
||||||
design.layout.to_save=true
|
design.layout.to_save=true
|
||||||
when /\A(#{zip_name})\/(themes)\/.*(\.css)\z/ #for themes css
|
when /\A(#{zip_name})\/(themes)\/.*(\.css)\z/
|
||||||
|
#for themes css
|
||||||
themes_entries << entry
|
themes_entries << entry
|
||||||
when /\A(#{zip_name})\/(javascripts)\/.*(\.js)\z/ #for js
|
when /\A(#{zip_name})\/(javascripts)\/.*(\.js)\z/
|
||||||
|
#for js
|
||||||
javascripts_entries << entry
|
javascripts_entries << entry
|
||||||
when /\A(#{zip_name})\/(images)\/.*((\.jpg)|(\.png)|(\.gif))\z/ #for img
|
when /\A(#{zip_name})\/(images)\/.*((\.jpg)|(\.png)|(\.gif))\z/ #for img
|
||||||
images_entries << entry
|
images_entries << entry
|
||||||
|
@ -68,7 +69,7 @@ class Admin::DesignsController < ApplicationController
|
||||||
build_and_store = eval("design.#{type}").build
|
build_and_store = eval("design.#{type}").build
|
||||||
build_and_store.file = temp_file
|
build_and_store.file = temp_file
|
||||||
build_and_store.file_filename = filename
|
build_and_store.file_filename = filename
|
||||||
build_and_store._type = (File.extname entry.to_s).delete '.'
|
# build_and_store._type = (File.extname entry.to_s).delete '.'
|
||||||
build_and_store.to_save = true
|
build_and_store.to_save = true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -63,6 +63,10 @@ module Parser
|
||||||
end
|
end
|
||||||
res
|
res
|
||||||
end
|
end
|
||||||
|
c.define_tag 'stylesheets' do |tag|
|
||||||
|
contents = tag.expand
|
||||||
|
contents.to_html
|
||||||
|
end
|
||||||
c.define_tag 'image' do |tag|
|
c.define_tag 'image' do |tag|
|
||||||
asset = Asset.find(tag.attr['id'])
|
asset = Asset.find(tag.attr['id'])
|
||||||
if asset
|
if asset
|
||||||
|
@ -158,6 +162,10 @@ module Parser
|
||||||
res << '>'
|
res << '>'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
c.define_tag 'stylesheets' do |tag|
|
||||||
|
contents = tag.expand
|
||||||
|
contents.to_html
|
||||||
|
end
|
||||||
c.define_tag 'layout_part' do |tag|
|
c.define_tag 'layout_part' do |tag|
|
||||||
part = page.page_parts.detect{ |p| p.name.to_s == tag.attr['name'].to_s }
|
part = page.page_parts.detect{ |p| p.name.to_s == tag.attr['name'].to_s }
|
||||||
ret = ''
|
ret = ''
|
||||||
|
@ -191,8 +199,13 @@ module Parser
|
||||||
parser.parse(layout_content)
|
parser.parse(layout_content)
|
||||||
end
|
end
|
||||||
|
|
||||||
def parser_context_code(page)
|
def parser_context_code(page) #context should be interpretd as the orginally one
|
||||||
Radius::Context.new do |c|
|
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|
|
c.define_tag 'layout_part' do |tag|
|
||||||
part = page.page_parts.detect{ |p| p.name.to_s == tag.attr['name'].to_s }
|
part = page.page_parts.detect{ |p| p.name.to_s == tag.attr['name'].to_s }
|
||||||
res = ''
|
res = ''
|
||||||
|
@ -216,6 +229,14 @@ module Parser
|
||||||
|
|
||||||
def parser_layout_layout_part(layout )
|
def parser_layout_layout_part(layout )
|
||||||
Radius::Context.new do |c|
|
Radius::Context.new do |c|
|
||||||
|
c.define_tag 'javascripts' do |tag|
|
||||||
|
contents = tag.expand
|
||||||
|
contents.to_s
|
||||||
|
end
|
||||||
|
c.define_tag 'stylesheets' do |tag|
|
||||||
|
contents = tag.expand
|
||||||
|
contents.to_s
|
||||||
|
end
|
||||||
c.define_tag 'layout_part' do |tag|
|
c.define_tag 'layout_part' do |tag|
|
||||||
data={}
|
data={}
|
||||||
data[:class_tag]=tag.attr['class'].to_s
|
data[:class_tag]=tag.attr['class'].to_s
|
||||||
|
|
Reference in New Issue