Module: OodAppkit::Configuration

Included in:
OodAppkit
Defined in:
lib/ood_appkit/configuration.rb

Overview

An object that stores and adds configuration options.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#bootstrapOpenStruct

Override Boostrap SASS variables in app

Returns:

  • (OpenStruct)

    bootstrap variables to override



53
54
55
# File 'lib/ood_appkit/configuration.rb', line 53

def bootstrap
  @bootstrap
end

#clustersOodCore::Clusters

Cluster information for local HPC center

Returns:

  • (OodCore::Clusters)

    hash of available clusters



17
18
19
# File 'lib/ood_appkit/configuration.rb', line 17

def clusters
  @clusters ||= parse_clusters(ENV['OOD_CLUSTERS'])
end

#dashboardDashboardUrl

System dashboard app url handler

Returns:

  • (DashboardUrl)

    the url handler for the system dashboard app



33
34
35
# File 'lib/ood_appkit/configuration.rb', line 33

def dashboard
  @dashboard
end

#datarootPathname?

Location where app data is stored on local filesystem

Returns:

  • (Pathname, nil)

    path to app data



10
11
12
# File 'lib/ood_appkit/configuration.rb', line 10

def dataroot
  Pathname.new(@dataroot).expand_path if @dataroot
end

#editorEditorUrl

System file editor app url handler

Returns:

  • (EditorUrl)

    the url handler for the system file editor app



45
46
47
# File 'lib/ood_appkit/configuration.rb', line 45

def editor
  @editor
end

#enable_log_formatterboolean

Set to false if you don’t want Rails.logger formatter to use LogFormatter and lograge to be enabled automatically

Returns:

  • (boolean)

    whether to use OodAppkit log formatting in production



58
59
60
# File 'lib/ood_appkit/configuration.rb', line 58

def enable_log_formatter
  @enable_log_formatter
end

#filesFilesUrl

System files app url handler

Returns:

  • (FilesUrl)

    the url handler for the system files app



41
42
43
# File 'lib/ood_appkit/configuration.rb', line 41

def files
  @files
end

#markdownRedcarpet::Markdown

A markdown renderer used when rendering ‘*.md` or `*.markdown` views

Returns:

  • (Redcarpet::Markdown)

    the markdown renderer used



25
26
27
# File 'lib/ood_appkit/configuration.rb', line 25

def markdown
  @markdown
end

#publicPublicUrl

Public assets url handler

Returns:

  • (PublicUrl)

    the url handler for the publicly available assets



29
30
31
# File 'lib/ood_appkit/configuration.rb', line 29

def public
  @public
end

#routesOpenStruct

Whether to auto-generate default routes for helpful apps/features

Returns:

  • (OpenStruct)

    whether to generate routes for apps



49
50
51
# File 'lib/ood_appkit/configuration.rb', line 49

def routes
  @routes
end

#shellShellUrl

System shell app url handler

Returns:

  • (ShellUrl)

    the url handler for the system shell app



37
38
39
# File 'lib/ood_appkit/configuration.rb', line 37

def shell
  @shell
end

Instance Method Details

#configure {|self| ... } ⇒ Object

Customize configuration for this object.

Yields:

  • (self)


62
63
64
# File 'lib/ood_appkit/configuration.rb', line 62

def configure
  yield self
end

#set_default_configurationvoid

This method returns an undefined value.

Sets the default configuration for this object.



68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
# File 'lib/ood_appkit/configuration.rb', line 68

def set_default_configuration
  ActiveSupport::Deprecation.warn("The environment variable RAILS_DATAROOT will be deprecated in an upcoming release, please use OOD_DATAROOT instead.") if ENV['RAILS_DATAROOT']
  self.dataroot = ENV['OOD_DATAROOT'] || ENV['RAILS_DATAROOT']
  self.dataroot ||= "~/#{ENV['OOD_PORTAL'] || "ondemand"}/data/#{ENV['APP_TOKEN']}" if ENV['APP_TOKEN']

  # Add markdown template support
  self.markdown = Redcarpet::Markdown.new(
    Redcarpet::Render::HTML,
    autolink: true,
    tables: true,
    strikethrough: true,
    fenced_code_blocks: true,
    no_intra_emphasis: true
  )

  # Initialize URL handlers for system apps
  self.public    = Urls::Public.new(
    title:    ENV['OOD_PUBLIC_TITLE'] || 'Public Assets',
    base_url: ENV['OOD_PUBLIC_URL']   || '/public'
  )
  self.dashboard = Urls::Dashboard.new(
    title:    ENV['OOD_DASHBOARD_TITLE'] || 'Open OnDemand',
    base_url: ENV['OOD_DASHBOARD_URL']   || '/pun/sys/dashboard'
  )
  self.shell     = Urls::Shell.new(
    title:    ENV['OOD_SHELL_TITLE'] || 'Shell',
    base_url: ENV['OOD_SHELL_URL']   || '/pun/sys/shell'
  )
  self.files     = Urls::Files.new(
    title:    ENV['OOD_FILES_TITLE'] || 'Files',
    base_url: ENV['OOD_FILES_URL']   || '/pun/sys/dashboard/files'
  )
  self.editor    = Urls::Editor.new(
    title:    ENV['OOD_EDITOR_TITLE'] || 'Editor',
    # this is not a typo => the editor is /edit off of the base url
    base_url: ENV['OOD_EDITOR_URL']   || '/pun/sys/dashboard/files'
  )

  # Add routes for useful features
  self.routes = OpenStruct.new(
    files_rack_app: true,
    wiki: true
  )

  # Override Bootstrap SASS variables
  self.bootstrap = OpenStruct.new(
    navbar_inverse_bg: '#53565a',
    navbar_inverse_link_color: '#fff',
    navbar_inverse_color: '$navbar-inverse-link-color',
    navbar_inverse_link_hover_color: 'darken($navbar-inverse-link-color, 20%)',
    navbar_inverse_brand_color: '$navbar-inverse-link-color',
    navbar_inverse_brand_hover_color: '$navbar-inverse-link-hover-color'
  )
  ENV.each {|k, v| /^BOOTSTRAP_(?<name>.+)$/ =~ k ? self.bootstrap[name.downcase] = v : nil}

  self.enable_log_formatter = ::Rails.env.production?
end