From 7885c16ff5d85585f92210864c25d7e13d8bae9f Mon Sep 17 00:00:00 2001 From: Tadhg Date: Sun, 21 Apr 2019 16:08:33 -0700 Subject: [PATCH 01/18] Enforce SSL --- config/environments/production.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/environments/production.rb b/config/environments/production.rb index 338dd3f..3c4a74e 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -32,7 +32,7 @@ Redstoner::Application.configure do # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. - # config.force_ssl = true + config.force_ssl = true # See everything in the log (default is :info) config.log_level = :info -- 2.52.0 From 81bf72982d3e808217b6dc3c59de005265bf11d4 Mon Sep 17 00:00:00 2001 From: Tadhg Date: Sun, 21 Apr 2019 16:10:39 -0700 Subject: [PATCH 02/18] Force no www --- config/routes.rb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/config/routes.rb b/config/routes.rb index 6ad277b..9fbb267 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -59,3 +59,9 @@ Redstoner::Application.routes.draw do root to: 'statics#index' end + +constraints(host: /^(?!www\.)/i) do + match '(*any)' => redirect { |params, request| + URI.parse(request.url).tap { |uri| uri.host = "www.#{uri.host}" }.to_s + } +end -- 2.52.0 From 96795a3cb8658f57588ff43b92dd6d5cc4b7e342 Mon Sep 17 00:00:00 2001 From: Tadhg Date: Sun, 21 Apr 2019 16:13:41 -0700 Subject: [PATCH 03/18] Create meta.yml --- config/meta.yml | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 config/meta.yml diff --git a/config/meta.yml b/config/meta.yml new file mode 100644 index 0000000..ea8b84f --- /dev/null +++ b/config/meta.yml @@ -0,0 +1,4 @@ +meta_title: "Redstoner Server" +meta_description: " Redstoner is an amazing minecraft server for all redstoners of any (or no) skill level, beginner to advanced, from combo locks to doors to CPUs!" +meta_image: "https://redstoner.com/assets/logo-91dbce98be157baa7fe6aa1baad7e0e2a01cd8f997bbe9fe160653dc46754ce3.svg" +twitter_account: "@RedstonerServer" -- 2.52.0 From 5f2a14eb756c81c8204698f10973f94807802f08 Mon Sep 17 00:00:00 2001 From: Tadhg Date: Sun, 21 Apr 2019 16:14:41 -0700 Subject: [PATCH 04/18] Create default_meta.rb --- config/initializers/default_meta.rb | 1 + 1 file changed, 1 insertion(+) create mode 100644 config/initializers/default_meta.rb diff --git a/config/initializers/default_meta.rb b/config/initializers/default_meta.rb new file mode 100644 index 0000000..356f385 --- /dev/null +++ b/config/initializers/default_meta.rb @@ -0,0 +1 @@ +DEFAULT_META = YAML.load_file(Rails.root.join("config/meta.yml")) -- 2.52.0 From 4b1ee22e91c88454633f949db14cb0f1fada209d Mon Sep 17 00:00:00 2001 From: Tadhg Date: Sun, 21 Apr 2019 16:15:53 -0700 Subject: [PATCH 05/18] Create meta_tags_helper.rb --- app/helpers/meta_tags_helper.rb | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 app/helpers/meta_tags_helper.rb diff --git a/app/helpers/meta_tags_helper.rb b/app/helpers/meta_tags_helper.rb new file mode 100644 index 0000000..62cc4eb --- /dev/null +++ b/app/helpers/meta_tags_helper.rb @@ -0,0 +1,14 @@ +module MetaTagsHelper + def meta_title + content_for?(:meta_title) ? content_for(:meta_title) : DEFAULT_META["meta_title"] + end + + def meta_description + content_for?(:meta_description) ? content_for(:meta_description) : DEFAULT_META["meta_description"] + end + + def meta_image + meta_image = (content_for?(:meta_image) ? content_for(:meta_image) : DEFAULT_META["meta_image"]) + meta_image.starts_with?("http") ? meta_image : image_url(meta_image) + end +end -- 2.52.0 From a4303b7a7fa77a6095f6292f7a7271f2731c7bc2 Mon Sep 17 00:00:00 2001 From: Tadhg Date: Sun, 21 Apr 2019 16:21:58 -0700 Subject: [PATCH 06/18] Redo + add metadata --- app/views/layouts/application.html.erb | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index def05b3..05b1b45 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -2,8 +2,28 @@ <%= yield(:site_title).present? ? "#{yield(:site_title)} – " : "" %>Redstoner + + - + + + + + + + + + + + + + + + + + + + <%= stylesheet_link_tag "application", :media => "all" %> <% if current_user.try(:dark) == true %> <%= stylesheet_link_tag "dark", :media => "all" %> -- 2.52.0 From 12cc37b71b403481ceccef62466b8279b0f4884e Mon Sep 17 00:00:00 2001 From: Tadhg Date: Sun, 21 Apr 2019 16:32:11 -0700 Subject: [PATCH 07/18] Add breadcrumbs_on_rails --- Gemfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Gemfile b/Gemfile index 4ef3294..3471b67 100644 --- a/Gemfile +++ b/Gemfile @@ -18,6 +18,7 @@ gem 'jquery-textcomplete-rails' # @mentions gem 'actionpack-action_caching', github: 'antulik/actionpack-action_caching', ref: '8c6e52c69315d67437f480da5dce4b7c8737fb32' gem 'mail-gpg', github: 'jomo/mail-gpg', ref: 'a666b48ee866dfa3eaa700f9c5edf4d195d0f8c9' gem 'totp' +gem "breadcrumbs_on_rails" # Gems used only for assets and not required # in production environments by default. -- 2.52.0 From 12dce42ef2aa6f571babf7dae93ae1ca1f5870cb Mon Sep 17 00:00:00 2001 From: Tadhg Date: Sun, 21 Apr 2019 16:36:37 -0700 Subject: [PATCH 08/18] Attempt 1 at breadcrumb --- app/controllers/forums_controller.rb | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/app/controllers/forums_controller.rb b/app/controllers/forums_controller.rb index 16ea5b2..2088dc6 100644 --- a/app/controllers/forums_controller.rb +++ b/app/controllers/forums_controller.rb @@ -2,6 +2,19 @@ class ForumsController < ApplicationController before_filter :check_permission, only: [:show, :edit, :update, :destroy] + add_breadcrumb "Forum", :forums_path + + def index + @forum = Forum.all + end + + def show + @forum = Forum.friendly.find(params[:id]) + add_breadcrumb @forum, forum_path(@forum) + end + +end + def index @groups = Forumgroup.select {|g| g.can_view?(current_user) } @groups.sort_by!{ |g| g.position || 0 } -- 2.52.0 From 62d5d421b78d98045a65a8e52971127643e91744 Mon Sep 17 00:00:00 2001 From: Tadhg Date: Sun, 21 Apr 2019 16:38:00 -0700 Subject: [PATCH 09/18] Add sitemap route --- config/routes.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/config/routes.rb b/config/routes.rb index 9fbb267..dc32f8e 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -60,6 +60,8 @@ Redstoner::Application.routes.draw do root to: 'statics#index' end +get '/sitemap.xml' => 'sitemaps#index', defaults: { format: 'xml' } + constraints(host: /^(?!www\.)/i) do match '(*any)' => redirect { |params, request| URI.parse(request.url).tap { |uri| uri.host = "www.#{uri.host}" }.to_s -- 2.52.0 From e98f95adc156a9dd57298d0bd971929e5b78fb99 Mon Sep 17 00:00:00 2001 From: Tadhg Date: Sun, 21 Apr 2019 16:39:24 -0700 Subject: [PATCH 10/18] Create sitemaps_controller.rb --- app/controllers/sitemaps_controller.rb | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 app/controllers/sitemaps_controller.rb diff --git a/app/controllers/sitemaps_controller.rb b/app/controllers/sitemaps_controller.rb new file mode 100644 index 0000000..bde01c8 --- /dev/null +++ b/app/controllers/sitemaps_controller.rb @@ -0,0 +1,16 @@ +class SitemapsController < ApplicationController + + layout :false + before_action :init_sitemap + + def index + @forums = Forum.all + end + + private + + def init_sitemap + headers['Content-Type'] = 'application/xml' + end + +end -- 2.52.0 From ec938b7b0cb5bf86570140bb5b744f8572aa9fe0 Mon Sep 17 00:00:00 2001 From: Tadhg Date: Sun, 21 Apr 2019 16:41:22 -0700 Subject: [PATCH 11/18] Create sitemaps folder --- app/views/sitemaps | 1 + 1 file changed, 1 insertion(+) create mode 100644 app/views/sitemaps diff --git a/app/views/sitemaps b/app/views/sitemaps new file mode 100644 index 0000000..b498fd4 --- /dev/null +++ b/app/views/sitemaps @@ -0,0 +1 @@ +/ -- 2.52.0 From b0e46aec101d818aba172f0bfb149eee2b03db12 Mon Sep 17 00:00:00 2001 From: Tadhg Date: Sun, 21 Apr 2019 16:42:21 -0700 Subject: [PATCH 12/18] Delete sitemaps --- app/views/sitemaps | 1 - 1 file changed, 1 deletion(-) delete mode 100644 app/views/sitemaps diff --git a/app/views/sitemaps b/app/views/sitemaps deleted file mode 100644 index b498fd4..0000000 --- a/app/views/sitemaps +++ /dev/null @@ -1 +0,0 @@ -/ -- 2.52.0 From 153cf3b504150e701d6b9a59fa873c86d24e5dba Mon Sep 17 00:00:00 2001 From: Tadhg Date: Sun, 21 Apr 2019 16:44:57 -0700 Subject: [PATCH 13/18] Create index.xml.builder --- app/views/sitemaps/index.xml.builder | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 app/views/sitemaps/index.xml.builder diff --git a/app/views/sitemaps/index.xml.builder b/app/views/sitemaps/index.xml.builder new file mode 100644 index 0000000..223fbb2 --- /dev/null +++ b/app/views/sitemaps/index.xml.builder @@ -0,0 +1,19 @@ +xml.instruct! :xml, version: '1.0' +xml.tag! 'sitemapindex', 'xmlns' => "http://www.sitemaps.org/schemas/sitemap/0.9" do + + xml.tag! 'url' do + xml.tag! 'loc', root_url + end + + xml.tag! 'url' do + xml.tag! 'loc', contact_url + end + + @posts.each do |post| + xml.tag! 'url' do + xml.tag! 'loc', post_url(post) + xml.lastmod post.updated_at.strftime("%F") + end + end + +end -- 2.52.0 From fa273c3f00b2e0ab3633771051903629426b5b8e Mon Sep 17 00:00:00 2001 From: Tadhg Date: Sun, 21 Apr 2019 16:57:25 -0700 Subject: [PATCH 14/18] Add robots.txt route --- config/routes.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/config/routes.rb b/config/routes.rb index dc32f8e..4c2a822 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -62,6 +62,8 @@ end get '/sitemap.xml' => 'sitemaps#index', defaults: { format: 'xml' } +get "/robots.:format", to: "pages#robots" + constraints(host: /^(?!www\.)/i) do match '(*any)' => redirect { |params, request| URI.parse(request.url).tap { |uri| uri.host = "www.#{uri.host}" }.to_s -- 2.52.0 From 4d6da0484481d6646d54769ad90f275b654e6fba Mon Sep 17 00:00:00 2001 From: Tadhg Date: Sun, 21 Apr 2019 17:00:18 -0700 Subject: [PATCH 15/18] Add robots controller --- app/controllers/forums_controller.rb | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/app/controllers/forums_controller.rb b/app/controllers/forums_controller.rb index 2088dc6..5fc6842 100644 --- a/app/controllers/forums_controller.rb +++ b/app/controllers/forums_controller.rb @@ -2,6 +2,14 @@ class ForumsController < ApplicationController before_filter :check_permission, only: [:show, :edit, :update, :destroy] + class PagesController < ApplicationController + + def robots + respond_to :text + end + +end + add_breadcrumb "Forum", :forums_path def index -- 2.52.0 From c4cdcaa82a79f3562e8900a3ac89bdc26f190426 Mon Sep 17 00:00:00 2001 From: Tadhg Date: Sun, 21 Apr 2019 17:10:58 -0700 Subject: [PATCH 16/18] Add sitemap --- public/robots.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/public/robots.txt b/public/robots.txt index 8c507d8..7b24b92 100644 --- a/public/robots.txt +++ b/public/robots.txt @@ -56,4 +56,6 @@ Disallow: /harm/to/self Crawl-delay: 10 # People don't like being stalked ;) -Disallow: /users \ No newline at end of file +Disallow: /users + +Sitemap: https://redstoner.com/sitemap.xml -- 2.52.0 From fc03e421dd7886dd14134d7c380386b458022b00 Mon Sep 17 00:00:00 2001 From: Tadhg Date: Sun, 21 Apr 2019 17:16:30 -0700 Subject: [PATCH 17/18] undo undo undo --- Gemfile | 1 - 1 file changed, 1 deletion(-) diff --git a/Gemfile b/Gemfile index 3471b67..4ef3294 100644 --- a/Gemfile +++ b/Gemfile @@ -18,7 +18,6 @@ gem 'jquery-textcomplete-rails' # @mentions gem 'actionpack-action_caching', github: 'antulik/actionpack-action_caching', ref: '8c6e52c69315d67437f480da5dce4b7c8737fb32' gem 'mail-gpg', github: 'jomo/mail-gpg', ref: 'a666b48ee866dfa3eaa700f9c5edf4d195d0f8c9' gem 'totp' -gem "breadcrumbs_on_rails" # Gems used only for assets and not required # in production environments by default. -- 2.52.0 From e966f953e18b78cc5cfd303c00fc29f9669713dd Mon Sep 17 00:00:00 2001 From: Tadhg Date: Sun, 21 Apr 2019 17:17:42 -0700 Subject: [PATCH 18/18] undo undo undo --- app/controllers/forums_controller.rb | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/app/controllers/forums_controller.rb b/app/controllers/forums_controller.rb index 5fc6842..279067f 100644 --- a/app/controllers/forums_controller.rb +++ b/app/controllers/forums_controller.rb @@ -1,26 +1,11 @@ class ForumsController < ApplicationController before_filter :check_permission, only: [:show, :edit, :update, :destroy] - - class PagesController < ApplicationController def robots respond_to :text end -end - - add_breadcrumb "Forum", :forums_path - - def index - @forum = Forum.all - end - - def show - @forum = Forum.friendly.find(params[:id]) - add_breadcrumb @forum, forum_path(@forum) - end - end def index -- 2.52.0