blob: f6fb45a7103707e3743c07b0729dd4d1232b86ae (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
class SharedPreviewsController < ApplicationController
def show
@page = Page.find_by!(preview_token: params[:token])
node = @page.node
if node
is_head = node.head_id == @page.id
is_draft = node.draft_id == @page.id
currently_public = is_head && @page.public?
superseded = !is_head && !is_draft
if superseded || currently_public
redirect_to @page.public_link
return
end
end
response.headers['X-Robots-Tag'] = 'noindex'
render template: @page.valid_template, layout: "application"
end
end
|