Merge pull request #419 from foodcoop1040/wiki
Improve sorting of wiki pages
This commit is contained in:
commit
8545190a84
5 changed files with 16 additions and 24 deletions
|
@ -108,22 +108,23 @@ class PagesController < ApplicationController
|
||||||
|
|
||||||
def all
|
def all
|
||||||
@pages = Page.non_redirected
|
@pages = Page.non_redirected
|
||||||
@partial = params[:view] || 'recent_changes'
|
@partial = params[:view] || 'title_list'
|
||||||
|
|
||||||
if params[:name]
|
if params[:name]
|
||||||
@pages = @pages.where("title LIKE ?", "%#{params[:name]}%").limit(20).order('updated_at DESC')
|
@pages = @pages.where("title LIKE ?", "%#{params[:name]}%").limit(20)
|
||||||
@partial = 'title_list'
|
@partial = 'title_list'
|
||||||
else
|
|
||||||
order = case @partial
|
|
||||||
when 'recent_changes' then
|
|
||||||
'updated_at DESC'
|
|
||||||
when 'site_map' then
|
|
||||||
'created_at DESC'
|
|
||||||
when 'title_list' then
|
|
||||||
'title DESC'
|
|
||||||
end
|
|
||||||
@pages.order(order)
|
|
||||||
end
|
end
|
||||||
|
if params[:sort]
|
||||||
|
sort = case params[:sort]
|
||||||
|
when "title" then "title"
|
||||||
|
when "title_reverse" then "title DESC"
|
||||||
|
when "last_updated" then "updated_at DESC"
|
||||||
|
when "last_updated_reverse" then "updated_at"
|
||||||
|
end
|
||||||
|
else
|
||||||
|
sort = "title"
|
||||||
|
end
|
||||||
|
@pages = @pages.order(sort)
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html
|
format.html
|
||||||
format.rss { render :layout => false }
|
format.rss { render :layout => false }
|
||||||
|
|
|
@ -1,8 +0,0 @@
|
||||||
%table.table.table-striped
|
|
||||||
%thead
|
|
||||||
%tr
|
|
||||||
%th= t 'pages.title'
|
|
||||||
%th= t 'pages.last_updated'
|
|
||||||
%tbody
|
|
||||||
- for page in @pages
|
|
||||||
= render :partial => "page_list_item", :locals => {:page => page, :level => 0, :siteMap => 0}
|
|
|
@ -8,5 +8,5 @@
|
||||||
= render :partial => 'page_list_item', :locals => {:page => homepage, :level => 0, :siteMap => 1}
|
= render :partial => 'page_list_item', :locals => {:page => homepage, :level => 0, :siteMap => 1}
|
||||||
%tbody
|
%tbody
|
||||||
- for page in @pages
|
- for page in @pages
|
||||||
- if page.id != homepage.try(:id)
|
- if page.id != homepage.try(:id) && !page.parent_id?
|
||||||
= render :partial => 'page_list_item', :locals => {:page => page, :level => 0, :siteMap => 1}
|
= render :partial => 'page_list_item', :locals => {:page => page, :level => 0, :siteMap => 1}
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
%table.table.table-striped
|
%table.table.table-striped
|
||||||
%thead
|
%thead
|
||||||
%tr
|
%tr
|
||||||
%th= t 'pages.title'
|
%th= sort_link_helper t('pages.title'), "title", :remote => false
|
||||||
%th= t 'pages.last_updated'
|
%th= sort_link_helper t('pages.last_updated'), "last_updated", :remote => false
|
||||||
%tbody
|
%tbody
|
||||||
- for page in @pages
|
- for page in @pages
|
||||||
= render :partial => "page_list_item", :locals => {:page => page, :level => 0, :siteMap => 0}
|
= render :partial => "page_list_item", :locals => {:page => page, :level => 0, :siteMap => 0}
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
.navbar
|
.navbar
|
||||||
.navbar-inner
|
.navbar-inner
|
||||||
%ul.nav
|
%ul.nav
|
||||||
%li= link_to t('.recent_changes'), all_pages_path(:view => 'recent_changes')
|
|
||||||
%li= link_to t('.title_list'), all_pages_path(:view => 'title_list')
|
%li= link_to t('.title_list'), all_pages_path(:view => 'title_list')
|
||||||
%li= link_to t('.site_map'), all_pages_path(:view => 'site_map')
|
%li= link_to t('.site_map'), all_pages_path(:view => 'site_map')
|
||||||
%li= link_to image_tag('icons/feed-icon-14x14.png', :alt => 'RSS Feed'), all_pages_rss_url
|
%li= link_to image_tag('icons/feed-icon-14x14.png', :alt => 'RSS Feed'), all_pages_rss_url
|
||||||
|
|
Loading…
Reference in a new issue