Updating branch refs/heads/master to d3282f858bbafd0605682b4cbc20ced0474df436 (commit) from a9d668779e6463870221d0d96c2981b75d3d8dac (commit)
commit d3282f858bbafd0605682b4cbc20ced0474df436 Author: Nick Schermer <n...@xfce.org> Date: Sun Nov 13 13:01:42 2011 +0100 Handle ordering like mod_autoindex. fancyindex/main.rb | 22 ++++++++++------------ fancyindex/models/archive.rb | 4 ++-- fancyindex/views/index.haml | 6 +++--- 3 files changed, 15 insertions(+), 17 deletions(-) diff --git a/fancyindex/main.rb b/fancyindex/main.rb index 8e5a7b7..e460190 100644 --- a/fancyindex/main.rb +++ b/fancyindex/main.rb @@ -23,18 +23,16 @@ module Fancyindex status 404 haml :notfound else - @order = params[:O] - reverse = false - if @order == 'A' - @order = 'D' - elsif @order == 'D' - @order = 'A' - reverse = true - else - @order = 'A' - end - #layout '*', :haml, { :format => :html5, :ugly => true } - @archive = Archive.new(path, requesturi, params[:C], reverse) + order = params[:O] + order = 'A' unless ['A', 'D'].include?(order) + + col = params[:C] + col = 'N' unless ['N', 'M', 'S'].include?(col) + + @dir = { 'N' => 'A', 'M' => 'A', 'S' => 'A' } + @dir.each {|c, o| @dir[c] = 'D' if col == c and order == o} + + @archive = Archive.new(path, requesturi, col, order == 'D') haml :index, :ugly => true end end diff --git a/fancyindex/models/archive.rb b/fancyindex/models/archive.rb index 5ff85db..78f828c 100644 --- a/fancyindex/models/archive.rb +++ b/fancyindex/models/archive.rb @@ -100,11 +100,11 @@ module Fancyindex def hreflink base = '/' - string = "<a href=\"/\">archive.xfce.org</a>/" + string = "<a href=\"/\">archive.xfce.org</a>" self.href.split('/').each do |part| next if part.empty? base += "#{part}/" - string += "<a href=\"#{base}\">#{part}</a>/" + string += "/<a href=\"#{base}\">#{part}</a>" end string end diff --git a/fancyindex/views/index.haml b/fancyindex/views/index.haml index 6e05e72..20208ac 100644 --- a/fancyindex/views/index.haml +++ b/fancyindex/views/index.haml @@ -38,11 +38,11 @@ %tr %th %th{:class => 'namecol'} - %a{:href => "?C=N;O=#{@order}"} Name + %a{:href => "?C=N;O=#{@dir['N']}"} Name %th - %a{:href => "?C=M;O=#{@order}"} Last modified + %a{:href => "?C=M;O=#{@dir['M']}"} Last modified %th - %a{:href => "?C=S;O=#{@order}"} Size + %a{:href => "?C=S;O=#{@dir['S']}"} Size %th - if @archive.parent %tr _______________________________________________ Xfce4-commits mailing list Xfce4-commits@xfce.org https://mail.xfce.org/mailman/listinfo/xfce4-commits