class Voom::Presenters::WebClient::CustomCss
This class renders custom CSS for the layout It looks for public/presenters/global.css first It then looks for public/presenters/#{env}.css
Attributes
host[R]
path[R]
root[R]
Public Class Methods
new(path, root:, host:)
click to toggle source
# File lib/voom/presenters/web_client/custom_css.rb, line 12 def initialize(path, root:, host:) @path = path @root = root @host = host end
Public Instance Methods
render()
click to toggle source
# File lib/voom/presenters/web_client/custom_css.rb, line 18 def render return unless custom_css_path [global_css, global_namespace_css(path), presenter_css(path)].join end
Private Instance Methods
_build_css_link_(path)
click to toggle source
# File lib/voom/presenters/web_client/custom_css.rb, line 57 def _build_css_link_(path) (<<~CSS) <link rel="stylesheet" type="text/css" href="#{host}/#{path.sub('public/', '')}"> CSS end
custom_css_path()
click to toggle source
# File lib/voom/presenters/web_client/custom_css.rb, line 25 def custom_css_path Presenters::Settings.config.presenters.web_client.custom_css end
global_css()
click to toggle source
loads a global css file - by default located at `public/presenters/global.css`
# File lib/voom/presenters/web_client/custom_css.rb, line 30 def global_css css_file = File.join(custom_css_path, 'global.css') full_path = File.join(root, css_file) _build_css_link_(css_file) if File.exists?(full_path) end
global_namespace_css(path)
click to toggle source
# File lib/voom/presenters/web_client/custom_css.rb, line 36 def global_namespace_css(path) return unless custom_css_path && path namespace_path = path.split('/').reject { |c| c.empty? }.first css_file = File.join(custom_css_path, namespace_path ? namespace_path : '') css_file = File.join(css_file, 'global.css') full_path = File.join(root, css_file) trace {"Loading global namespace: #{full_path}"} _build_css_link_(css_file) if File.exists?(full_path) end
presenter_css(path)
click to toggle source
loads a custom css file that matches the presenter namespace/presenter.css by default located at public/presenters/#{namespace}/#{presenter}.css
# File lib/voom/presenters/web_client/custom_css.rb, line 48 def presenter_css(path) return unless custom_css_path && path css_file = File.join(custom_css_path, path) css_file = File.join(css_file, 'index') if path == '/' css_file = "#{css_file}.css" full_path = File.join(root, css_file) _build_css_link_(css_file) if File.exists?(full_path) end