Skip to content

Commit

Permalink
Stale page added in controller
Browse files Browse the repository at this point in the history
  • Loading branch information
mal-wtag committed Jan 11, 2018
1 parent a876a84 commit 91a6a83
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ DEPENDENCIES
recaptcha
rest-client
rspec
rubocop
rubocop (~> 0.52.0)
ruby-openid
sass-rails (~> 4.0.0)
scrypt (~> 3)
Expand Down
20 changes: 20 additions & 0 deletions app/controllers/wiki_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,26 @@ def index
@paginated = true
end

def stale
@title = I18n.t('wiki_controller.wiki')

order_string = if params[:order] == 'alphabetic'
'node_revisions.title ASC'
else
'node_revisions.timestamp ASC'
end

@wikis = Node.includes(:revision)
.references(:node_revisions)
.group('node_revisions.nid')
.order(order_string)
.where("node_revisions.status = 1 AND node.status = 1 AND (type = 'page' OR type = 'tool' OR type = 'place')")
.page(params[:page])

@paginated = true
render template: 'wiki/index'
end

def popular
@title = I18n.t('wiki_controller.popular_wiki_pages')
@wikis = Node.limit(40)
Expand Down
1 change: 1 addition & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@
get 'wiki/:lang/:id' => 'wiki#show'
get 'wiki/edit/:lang/:id' => 'wiki#edit'
get 'wiki' => 'wiki#index'
get 'wiki' => 'wiki#stale'

get 'place/:id/feed' => 'place#feed'
get 'n/:id' => 'notes#shortlink'
Expand Down

0 comments on commit 91a6a83

Please sign in to comment.