Changeset 268
- Timestamp:
- 04/25/08 10:10:36 (7 months ago)
- Files:
-
- trunk/lib/picolena/templates/app/helpers/documents_helper.rb (modified) (1 diff)
- trunk/lib/picolena/templates/app/models/document.rb (modified) (1 diff)
- trunk/lib/picolena/templates/config/initializers/002_load_indexed_dirs.rb (modified) (1 diff)
- trunk/lib/picolena/templates/config/initializers/003_load_white_list_IPs.rb (modified) (1 diff)
- trunk/lib/picolena/templates/config/initializers/005_load_custom_title_and_names_and_links.rb (modified) (1 diff)
- trunk/lib/picolena/templates/config/initializers/006_load_icons.rb (modified) (1 diff)
- trunk/lib/picolena/templates/spec/helpers/documents_helper_spec.rb (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/lib/picolena/templates/app/helpers/documents_helper.rb
r263 r268 39 39 40 40 def language_icon_for(document) 41 (lang=document.language) && link_to(image_tag("flags/#{lang}.png"), document_url('lang:'<<lang)) 41 lang=document.language 42 link_to(image_tag("flags/#{lang}.png"), document_url('lang:'<<lang)) unless lang.blank? 42 43 end 43 44 44 45 # Returns icon and filename for any given document. 45 46 def icon_and_filename_for(document) 46 [icon_for(document.ext name),document.filename].join(" ")47 [icon_for(document.ext_as_sym),document.filename].join(" ") 47 48 end 48 49 49 50 # Returns the location (if avaible) of the filetype icon. 50 def icon_for( filetype)51 icon_symbol= FiletypeToIconSymbol[filetype.downcase.sub(/^\./,'')]51 def icon_for(ext) 52 icon_symbol=Picolena::FiletypeToIconSymbol[ext] 52 53 image_tag("icons/#{icon_symbol}.png") if icon_symbol 53 54 end trunk/lib/picolena/templates/app/models/document.rb
r263 r268 12 12 13 13 #Delegating properties to File::method_name(complete_path) 14 [:dirname, :basename, :extname, : size?, :file?, :read, :ext_as_sym].each{|method_name|14 [:dirname, :basename, :extname, :ext_as_sym, :size?, :file?, :read, :ext_as_sym].each{|method_name| 15 15 define_method(method_name){File.send(method_name,complete_path)} 16 16 } trunk/lib/picolena/templates/config/initializers/002_load_indexed_dirs.rb
r167 r268 1 1 module Picolena 2 #Loading directories to be indexed3 indexed_dir_config_file='config/custom/indexed_directories.yml'4 IndexedDirectories={}5 YAML.load_file(indexed_dir_config_file)[RAILS_ENV].each_pair{|abs_or_rel_path, alias_path|6 IndexedDirectories[Pathname(abs_or_rel_path).realpath.to_s]=alias_path7 }8 9 IndexSavePath=File.join(IndexesSavePath,ENV["RAILS_ENV"] || "development")2 #Loading directories to be indexed 3 indexed_dir_config_file='config/custom/indexed_directories.yml' 4 IndexedDirectories={} 5 YAML.load_file(indexed_dir_config_file)[RAILS_ENV].each_pair{|abs_or_rel_path, alias_path| 6 IndexedDirectories[Pathname(abs_or_rel_path).realpath.to_s]=alias_path 7 } 8 9 IndexSavePath=File.join(IndexesSavePath,ENV["RAILS_ENV"] || "development") 10 10 end trunk/lib/picolena/templates/config/initializers/003_load_white_list_IPs.rb
r167 r268 1 1 module Picolena 2 #Deny all, Allow only IPs described in config/custom/white_list_ip.yml3 white_list_ip_config_file='config/custom/white_list_ip.yml'4 WhiteListIPs=Regexp.new(5 "^("<<6 YAML.load_file(white_list_ip_config_file)["Allow"].collect{|ip|7 ip.downcase.include?("all") ? /.*/ : Regexp.escape(ip)8 }.join("|")<<")"9 ) rescue /^(127\.0\.0\.1|0\.0\.0\.0)/2 #Deny all, Allow only IPs described in config/custom/white_list_ip.yml 3 white_list_ip_config_file='config/custom/white_list_ip.yml' 4 WhiteListIPs=Regexp.new( 5 "^("<< 6 YAML.load_file(white_list_ip_config_file)["Allow"].collect{|ip| 7 ip.downcase.include?("all") ? /.*/ : Regexp.escape(ip) 8 }.join("|")<<")" 9 ) rescue /^(127\.0\.0\.1|0\.0\.0\.0)/ 10 10 end trunk/lib/picolena/templates/config/initializers/005_load_custom_title_and_names_and_links.rb
r167 r268 1 1 module Picolena 2 custom_localization_yml=File.join(RAILS_ROOT,'config/custom/title_and_names_and_links.yml')3 4 YAML.load_file(custom_localization_yml).each{|key_name, custom_translation|5 Globalite.localizations[key_name.to_sym]=custom_translation unless custom_translation.blank?6 }2 custom_localization_yml=File.join(RAILS_ROOT,'config/custom/title_and_names_and_links.yml') 3 4 YAML.load_file(custom_localization_yml).each{|key_name, custom_translation| 5 Globalite.localizations[key_name.to_sym]=custom_translation unless custom_translation.blank? 6 } 7 7 end trunk/lib/picolena/templates/config/initializers/006_load_icons.rb
r166 r268 1 icons_config_file='config/custom/icons_and_filetypes.yml' 2 FiletypeToIconSymbol={} 3 YAML.load_file(icons_config_file).each_pair{|icon_name, filetypes| 4 icon_symbol=icon_name.to_sym 5 filetypes.split(/\s/).each{|filetype| 6 FiletypeToIconSymbol[filetype.downcase]=icon_symbol 1 module Picolena 2 icons_config_file='config/custom/icons_and_filetypes.yml' 3 FiletypeToIconSymbol={} 4 YAML.load_file(icons_config_file).each_pair{|icon_name, filetypes| 5 icon_symbol=icon_name.to_sym 6 filetypes.split(/\s/).each{|filetype| 7 FiletypeToIconSymbol[filetype.downcase.to_sym]=icon_symbol 8 } 7 9 } 8 } 10 end trunk/lib/picolena/templates/spec/helpers/documents_helper_spec.rb
r263 r268 6 6 PlainTextExtractor.supported_extensions.each{|ext| 7 7 it "should have an icon for .#{ext} filetype" do 8 icon_for(ext .to_s).should_not be_nil8 icon_for(ext).should_not be_nil 9 9 end 10 10 }
