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



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

def bootstrap
  @bootstrap
end

#clustersOpenStruct

Cluster information for local HPC center

Returns:

  • (OpenStruct)

    hash of available clusters



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

def clusters
  @clusters
end

#dashboardDashboardUrl

System dashboard app url handler

Returns:

  • (DashboardUrl)

    the url handler for the system dashboard app



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

def dashboard
  @dashboard
end

#datarootPathname?

Location where app data is stored on local filesystem

Returns:

  • (Pathname, nil)

    path to app data



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

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

#editorEditorUrl

System file editor app url handler

Returns:

  • (EditorUrl)

    the url handler for the system file editor app



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

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



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

def enable_log_formatter
  @enable_log_formatter
end

#filesFilesUrl

System files app url handler

Returns:

  • (FilesUrl)

    the url handler for the system files app



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

def files
  @files
end

#markdownRedcarpet::Markdown

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

Returns:

  • (Redcarpet::Markdown)

    the markdown renderer used



20
21
22
# File 'lib/ood_appkit/configuration.rb', line 20

def markdown
  @markdown
end

#publicPublicUrl

Public assets url handler

Returns:

  • (PublicUrl)

    the url handler for the publicly available assets



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

def public
  @public
end

#routesOpenStruct

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

Returns:

  • (OpenStruct)

    whether to generate routes for apps



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

def routes
  @routes
end

#shellShellUrl

System shell app url handler

Returns:

  • (ShellUrl)

    the url handler for the system shell app



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

def shell
  @shell
end

Instance Method Details

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

Customize configuration for this object.

Yields:

  • (self)


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

def configure
  yield self
end

#set_default_configurationvoid

This method returns an undefined value.

Sets the default configuration for this object.



63
64
65
66
67
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
125
126
127
# File 'lib/ood_appkit/configuration.rb', line 63

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']

  # Initialize list of available clusters
  self.clusters = OpenStruct.new
  clusters.all = OodAppkit::Cluster.all( ENV['OOD_CLUSTERS'] ? {file: ENV['OOD_CLUSTERS']} : {} )
  def clusters.hpc
    all.select {|k,v| v.hpc_cluster?}
  end
  def clusters.lpc
    all.reject {|k,v| v.hpc_cluster?}
  end

  # 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    = PublicUrl.new(
    title:    ENV['OOD_PUBLIC_TITLE'] || 'Public Assets',
    base_url: ENV['OOD_PUBLIC_URL']   || '/public'
  )
  self.dashboard = DashboardUrl.new(
    title:    ENV['OOD_DASHBOARD_TITLE'] || 'Dashboard',
    base_url: ENV['OOD_DASHBOARD_URL']   || '/pun/sys/dashboard'
  )
  self.shell     = ShellUrl.new(
    title:    ENV['OOD_SHELL_TITLE'] || 'Shell',
    base_url: ENV['OOD_SHELL_URL']   || '/pun/sys/shell'
  )
  self.files     = FilesUrl.new(
    title:    ENV['OOD_FILES_TITLE'] || 'Files',
    base_url: ENV['OOD_FILES_URL']   || '/pun/sys/files'
  )
  self.editor    = EditorUrl.new(
    title:    ENV['OOD_EDITOR_TITLE'] || 'Editor',
    base_url: ENV['OOD_EDITOR_URL']   || '/pun/sys/file-editor'
  )

  # 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