DEV: Apply syntax_tree formatting to app/*

This commit is contained in:
David Taylor
2023-01-09 12:20:10 +00:00
parent a641ce4b62
commit 5a003715d3
696 changed files with 18447 additions and 15481 deletions

View File

@@ -1,14 +1,17 @@
# frozen_string_literal: true
class SvgSpriteController < ApplicationController
skip_before_action :preload_json, :redirect_to_login_if_required, :check_xhr, :verify_authenticity_token, only: [:show, :search, :svg_icon]
skip_before_action :preload_json,
:redirect_to_login_if_required,
:check_xhr,
:verify_authenticity_token,
only: %i[show search svg_icon]
before_action :apply_cdn_headers, only: [:show, :search, :svg_icon]
before_action :apply_cdn_headers, only: %i[show search svg_icon]
requires_login except: [:show, :svg_icon]
requires_login except: %i[show svg_icon]
def show
no_cookies
RailsMultisite::ConnectionManagement.with_hostname(params[:hostname]) do
@@ -24,20 +27,19 @@ class SvgSpriteController < ApplicationController
response.headers["Content-Length"] = svg_sprite.bytesize.to_s
immutable_for 1.year
render plain: svg_sprite, disposition: nil, content_type: 'application/javascript'
render plain: svg_sprite, disposition: nil, content_type: "application/javascript"
end
end
def search
RailsMultisite::ConnectionManagement.with_hostname(params[:hostname]) do
keyword = params.require(:keyword)
data = SvgSprite.search(keyword)
if data.blank?
render body: nil, status: 404
else
render plain: data.inspect, disposition: nil, content_type: 'text/plain'
render plain: data.inspect, disposition: nil, content_type: "text/plain"
end
end
end
@@ -65,14 +67,14 @@ class SvgSpriteController < ApplicationController
else
doc = Nokogiri.XML(icon)
doc.at_xpath("symbol").name = "svg"
doc.at_xpath("svg")['xmlns'] = "http://www.w3.org/2000/svg"
doc.at_xpath("svg")['fill'] = adjust_hex(params[:color]) if params[:color]
doc.at_xpath("svg")["xmlns"] = "http://www.w3.org/2000/svg"
doc.at_xpath("svg")["fill"] = adjust_hex(params[:color]) if params[:color]
response.headers["Last-Modified"] = 1.years.ago.httpdate
response.headers["Content-Length"] = doc.to_s.bytesize.to_s
immutable_for 1.day
render plain: doc, disposition: nil, content_type: 'image/svg+xml'
render plain: doc, disposition: nil, content_type: "image/svg+xml"
end
end
end