uploading is ok,checking parsing result is needed

This commit is contained in:
Kaito 2011-08-16 17:10:16 +08:00
parent d75dd4f936
commit d2c2e174ac
2 changed files with 35 additions and 13 deletions

View File

@ -31,27 +31,28 @@ class Admin::DesignsController < ApplicationController
themes_entries = []
javascripts_entries = []
images_entries = []
temp_file4layout = File.new(dir + '/' + zip_name+'-1', 'w+')
temp_file4layout.binmode
#dir/zip_name
temp_file4structure = File.new(dir + '/' + zip_name+'-2', 'w+')
temp_file4structure.binmode
#dir/zip_name
zip_file.entries.each do |entry|
case (path = entry.to_s)
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 )
design.structure_css = temp_file4structure
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 )
design.layout.file = temp_file4structure
design.layout.file = temp_file4layout
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
when /\A(#{zip_name})\/(javascripts)\/.*(\.js)\z/ #for js
when /\A(#{zip_name})\/(javascripts)\/.*(\.js)\z/
#for js
javascripts_entries << entry
when /\A(#{zip_name})\/(images)\/.*((\.jpg)|(\.png)|(\.gif))\z/ #for img
images_entries << entry
@ -68,7 +69,7 @@ class Admin::DesignsController < ApplicationController
build_and_store = eval("design.#{type}").build
build_and_store.file = temp_file
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
end
end

View File

@ -63,6 +63,10 @@ module Parser
end
res
end
c.define_tag 'stylesheets' do |tag|
contents = tag.expand
contents.to_html
end
c.define_tag 'image' do |tag|
asset = Asset.find(tag.attr['id'])
if asset
@ -158,6 +162,10 @@ module Parser
res << '>'
end
end
c.define_tag 'stylesheets' do |tag|
contents = tag.expand
contents.to_html
end
c.define_tag 'layout_part' do |tag|
part = page.page_parts.detect{ |p| p.name.to_s == tag.attr['name'].to_s }
ret = ''
@ -191,8 +199,13 @@ module Parser
parser.parse(layout_content)
end
def parser_context_code(page)
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 = ''
@ -216,6 +229,14 @@ module Parser
def parser_layout_layout_part(layout )
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|
data={}
data[:class_tag]=tag.attr['class'].to_s