bord 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.md +193 -0
  4. data/Rakefile +9 -0
  5. data/app/assets/javascripts/bord/application.js +2361 -0
  6. data/app/assets/javascripts/bord/attract.js +319 -0
  7. data/app/assets/javascripts/bord/attractive.js +1642 -0
  8. data/app/assets/javascripts/bord/entry.js +67 -0
  9. data/app/assets/javascripts/bord/request.js +314 -0
  10. data/app/assets/javascripts/bord/runtime/addons/response.js +51 -0
  11. data/app/assets/javascripts/bord/runtime/addons/template.js +120 -0
  12. data/app/assets/javascripts/bord/runtime/debug.js +18 -0
  13. data/app/assets/stylesheets/bord/application.css +736 -0
  14. data/app/controllers/bord/actions_controller.rb +29 -0
  15. data/app/controllers/bord/application_controller.rb +23 -0
  16. data/app/controllers/bord/pages_controller.rb +13 -0
  17. data/app/controllers/bord/records_controller.rb +14 -0
  18. data/app/controllers/bord/widgets_controller.rb +18 -0
  19. data/app/helpers/bord/application_helper.rb +4 -0
  20. data/app/jobs/bord/application_job.rb +4 -0
  21. data/app/models/bord/action.rb +8 -0
  22. data/app/models/bord/action_parameters.rb +19 -0
  23. data/app/models/bord/allowed_actions.rb +65 -0
  24. data/app/models/bord/application_record.rb +5 -0
  25. data/app/models/bord/attract_actions.rb +101 -0
  26. data/app/models/bord/category.rb +18 -0
  27. data/app/models/bord/dashboard.rb +25 -0
  28. data/app/models/bord/entry.rb +98 -0
  29. data/app/models/bord/page/decorator.rb +33 -0
  30. data/app/models/bord/page/record_decorator.rb +44 -0
  31. data/app/models/bord/page.rb +82 -0
  32. data/app/models/bord/widget/decorator.rb +69 -0
  33. data/app/models/bord/widget.rb +40 -0
  34. data/app/models/concerns/bord/conditionable.rb +8 -0
  35. data/app/views/bord/pages/show.html.erb +9 -0
  36. data/app/views/bord/records/show.html.erb +13 -0
  37. data/app/views/bord/shared/_templates.html.erb +75 -0
  38. data/app/views/bord/widgets/_action.html.erb +7 -0
  39. data/app/views/bord/widgets/_widget.html.erb +25 -0
  40. data/app/views/bord/widgets/index.html.erb +17 -0
  41. data/app/views/layouts/bord/application.html.erb +38 -0
  42. data/config/routes.rb +11 -0
  43. data/lib/bord/configuration.rb +60 -0
  44. data/lib/bord/engine.rb +11 -0
  45. data/lib/bord/loader.rb +8 -0
  46. data/lib/bord/options.rb +17 -0
  47. data/lib/bord/presets/action_mailbox.json +20 -0
  48. data/lib/bord/presets/active_storage.json +20 -0
  49. data/lib/bord/presets/devise.json +1 -0
  50. data/lib/bord/presets/good_job.json +25 -0
  51. data/lib/bord/presets/sidekiq.json +28 -0
  52. data/lib/bord/presets/solid_queue.json +12 -0
  53. data/lib/bord/presets/stripe.json +30 -0
  54. data/lib/bord/presets/user.json +22 -0
  55. data/lib/bord/version.rb +3 -0
  56. data/lib/bord.rb +71 -0
  57. data/lib/generators/bord/install_generator.rb +16 -0
  58. data/lib/generators/bord/presets_generator.rb +62 -0
  59. metadata +116 -0
