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 = []
|
themes_entries = []
|
||||||
javascripts_entries = []
|
javascripts_entries = []
|
||||||
images_entries = []
|
images_entries = []
|
||||||
#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})\/(default\.css)\z/ #for default css
|
||||||
filename = File.basename(entry.to_s)
|
filename = File.basename(entry.to_s)
|
||||||
temp_file4structure = File.new(dir + '/' + filename, 'w+')
|
temp_file = File.new(dir + '/' + filename, 'w+')
|
||||||
temp_file4structure.write (zip_file.read entry ).force_encoding('UTF-8')
|
temp_file.write (zip_file.read entry ).force_encoding('UTF-8')
|
||||||
design.structure_css = temp_file4structure
|
design.default_css = temp_file
|
||||||
when /\A(#{zip_name})\/[^\/]*(\.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_file4layout = File.new(dir + '/' + filename, 'w+')
|
temp_file = File.new(dir + '/' + filename, 'w+')
|
||||||
temp_file4layout.write (zip_file.read entry ).force_encoding('UTF-8')
|
temp_file.write (zip_file.read entry ).force_encoding('UTF-8')
|
||||||
design.layout.file = temp_file4layout
|
design.layout.file = temp_file
|
||||||
design.layout.to_save=true
|
design.layout.to_save=true
|
||||||
when /\A(#{zip_name})\/(themes)\/.*(\.css)\z/
|
when /\A(#{zip_name})\/(themes)\/.*(\.css)\z/ #for themes css
|
||||||
#for themes css
|
|
||||||
themes_entries << entry
|
themes_entries << entry
|
||||||
when /\A(#{zip_name})\/(javascripts)\/.*(\.js)\z/
|
when /\A(#{zip_name})\/(javascripts)\/.*(\.js)\z/ #for js
|
||||||
#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
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -23,7 +23,6 @@ class Admin::PagesController < ApplicationController
|
||||||
@item.parent_id = @parent_item.id rescue nil
|
@item.parent_id = @parent_item.id rescue nil
|
||||||
@designs = Design.all.entries
|
@designs = Design.all.entries
|
||||||
@default_design = Design.first
|
@default_design = Design.first
|
||||||
@default_theme = @default_design.themes.detect {|t| t.name.to_s == 'default' }
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def edit
|
def edit
|
||||||
|
@ -90,7 +89,6 @@ class Admin::PagesController < ApplicationController
|
||||||
def reload_themes
|
def reload_themes
|
||||||
@design = Design.find(params[:id])
|
@design = Design.find(params[:id])
|
||||||
@themes = @design.themes
|
@themes = @design.themes
|
||||||
@default_theme = @themes.detect {|t| t.name.to_s == 'default' }
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.js {}
|
format.js {}
|
||||||
end
|
end
|
||||||
|
|
|
@ -64,10 +64,10 @@ class Admin::PurchasesController < ApplicationController
|
||||||
design.layout.file = temp
|
design.layout.file = temp
|
||||||
design.layout.to_save = true
|
design.layout.to_save = true
|
||||||
|
|
||||||
title = design.structure_css_filename
|
title = design.default_css_filename
|
||||||
temp = File.new(dir + '/' + title, 'w+')
|
temp = File.new(dir + '/' + title, 'w+')
|
||||||
temp.write orig_zip.read(zip_name + '/' + title)
|
temp.write orig_zip.read(zip_name + '/' + title)
|
||||||
design.structure_css = temp
|
design.default_css = temp
|
||||||
|
|
||||||
['themes', 'javascripts', 'images'].each do |type|
|
['themes', 'javascripts', 'images'].each do |type|
|
||||||
design.send(type).each do |object|
|
design.send(type).each do |object|
|
||||||
|
|
|
@ -15,7 +15,7 @@ class Design
|
||||||
has_many :pages
|
has_many :pages
|
||||||
|
|
||||||
embeds_one :layout
|
embeds_one :layout
|
||||||
mount_uploader :structure_css, AssetUploader
|
mount_uploader :default_css, AssetUploader
|
||||||
|
|
||||||
embeds_many :themes
|
embeds_many :themes
|
||||||
embeds_many :javascripts
|
embeds_many :javascripts
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
class Page < Item
|
class Page < Item
|
||||||
|
|
||||||
field :content
|
field :content
|
||||||
field :theme_id, :type => BSON::ObjectId
|
field :theme_id, :type => BSON::ObjectId, :default => nil
|
||||||
|
|
||||||
belongs_to :design
|
belongs_to :design
|
||||||
has_many :page_parts
|
has_many :page_parts
|
||||||
|
|
|
@ -26,11 +26,11 @@
|
||||||
<% end %>
|
<% end %>
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
<%= f.label "structure_css", t('admin.structure_css') %>
|
<%= f.label "default_css", t('admin.default_css') %>
|
||||||
<% if @design.structure_css.blank? %>
|
<% if @design.default_css.blank? %>
|
||||||
<%= f.file_field :structure_css %>
|
<%= f.file_field :default_css %>
|
||||||
<% else%>
|
<% else%>
|
||||||
<%= File.basename (@design.structure_css.url) %>
|
<%= File.basename (@design.default_css.url) %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
<% if @design %>
|
<% if @design %>
|
||||||
<%= f.select :theme_id, @design.themes.collect { |t| [t.name.capitalize, t.id] }%>
|
<%= f.select :theme_id, @design.themes.collect { |t| [t.name.capitalize, t.id] }%>
|
||||||
<% else %>
|
<% 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 %>
|
<% end %>
|
||||||
</p>
|
</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
|
My_design.zip
|
||||||
- info.json
|
- info.json
|
||||||
- layout.html
|
- layout.html
|
||||||
- structure.css
|
- default.css
|
||||||
- themes
|
- themes
|
||||||
- default.css
|
|
||||||
- blue.css
|
- blue.css
|
||||||
- red.css
|
- red.css
|
||||||
- javascripts
|
- javascripts
|
||||||
|
|
|
@ -65,7 +65,7 @@ module Parser
|
||||||
end
|
end
|
||||||
c.define_tag 'stylesheets' do |tag|
|
c.define_tag 'stylesheets' do |tag|
|
||||||
res = ''
|
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 }
|
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' />"
|
||||||
end
|
end
|
||||||
|
@ -173,7 +173,7 @@ module Parser
|
||||||
end
|
end
|
||||||
c.define_tag 'stylesheets' do |tag|
|
c.define_tag 'stylesheets' do |tag|
|
||||||
res = ''
|
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 }
|
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' />"
|
||||||
end
|
end
|
||||||
|
@ -226,7 +226,7 @@ module Parser
|
||||||
res << menu.values["class_#{current}"]
|
res << menu.values["class_#{current}"]
|
||||||
res << ">"
|
res << ">"
|
||||||
i = nil
|
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')
|
if current == 1 && menu.values['home'].eql?('true')
|
||||||
res << menu_li(page, current, menu, i)
|
res << menu_li(page, current, menu, i)
|
||||||
i += 1 if i
|
i += 1 if i
|
||||||
|
@ -267,7 +267,7 @@ module Parser
|
||||||
layout.build_menu(:levels => 0, :values => {}) unless layout.menu
|
layout.build_menu(:levels => 0, :values => {}) unless layout.menu
|
||||||
layout.menu.levels = i = tag.attr['level'].to_i
|
layout.menu.levels = i = tag.attr['level'].to_i
|
||||||
layout.menu.values.merge!({'home' => tag.attr['home']}) if i == 1
|
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
|
layout.menu.save
|
||||||
tag.expand
|
tag.expand
|
||||||
end
|
end
|
||||||
|
|
Reference in New Issue