Skip to content

Commit

Permalink
Better validation of users stylesheet
Browse files Browse the repository at this point in the history
  • Loading branch information
nono committed Jul 20, 2012
1 parent 356504d commit 7b6d176
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion app/models/stylesheet.rb
Expand Up @@ -5,7 +5,9 @@ class Stylesheet < Struct.new(:name, :url, :image)
BASE_DIR = Rails.root.join("app/assets/stylesheets/contrib")

def self.include?(css)
Dir["#{BASE_DIR.sub '/contrib', ''}/#{css}*css"].any?
return true if css == "mobile"
css.prepend 'contrib/' unless css.starts_with? 'contrib/'
Dir["#{BASE_DIR}/#{css.sub 'contrib/', ''}.css.scss"].any?
end

def self.all
Expand Down
2 changes: 1 addition & 1 deletion app/views/stylesheets/edit.html.haml
Expand Up @@ -15,7 +15,7 @@
%img{ :src => css.image, :alt => css.name }

= form_tag "/stylesheet" do
= label_tag :stylesheet, "Autre feuille de style"
= label_tag :stylesheet, "Pour utiliser une feuille de style externe, veuillez saisir son URL :"
= text_field_tag :stylesheet
= submit_tag 'OK'

Expand Down

0 comments on commit 7b6d176

Please sign in to comment.