Include git hash in http headers and <meta> tags.
* Add X-Git-Hash http header. * Add `<meta name="git-hash" content="<hash>">` meta tag. * Include full hash in development mode.
This commit is contained in:
@@ -13,7 +13,7 @@ class ApplicationController < ActionController::Base
|
|||||||
before_action :api_check
|
before_action :api_check
|
||||||
before_action :ip_ban_check
|
before_action :ip_ban_check
|
||||||
before_action :set_variant
|
before_action :set_variant
|
||||||
before_action :enable_cors
|
before_action :add_headers
|
||||||
before_action :cause_error
|
before_action :cause_error
|
||||||
after_action :reset_current_user
|
after_action :reset_current_user
|
||||||
layout "default"
|
layout "default"
|
||||||
@@ -65,8 +65,9 @@ class ApplicationController < ActionController::Base
|
|||||||
|
|
||||||
protected
|
protected
|
||||||
|
|
||||||
def enable_cors
|
def add_headers
|
||||||
response.headers["Access-Control-Allow-Origin"] = "*"
|
response.headers["Access-Control-Allow-Origin"] = "*"
|
||||||
|
response.headers["X-Git-Hash"] = Rails.application.config.x.git_hash
|
||||||
end
|
end
|
||||||
|
|
||||||
def api_check
|
def api_check
|
||||||
|
|||||||
@@ -77,6 +77,8 @@
|
|||||||
<%= tag.meta name: "twitter:title", content: page_title %>
|
<%= tag.meta name: "twitter:title", content: page_title %>
|
||||||
<%= tag.meta name: "twitter:description", content: meta_description %>
|
<%= tag.meta name: "twitter:description", content: meta_description %>
|
||||||
|
|
||||||
|
<%= tag.meta name: "git-hash", content: Rails.application.config.x.git_hash %>
|
||||||
|
|
||||||
<%= yield :html_header %>
|
<%= yield :html_header %>
|
||||||
<%= raw Danbooru.config.custom_html_header_content %>
|
<%= raw Danbooru.config.custom_html_header_content %>
|
||||||
</head>
|
</head>
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ module Danbooru
|
|||||||
if File.exist?("#{config.root}/REVISION")
|
if File.exist?("#{config.root}/REVISION")
|
||||||
config.x.git_hash = File.read("#{config.root}/REVISION").strip
|
config.x.git_hash = File.read("#{config.root}/REVISION").strip
|
||||||
elsif system("type git > /dev/null && git rev-parse --show-toplevel > /dev/null")
|
elsif system("type git > /dev/null && git rev-parse --show-toplevel > /dev/null")
|
||||||
config.x.git_hash = `git rev-parse --short HEAD`.strip
|
config.x.git_hash = `git rev-parse HEAD`.strip
|
||||||
else
|
else
|
||||||
config.x.git_hash = nil
|
config.x.git_hash = nil
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user