Changeset 1235

Show
Ignore:
Timestamp:
2008-10-23 13:23:05 (3 months ago)
Author:
gaspard
Message:

commit 66c5c686b382091bffcf43bb370385ceab5e812d
Author: Gaspard Bucher <gaspard@teti.ch>

Sort iformats by surface instead of name.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/app/models/iformat.rb

    r1016 r1235  
    2323        end 
    2424      end 
    25       res.sort {|a,b| a[:name] <=> b[:name]} 
     25      res.sort do |a,b| 
     26        if a.size == 'keep' 
     27          b.size == 'keep' ? a[:name] <=> b[:name] : 1 
     28        else 
     29          (a.width * a.height) <=> (b.width * b.height) 
     30        end 
     31      end 
    2632    end 
    2733     
  • trunk/config/deploy.rb

    r1234 r1235  
    2828 
    2929set :deploy_to,    "/var/zena" 
     30set :zena_sites,   "/var/www/zena" 
     31set :apache2_vhost_root, "/etc/apache2/sites-available" 
     32set :apache2_deflate,       true 
     33set :apache2_debug_deflate, false 
     34set :apache2_debug_rewrite, false 
     35set :apache2_static,        [] 
     36set :apache2_reload_cmd, "/etc/init.d/apache2 reload" 
     37set :debian_host,           true 
     38 
    3039role :web,         "root@#{server_ip}" 
    3140role :app,         "root@#{server_ip}" 
    3241role :db,          "root@#{server_ip}", :primary => true 
    33 set :apache2_deflate,       true 
    34 set :apache2_debug_deflate, false 
    35 set :apache2_debug_rewrite, false 
    36 # cgi-bin not working...? FIXME: set :apache2_static,        ['cgi-bin', 'awstats-icon'] 
    37 set :apache2_static,        [] 
    3842 
    3943load File.join(File.dirname(__FILE__), 'deploy_config') 
     
    7074task :set_permissions, :roles => :app do 
    7175  run "chown -R www-data:www-data #{deploy_to}" 
    72   run "chown -R www-data:www-data /var/www/zena
     76  run "chown -R www-data:www-data #{zena_sites}
    7377end 
    7478 
     
    100104task :app_update_symlinks, :roles => :app do 
    101105  run "test ! -e #{deploy_to}/current/sites || rm #{deploy_to}/current/sites" 
    102   run "ln -sf /var/www/zena #{deploy_to}/current/sites" 
     106  run "ln -sf #{zena_sites} #{deploy_to}/current/sites" 
    103107  set_permissions 
    104108end 
     
    112116task :app_setup, :roles => :app do 
    113117  run "test -e #{deploy_to}  || mkdir #{deploy_to}" 
    114   run "test -e /var/www/zena || mkdir /var/www/zena
     118  run "test -e #{zena_sites} || mkdir #{zena_sites}
    115119  deploy::setup 
    116120end 
     
    197201                  :balancer    => db_name 
    198202                  ) 
    199     put(vhost, "/etc/apache2/sites-available/#{self[:host]}") 
    200     run "test -e /etc/apache2/sites-enabled/#{self[:host]} || a2ensite #{self[:host]}" 
     203    put(vhost, "#{apache2_vhost_root}/#{self[:host]}") 
     204 
     205    run "test -e /etc/apache2/sites-enabled/#{self[:host]} || a2ensite #{self[:host]}" if debian_host 
    201206     
    202207    unless self[:host] =~ /^www/ 
     
    204209                    :host        => self[:host] 
    205210                    ) 
    206       put(vhost_www, "/etc/apache2/sites-available/www.#{self[:host]}") 
    207       run "test -e /etc/apache2/sites-enabled/www.#{self[:host]} || a2ensite www.#{self[:host]}" 
    208     end 
    209     run "/etc/init.d/apache2 reload" 
     211      put(vhost_www, "#{apache2_vhost_root}/www.#{self[:host]}") 
     212      run "test -e /etc/apache2/sites-enabled/www.#{self[:host]} || a2ensite www.#{self[:host]}" if debian_host 
     213    end 
     214    run apache2_reload_cmd 
    210215  end 
    211216end 
     
    214219desc "Update awstats configuration file" 
    215220task :create_awstats, :roles => :web do 
    216   unless self[:host] && self[:pass] 
    217     puts "host or password not set (use -s host=... -s pass=...)
     221  unless debian_host 
     222    puts "skipping debian specific awstats
    218223  else 
    219     # create awstats config file 
    220     awstats_conf = render("config/awstats.conf.rhtml", :host => self[:host] ) 
    221     put(awstats_conf, "/etc/awstats/awstats.#{self[:host]}.conf") 
    222      
    223     # create stats vhost 
    224     stats_vhost = render("config/stats.vhost.rhtml", :host => self[:host] ) 
    225     put(stats_vhost, "/etc/apache2/sites-available/stats.#{self[:host]}") 
    226     run "test -e /etc/apache2/sites-enabled/stats.#{self[:host]} || a2ensite stats.#{self[:host]}" 
    227      
    228     # directory setup for stats 
    229     run "test -e /var/www/zena/#{self[:host]}/log/awstats || mkdir /var/www/zena/#{self[:host]}/log/awstats" 
    230     run "chown www-data:www-data /var/www/zena/#{self[:host]}/log/awstats" 
    231      
    232     # setup cron task for awstats 
    233     run "cat /etc/cron.d/awstats | grep \"#{self[:host]}\" || echo \"0,10,20,30,40,50 * * * * www-data [ -x /usr/lib/cgi-bin/awstats.pl -a -f /etc/awstats/awstats.#{self[:host]}.conf -a -r /var/www/zena/#{self[:host]}/log/apache2.access.log ] && /usr/lib/cgi-bin/awstats.pl -config=#{self[:host]} -update >/dev/null\n\" >> /etc/cron.d/awstats" 
    234      
    235     # create .htpasswd file 
    236     run "test ! -e /var/www/zena/#{self[:host]}/log/.awstatspw || rm /var/www/zena/#{self[:host]}/log/.awstatspw" 
    237     run "htpasswd -c -b /var/www/zena/#{self[:host]}/log/.awstatspw 'admin' '#{self[:pass]}'" 
    238      
    239     # reload apache 
    240     run "/etc/init.d/apache2 reload" 
     224    unless self[:host] && self[:pass] 
     225      puts "host or password not set (use -s host=... -s pass=...)" 
     226    else 
     227      # create awstats config file 
     228      awstats_conf = render("config/awstats.conf.rhtml", :host => self[:host] ) 
     229      put(awstats_conf, "/etc/awstats/awstats.#{self[:host]}.conf") 
     230     
     231      # create stats vhost 
     232      stats_vhost = render("config/stats.vhost.rhtml", :host => self[:host] ) 
     233      put(stats_vhost, "#{apache2_vhost_root}/stats.#{self[:host]}") 
     234      run "test -e /etc/apache2/sites-enabled/stats.#{self[:host]} || a2ensite stats.#{self[:host]}" 
     235     
     236      # directory setup for stats 
     237      run "test -e #{zena_sites}/#{self[:host]}/log/awstats || mkdir #{zena_sites}/#{self[:host]}/log/awstats" 
     238      run "chown www-data:www-data #{zena_sites}/#{self[:host]}/log/awstats" 
     239     
     240      # setup cron task for awstats 
     241      run "cat /etc/cron.d/awstats | grep \"#{self[:host]}\" || echo \"0,10,20,30,40,50 * * * * www-data [ -x /usr/lib/cgi-bin/awstats.pl -a -f /etc/awstats/awstats.#{self[:host]}.conf -a -r #{zena_sites}/#{self[:host]}/log/apache2.access.log ] && /usr/lib/cgi-bin/awstats.pl -config=#{self[:host]} -update >/dev/null\n\" >> /etc/cron.d/awstats" 
     242     
     243      # create .htpasswd file 
     244      run "test ! -e #{zena_sites}/#{self[:host]}/log/.awstatspw || rm #{zena_sites}/#{self[:host]}/log/.awstatspw" 
     245      run "htpasswd -c -b #{zena_sites}/#{self[:host]}/log/.awstatspw 'admin' '#{self[:pass]}'" 
     246     
     247      # reload apache 
     248      run "/etc/init.d/apache2 reload" 
     249    end 
    241250  end 
    242251end 
     
    248257  else 
    249258    run "#{in_current} rake zena:rename_host OLD_HOST='#{self[:old_host]}' HOST='#{self[:host]}' RAILS_ENV='production'" 
    250     old_vhost_path = "/etc/apache2/sites-available/#{self[:old_host]}" 
     259    old_vhost_path = "#{apache2_vhost_root}/#{self[:old_host]}" 
    251260    run "a2dissite #{self[:old_host]}" 
    252261    run "test -e #{old_vhost_path} && rm #{old_vhost_path}" 
  • trunk/test/unit/iformat_test.rb

    r1219 r1235  
    3434  def test_list 
    3535    login(:lion) 
    36     assert_equal ["edit","full","low","med","mini","pv","side","square","std","tiny","top"], Iformat.list.map{|h| h[:name]} 
     36    assert_equal %w{tiny mini pv square top low med side edit std full}, Iformat.list.map{|h| h[:name]} 
    3737     
    3838    login(:whale) 
    39     assert_equal ["edit","full","header", "low","med","mini","pv","side","square","std","tiny","top"], Iformat.list.map{|h| h[:name]} 
     39    assert_equal %w{tiny mini pv square med top low side header edit std full}, Iformat.list.map{|h| h[:name]} 
    4040  end 
    4141