button to see all theme assets (including hidden ones)
This commit is contained in:
parent
c444b1d58a
commit
32f8351889
@ -10,7 +10,8 @@ module Admin
|
||||
respond_to :json, :only => [:create, :update]
|
||||
|
||||
def index
|
||||
@assets = current_site.theme_assets.visible.all.order_by([[:slug, :asc]]).group_by { |a| a.folder.split('/').first.to_sym }
|
||||
@assets = current_site.theme_assets.visible(params[:all]).order_by([[:slug, :asc]])
|
||||
@assets = @assets.group_by { |a| a.folder.split('/').first.to_sym }
|
||||
@js_and_css_assets = (@assets[:javascripts] || []) + (@assets[:stylesheets] || [])
|
||||
|
||||
if request.xhr?
|
||||
|
@ -26,24 +26,19 @@ class ThemeAsset
|
||||
|
||||
## validations ##
|
||||
validates_presence_of :site, :source
|
||||
validates_presence_of :plain_text_name, :if => Proc.new { |a| puts "===> performing_plain_text? = #{a.performing_plain_text?}"; a.performing_plain_text? }
|
||||
validates_presence_of :plain_text_name, :if => Proc.new { |a| a.performing_plain_text? }
|
||||
validates_uniqueness_of :local_path, :scope => :site_id
|
||||
validates_integrity_of :source
|
||||
validate :content_type_can_not_changed
|
||||
|
||||
## named scopes ##
|
||||
scope :visible, :where => { :hidden => false }
|
||||
scope :visible, lambda { |all| all ? {} : { :where => { :hidden => false } } }
|
||||
|
||||
## accessors ##
|
||||
attr_accessor :plain_text_name, :plain_text, :performing_plain_text #, :new_file
|
||||
attr_accessor :plain_text_name, :plain_text, :performing_plain_text
|
||||
|
||||
## methods ##
|
||||
|
||||
# def source=(new_file)
|
||||
# super
|
||||
# @new_source = true
|
||||
# end
|
||||
|
||||
%w{movie image stylesheet javascript font}.each do |type|
|
||||
define_method("#{type}?") do
|
||||
self.content_type == type
|
||||
@ -68,19 +63,8 @@ class ThemeAsset
|
||||
|
||||
def plain_text
|
||||
@plain_text ||= self.source.read
|
||||
# puts "\tperforming plain text ? #{self.performing_plain_text?}"
|
||||
# if not self.performing_plain_text? #not @plain_text_changed
|
||||
# @plain_text = self.source.read #rescue nil
|
||||
# end
|
||||
# @plain_text
|
||||
end
|
||||
|
||||
# def plain_text=(source)
|
||||
# # @plain_text_changed = true
|
||||
# # self.performing_plain_text = true unless source.blank?
|
||||
# @plain_text = source
|
||||
# end
|
||||
|
||||
def performing_plain_text?
|
||||
Boolean.set(self.performing_plain_text) || false
|
||||
end
|
||||
@ -92,11 +76,6 @@ class ThemeAsset
|
||||
|
||||
sanitized_source = self.escape_shortcut_urls(data)
|
||||
|
||||
puts "================"
|
||||
puts "\tperforming plain text ? #{self.performing_plain_text?}"
|
||||
puts "\data = #{data[0..100]}"
|
||||
# puts self.source.instance_variable_get(:@original_file).inspect
|
||||
|
||||
self.source = CarrierWave::SanitizedFile.new({
|
||||
:tempfile => StringIO.new(sanitized_source),
|
||||
:filename => "#{self.plain_text_name}.#{self.stylesheet? ? 'css' : 'js'}"
|
||||
@ -126,7 +105,6 @@ class ThemeAsset
|
||||
end
|
||||
|
||||
def build_local_path
|
||||
# puts "self.source_filename = #{self.source_filename} / #{self.safe_source_filename} / #{File.join(self.folder, self.safe_source_filename)}"
|
||||
self.local_path = File.join(self.folder, self.safe_source_filename)
|
||||
end
|
||||
|
||||
|
@ -6,45 +6,13 @@ class ThemeAssetUploader < AssetUploader
|
||||
process :set_size
|
||||
process :set_width_and_height
|
||||
|
||||
# after :store, :foo
|
||||
#
|
||||
# def filename_was
|
||||
# column = model.send(:_mounter, self.mounted_as).send(:serialization_column)
|
||||
# model.send("#{column}_was")
|
||||
# end
|
||||
#
|
||||
# def filename_changed?
|
||||
# column = model.send(:_mounter, self.mounted_as).send(:serialization_column)
|
||||
# model.send("#{column}_changed?")
|
||||
# end
|
||||
|
||||
def store_dir
|
||||
File.join('sites', model.site_id.to_s, 'theme', model.folder_was || model.folder)
|
||||
end
|
||||
|
||||
# def store_dir_was
|
||||
# File.join('sites', model.site_id.to_s, 'theme', model.folder_was)
|
||||
# end
|
||||
#
|
||||
def stale_model?
|
||||
!model.new_record? && model.folder_changed?
|
||||
end
|
||||
#
|
||||
# def store_dir_was
|
||||
# File.join('sites', model.site_id.to_s, 'theme', model.folder_was) rescue nil
|
||||
# end
|
||||
#
|
||||
# def store_dir_changed?
|
||||
# self.store_dir_was && self.store_dir_was != self.store_dir
|
||||
# end
|
||||
#
|
||||
# def store_path_was(for_file=filename)
|
||||
# File.join([store_dir_was, full_filename(for_file)].compact)
|
||||
# end
|
||||
#
|
||||
# def foo
|
||||
# "store_dir_was = #{store_dir_was.inspect} / #{store_path_was}"
|
||||
# end
|
||||
|
||||
def extension_white_list
|
||||
%w(jpg jpeg gif png css js swf flv eot svg ttf woff)
|
||||
|
@ -1,4 +1,4 @@
|
||||
%li
|
||||
%li{ :class => "#{'hidden' if asset.hidden?}" }
|
||||
%em
|
||||
%strong= link_to asset.local_path, edit_admin_theme_asset_path(asset)
|
||||
.more
|
||||
|
@ -4,6 +4,7 @@
|
||||
= render 'admin/shared/menu/settings'
|
||||
|
||||
- content_for :buttons do
|
||||
= admin_button_tag t('admin.theme_assets.index.all'), all_admin_theme_assets_url, :class => 'show'
|
||||
= admin_button_tag t('admin.snippets.index.new'), new_admin_snippet_url, :class => 'new'
|
||||
= admin_button_tag :new, new_admin_theme_asset_url, :class => 'new'
|
||||
|
||||
|
@ -159,6 +159,7 @@ en:
|
||||
index:
|
||||
title: Listing theme files
|
||||
help: "The theme files section is the place where you manage the files needed by your layout, ...etc. If you need to manage an image gallery, go to the Assets section instead."
|
||||
all: all assets
|
||||
new: new file
|
||||
snippets: Snippets
|
||||
css_and_js: Style and javascript
|
||||
|
@ -159,6 +159,7 @@ fr:
|
||||
index:
|
||||
title: Liste des fichiers du thème
|
||||
help: "Les fichiers du thème sont utilisés pour construire le gabarit de vos pages. Si vous avez besoin d'une galerie d'images, la section Média est plus adéquate."
|
||||
all: tous les fichiers
|
||||
new: nouveau fichier
|
||||
snippets: Snippets
|
||||
css_and_js: Style et javascript
|
||||
|
@ -29,7 +29,9 @@ Rails.application.routes.draw do
|
||||
|
||||
resources :memberships
|
||||
|
||||
resources :theme_assets
|
||||
resources :theme_assets do
|
||||
get :all, :action => 'index', :on => :collection, :defaults => { :all => true }
|
||||
end
|
||||
|
||||
resources :asset_collections
|
||||
|
||||
|
@ -105,58 +105,6 @@ ul.list li span.handle {
|
||||
cursor: move;
|
||||
}
|
||||
|
||||
|
||||
/*ul.list li {
|
||||
height: 31px;
|
||||
margin-bottom: 10px;
|
||||
position: relative;
|
||||
clear: both;
|
||||
background: transparent url(/images/admin/list/item.png) no-repeat 0 0;
|
||||
}
|
||||
|
||||
ul.list li em {
|
||||
display: block;
|
||||
float: left;
|
||||
background: transparent url(/images/admin/list/item-left.png) no-repeat left 0;
|
||||
height: 31px;
|
||||
width: 18px;
|
||||
}
|
||||
|
||||
ul.list li strong a {
|
||||
position: relative;
|
||||
top: 2px;
|
||||
left: 15px;
|
||||
text-decoration: none;
|
||||
color: #1f82bc;
|
||||
font-size: 0.9em;
|
||||
text-shadow: 1px 1px 1px #fff;
|
||||
}
|
||||
|
||||
ul.list.sortable li strong a { left: 10px; }
|
||||
|
||||
ul.list li strong a:hover { text-decoration: underline; }
|
||||
|
||||
ul.list li div.more {
|
||||
position: absolute;
|
||||
top: 3px;
|
||||
right: 15px;
|
||||
font-size: 0.7em;
|
||||
color: #8b8d9a;
|
||||
}
|
||||
|
||||
ul.list li div.more a {
|
||||
margin-left: 10px;
|
||||
position: relative;
|
||||
top: 4px;
|
||||
}
|
||||
|
||||
ul.list li span.handle {
|
||||
position: relative;
|
||||
top: 5px;
|
||||
margin: 0 0 0 15px;
|
||||
cursor: move;
|
||||
}
|
||||
*/
|
||||
/* ___ asset collections ___ */
|
||||
|
||||
div#asset-uploader { display: inline-block; margin-left: 10px; }
|
||||
@ -167,6 +115,8 @@ div#uploadAssetsInputQueue { display: none; }
|
||||
|
||||
ul.theme-assets { margin-left: 40px; }
|
||||
|
||||
ul.theme-assets li.hidden strong a { font-style: italic; color: #8B8D9A; font-weight: normal; }
|
||||
|
||||
/* ___ contents ___ */
|
||||
|
||||
#contents-list li { background: none; }
|
||||
@ -185,21 +135,6 @@ ul.theme-assets { margin-left: 40px; }
|
||||
|
||||
/* ___ snippets ___ */
|
||||
|
||||
/*#snippets-list { margin-left: 40px; }
|
||||
|
||||
#snippets-list li { background: none; }
|
||||
|
||||
#snippets-list li em {
|
||||
background-position: left 0px;
|
||||
}
|
||||
|
||||
#snippets-list li strong {
|
||||
margin-left: 18px;
|
||||
display: block;
|
||||
height: 31px;
|
||||
background: transparent url(/images/admin/list/item-right.png) no-repeat right 0;
|
||||
}
|
||||
*/
|
||||
/* ___ pages ___ */
|
||||
|
||||
#pages-list {
|
||||
@ -289,19 +224,6 @@ ul.theme-assets { margin-left: 40px; }
|
||||
|
||||
#import-steps { margin: 0px 200px; }
|
||||
|
||||
/*#import-steps li { background: none; }
|
||||
|
||||
#import-steps li em {
|
||||
background-position: left 0px;
|
||||
}
|
||||
|
||||
#import-steps li strong {
|
||||
margin-left: 18px;
|
||||
display: block;
|
||||
height: 31px;
|
||||
background: transparent url(/images/admin/list/item-right.png) no-repeat right 0;
|
||||
}*/
|
||||
|
||||
#import-steps li strong a { color: #b7baca; }
|
||||
|
||||
#import-steps li .more .states {
|
||||
|
Loading…
Reference in New Issue
Block a user