athar 0.2.1 → 0.3.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -1
- data/README.md +60 -0
- data/app/assets/images/athar/logo.png +0 -0
- data/app/assets/javascripts/athar/dashboard.js +290 -0
- data/app/assets/stylesheets/athar/dashboard.css +841 -0
- data/app/controllers/athar/application_controller.rb +10 -0
- data/app/controllers/athar/dashboard_controller.rb +57 -0
- data/app/controllers/athar/deletions_controller.rb +14 -0
- data/app/controllers/athar/table_events_controller.rb +11 -0
- data/app/controllers/athar/themes_controller.rb +16 -0
- data/app/helpers/athar/asset_helper.rb +28 -0
- data/app/helpers/athar/dashboard/cell_helper.rb +88 -0
- data/app/helpers/athar/dashboard/detail_helper.rb +50 -0
- data/app/helpers/athar/dashboard/filter_link_helper.rb +22 -0
- data/app/helpers/athar/dashboard/formatting_helper.rb +47 -0
- data/app/helpers/athar/dashboard/icon_helper.rb +40 -0
- data/app/helpers/athar/dashboard_helper.rb +11 -0
- data/app/views/athar/dashboard/_filter_bar.html.erb +95 -0
- data/app/views/athar/dashboard/_kpi_strip.html.erb +46 -0
- data/app/views/athar/dashboard/_pager.html.erb +32 -0
- data/app/views/athar/dashboard/_row.html.erb +72 -0
- data/app/views/athar/dashboard/_sidebar.html.erb +106 -0
- data/app/views/athar/dashboard/_table.html.erb +30 -0
- data/app/views/athar/dashboard/_topbar.html.erb +30 -0
- data/app/views/athar/dashboard/index.html.erb +31 -0
- data/app/views/athar/deletions/_detail.html.erb +115 -0
- data/app/views/athar/deletions/show.html.erb +3 -0
- data/app/views/athar/table_events/_detail.html.erb +80 -0
- data/app/views/athar/table_events/show.html.erb +3 -0
- data/app/views/layouts/athar/application.html.erb +29 -0
- data/config/routes.rb +8 -0
- data/lib/athar/dashboard/actor_labels.rb +31 -0
- data/lib/athar/dashboard/actor_options.rb +71 -0
- data/lib/athar/dashboard/connection_info.rb +25 -0
- data/lib/athar/dashboard/feed_query.rb +222 -0
- data/lib/athar/dashboard/filter_set.rb +63 -0
- data/lib/athar/dashboard/kpi_calculator.rb +102 -0
- data/lib/athar/dashboard/model_registry.rb +141 -0
- data/lib/athar/dashboard/sparkline.rb +42 -0
- data/lib/athar/dashboard/trigger_args_parser.rb +42 -0
- data/lib/athar/dashboard.rb +16 -0
- data/lib/athar/engine.rb +12 -0
- data/lib/athar/middleware/asset_server.rb +78 -0
- data/lib/athar/version.rb +1 -1
- data/lib/athar.rb +1 -0
- metadata +41 -1
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Athar
|
|
4
|
+
module Middleware
|
|
5
|
+
# Serves Athar's dashboard assets (`dashboard.js`, `dashboard.css`) directly
|
|
6
|
+
# to hosts that don't have an asset pipeline configured. Rails apps with
|
|
7
|
+
# Sprockets or Propshaft never reach this middleware — the layout helper
|
|
8
|
+
# resolves to a digested asset path served by the asset pipeline.
|
|
9
|
+
#
|
|
10
|
+
# The URL embeds Athar::VERSION as a cache-busting prefix
|
|
11
|
+
# (`/athar-assets/<version>/dashboard.js`); the version segment is stripped
|
|
12
|
+
# before resolving to disk so a single canonical file lives in
|
|
13
|
+
# `app/assets/`. New gem version → new URL → fresh cache.
|
|
14
|
+
class AssetServer
|
|
15
|
+
PREFIX_PATTERN = %r{\A/athar-assets/[^/]+/(.+)\z}
|
|
16
|
+
|
|
17
|
+
MIME_TYPES = {
|
|
18
|
+
".js" => "application/javascript",
|
|
19
|
+
".css" => "text/css"
|
|
20
|
+
}.freeze
|
|
21
|
+
|
|
22
|
+
# Where each file extension lives, relative to the engine root.
|
|
23
|
+
EXTENSION_DIRS = {
|
|
24
|
+
".js" => "app/assets/javascripts/athar",
|
|
25
|
+
".css" => "app/assets/stylesheets/athar"
|
|
26
|
+
}.freeze
|
|
27
|
+
|
|
28
|
+
def initialize(app, engine_root)
|
|
29
|
+
@app = app
|
|
30
|
+
@root = File.expand_path(engine_root.to_s)
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def call(env)
|
|
34
|
+
path = env["PATH_INFO"].to_s
|
|
35
|
+
match = PREFIX_PATTERN.match(path)
|
|
36
|
+
return @app.call(env) unless match
|
|
37
|
+
|
|
38
|
+
file = resolve(match[1])
|
|
39
|
+
return not_found unless file
|
|
40
|
+
|
|
41
|
+
[200, response_headers(file), [File.binread(file)]]
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
private
|
|
45
|
+
|
|
46
|
+
def resolve(filename)
|
|
47
|
+
ext = File.extname(filename)
|
|
48
|
+
dir = EXTENSION_DIRS[ext]
|
|
49
|
+
return nil unless dir
|
|
50
|
+
|
|
51
|
+
source_dir = File.expand_path(dir, @root)
|
|
52
|
+
file = File.expand_path(filename, source_dir)
|
|
53
|
+
|
|
54
|
+
return nil unless file.start_with?(source_dir) && File.file?(file)
|
|
55
|
+
|
|
56
|
+
file
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def response_headers(file)
|
|
60
|
+
cache = if defined?(::Rails) && ::Rails.env.development?
|
|
61
|
+
"no-cache, no-store, must-revalidate"
|
|
62
|
+
else
|
|
63
|
+
"public, max-age=31536000, immutable"
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
{
|
|
67
|
+
"Content-Type" => MIME_TYPES[File.extname(file)] || "application/octet-stream",
|
|
68
|
+
"Cache-Control" => cache,
|
|
69
|
+
"Vary" => "Accept-Encoding"
|
|
70
|
+
}
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
def not_found
|
|
74
|
+
[404, { "Content-Type" => "text/plain" }, ["Not found"]]
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
end
|
data/lib/athar/version.rb
CHANGED
data/lib/athar.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: athar
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.3.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ali Hamdi Ali Fadel
|
|
@@ -90,13 +90,53 @@ files:
|
|
|
90
90
|
- CHANGELOG.md
|
|
91
91
|
- LICENSE.txt
|
|
92
92
|
- README.md
|
|
93
|
+
- app/assets/images/athar/logo.png
|
|
94
|
+
- app/assets/javascripts/athar/dashboard.js
|
|
95
|
+
- app/assets/stylesheets/athar/dashboard.css
|
|
96
|
+
- app/controllers/athar/application_controller.rb
|
|
97
|
+
- app/controllers/athar/dashboard_controller.rb
|
|
98
|
+
- app/controllers/athar/deletions_controller.rb
|
|
99
|
+
- app/controllers/athar/table_events_controller.rb
|
|
100
|
+
- app/controllers/athar/themes_controller.rb
|
|
101
|
+
- app/helpers/athar/asset_helper.rb
|
|
102
|
+
- app/helpers/athar/dashboard/cell_helper.rb
|
|
103
|
+
- app/helpers/athar/dashboard/detail_helper.rb
|
|
104
|
+
- app/helpers/athar/dashboard/filter_link_helper.rb
|
|
105
|
+
- app/helpers/athar/dashboard/formatting_helper.rb
|
|
106
|
+
- app/helpers/athar/dashboard/icon_helper.rb
|
|
107
|
+
- app/helpers/athar/dashboard_helper.rb
|
|
108
|
+
- app/views/athar/dashboard/_filter_bar.html.erb
|
|
109
|
+
- app/views/athar/dashboard/_kpi_strip.html.erb
|
|
110
|
+
- app/views/athar/dashboard/_pager.html.erb
|
|
111
|
+
- app/views/athar/dashboard/_row.html.erb
|
|
112
|
+
- app/views/athar/dashboard/_sidebar.html.erb
|
|
113
|
+
- app/views/athar/dashboard/_table.html.erb
|
|
114
|
+
- app/views/athar/dashboard/_topbar.html.erb
|
|
115
|
+
- app/views/athar/dashboard/index.html.erb
|
|
116
|
+
- app/views/athar/deletions/_detail.html.erb
|
|
117
|
+
- app/views/athar/deletions/show.html.erb
|
|
118
|
+
- app/views/athar/table_events/_detail.html.erb
|
|
119
|
+
- app/views/athar/table_events/show.html.erb
|
|
120
|
+
- app/views/layouts/athar/application.html.erb
|
|
121
|
+
- config/routes.rb
|
|
93
122
|
- lib/athar.rb
|
|
94
123
|
- lib/athar/actor_lookup.rb
|
|
95
124
|
- lib/athar/configuration.rb
|
|
96
125
|
- lib/athar/context.rb
|
|
126
|
+
- lib/athar/dashboard.rb
|
|
127
|
+
- lib/athar/dashboard/actor_labels.rb
|
|
128
|
+
- lib/athar/dashboard/actor_options.rb
|
|
129
|
+
- lib/athar/dashboard/connection_info.rb
|
|
130
|
+
- lib/athar/dashboard/feed_query.rb
|
|
131
|
+
- lib/athar/dashboard/filter_set.rb
|
|
132
|
+
- lib/athar/dashboard/kpi_calculator.rb
|
|
133
|
+
- lib/athar/dashboard/model_registry.rb
|
|
134
|
+
- lib/athar/dashboard/sparkline.rb
|
|
135
|
+
- lib/athar/dashboard/trigger_args_parser.rb
|
|
97
136
|
- lib/athar/deletion.rb
|
|
98
137
|
- lib/athar/engine.rb
|
|
99
138
|
- lib/athar/metadata_stack.rb
|
|
139
|
+
- lib/athar/middleware/asset_server.rb
|
|
100
140
|
- lib/athar/retention.rb
|
|
101
141
|
- lib/athar/retention_job.rb
|
|
102
142
|
- lib/athar/sql.rb
|