Skip to content

Commit

Permalink
make /tag/____ able to fetch wiki by id in addition to slug (publicla…
Browse files Browse the repository at this point in the history
  • Loading branch information
jywarren authored and enviro3 committed Aug 12, 2019
1 parent 4edc509 commit 1bb60c2
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions app/controllers/tag_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,12 @@ def index
end

def show
@wiki = Node.where(path: "/wiki/#{params[:id]}").try(:first) || Node.where(path: "/#{params[:id]}").try(:first)
@wiki = Node.where(slug: @wiki.power_tag('redirect'))&.first if @wiki&.has_power_tag('redirect') # use a redirected wiki page if it exists
if params[:id].is_a? Integer
@wiki = Node.find(params[:id])&.first
else
@wiki = Node.where(path: "/wiki/#{params[:id]}").try(:first) || Node.where(path: "/#{params[:id]}").try(:first)
@wiki = Node.where(slug: @wiki.power_tag('redirect'))&.first if @wiki&.has_power_tag('redirect') # use a redirected wiki page if it exists
end

default_type = params[:id].match?('question:') ? 'questions' : 'note'

Expand Down

0 comments on commit 1bb60c2

Please sign in to comment.