@@ -0,0 +1,40 @@
1
+ module Bord
2
+ class Widget
3
+ include Conditionable
4
+
5
+ attr_reader :id, :kind, :label, :icon, :href, :actions, :position
6
+
7
+ def initialize(id:, kind:, label: nil, icon: nil, href: nil, items: nil, value: nil, actions: [], position: nil, **options)
8
+ @id = id.to_s.parameterize
9
+ @kind = kind.to_s.inquiry
10
+ @label = label || id.to_s.humanize
11
+ @icon = icon
12
+ @href = href
13
+ @items = items
14
+ @value = value
15
+ @actions = actions.map { it.symbolize_keys }
16
+ @position = position && Options.position(position, "widget :#{id}")
17
+
18
+ @if_condition = options.delete(:if)
19
+ @unless_condition = options.delete(:unless)
20
+
21
+ Options.assert_known!(options, context: "widget :#{id}")
22
+ end
23
+
24
+ def value(context = nil)
25
+ return @value unless @value.respond_to?(:call)
26
+
27
+ context ? context.instance_exec(&@value) : @value.call
28
+ end
29
+
30
+ def items(context = nil)
31
+ return @items unless @items.respond_to?(:call)
32
+
33
+ context ? context.instance_exec(&@items) : @items.call
34
+ end
35
+
36
+ def decorate(view_context: nil)
37
+ Widget::Decorator.new(self, view_context: view_context)
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,8 @@
1
+ module Bord
2
+ module Conditionable
3
+ def show?(context)
4
+ (@if_condition.nil? || context.instance_exec(&@if_condition)) &&
5
+ (@unless_condition.nil? || !context.instance_exec(&@unless_condition))
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,9 @@
1
+ <header class="page-header">
2
+ <div>
3
+ <h1 class="title"><%= @page.label %></h1>
4
+
5
+ <%= tag.p @page.description, class: "description" if @page.description %>
6
+ </div>
7
+ </header>
8
+
9
+ <ul class="records" id="page-entries" @action="get#<%= bord.page_path(@page.id, format: :json) %>:mounted"><li class="placeholder">Loading records…</li></ul>
@@ -0,0 +1,13 @@
1
+ <header class="page-header">
2
+ <div>
3
+ <%= link_to bord.page_path(@page.id), class: "back-link" do %>
4
+ <svg class="icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256" fill="currentColor"><path d="M165.66,202.34a8,8,0,0,1-11.32,11.32l-80-80a8,8,0,0,1,0-11.32l80-80a8,8,0,0,1,11.32,11.32L91.31,128Z"/></svg>
5
+
6
+ <span>Back to <%= @page.label %></span>
7
+ <% end %>
8
+
9
+ <h1 class="title"><%= @page.label %></h1>
10
+ </div>
11
+ </header>
12
+
13
+ <div id="page-detail" @action="get#<%= bord.page_record_path(@page.id, params[:id], format: :json) %>:mounted"><div class="placeholder">Loading…</div></div>
@@ -0,0 +1,75 @@
1
+ <template id="bord-value">
2
+ <p class="value" attract-field="value"></p>
3
+ </template>
4
+
5
+ <template id="bord-value-link">
6
+ <a class="value" attract-href attract-field="value"></a>
7
+ </template>
8
+
9
+ <template id="bord-entry">
10
+ <li class="item">
11
+ <span class="icon" attract-icon></span>
12
+
13
+ <a class="entry" attract-href><span attract-field="label"></span></a>
14
+
15
+ <div class="actions"></div>
16
+ </li>
17
+ </template>
18
+
19
+ <template id="bord-entry-link">
20
+ <a class="action" attract-href attract-variant attract-field="label"></a>
21
+ </template>
22
+
23
+ <template id="bord-entry-action">
24
+ <form action="<%= bord.actions_path %>" method="post" @attract attract-confirm>
25
+ <input type="hidden" name="authenticity_token" value="<%= form_authenticity_token %>">
26
+ <input type="hidden" name="owner" attract-field="owner">
27
+ <input type="hidden" name="record" attract-field="record">
28
+ <input type="hidden" name="method" attract-field="method">
29
+ <input type="hidden" name="params" attract-field="params">
30
+
31
+ <button class="action" attract-variant attract-field="label"></button>
32
+ </form>
33
+ </template>
34
+
35
+ <template id="bord-page-entry">
36
+ <li class="record">
37
+ <span class="icon" attract-icon></span>
38
+
39
+ <div class="body">
40
+ <strong class="title" attract-field="title"></strong>
41
+
42
+ <span class="description" attract-field="description"></span>
43
+ </div>
44
+
45
+ <div class="actions"></div>
46
+ </li>
47
+ </template>
48
+
49
+ <template id="bord-page-detail">
50
+ <div class="detail">
51
+ <div class="heading">
52
+ <span class="icon" attract-icon></span>
53
+
54
+ <h3 class="title" attract-field="title"></h3>
55
+ </div>
56
+
57
+ <p class="description" attract-field="description"></p>
58
+
59
+ <dl class="details"></dl>
60
+
61
+ <div class="actions"></div>
62
+ </div>
63
+ </template>
64
+
65
+ <template id="bord-page-field">
66
+ <div class="field">
67
+ <dt attract-field="label"></dt>
68
+
69
+ <dd attract-field="value"></dd>
70
+ </div>
71
+ </template>
72
+
73
+ <template id="bord-flash-template">
74
+ <div id="bord-flash" class="flash flash-notice"><span attract-field="message"></span></div>
75
+ </template>
@@ -0,0 +1,7 @@
1
+ <div class="block w-full">
2
+ <% if action[:action] %>
3
+ <%= button_to action[:label], actions_path, params: action[:action], form_class: "block w-full", class: action[:variant] ? "action action--#{action[:variant]}" : "action" %>
4
+ <% else %>
5
+ <%= button_to action[:label], action[:href], method: action[:method] || :get, form_class: "block w-full", class: action[:variant] ? "action action--#{action[:variant]}" : "action" %>
6
+ <% end %>
7
+ </div>
@@ -0,0 +1,25 @@
1
+ <li class="widget widget--<%= widget.kind %>" id="widget-<%= widget.id %>">
2
+ <h3 class="title">
3
+ <%= icon widget.icon, class: "icon" if widget.icon %>
4
+
5
+ <%= widget.label %>
6
+ </h3>
7
+
8
+ <% if widget.kind.metric? %>
9
+ <% if widget.href %>
10
+ <a class="value" href="<%= widget.href %>" id="widget-<%= widget.id %>-value"></a>
11
+ <% else %>
12
+ <p class="value" id="widget-<%= widget.id %>-value"></p>
13
+ <% end %>
14
+ <% end %>
15
+
16
+ <% if widget.kind.list? %>
17
+ <ul class="items" id="widget-<%= widget.id %>-entries"></ul>
18
+ <% end %>
19
+
20
+ <%= tag.div class: "actions" do %>
21
+ <% widget.actions.each do %>
22
+ <%= render "bord/widgets/action", action: it %>
23
+ <% end %>
24
+ <% end if widget.actions.any? %>
25
+ </li>
@@ -0,0 +1,17 @@
1
+ <div class="dashboard" @action="get#<%= bord.data_path %>:mounted">
2
+ <% @dashboard.categories.each do |category, widgets| %>
3
+ <category class="category">
4
+ <h2 class="title"><%= category.label %></h2>
5
+
6
+ <ul class="widgets">
7
+ <%= render partial: "widget", collection: widgets %>
8
+ </ul>
9
+ </category>
10
+ <% end %>
11
+
12
+ <category class="category">
13
+ <ul class="widgets">
14
+ <%= render partial: "widget", collection: @dashboard.uncategoryed_widgets %>
15
+ </ul>
16
+ </category>
17
+ </div>
@@ -0,0 +1,38 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1">
6
+ <title><%= Bord.title %></title>
7
+
8
+ <%= csrf_meta_tags %>
9
+ <%= csp_meta_tag %>
10
+ <%= stylesheet_link_tag "bord/application", media: "all" %>
11
+ <%= javascript_include_tag "bord/application" %>
12
+
13
+ <style>
14
+ :root { --brand-hue: <%= Bord.brand_hue %>; }
15
+ </style>
16
+ </head>
17
+ <body>
18
+ <header class="navigation">
19
+ <%= link_to Bord.title, bord.root_path, class: "brand" %>
20
+ </header>
21
+
22
+ <main class="content">
23
+ <% if flash[:notice] %>
24
+ <div class="flash flash-notice"><%= flash[:notice] %></div>
25
+ <% end %>
26
+
27
+ <% if flash[:alert] %>
28
+ <div class="flash flash-alert"><%= flash[:alert] %></div>
29
+ <% end %>
30
+
31
+ <div id="bord-flash"></div>
32
+
33
+ <%= yield %>
34
+ </main>
35
+
36
+ <%= render "bord/shared/templates" %>
37
+ </body>
38
+ </html>
data/config/routes.rb ADDED
@@ -0,0 +1,11 @@
1
+ Bord::Engine.routes.draw do
2
+ root to: "widgets#index"
3
+
4
+ resource :data, only: :show, controller: "widgets"
5
+
6
+ resources :actions, only: :create
7
+
8
+ resources :pages, only: :show do
9
+ resources :records, only: :show
10
+ end
11
+ end
@@ -0,0 +1,60 @@
1
+ module Bord
2
+ class Configuration
3
+ def metric(id, **options)
4
+ add_widget(Widget.new(id: id, kind: :metric, **options))
5
+ end
6
+
7
+ def list(id, **options)
8
+ add_widget(Widget.new(id: id, kind: :list, **options))
9
+ end
10
+
11
+ def category(id, **options, &block)
12
+ if Bord.categories.any? { it.id == id.to_s }
13
+ raise ArgumentError, "Category :#{id} is already defined"
14
+ end
15
+
16
+ category = Category.new(id: id, **options)
17
+ Bord.categories << category
18
+
19
+ previous_category = @category
20
+ @category = category
21
+ instance_eval(&block) if block
22
+ ensure
23
+ @category = previous_category
24
+ end
25
+
26
+ def page(id, **options)
27
+ if Bord.pages.any? { it.id == id.to_s }
28
+ raise ArgumentError, "Page :#{id} is already defined"
29
+ end
30
+
31
+ Bord.pages << Page.new(id: id, **options)
32
+ end
33
+
34
+ def parent_controller=(value)
35
+ Bord.parent_controller = value
36
+ end
37
+
38
+ def title(value)
39
+ Bord.title = value
40
+ end
41
+
42
+ def brand_hue=(value)
43
+ Bord.brand_hue = value
44
+ end
45
+
46
+ private
47
+
48
+ def add_widget(widget)
49
+ if Bord.widgets.any? { it.id == widget.id }
50
+ raise ArgumentError, "Widget :#{widget.id} is already defined"
51
+ end
52
+
53
+ if @category
54
+ @category.widgets << widget
55
+ else
56
+ Bord.uncategoryed_widgets << widget
57
+ end
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,11 @@
1
+ module Bord
2
+ class Engine < ::Rails::Engine
3
+ isolate_namespace Bord
4
+
5
+ initializer "bord.load_configuration" do |application|
6
+ application.config.to_prepare do
7
+ Bord::Loader.reload
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,8 @@
1
+ module Bord
2
+ module Loader
3
+ def self.reload
4
+ Bord.reset!
5
+ Dir[Rails.root.join("config", "bord", "**", "*.rb")].sort.each { Kernel.load(it) }
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,17 @@
1
+ module Bord
2
+ module Options
3
+ module_function
4
+
5
+ def position(value, context)
6
+ Integer(value)
7
+ rescue ArgumentError, TypeError
8
+ raise ArgumentError, "Invalid position #{value.inspect} for #{context}"
9
+ end
10
+
11
+ def assert_known!(given, context:)
12
+ return if given.empty?
13
+
14
+ raise ArgumentError, "Unknown option#{"s" if given.size > 1} #{given.keys.map(&:inspect).join(", ")} for #{context}"
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,20 @@
1
+ [
2
+ {
3
+ "name": "Failed Emails",
4
+ "description": "Number of failed inbound emails",
5
+ "code": "Bord.metric :failed_emails, label: \"Failed Emails\", value: ActionMailbox::InboundEmail.where(status: :failed).count"
6
+ },
7
+ {
8
+ "name": "Recent Inbound Emails",
9
+ "description": "Latest inbound emails",
10
+ "code": [
11
+ "Bord.list :inbound_emails,",
12
+ " label: \"Inbound Emails\",",
13
+ " items: -> {",
14
+ " ActionMailbox::InboundEmail.order(created_at: :desc).limit(5).map do |email|",
15
+ " {label: email.message_id, href: \"/rails/bord/action_mailbox/inbound_emails/#{email.id}\"}",
16
+ " end",
17
+ " }"
18
+ ]
19
+ }
20
+ ]
@@ -0,0 +1,20 @@
1
+ [
2
+ {
3
+ "name": "Total Blobs",
4
+ "description": "Total Active Storage blob count",
5
+ "code": "Bord.metric :total_blobs, label: \"Total Blobs\", value: ActiveStorage::Blob.count"
6
+ },
7
+ {
8
+ "name": "Recent Uploads",
9
+ "description": "Latest Active Storage uploads",
10
+ "code": [
11
+ "Bord.list :recent_uploads,",
12
+ " label: \"Recent Uploads\",",
13
+ " items: -> {",
14
+ " ActiveStorage::Blob.order(created_at: :desc).limit(5).map do |blob|",
15
+ " {label: blob.filename.to_s}",
16
+ " end",
17
+ " }"
18
+ ]
19
+ }
20
+ ]
@@ -0,0 +1 @@
1
+ []
@@ -0,0 +1,25 @@
1
+ [
2
+ {
3
+ "name": "Failed Jobs",
4
+ "description": "Number of failed Good Job jobs",
5
+ "code": "Bord.metric :failed_jobs, label: \"Failed Jobs\", value: GoodJob::Job.where.not(error: nil).count"
6
+ },
7
+ {
8
+ "name": "Pending Jobs",
9
+ "description": "Count of pending Good Job jobs",
10
+ "code": "Bord.metric :pending_jobs, label: \"Pending Jobs\", value: GoodJob::Job.where(dispatched_at: nil).count"
11
+ },
12
+ {
13
+ "name": "Queue Depth",
14
+ "description": "Jobs per queue",
15
+ "code": [
16
+ "Bord.list :queue_depth,",
17
+ " label: \"Queue Depth\",",
18
+ " items: -> {",
19
+ " GoodJob::Job.where(dispatched_at: nil).group(:queue_name).count.map do |name, count|",
20
+ " {label: \"#{name}: #{count}\"}",
21
+ " end",
22
+ " }"
23
+ ]
24
+ }
25
+ ]
@@ -0,0 +1,28 @@
1
+ [
2
+ {
3
+ "name": "Retries",
4
+ "description": "Number of Sidekiq jobs waiting to retry",
5
+ "note": "Requires the Sidekiq gem",
6
+ "code": "Bord.metric :retries, label: \"Retries\", value: Sidekiq::RetrySet.new.size"
7
+ },
8
+ {
9
+ "name": "Dead Jobs",
10
+ "description": "Number of dead Sidekiq jobs",
11
+ "note": "Requires the Sidekiq gem",
12
+ "code": "Bord.metric :dead_jobs, label: \"Dead Jobs\", value: Sidekiq::DeadSet.new.size"
13
+ },
14
+ {
15
+ "name": "Queue Sizes",
16
+ "description": "Job count per Sidekiq queue",
17
+ "note": "Requires the Sidekiq gem",
18
+ "code": [
19
+ "Bord.list :queue_sizes,",
20
+ " label: \"Queue Sizes\",",
21
+ " items: -> {",
22
+ " Sidekiq::Queue.all.map do |queue|",
23
+ " {label: \"#{queue.name}: #{queue.size}\"}",
24
+ " end",
25
+ " }"
26
+ ]
27
+ }
28
+ ]
@@ -0,0 +1,12 @@
1
+ [
2
+ {
3
+ "name": "Failed Jobs",
4
+ "description": "Number of failed jobs in Solid Queue",
5
+ "code": "Bord.metric :failed_jobs, label: \"Failed Jobs\", value: SolidQueue::FailedExecution.count"
6
+ },
7
+ {
8
+ "name": "Pending Jobs",
9
+ "description": "Count of ready jobs waiting to be processed",
10
+ "code": "Bord.metric :pending_jobs, label: \"Pending Jobs\", value: SolidQueue::ReadyExecution.count"
11
+ }
12
+ ]
@@ -0,0 +1,30 @@
1
+ [
2
+ {
3
+ "name": "Recent Customers",
4
+ "description": "Latest Stripe customers",
5
+ "note": "Requires the Stripe gem",
6
+ "code": [
7
+ "Bord.list :recent_customers,",
8
+ " label: \"Recent Customers\",",
9
+ " items: -> {",
10
+ " Stripe::Customer.list(limit: 5).map do |customer|",
11
+ " {label: customer.email || customer.id, href: \"https://dashboard.stripe.com/customers/#{customer.id}\"}",
12
+ " end",
13
+ " }"
14
+ ]
15
+ },
16
+ {
17
+ "name": "Recent Charges",
18
+ "description": "Latest Stripe charges",
19
+ "note": "Requires the Stripe gem",
20
+ "code": [
21
+ "Bord.list :recent_charges,",
22
+ " label: \"Recent Charges\",",
23
+ " items: -> {",
24
+ " Stripe::Charge.list(limit: 5).map do |charge|",
25
+ " {label: \"#{charge.amount / 100.0} #{charge.currency.upcase}\", href: \"https://dashboard.stripe.com/charges/#{charge.id}\"}",
26
+ " end",
27
+ " }"
28
+ ]
29
+ }
30
+ ]
@@ -0,0 +1,22 @@
1
+ [
2
+ {
3
+ "name": "Recent Users",
4
+ "description": "Latest user signups",
5
+ "note": "Replace User with your model name",
6
+ "code": [
7
+ "Bord.list :recent_users,",
8
+ " label: \"Recent Users\",",
9
+ " items: -> {",
10
+ " User.order(created_at: :desc).limit(5).map do |user|",
11
+ " {label: user.email}",
12
+ " end",
13
+ " }"
14
+ ]
15
+ },
16
+ {
17
+ "name": "User Count",
18
+ "description": "Total registered users",
19
+ "note": "Replace User with your model name",
20
+ "code": "Bord.metric :users, label: \"Users\", value: -> { User.count }"
21
+ }
22
+ ]
@@ -0,0 +1,3 @@
1
+ module Bord
2
+ VERSION = "0.5.0"
3
+ end
data/lib/bord.rb ADDED
@@ -0,0 +1,71 @@
1
+ require "bord/version"
2
+ require "bord/engine"
3
+ require "bord/configuration"
4
+ require "bord/loader"
5
+ require "bord/options"
6
+
7
+ module Bord
8
+ mattr_accessor :parent_controller, :title, :brand_hue
9
+
10
+ self.parent_controller = "ActionController::Base"
11
+ self.title = "Bord"
12
+ self.brand_hue = 250
13
+
14
+ def self.configure
15
+ yield Configuration.new
16
+ end
17
+
18
+ def self.draw(&block)
19
+ Configuration.new.instance_eval(&block)
20
+ end
21
+
22
+ def self.categories
23
+ @categories ||= []
24
+ end
25
+
26
+ def self.uncategoryed_widgets
27
+ @uncategoryed_widgets ||= []
28
+ end
29
+
30
+ def self.widgets
31
+ sort_by_position(categories).flat_map { |category| sort_by_position(category.widgets) } +
32
+ sort_by_position(uncategoryed_widgets)
33
+ end
34
+
35
+ def self.sort_by_position(collection)
36
+ collection
37
+ .each_with_index
38
+ .sort_by { [it.first.position || Float::INFINITY, it.last] }
39
+ .map(&:first)
40
+ end
41
+
42
+ def self.pages
43
+ @pages ||= []
44
+ end
45
+
46
+ def self.metric(id, **options)
47
+ Configuration.new.metric(id, **options)
48
+ end
49
+
50
+ def self.list(id, **options)
51
+ Configuration.new.list(id, **options)
52
+ end
53
+
54
+ def self.category(id, **options, &block)
55
+ Configuration.new.category(id, **options, &block)
56
+ end
57
+
58
+ def self.page(id, **options)
59
+ Configuration.new.page(id, **options)
60
+ end
61
+
62
+ def self.reset!
63
+ @categories = []
64
+ @uncategoryed_widgets = []
65
+ @pages = []
66
+ end
67
+
68
+ def self.locked?(env = Rails.env)
69
+ !env.development? && !env.test? && parent_controller == "ActionController::Base"
70
+ end
71
+ end
@@ -0,0 +1,16 @@
1
+ class Bord::InstallGenerator < Rails::Generators::Base
2
+ desc "Installs Bord: creates configuration and mounts the engine"
3
+
4
+ def create_configuration
5
+ create_file "config/bord/dashboard.rb", <<~RUBY
6
+ Bord.draw do
7
+ metric :users, label: "Users", value: -> { User.count }
8
+ list :recent, label: "Recent", items: -> { User.limit(3) }
9
+ end
10
+ RUBY
11
+ end
12
+
13
+ def mount_engine
14
+ route 'mount Bord::Engine => "/bord"'
15
+ end
16
+ end