The Great SEO Revamp of 2019 #59
@@ -1,7 +1,13 @@
|
||||
class ForumsController < ApplicationController
|
||||
|
||||
before_filter :check_permission, only: [:show, :edit, :update, :destroy]
|
||||
|
||||
def robots
|
||||
respond_to :text
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
def index
|
||||
@groups = Forumgroup.select {|g| g.can_view?(current_user) }
|
||||
@groups.sort_by!{ |g| g.position || 0 }
|
||||
|
||||
16
app/controllers/sitemaps_controller.rb
Normal file
16
app/controllers/sitemaps_controller.rb
Normal file
@@ -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
|
||||
14
app/helpers/meta_tags_helper.rb
Normal file
14
app/helpers/meta_tags_helper.rb
Normal file
@@ -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,8 +2,28 @@
|
||||
<html>
|
||||
<head>
|
||||
<title><%= yield(:site_title).present? ? "#{yield(:site_title)} – " : "" %>Redstoner</title>
|
||||
|
||||
<!-- begin meta -->
|
||||
<meta name="viewport" content="initial-scale=1,maximum-scale=1">
|
||||
<meta name="description" content="Redstoner is a creative minecraft server made for redstoners">
|
||||
<meta name="description" content="#{meta_description}">
|
||||
|
||||
<!-- Facebook Open Graph data -->
|
||||
<meta property="og:title" content="#{meta_title}">
|
||||
<meta property="og:type" content="website">
|
||||
<meta property="og:url" content="#{request.original_url}">
|
||||
<meta property="og:image" content="#{meta_image}">
|
||||
<meta property="og:description" content="#{meta_description}">
|
||||
<meta property="og:site_name" content="#{meta_title}">
|
||||
|
||||
<!-- Twitter Card data -->
|
||||
<meta name="twitter:card" content="summary_large_image">
|
||||
<meta name="twitter:site" content="#{DEFAULT_META["twitter_account"]}">
|
||||
<meta name="twitter:title" content="#{meta_title}">
|
||||
<meta name="twitter:description" content="#{meta_description}">
|
||||
<meta name="twitter:creator" content="#{DEFAULT_META["twitter_account"]}">
|
||||
<meta name="twitter:image:src" content="#{meta_image}">
|
||||
<!-- end meta -->
|
||||
|
||||
<%= stylesheet_link_tag "application", :media => "all" %>
|
||||
<% if current_user.try(:dark) == true %>
|
||||
<%= stylesheet_link_tag "dark", :media => "all" %>
|
||||
|
||||
19
app/views/sitemaps/index.xml.builder
Normal file
19
app/views/sitemaps/index.xml.builder
Normal file
@@ -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
|
||||
@@ -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
|
||||
|
||||
1
config/initializers/default_meta.rb
Normal file
1
config/initializers/default_meta.rb
Normal file
@@ -0,0 +1 @@
|
||||
DEFAULT_META = YAML.load_file(Rails.root.join("config/meta.yml"))
|
||||
4
config/meta.yml
Normal file
4
config/meta.yml
Normal file
@@ -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"
|
||||
@@ -59,3 +59,13 @@ Redstoner::Application.routes.draw do
|
||||
|
||||
root to: 'statics#index'
|
||||
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
|
||||
}
|
||||
end
|
||||
|
||||
4
public/robots.txt
vendored
4
public/robots.txt
vendored
@@ -56,4 +56,6 @@ Disallow: /harm/to/self
|
||||
Crawl-delay: 10
|
||||
|
||||
# People don't like being stalked ;)
|
||||
Disallow: /users
|
||||
Disallow: /users
|
||||
|
||||
Sitemap: https://redstoner.com/sitemap.xml
|
||||
|
||||
Reference in New Issue
Block a user