structure.css -> default.css
Themes are optional, a theme overrides style in default.css
This commit is contained in:
parent
f4b1d1e182
commit
151f005815
|
@ -94,28 +94,25 @@ class Admin::DesignsController < ApplicationController
|
|||
themes_entries = []
|
||||
javascripts_entries = []
|
||||
images_entries = []
|
||||
#dir/zip_name
|
||||
#dir/zip_name
|
||||
|
||||
zip_file.entries.each do |entry|
|
||||
case (path = entry.to_s)
|
||||
when /\A(#{zip_name})\/[^\/]*(\.css)\z/ #for structure css
|
||||
when /\A(#{zip_name})\/(default\.css)\z/ #for default css
|
||||
filename = File.basename(entry.to_s)
|
||||
temp_file4structure = File.new(dir + '/' + filename, 'w+')
|
||||
temp_file4structure.write (zip_file.read entry ).force_encoding('UTF-8')
|
||||
design.structure_css = temp_file4structure
|
||||
when /\A(#{zip_name})\/[^\/]*(\.html)\z/ #for layout html
|
||||
temp_file = File.new(dir + '/' + filename, 'w+')
|
||||
temp_file.write (zip_file.read entry ).force_encoding('UTF-8')
|
||||
design.default_css = temp_file
|
||||
when /\A(#{zip_name})\/(layout\.html)\z/ #for layout html
|
||||
filename = File.basename(entry.to_s)
|
||||
temp_file4layout = File.new(dir + '/' + filename, 'w+')
|
||||
temp_file4layout.write (zip_file.read entry ).force_encoding('UTF-8')
|
||||
design.layout.file = temp_file4layout
|
||||
temp_file = File.new(dir + '/' + filename, 'w+')
|
||||
temp_file.write (zip_file.read entry ).force_encoding('UTF-8')
|
||||
design.layout.file = temp_file
|
||||
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
|
||||
when /\A(#{zip_name})\/(images)\/.*((\.jpg)|(\.png)|(\.gif))\z/ #for img
|
||||
images_entries << entry
|
||||
end
|
||||
end
|
||||
|
|
|
@ -23,7 +23,6 @@ class Admin::PagesController < ApplicationController
|
|||
@item.parent_id = @parent_item.id rescue nil
|
||||
@designs = Design.all.entries
|
||||
@default_design = Design.first
|
||||
@default_theme = @default_design.themes.detect {|t| t.name.to_s == 'default' }
|
||||
end
|
||||
|
||||
def edit
|
||||
|
@ -90,7 +89,6 @@ class Admin::PagesController < ApplicationController
|
|||
def reload_themes
|
||||
@design = Design.find(params[:id])
|
||||
@themes = @design.themes
|
||||
@default_theme = @themes.detect {|t| t.name.to_s == 'default' }
|
||||
respond_to do |format|
|
||||
format.js {}
|
||||
end
|
||||
|
|
|
@ -64,10 +64,10 @@ class Admin::PurchasesController < ApplicationController
|
|||
design.layout.file = temp
|
||||
design.layout.to_save = true
|
||||
|
||||
title = design.structure_css_filename
|
||||
title = design.default_css_filename
|
||||
temp = File.new(dir + '/' + title, 'w+')
|
||||
temp.write orig_zip.read(zip_name + '/' + title)
|
||||
design.structure_css = temp
|
||||
design.default_css = temp
|
||||
|
||||
['themes', 'javascripts', 'images'].each do |type|
|
||||
design.send(type).each do |object|
|
||||
|
|
|
@ -15,7 +15,7 @@ class Design
|
|||
has_many :pages
|
||||
|
||||
embeds_one :layout
|
||||
mount_uploader :structure_css, AssetUploader
|
||||
mount_uploader :default_css, AssetUploader
|
||||
|
||||
embeds_many :themes
|
||||
embeds_many :javascripts
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
class Page < Item
|
||||
|
||||
field :content
|
||||
field :theme_id, :type => BSON::ObjectId
|
||||
field :theme_id, :type => BSON::ObjectId, :default => nil
|
||||
|
||||
belongs_to :design
|
||||
has_many :page_parts
|
||||
|
|
|
@ -26,11 +26,11 @@
|
|||
<% end %>
|
||||
</p>
|
||||
<p>
|
||||
<%= f.label "structure_css", t('admin.structure_css') %>
|
||||
<% if @design.structure_css.blank? %>
|
||||
<%= f.file_field :structure_css %>
|
||||
<%= f.label "default_css", t('admin.default_css') %>
|
||||
<% if @design.default_css.blank? %>
|
||||
<%= f.file_field :default_css %>
|
||||
<% else%>
|
||||
<%= File.basename (@design.structure_css.url) %>
|
||||
<%= File.basename (@design.default_css.url) %>
|
||||
<% end %>
|
||||
</p>
|
||||
<p>
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
<% if @design %>
|
||||
<%= f.select :theme_id, @design.themes.collect { |t| [t.name.capitalize, t.id] }%>
|
||||
<% else %>
|
||||
<%= f.select :theme_id, @default_design.themes.collect { |t| [t.name.capitalize, t.id] }, :selected => @default_theme.id %>
|
||||
<%= f.select :theme_id, @default_design.themes.collect { |t| [t.name.capitalize, t.id] }, :include_blank => true %>
|
||||
<% end %>
|
||||
</p>
|
||||
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
<option></option>
|
||||
<%= options_from_collection_for_select(@themes, :id, :name) %>
|
|
@ -1 +1 @@
|
|||
$('#page_theme_id').html("<%= escape_javascript(options_from_collection_for_select(@themes, :id, :name, @default_theme.id )) %>");
|
||||
$('#page_theme_id').html("<%= escape_javascript(render :partial => 'admin/pages/themes_ddl') %>");
|
|
@ -10,9 +10,8 @@ Package content:
|
|||
My_design.zip
|
||||
- info.json
|
||||
- layout.html
|
||||
- structure.css
|
||||
- default.css
|
||||
- themes
|
||||
- default.css
|
||||
- blue.css
|
||||
- red.css
|
||||
- javascripts
|
||||
|
|
|
@ -65,7 +65,7 @@ module Parser
|
|||
end
|
||||
c.define_tag 'stylesheets' do |tag|
|
||||
res = ''
|
||||
res << "<link href='#{page.design.structure_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 }
|
||||
res << "<link href='#{theme.file.url}' rel='stylesheet' type='text/css' />"
|
||||
end
|
||||
|
@ -173,7 +173,7 @@ module Parser
|
|||
end
|
||||
c.define_tag 'stylesheets' do |tag|
|
||||
res = ''
|
||||
res << "<link href='#{page.design.structure_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 }
|
||||
res << "<link href='#{theme.file.url}' rel='stylesheet' type='text/css' />"
|
||||
end
|
||||
|
@ -226,7 +226,7 @@ module Parser
|
|||
res << menu.values["class_#{current}"]
|
||||
res << ">"
|
||||
i = nil
|
||||
i = 1 if menu.values["li_recursive_#{current}"]
|
||||
i = 1 if menu.values["li_incremental_#{current}"]
|
||||
if current == 1 && menu.values['home'].eql?('true')
|
||||
res << menu_li(page, current, menu, i)
|
||||
i += 1 if i
|
||||
|
@ -267,7 +267,7 @@ module Parser
|
|||
layout.build_menu(:levels => 0, :values => {}) unless layout.menu
|
||||
layout.menu.levels = i = tag.attr['level'].to_i
|
||||
layout.menu.values.merge!({'home' => tag.attr['home']}) if i == 1
|
||||
layout.menu.values.merge!({"id_#{i}" => tag.attr['id'], "class_#{i}" => tag.attr['class'], "li_class_#{i}" => tag.attr['li_class'], "li_recursive_#{i}" => tag.attr['li_recursive']})
|
||||
layout.menu.values.merge!({"id_#{i}" => tag.attr['id'], "class_#{i}" => tag.attr['class'], "li_class_#{i}" => tag.attr['li_class'], "li_incremental_#{i}" => tag.attr['li_incremental']})
|
||||
layout.menu.save
|
||||
tag.expand
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue