diff --git a/app/controllers/admin/theme_assets_controller.rb b/app/controllers/admin/theme_assets_controller.rb index 55f2fe7f..45313c1d 100644 --- a/app/controllers/admin/theme_assets_controller.rb +++ b/app/controllers/admin/theme_assets_controller.rb @@ -13,7 +13,7 @@ module Admin before_filter :sanitize_params, :only => [:create, :update] def index - @assets = ThemeAsset.all_grouped_by_folder(current_site, params[:all]) + @assets = ThemeAsset.all_grouped_by_folder(current_site) @js_and_css_assets = (@assets[:javascripts] || []) + (@assets[:stylesheets] || []) if request.xhr? @@ -48,9 +48,6 @@ module Admin def sanitize_params params[:theme_asset] = { :source => params[:file] } if params[:file] - - # performing_plain_text = params[:theme_asset][:performing_plain_text] - # params[:theme_asset].delete(:content_type) if performing_plain_text.blank? || performing_plain_text == 'false' end end diff --git a/app/models/theme_asset.rb b/app/models/theme_asset.rb index 9548ca16..d64135b5 100644 --- a/app/models/theme_asset.rb +++ b/app/models/theme_asset.rb @@ -12,7 +12,6 @@ class ThemeAsset field :height, :type => Integer field :size, :type => Integer field :folder, :default => nil - field :hidden, :type => Boolean, :default => false mount_uploader :source, ThemeAssetUploader ## associations ## @@ -35,7 +34,6 @@ class ThemeAsset validate :content_type_can_not_changed ## named scopes ## - scope :visible, lambda { |all| all ? {} : { :where => { :hidden => false } } } ## accessors ## attr_accessor :plain_text_name, :plain_text, :plain_text_type, :performing_plain_text @@ -101,8 +99,8 @@ class ThemeAsset { :url => self.source.url }.merge(self.attributes).stringify_keys end - def self.all_grouped_by_folder(site, include_all = true) - assets = site.theme_assets.visible(include_all).order_by([[:slug, :asc]]) + def self.all_grouped_by_folder(site) + assets = site.theme_assets.order_by([[:slug, :asc]]) assets.group_by { |a| a.folder.split('/').first.to_sym } end diff --git a/app/views/admin/theme_assets/_asset.html.haml b/app/views/admin/theme_assets/_asset.html.haml index b6bee5ac..99f0e080 100644 --- a/app/views/admin/theme_assets/_asset.html.haml +++ b/app/views/admin/theme_assets/_asset.html.haml @@ -1,6 +1,6 @@ - edit = local_assigns.key?(:edit) ? edit : true -%li{ :class => "#{asset.new_record? ? 'new-asset' : 'asset'} #{'hidden' if asset.hidden?}" } +%li{ :class => (asset.new_record? ? 'new-asset' : 'asset') } %em %strong= link_to asset.local_path(!edit), edit ? edit_admin_theme_asset_path(asset) : asset.source.url, :'data-local-path' => asset.local_path .more diff --git a/app/views/admin/theme_assets/_form.html.haml b/app/views/admin/theme_assets/_form.html.haml index 53083cde..fcd9bb1e 100644 --- a/app/views/admin/theme_assets/_form.html.haml +++ b/app/views/admin/theme_assets/_form.html.haml @@ -32,6 +32,4 @@ != t('admin.theme_assets.form.choose_file') = f.foldable_inputs :name => :options do - = f.input :folder - = f.custom_input :hidden, :css => 'toggle' do - = f.check_box :hidden + = f.input :folder \ No newline at end of file diff --git a/app/views/admin/theme_assets/index.html.haml b/app/views/admin/theme_assets/index.html.haml index 4f979655..ff8deed0 100644 --- a/app/views/admin/theme_assets/index.html.haml +++ b/app/views/admin/theme_assets/index.html.haml @@ -4,7 +4,6 @@ = 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' if can?(:manage, ThemeAsset) = admin_button_tag t('admin.snippets.index.new'), new_admin_snippet_url, :class => 'new' if can?(:manage, Snippet) = admin_button_tag :new, new_admin_theme_asset_url, :class => 'new' if can?(:manage, ThemeAsset) diff --git a/config/locales/admin_ui.de.yml b/config/locales/admin_ui.de.yml index 51254f1d..cea5d3d9 100644 --- a/config/locales/admin_ui.de.yml +++ b/config/locales/admin_ui.de.yml @@ -168,7 +168,6 @@ de: index: title: Template-Dateien help: "In diesem Bereich kannst du alle Dateien organisieren, die für dein Layout verwendet werden. Wenn du eine Bilder-Galerie organisieren möchtest, dann gehe dazu in den Galerien-Abschnitt." - all: alle Dateien new: neue Datei snippets: Snippets css_and_js: Style und Javascript diff --git a/config/locales/admin_ui.en.yml b/config/locales/admin_ui.en.yml index f7803c98..dfea6d19 100644 --- a/config/locales/admin_ui.en.yml +++ b/config/locales/admin_ui.en.yml @@ -172,7 +172,6 @@ en: index: title: Listing theme files help: "The theme files section is the place where you manage the files needed by your layout, snippets...etc. If you need to manage an image gallery, create a new content type instead.
Warning: you may not see all the assets depending on your rights." - all: all assets new: new file snippets: Snippets css_and_js: Style and javascript diff --git a/config/locales/admin_ui.fr.yml b/config/locales/admin_ui.fr.yml index 6bf26378..9e654f1b 100644 --- a/config/locales/admin_ui.fr.yml +++ b/config/locales/admin_ui.fr.yml @@ -169,7 +169,6 @@ 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, créer un modèle sera plus adéquate.
Attention : Suivant les droits que vous avez, il se peut que vous ne puissiez pas voir tous les fichiers." - all: tous les fichiers new: nouveau fichier snippets: Snippets css_and_js: Style et javascript diff --git a/config/locales/admin_ui.it.yml b/config/locales/admin_ui.it.yml index 86eb2d51..eedb8252 100644 --- a/config/locales/admin_ui.it.yml +++ b/config/locales/admin_ui.it.yml @@ -166,7 +166,6 @@ it: index: title: Lista file del tema help: "La sezione di file del tema è il luogo in cui si amministrano i file necessari al layout, ...ecc. Se devi invece amministrare una galleria immagini, vai nella sezione Risorse." - all: tutte le risorse new: nuovo file snippets: Frammenti css_and_js: Style e javascript diff --git a/config/locales/admin_ui.pt-BR.yml b/config/locales/admin_ui.pt-BR.yml index 4f888baa..c49bee7e 100644 --- a/config/locales/admin_ui.pt-BR.yml +++ b/config/locales/admin_ui.pt-BR.yml @@ -163,7 +163,6 @@ pt-BR: index: title: Listando arquivos do tema help: "Nesta seção todos os arquivos relacionados a layout são armazenados e gerenciados. Se você precisa de uma galeria de imagens, vá a seção de Arquivos." - all: todos arquivos new: novo arquivo snippets: Blocos css_and_js: CSS e Javascript diff --git a/config/locales/formtastic.fr.yml b/config/locales/formtastic.fr.yml index 5903331f..8dc58e95 100644 --- a/config/locales/formtastic.fr.yml +++ b/config/locales/formtastic.fr.yml @@ -27,7 +27,6 @@ fr: plain_text_name: Nom du fichier content_type: Type du fichier folder: Dossier - hidden: Caché new: source: Fichier edit: diff --git a/doc/TODO b/doc/TODO index 215d7c0a..57dca5ef 100644 --- a/doc/TODO +++ b/doc/TODO @@ -63,14 +63,14 @@ x bug: duplicate fields (new entry) when errors in the content type form x tinyMCE => fullscreen x export site x rake task to import a remote template - -=> MERGE +x MERGE +x remove withelist for assets since we've got now roles +- test and/or convert existing templates (the 2 of the themes section) - overide sort for contents - icon for redirection page in the pages section (back-office) -- test and/or convert existing templates (the 2 of the themes section) - [bushido] guiders / welcome page / devise cas authentication (SSO) -- remove withelist for assets since we've now roles + BACKLOG: diff --git a/features/admin/authorization/theme_assets.feature b/features/admin/authorization/theme_assets.feature index b77c25b7..1adccf01 100644 --- a/features/admin/authorization/theme_assets.feature +++ b/features/admin/authorization/theme_assets.feature @@ -11,12 +11,11 @@ Background: Given I am not authenticated When I go to theme assets Then I should see "Log in" - + Scenario: Accessing theme assets as an Admin Given I am an authenticated "admin" When I go to theme assets - Then I should see "all assets" - And I should see "new snippet" + Then I should see "new snippet" And I should see "new file" And I should see "Snippets" And I should see "Style and javascript" @@ -25,8 +24,7 @@ Background: Scenario: Accessing theme assets as a Designer Given I am an authenticated "designer" When I go to theme assets - Then I should see "all assets" - And I should see "new snippet" + Then I should see "new snippet" And I should see "new file" And I should see "Snippets" And I should see "Style and javascript" @@ -35,8 +33,7 @@ Background: Scenario: Accessing theme assets as an Author Given I am an authenticated "author" When I go to theme assets - Then I should not see "all assets" - And I should not see "new snippet" + Then I should not see "new snippet" And I should not see "new file" And I should not see "Snippets" And I should not see "Style and javascript" diff --git a/lib/locomotive/import/assets.rb b/lib/locomotive/import/assets.rb index 98eb4485..73957044 100644 --- a/lib/locomotive/import/assets.rb +++ b/lib/locomotive/import/assets.rb @@ -3,32 +3,26 @@ module Locomotive class Assets < Base def process - whitelist = self.build_regexps_in_withlist(database['site']['assets']['whitelist']) rescue nil - - self.log "white list = #{whitelist.inspect}" - - self.add_theme_assets(whitelist) + self.add_theme_assets self.add_other_assets end protected - def add_theme_assets(whitelist) + def add_theme_assets %w(images media fonts javascripts stylesheets).each do |kind| Dir[File.join(theme_path, 'public', kind, '**/*')].each do |asset_path| next if File.directory?(asset_path) - visible = self.check_against_whitelist(whitelist, asset_path.gsub(File.join(theme_path, 'public'), '').gsub(/^\//, '')) - folder = asset_path.gsub(File.join(theme_path, 'public'), '').gsub(File.basename(asset_path), '').gsub(/^\//, '').gsub(/\/$/, '') asset = site.theme_assets.where(:local_path => File.join(folder, File.basename(asset_path))).first asset ||= site.theme_assets.build(:folder => folder) - asset.attributes = { :source => File.open(asset_path), :performing_plain_text => false, :hidden => !visible } + asset.attributes = { :source => File.open(asset_path), :performing_plain_text => false } begin asset.save! @@ -63,18 +57,6 @@ module Locomotive end end end - - def check_against_whitelist(whitelist, path) - (whitelist || []).each do |rule| - case rule - when Regexp - return true if path =~ rule - when String - return true if path == rule - end - end - false - end end end end \ No newline at end of file diff --git a/lib/locomotive/liquid/drops/base.rb b/lib/locomotive/liquid/drops/base.rb index 8ba0d8a9..f5717f5f 100644 --- a/lib/locomotive/liquid/drops/base.rb +++ b/lib/locomotive/liquid/drops/base.rb @@ -1,4 +1,4 @@ -# Code taken from Mephisto sources (http://mephistoblog.com/) +# Liquify taken from Mephisto sources (http://mephistoblog.com/) module Locomotive module Liquid module Drops @@ -6,26 +6,16 @@ module Locomotive @@forbidden_attributes = %w{_id _version _index} - class_inheritable_reader :liquid_attributes - write_inheritable_attribute :liquid_attributes, [] attr_reader :_source - delegate :hash, :to => :_source def initialize(source) - unless source.nil? - @_source = source - @liquid = liquid_attributes.flatten.inject({}) { |h, k| h.update k.to_s => @_source.send(k) } - end + @_source = source end def id (@_source.respond_to?(:id) ? @_source.id : nil) || 'new' end - def before_method(method) - @liquid[method.to_s] - end - # converts an array of records to an array of liquid drops def self.liquify(*records, &block) i = -1 diff --git a/lib/locomotive/liquid/drops/content.rb b/lib/locomotive/liquid/drops/content.rb index 1475f47b..1aefc759 100644 --- a/lib/locomotive/liquid/drops/content.rb +++ b/lib/locomotive/liquid/drops/content.rb @@ -2,6 +2,7 @@ module Locomotive module Liquid module Drops class Content < Base + delegate :seo_title, :meta_keywords, :meta_description, :to => '_source' def _id diff --git a/lib/locomotive/liquid/drops/page.rb b/lib/locomotive/liquid/drops/page.rb index 18aa0def..8de62944 100644 --- a/lib/locomotive/liquid/drops/page.rb +++ b/lib/locomotive/liquid/drops/page.rb @@ -2,7 +2,8 @@ module Locomotive module Liquid module Drops class Page < Base - delegate :seo_title, :meta_keywords, :meta_description, :to => "_source" + + delegate :seo_title, :meta_keywords, :meta_description, :to => '_source' def title self._source.templatized? ? @context['content_instance'].highlighted_field_value : self._source.title diff --git a/lib/locomotive/liquid/drops/site.rb b/lib/locomotive/liquid/drops/site.rb index 1ff8f8d2..1a52a2e0 100644 --- a/lib/locomotive/liquid/drops/site.rb +++ b/lib/locomotive/liquid/drops/site.rb @@ -3,14 +3,14 @@ module Locomotive module Drops class Site < Base - liquid_attributes << :name << :seo_title << :meta_keywords << :meta_description + delegate :name, :seo_title, :meta_keywords, :meta_description, :to => '_source' def index @index ||= self._source.pages.root.first end def pages - @pages ||= self._source.pages.to_a.collect(&:to_liquid) + @pages ||= liquify(*self._source.pages) end end diff --git a/public/javascripts/admin/application.js b/public/javascripts/admin/application.js index 141db672..86e33e6b 100644 --- a/public/javascripts/admin/application.js +++ b/public/javascripts/admin/application.js @@ -130,4 +130,5 @@ $(document).ready(function() { $('.formtastic fieldset.inputs').bind('refresh', function(e) { $(this).find('ol li:not(.item)').removeClass('last').filter(':visible').last().addClass('last'); }) .trigger('refresh'); + $('.formtastic fieldset.inputs ol li:not(.item)').last().addClass('last'); }); diff --git a/spec/fixtures/themes/default.zip b/spec/fixtures/themes/default.zip index 9d3cc5c9..22fa1564 100644 Binary files a/spec/fixtures/themes/default.zip and b/spec/fixtures/themes/default.zip differ diff --git a/spec/lib/locomotive/import_spec.rb b/spec/lib/locomotive/import_spec.rb index 516d522b..5dbcc5b3 100644 --- a/spec/lib/locomotive/import_spec.rb +++ b/spec/lib/locomotive/import_spec.rb @@ -46,14 +46,6 @@ describe Locomotive::Import::Job do @site.theme_assets.count.should == 10 end - it 'hides some theme assets' do - asset = @site.theme_assets.where(:local_path => 'stylesheets/style.css').first - asset.hidden.should == false - - asset = @site.theme_assets.where(:local_path => 'stylesheets/ie7.css').first - asset.hidden.should == true - end - it 'inserts all the pages' do @site.pages.count.should == 11 end