Add plausible
This commit is contained in:
parent
f47b32c5bc
commit
671162f6a2
|
@ -8,7 +8,7 @@ class ApplicationController < ActionController::Base
|
||||||
before_action :initialize_session
|
before_action :initialize_session
|
||||||
before_action :normalize_search
|
before_action :normalize_search
|
||||||
before_action :set_common_headers
|
before_action :set_common_headers
|
||||||
helper_method :site_domain, :assets_path, :safe_site_name, :site_title, :site_color, :controller_param, :action_param, :body_class, :stimulus_class
|
helper_method :plausible_domain, :site_domain, :assets_path, :safe_site_name, :site_title, :site_color, :controller_param, :action_param, :body_class, :stimulus_class
|
||||||
skip_before_action :verify_authenticity_token
|
skip_before_action :verify_authenticity_token
|
||||||
|
|
||||||
rescue_from Exception, with: :rescue_exception
|
rescue_from Exception, with: :rescue_exception
|
||||||
|
@ -29,6 +29,10 @@ class ApplicationController < ActionController::Base
|
||||||
CurrentUser.ip_addr = request.remote_ip
|
CurrentUser.ip_addr = request.remote_ip
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def plausible_domain
|
||||||
|
nil
|
||||||
|
end
|
||||||
|
|
||||||
def site_domain
|
def site_domain
|
||||||
"unknown"
|
"unknown"
|
||||||
end
|
end
|
||||||
|
|
|
@ -6,6 +6,10 @@ module ButtsAreCool
|
||||||
ButtsAreCoolRoutes::DOMAIN
|
ButtsAreCoolRoutes::DOMAIN
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def plausible_domain
|
||||||
|
"butts-are.cool"
|
||||||
|
end
|
||||||
|
|
||||||
def site_title
|
def site_title
|
||||||
"Butts Are Cool"
|
"Butts Are Cool"
|
||||||
end
|
end
|
||||||
|
|
|
@ -6,6 +6,10 @@ module E621Ws
|
||||||
E621WsRoutes::DOMAIN
|
E621WsRoutes::DOMAIN
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def plausible_domain
|
||||||
|
"e621.ws"
|
||||||
|
end
|
||||||
|
|
||||||
def assets_path
|
def assets_path
|
||||||
E621WsRoutes::DOMAIN
|
E621WsRoutes::DOMAIN
|
||||||
end
|
end
|
||||||
|
|
|
@ -6,6 +6,10 @@ module FurryCool
|
||||||
FurryCoolRoutes::DOMAIN
|
FurryCoolRoutes::DOMAIN
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def plausible_domain
|
||||||
|
"furry.cool"
|
||||||
|
end
|
||||||
|
|
||||||
def site_title
|
def site_title
|
||||||
"Donovan_DMC"
|
"Donovan_DMC"
|
||||||
end
|
end
|
||||||
|
|
|
@ -6,6 +6,10 @@ module MaidboyeCafe
|
||||||
MaidboyeCafeRoutes::DOMAIN
|
MaidboyeCafeRoutes::DOMAIN
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def plausible_domain
|
||||||
|
"maidboye.cafe"
|
||||||
|
end
|
||||||
|
|
||||||
def site_title
|
def site_title
|
||||||
"Maid Boye"
|
"Maid Boye"
|
||||||
end
|
end
|
||||||
|
|
|
@ -6,6 +6,10 @@ module OceanicWs
|
||||||
OceanicWsRoutes::DOMAIN
|
OceanicWsRoutes::DOMAIN
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def plausible_domain
|
||||||
|
"oceanic.ws"
|
||||||
|
end
|
||||||
|
|
||||||
def site_title
|
def site_title
|
||||||
"Oceanic"
|
"Oceanic"
|
||||||
end
|
end
|
||||||
|
|
|
@ -6,6 +6,10 @@ module YiffMedia
|
||||||
YiffMediaRoutes::DOMAIN
|
YiffMediaRoutes::DOMAIN
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def plausible_domain
|
||||||
|
"yiff.media"
|
||||||
|
end
|
||||||
|
|
||||||
def site_title
|
def site_title
|
||||||
"YiffyAPI"
|
"YiffyAPI"
|
||||||
end
|
end
|
||||||
|
|
|
@ -12,6 +12,10 @@ module YiffRest
|
||||||
YiffRestRoutes::DOMAIN
|
YiffRestRoutes::DOMAIN
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def plausible_domain
|
||||||
|
"yiff.rest"
|
||||||
|
end
|
||||||
|
|
||||||
def site_title
|
def site_title
|
||||||
"YiffyAPI"
|
"YiffyAPI"
|
||||||
end
|
end
|
||||||
|
|
21
app/controllers/yiff_rocks/application_controller.rb
Normal file
21
app/controllers/yiff_rocks/application_controller.rb
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
module YiffRocks
|
||||||
|
class ApplicationController < YiffRest::ApplicationController
|
||||||
|
def site_domain
|
||||||
|
YiffRocksRoutes::DOMAIN
|
||||||
|
end
|
||||||
|
|
||||||
|
def plausible_domain
|
||||||
|
"yiff.rocks"
|
||||||
|
end
|
||||||
|
|
||||||
|
def site_title
|
||||||
|
"Yiff Rocks - URL Shortener"
|
||||||
|
end
|
||||||
|
|
||||||
|
def assets_path
|
||||||
|
YiffMediaRoutes::DOMAIN
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -1,7 +1,7 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
module YiffRocks
|
module YiffRocks
|
||||||
class HomeController < YiffRest::ApplicationController
|
class HomeController < ApplicationController
|
||||||
include ::ApplicationController::ReadonlyMethods
|
include ::ApplicationController::ReadonlyMethods
|
||||||
before_action :handle_ratelimit, only: %i[create update destroy]
|
before_action :handle_ratelimit, only: %i[create update destroy]
|
||||||
before_action :validate_api_key_required, only: %i[create update destroy]
|
before_action :validate_api_key_required, only: %i[create update destroy]
|
||||||
|
@ -61,18 +61,6 @@ module YiffRocks
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def site_domain
|
|
||||||
YiffRocksRoutes::DOMAIN
|
|
||||||
end
|
|
||||||
|
|
||||||
def site_title
|
|
||||||
"Yiff Rocks - URL Shortener"
|
|
||||||
end
|
|
||||||
|
|
||||||
def assets_path
|
|
||||||
YiffMediaRoutes::DOMAIN
|
|
||||||
end
|
|
||||||
|
|
||||||
def short_url_params(context = nil)
|
def short_url_params(context = nil)
|
||||||
permitted_params = %i[url credit creator_name]
|
permitted_params = %i[url credit creator_name]
|
||||||
permitted_params += %i[code] if context == :create
|
permitted_params += %i[code] if context == :create
|
||||||
|
|
2
app/javascript/@types/global.d.ts
vendored
2
app/javascript/@types/global.d.ts
vendored
|
@ -1,6 +1,6 @@
|
||||||
|
|
||||||
interface Window {
|
interface Window {
|
||||||
Stimulus: import("@hotwired/stimulus").Application
|
Stimulus: import("@hotwired/stimulus").Application;
|
||||||
jQuery: JQueryStatic;
|
jQuery: JQueryStatic;
|
||||||
$: JQueryStatic;
|
$: JQueryStatic;
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,9 @@
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<%= csrf_meta_tags %>
|
<%= csrf_meta_tags %>
|
||||||
<%= csp_meta_tag %>
|
<%= csp_meta_tag %>
|
||||||
|
<% if Websites.config.enable_analytics && plausible_domain.present? %>
|
||||||
|
<%= Websites.config.plausible_script(plausible_domain).html_safe %>
|
||||||
|
<% end %>
|
||||||
<% if content_for(:html_head) %>
|
<% if content_for(:html_head) %>
|
||||||
<%= yield :html_head %>
|
<%= yield :html_head %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
|
@ -199,7 +199,8 @@ module Websites
|
||||||
].join("; "),
|
].join("; "),
|
||||||
"Content-Security-Policy": [
|
"Content-Security-Policy": [
|
||||||
"default-src 'self' #{domain} *.#{domain}",
|
"default-src 'self' #{domain} *.#{domain}",
|
||||||
"script-src 'self' 'unsafe-inline' #{domain} *.#{domain} https://cdnjs.cloudflare.com https://static.cloudflareinsights.com",
|
"script-src 'self' 'unsafe-inline' #{domain} *.#{domain} https://cdnjs.cloudflare.com https://static.cloudflareinsights.com https://plausible.furry.computer",
|
||||||
|
"connect-src 'self' https://plausible.furry.computer",
|
||||||
"style-src 'self' 'unsafe-inline' #{domain} *.#{domain} https://cdnjs.cloudflare.com https://fonts.googleapis.com",
|
"style-src 'self' 'unsafe-inline' #{domain} *.#{domain} https://cdnjs.cloudflare.com https://fonts.googleapis.com",
|
||||||
"img-src 'self' https: data:",
|
"img-src 'self' https: data:",
|
||||||
"font-src 'self' https: data:",
|
"font-src 'self' https: data:",
|
||||||
|
@ -267,6 +268,14 @@ module Websites
|
||||||
|
|
||||||
def exceptions_domain
|
def exceptions_domain
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def enable_analytics
|
||||||
|
Rails.env.production?
|
||||||
|
end
|
||||||
|
|
||||||
|
def plausible_script(domain)
|
||||||
|
%(<script defer data-domain="#{domain}" src="https://plausible.furry.computer/js/script.js"></script>)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class EnvironmentConfiguration
|
class EnvironmentConfiguration
|
||||||
|
|
Loading…
Reference in New Issue
Block a user