mirror of
https://github.com/Retrospring/retrospring.git
synced 2025-01-19 10:16:03 +01:00
87ec3093a9
this uses our ✨new and improved✨ logo by default, but can be easily changed by modifying `/public/logo.svg`. the svg is loaded only once when the application starts, so any modifications to it after a deployment are visible immediately. thanks to the power of CSS and SVG being able to make use of it, custom colour schemes still work too.
20 lines
767 B
Ruby
20 lines
767 B
Ruby
# frozen_string_literal: true
|
|
|
|
return unless APP_CONFIG[:use_svg_logo]
|
|
|
|
begin
|
|
logo_path = Rails.public_path.join("logo.svg")
|
|
# we are only interested in the first element which should be the <svg> node --> extract it and transform some attributes
|
|
logo_svg = File.read(logo_path)
|
|
svg_doc = Nokogiri::XML(logo_svg)
|
|
svg_node = svg_doc.first_element_child
|
|
# remove some attributes that might interfere with the rest of the layout
|
|
%w[id name class width height].each do |attr|
|
|
svg_node.remove_attribute attr
|
|
end
|
|
|
|
Rails.application.config.justask_svg_logo = svg_node.to_xml
|
|
rescue => e
|
|
warn "use_svg_logo is enabled, but the SVG could not be read due to: #{e.message} (#{e.class.name}). Disabling SVG logo."
|
|
APP_CONFIG[:use_svg_logo] = false
|
|
end
|