From f0871346f79b18d5f2c2cf51ce234af669eb397a Mon Sep 17 00:00:00 2001 From: Ben Halpern Date: Fri, 10 May 2019 16:20:40 -0400 Subject: [PATCH] Add security and faq pages as generatable via the Page model (#2792) --- app/controllers/pages_controller.rb | 14 +++++++++++++- app/models/page.rb | 6 ++++-- app/views/pages/information.html.erb | 2 +- app/views/pages/show.html.erb | 6 +++--- app/views/users/_publishing_from_rss.html.erb | 5 ++--- 5 files changed, 23 insertions(+), 10 deletions(-) diff --git a/app/controllers/pages_controller.rb b/app/controllers/pages_controller.rb index edccfba3e..d570e2c5b 100644 --- a/app/controllers/pages_controller.rb +++ b/app/controllers/pages_controller.rb @@ -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 diff --git a/app/models/page.rb b/app/models/page.rb index 00f9da6d5..b859baad6 100644 --- a/app/models/page.rb +++ b/app/models/page.rb @@ -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 diff --git a/app/views/pages/information.html.erb b/app/views/pages/information.html.erb index c39014060..80889bf79 100644 --- a/app/views/pages/information.html.erb +++ b/app/views/pages/information.html.erb @@ -50,7 +50,7 @@
  • About
  • DEV Shop
  • Sponsors
  • -
  • Events
  • +
  • FAQ
  • Privacy Policy
  • Terms of Use
  • Contact
  • diff --git a/app/views/pages/show.html.erb b/app/views/pages/show.html.erb index 625698a72..c917ce48a 100644 --- a/app/views/pages/show.html.erb +++ b/app/views/pages/show.html.erb @@ -1,12 +1,12 @@ <% title @page.title %> <%= content_for :page_meta do %> - + - + " /> @@ -35,4 +35,4 @@ <% else %> <%= @page.processed_html.html_safe %> -<% end %> \ No newline at end of file +<% end %> diff --git a/app/views/users/_publishing_from_rss.html.erb b/app/views/users/_publishing_from_rss.html.erb index e2b09a6ee..7ca5699dd 100644 --- a/app/views/users/_publishing_from_rss.html.erb +++ b/app/views/users/_publishing_from_rss.html.erb @@ -5,10 +5,9 @@ <%= 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" %>

    - Last Updated: