Changeset 268

Show
Ignore:
Timestamp:
04/25/08 10:10:36 (7 months ago)
Author:
eric.dumin..@gmail.com
Message:

ext_as_sym used instead of extname

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/lib/picolena/templates/app/helpers/documents_helper.rb

    r263 r268  
    3939 
    4040  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? 
    4243  end 
    4344 
    4445  # Returns icon and filename for any given document. 
    4546  def icon_and_filename_for(document) 
    46     [icon_for(document.extname),document.filename].join("&nbsp;") 
     47    [icon_for(document.ext_as_sym),document.filename].join("&nbsp;") 
    4748  end 
    4849 
    4950  # 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
    5253    image_tag("icons/#{icon_symbol}.png") if icon_symbol 
    5354  end 
  • trunk/lib/picolena/templates/app/models/document.rb

    r263 r268  
    1212 
    1313  #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| 
    1515    define_method(method_name){File.send(method_name,complete_path)} 
    1616  } 
  • trunk/lib/picolena/templates/config/initializers/002_load_indexed_dirs.rb

    r167 r268  
    11module Picolena 
    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") 
     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") 
    1010end 
  • trunk/lib/picolena/templates/config/initializers/003_load_white_list_IPs.rb

    r167 r268  
    11module Picolena 
    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)/ 
     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)/ 
    1010end 
  • trunk/lib/picolena/templates/config/initializers/005_load_custom_title_and_names_and_links.rb

    r167 r268  
    11module 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 
    77end 
  • 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 
     1module 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    } 
    79  } 
    8 
     10end 
  • trunk/lib/picolena/templates/spec/helpers/documents_helper_spec.rb

    r263 r268  
    66  PlainTextExtractor.supported_extensions.each{|ext| 
    77    it "should have an icon for .#{ext} filetype" do 
    8       icon_for(ext.to_s).should_not be_nil 
     8      icon_for(ext).should_not be_nil 
    99    end 
    1010  }