Merge branch 'publication'

This commit is contained in:
chris 2012-12-07 12:39:37 +08:00
commit f1c628f2d6
12 changed files with 44 additions and 6 deletions

View File

@ -18,6 +18,7 @@ class Admin::PurchasesController < ApplicationController
unzip_design(temp_file, zip_name) unzip_design(temp_file, zip_name)
temp_file.close temp_file.close
temp_file.unlink temp_file.unlink
redirect_to admin_designs_url
end end
def download def download

View File

@ -57,6 +57,24 @@ class Admin::SitesController < ApplicationController
end end
def change_design
design = Design.find(params[:site_id]) rescue nil
update_design(design) if design
render :nothing => true
end
protected
def update_design(design)
@site.design = design
if @site.save
theme_id = design.themes.first.id
Page.all.each do |page|
page.update_attributes({design_id: design.id, theme_id: (theme_id unless page.root?)})
end
end
end
private private
def get_site def get_site

View File

@ -10,6 +10,7 @@ class Design
mount_uploader :zip_file, AssetUploader mount_uploader :zip_file, AssetUploader
has_one :site
has_one :css_default, as: :css, :autosave => true, :dependent => :destroy has_one :css_default, as: :css, :autosave => true, :dependent => :destroy
has_one :layout, :autosave => true, :dependent => :destroy has_one :layout, :autosave => true, :dependent => :destroy
has_one :css_reset, :autosave => true, :dependent => :destroy has_one :css_reset, :autosave => true, :dependent => :destroy

View File

@ -26,6 +26,7 @@ class Site
field :footer, localize: true field :footer, localize: true
field :sub_menu, localize: true field :sub_menu, localize: true
belongs_to :design
has_many :site_metas, :autosave => true, :dependent => :destroy has_many :site_metas, :autosave => true, :dependent => :destroy
def generate_keys def generate_keys

View File

@ -9,6 +9,7 @@
</ul> </ul>
</div> </div>
</td> </td>
<td class="span1"><%= radio_button_tag 'design_default', design.id, (@site.design.id.to_s.eql?(design.id.to_s) ? true : false), :class => 'design_default', :rel => admin_sites_path %></td>
<td class="span7"><%= design.intro %></td> <td class="span7"><%= design.intro %></td>
<td class="span2"><%= design.author %></td> <td class="span2"><%= design.author %></td>
</tr> </tr>

View File

@ -2,6 +2,7 @@
<tr> <tr>
<th class="span1 strong"></th> <th class="span1 strong"></th>
<th class="span2"></th> <th class="span2"></th>
<th class="span1"></th>
<th class="span7"></th> <th class="span7"></th>
<th class="span2"></th> <th class="span2"></th>
</tr> </tr>
@ -9,4 +10,15 @@
<tbody> <tbody>
<tbody id="tbody_designs" class="sort-holder"> <tbody id="tbody_designs" class="sort-holder">
<%= render :partial => 'design', :collection => @designs %> <%= render :partial => 'design', :collection => @designs %>
</tbody> </tbody>
<% content_for :page_specific_javascript do %>
<script>
$(document).ready(function(){
$(document).on('change', '.design_default', function(){
$(this).attr('value');
$.getScript($(this).attr('rel') + '/' + $(this).val() + '/change_design');
});
});
</script>
<% end %>

View File

@ -1,4 +1,5 @@
<%= render_sort_bar(true, delete_admin_designs_path(:direction => params[:direction], :sort => params[:sort], :sort_options => params[:sort_options]), <%= render_sort_bar(true, delete_admin_designs_path(:direction => params[:direction], :sort => params[:sort], :sort_options => params[:sort_options]),
['title', 'title','span2', :title], ['title', 'title','span2', :title],
['', '', 'span1', :default],
['intro', 'intro', 'span7', :intro], ['intro', 'intro', 'span7', :intro],
['author', 'author', 'span2', :author]).html_safe %> ['author', 'author', 'span2', :author]).html_safe %>

View File

@ -25,7 +25,7 @@
<h2 class="item-name">Module Name</h2> <h2 class="item-name">Module Name</h2>
<a id="download" href="">free download</a> <a id="download" href="">free download</a>
<ul class="item-extra-info"> <ul class="item-extra-info">
<li><span class="title">downloads</span><span class="count"><%= Random.rand(20000) %></span></li> <li><span class="title">downloads</span><span class="count"><%= Random.new.rand(10..100) %></span></li>
</ul> </ul>
<h3>who use it?</h3> <h3>who use it?</h3>
<ul class="user-list"> <ul class="user-list">

View File

@ -25,8 +25,8 @@
<h2 class="item-name"><%= @template['title'] %></h2> <h2 class="item-name"><%= @template['title'] %></h2>
<%= link_to 'free download', buy_template_admin_purchase_path(@template['id']), :id => "download" %> <%= link_to 'free download', buy_template_admin_purchase_path(@template['id']), :id => "download" %>
<ul class="item-extra-info"> <ul class="item-extra-info">
<li><span class="title">views</span><span class="count">15,241</span></li> <li><span class="title">views</span><span class="count"><%= Random.new.rand(10..100) %></span></li>
<li><span class="title">color</span><span class="color-tag green"></span></li> <!-- <li><span class="title">color</span><span class="color-tag green"></span></li> -->
</ul> </ul>
</div> </div>
</div> </div>
@ -56,8 +56,8 @@
<h2 class="item-name">Template Name</h2> <h2 class="item-name">Template Name</h2>
<a id="download" href="">free download</a> <a id="download" href="">free download</a>
<ul class="item-extra-info"> <ul class="item-extra-info">
<li><span class="title">views</span><span class="count">15,241</span></li> <li><span class="title">views</span><span class="count"><%= Random.new.rand(10..100) %></span></li>
<li><span class="title">color</span><span class="color-tag green"></span></li> <!-- <li><span class="title">color</span><span class="color-tag green"></span></li> -->
</ul> </ul>
</div> </div>
</div> </div>

View File

@ -148,6 +148,7 @@ en:
web_link: Link web_link: Link
dashboard_: Dashboard dashboard_: Dashboard
deadline: Deadline deadline: Deadline
default: Default
default_css: Default CSS default_css: Default CSS
delete: delete:
file: Delete file file: Delete file

View File

@ -148,6 +148,7 @@ zh_tw:
web_link: 鏈接 web_link: 鏈接
dashboard_: 儀表版 dashboard_: 儀表版
deadline: 最後期限 deadline: 最後期限
default: Default
default_css: 預設樣式表 default_css: 預設樣式表
delete: delete:
file: 刪除檔案 file: 刪除檔案

View File

@ -128,6 +128,7 @@ Orbit::Application.routes.draw do
get 'sitemap_toggle', :on => :member get 'sitemap_toggle', :on => :member
get 'system_info' get 'system_info'
get 'ui_theme' get 'ui_theme'
get 'change_design'
end end
resources :tags resources :tags
resources :users resources :users