class AdminUI::Context
Web context for the UI
Attributes
Public Class Methods
Source
# File app/lib/ui/context.rb, line 258 def initialize(route, params, title: nil, show_formats: true) @route = route @params = params page = TopMenu.instance.route_names[route] deftitle = title || File.basename(route).capitalize @title = page ? page.fetch(:title, deftitle) : deftitle @description = TopMenu.instance.description_for_route(@route) @breadcrumbs = breadcrumbs # Breadcrumbs are an array of hashes with keys :title and :url @show_formats = show_formats @ctime = if File.exist?('/var/tast/Gemfile.lock') File.ctime('/var/task/Gemfile.lock').strftime('%Y%m%d_%H%M%S') else Time.now.strftime('%Y%m%d_%H%M%S') end end
Public Instance Methods
Source
# File app/lib/ui/context.rb, line 301 def altformats return unless @show_formats %( <a href="#{UC3::UC3Client.make_url_with_key(@route, @params, 'admintoolformat', 'json')}">JSON</a> <a href="#{UC3::UC3Client.make_url_with_key(@route, @params, 'admintoolformat', 'csv')}">CSV</a> <a href="#{UC3::UC3Client.make_url_with_key(@route, @params, 'admintoolformat', 'text')}">TEXT</a> ) end
Source
# File app/lib/ui/context.rb, line 276 def classes classes = [] begin classes << 'no-db' unless UC3Query::QueryClient.client.enabled classes << 'no-zk' unless UC3Queue::ZKClient.client.enabled || UC3::UC3Client.dbsnapshot_stack? classes << 'no-ldap' unless UC3Ldap::LDAPClient.client.enabled rescue StandardError # allow clients to be commented out for debugging end classes end
Source
# File app/lib/ui/context.rb, line 292 def description description = Redcarpet::Markdown.new( Redcarpet::Render::HTML.new, fenced_code_blocks: true, tables: true ).render(@description) Mustache.render(description, ENV) end
Source
# File app/lib/ui/context.rb, line 311 def to_h { title: @title, route: @route, description: @description } end