Handle "reset.css" and add link in the generated menu
This commit is contained in:
parent
151f005815
commit
22c9ca4c74
|
@ -102,6 +102,11 @@ class Admin::DesignsController < ApplicationController
|
||||||
temp_file = File.new(dir + '/' + filename, 'w+')
|
temp_file = File.new(dir + '/' + filename, 'w+')
|
||||||
temp_file.write (zip_file.read entry ).force_encoding('UTF-8')
|
temp_file.write (zip_file.read entry ).force_encoding('UTF-8')
|
||||||
design.default_css = temp_file
|
design.default_css = temp_file
|
||||||
|
when /\A(#{zip_name})\/(reset\.css)\z/ #for reset css
|
||||||
|
filename = File.basename(entry.to_s)
|
||||||
|
temp_file = File.new(dir + '/' + filename, 'w+')
|
||||||
|
temp_file.write (zip_file.read entry ).force_encoding('UTF-8')
|
||||||
|
design.reset_css = temp_file
|
||||||
when /\A(#{zip_name})\/(layout\.html)\z/ #for layout html
|
when /\A(#{zip_name})\/(layout\.html)\z/ #for layout html
|
||||||
filename = File.basename(entry.to_s)
|
filename = File.basename(entry.to_s)
|
||||||
temp_file = File.new(dir + '/' + filename, 'w+')
|
temp_file = File.new(dir + '/' + filename, 'w+')
|
||||||
|
|
|
@ -2,25 +2,24 @@ class Design
|
||||||
include Mongoid::Document
|
include Mongoid::Document
|
||||||
include Mongoid::Timestamps
|
include Mongoid::Timestamps
|
||||||
|
|
||||||
|
|
||||||
field :title
|
field :title
|
||||||
field :author
|
field :author
|
||||||
field :intro
|
field :intro
|
||||||
|
|
||||||
field :version
|
field :version
|
||||||
|
|
||||||
validates_presence_of :title
|
mount_uploader :default_css, AssetUploader
|
||||||
validates_presence_of :author
|
mount_uploader :reset_css, AssetUploader
|
||||||
|
|
||||||
has_many :pages
|
has_many :pages
|
||||||
|
|
||||||
embeds_one :layout
|
embeds_one :layout
|
||||||
mount_uploader :default_css, AssetUploader
|
|
||||||
|
|
||||||
embeds_many :themes
|
embeds_many :themes
|
||||||
embeds_many :javascripts
|
embeds_many :javascripts
|
||||||
embeds_many :images
|
embeds_many :images
|
||||||
|
|
||||||
|
validates_presence_of :title
|
||||||
|
validates_presence_of :author
|
||||||
|
|
||||||
after_save :procs_embedded_objects
|
after_save :procs_embedded_objects
|
||||||
# after_destroy :del_embedded_objects
|
# after_destroy :del_embedded_objects
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,6 @@ class Layout < DesignFile
|
||||||
end
|
end
|
||||||
|
|
||||||
def parse_layout
|
def parse_layout
|
||||||
debugger
|
|
||||||
parse_layout_contents(self)
|
parse_layout_contents(self)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -21,4 +21,8 @@ class Page < Item
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def is_home?
|
||||||
|
self.parent ? false : true
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -65,9 +65,10 @@ module Parser
|
||||||
end
|
end
|
||||||
c.define_tag 'stylesheets' do |tag|
|
c.define_tag 'stylesheets' do |tag|
|
||||||
res = ''
|
res = ''
|
||||||
|
res << "<link href='#{page.design.reset_css.url}' rel='stylesheet' type='text/css' />"
|
||||||
res << "<link href='#{page.design.default_css.url}' rel='stylesheet' type='text/css' /> "
|
res << "<link href='#{page.design.default_css.url}' rel='stylesheet' type='text/css' /> "
|
||||||
theme = page.design.themes.detect{ |d| d.id == page.theme_id }
|
theme = page.design.themes.detect{ |d| d.id == page.theme_id }
|
||||||
res << "<link href='#{theme.file.url}' rel='stylesheet' type='text/css' />"
|
res << "<link href='#{theme.file.url}' rel='stylesheet' type='text/css' />" if theme
|
||||||
end
|
end
|
||||||
c.define_tag 'javascripts' do |tag|
|
c.define_tag 'javascripts' do |tag|
|
||||||
res = ''
|
res = ''
|
||||||
|
@ -173,9 +174,10 @@ module Parser
|
||||||
end
|
end
|
||||||
c.define_tag 'stylesheets' do |tag|
|
c.define_tag 'stylesheets' do |tag|
|
||||||
res = ''
|
res = ''
|
||||||
|
res << "<link href='#{page.design.reset_css.url}' rel='stylesheet' type='text/css' />"
|
||||||
res << "<link href='#{page.design.default_css.url}' rel='stylesheet' type='text/css' />"
|
res << "<link href='#{page.design.default_css.url}' rel='stylesheet' type='text/css' />"
|
||||||
theme = page.design.themes.detect{ |d| d.id == page.theme_id }
|
theme = page.design.themes.detect{ |d| d.id == page.theme_id }
|
||||||
res << "<link href='#{theme.file.url}' rel='stylesheet' type='text/css' />"
|
res << "<link href='#{theme.file.url}' rel='stylesheet' type='text/css' />" if theme
|
||||||
end
|
end
|
||||||
c.define_tag 'javascripts' do |tag|
|
c.define_tag 'javascripts' do |tag|
|
||||||
res = ''
|
res = ''
|
||||||
|
@ -244,8 +246,8 @@ module Parser
|
||||||
res << menu.values["li_class_#{current}"]
|
res << menu.values["li_class_#{current}"]
|
||||||
res << "_#{i}" if i
|
res << "_#{i}" if i
|
||||||
res << ">"
|
res << ">"
|
||||||
res << page.name
|
res << "<a href='#{page.full_name}'>#{page.name}</a>"
|
||||||
res << menu_level(page, current + 1, menu) if page.children.size > 0
|
res << menu_level(page, current + 1, menu) if page.children.size > 0 && !page.is_home?
|
||||||
res << "</li>"
|
res << "</li>"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue