Add security and faq pages as generatable via the Page model (#2792)
This commit is contained in:
parent
85e517a821
commit
f0871346f7
5 changed files with 23 additions and 10 deletions
|
|
@ -1,6 +1,6 @@
|
|||
class PagesController < ApplicationController
|
||||
# No authorization required for entirely public controller
|
||||
before_action :set_cache_control_headers, only: %i[show rlyweb now survey badge shecoded]
|
||||
before_action :set_cache_control_headers, only: %i[show rlyweb now survey badge shecoded bounty faq]
|
||||
|
||||
def show
|
||||
@page = Page.find_by!(slug: params[:slug])
|
||||
|
|
@ -21,6 +21,18 @@ class PagesController < ApplicationController
|
|||
set_surrogate_key_header "about_page"
|
||||
end
|
||||
|
||||
def faq
|
||||
@page = Page.find_by(slug: "faq")
|
||||
render :show if @page
|
||||
set_surrogate_key_header "faq_page"
|
||||
end
|
||||
|
||||
def bounty
|
||||
@page = Page.find_by(slug: "security")
|
||||
render :show if @page
|
||||
set_surrogate_key_header "bounty_page"
|
||||
end
|
||||
|
||||
def badge
|
||||
@html_variant = HtmlVariant.find_for_test([], "badge_landing_page")
|
||||
render layout: false
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ class Page < ApplicationRecord
|
|||
validate :body_present
|
||||
|
||||
before_save :evaluate_markdown
|
||||
before_save :bust_cache
|
||||
after_save :bust_cache
|
||||
before_validation :set_default_template
|
||||
|
||||
mount_uploader :social_image, ProfileImageUploader
|
||||
|
|
@ -31,7 +31,9 @@ class Page < ApplicationRecord
|
|||
end
|
||||
|
||||
def bust_cache
|
||||
CacheBuster.new.bust "/page/"
|
||||
CacheBuster.new.bust "/page/#{slug}"
|
||||
CacheBuster.new.bust "/page/#{slug}?i=i"
|
||||
CacheBuster.new.bust "/#{slug}"
|
||||
CacheBuster.new.bust "/#{slug}?i=i"
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@
|
|||
<li><a href="/about">About</a></li>
|
||||
<li><a href="https://shop.dev.to/">DEV Shop</a></li>
|
||||
<li><a href="/sponsors">Sponsors</a></li>
|
||||
<li><a href="/events">Events</a></li>
|
||||
<li><a href="/FAQ">FAQ</a></li>
|
||||
<li><a href="/privacy">Privacy Policy</a></li>
|
||||
<li><a href="/terms">Terms of Use</a></li>
|
||||
<li><a href="/contact">Contact</a></li>
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
<% title @page.title %>
|
||||
|
||||
<%= content_for :page_meta do %>
|
||||
<link rel="canonical" href="https://dev.to/<%= @page.slug %>" />
|
||||
<link rel="canonical" href="https://dev.to<%= request.path %>" />
|
||||
<meta name="description" content="<%= @page.title %> — <%= community_qualified_name %>">
|
||||
<meta name="keywords" content="software development,engineering,rails,javascript,ruby">
|
||||
|
||||
<meta property="og:type" content="article" />
|
||||
<meta property="og:url" content="https://dev.to/<%= @page.slug %>" />
|
||||
<meta property="og:url" content="https://dev.to<%= request.path %>" />
|
||||
<meta property="og:title" content="<%= @page.title %> — <%= community_qualified_name %>" />
|
||||
<meta property="og:image" content="<%= @page.social_image_url || "https://thepracticaldev.s3.amazonaws.com/i/g355ol6qsrg0j2mhngz9.png" %>" />
|
||||
<meta property="og:description" content="<%= @page.description %>" />
|
||||
|
|
@ -35,4 +35,4 @@
|
|||
</div>
|
||||
<% else %>
|
||||
<%= @page.processed_html.html_safe %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
|
|
|||
|
|
@ -5,10 +5,9 @@
|
|||
<label></label>
|
||||
<%= f.hidden_field :feed_url, value: @user.feed_url %>
|
||||
<%= f.hidden_field :tab, value: @tab %>
|
||||
<%= f.submit "Refresh Feed" %>
|
||||
<%= f.submit "Fetch Feed Now", class: "cta" %>
|
||||
<p><em>
|
||||
Last Updated: <time id="rss-fetch-time" datetime="<%= @user.feed_fetched_at.iso8601 %>">
|
||||
<%= @user.feed_fetched_at.strftime("%b %d, %H:%M:%S %Z") %>
|
||||
Last Fetched: <time id="rss-fetch-time" datetime="<%= @user.feed_fetched_at.iso8601 %>">
|
||||
</time>
|
||||
</em></p>
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue