Skip to content

Commit 8c3ca44

Browse files
committed
panels now loaded by their full lua 'require' path
1 parent 77a827b commit 8c3ca44

11 files changed

+31
-38
lines changed

README.md

+11-17
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ Luminary uses the Tup build system.
5757
## Privacy and Security Notice ##
5858

5959
This toolbar should __never__ be exposed to a production/public-facing website. It will expose the entire configuration and
60-
environment of your server, display request contents (including passwords), and slow down your site. Luminary will
60+
environment of your server, display request contents (including passwords), and impact your site's performance. Luminary will
6161
restrict itself to the "development" environment by default.
6262

6363
## Usage ##
@@ -170,12 +170,12 @@ Each link in Luminary's navigation bar corresponds to an associated panel. A pan
170170
a lapis widget rendered as a tab within the toolbar. Luminary comes with several panels
171171
that are loaded by default:
172172

173-
* __request__: Lapis request data
174-
* __router__: Lapis router information
175-
* __queries__: Database queries performed while serving request (pgsql through lapis.db)
176-
* __ngx__: OpenResty build information, server configuration, and Nginx variables
177-
* __environment__: Lapis environment configuration
178-
* __console__: Embedded lapis-console
173+
* `luminary.panels.request`: Lapis request data
174+
* `luminary.panels.router`: Lapis router information
175+
* `luminary.panels.queries`: Database queries performed while serving request (pgsql through lapis.db)
176+
* `luminary.panels.ngx`: OpenResty build information, server configuration, and Nginx variables
177+
* `luminary.panels.environment`: Lapis environment configuration
178+
* `luminary.panels.console`: Embedded lapis-console
179179

180180
Since panels are just Lapis widgets, you can extend Luminary by creating your own panels filled
181181
with whatever debug information you want. Take a look at any of the panels in `luminary/panels/`
@@ -197,21 +197,15 @@ config {"development", "test"}, ->
197197
session_name "MyApp"
198198
postgresql_url "postgres://#{pg.user}:#{pg.pass}@127.0.0.1/#{pg.db}"
199199
200-
-- This example removes the default "ngx" panel
200+
-- This example removes all of the defaults except for the 'request' and 'router' panels
201201
luminary ->
202202
panels {
203-
"request"
204-
"router"
205-
"console"
203+
"luminary.panels.request"
204+
"luminary.panels.router"
206205
}
207206
```
208207

209-
Panels are loaded internally using something like:
210-
211-
```moonscript
212-
p = require "luminary.panels.#{panel_name}"
213-
p\include_helper @
214-
```
208+
Panels are loaded internally using their Lua path (much like Python Debug Toolbar's panel loading scheme)
215209

216210
### Creating Panels ###
217211

panels/db.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ do
55
end
66
local label_wrap, float_wrap
77
do
8-
local _obj_0 = require("luminary.panels.util")
8+
local _obj_0 = require("luminary.util")
99
label_wrap, float_wrap = _obj_0.label_wrap, _obj_0.float_wrap
1010
end
1111
local sort, concat

panels/db.moon

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22
import render_html from require "lapis.html"
3-
import label_wrap, float_wrap from require "luminary.panels.util"
3+
import label_wrap, float_wrap from require "luminary.util"
44
import sort, concat from table
55

66
format_query = (q) ->

panels/environment.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
local config = require("lapis.config").get()
22
local label_wrap, float_wrap
33
do
4-
local _obj_0 = require("luminary.panels.util")
4+
local _obj_0 = require("luminary.util")
55
label_wrap, float_wrap = _obj_0.label_wrap, _obj_0.float_wrap
66
end
77
local sort, concat

panels/environment.moon

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
config = require"lapis.config".get!
33

4-
import label_wrap, float_wrap from require "luminary.panels.util"
4+
import label_wrap, float_wrap from require "luminary.util"
55
import sort, concat from table
66

77
class LapisEnvironmentPanel extends require "luminary.panels.base"

panels/ngx.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
local label_wrap, float_wrap
22
do
3-
local _obj_0 = require("luminary.panels.util")
3+
local _obj_0 = require("luminary.util")
44
label_wrap, float_wrap = _obj_0.label_wrap, _obj_0.float_wrap
55
end
66
local sort, concat

panels/ngx.moon

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
import label_wrap, float_wrap from require "luminary.panels.util"
2+
import label_wrap, float_wrap from require "luminary.util"
33
import sort, concat from table
44

55
-- Available ngx variables
File renamed without changes.
File renamed without changes.

views/toolbar.lua

+7-7
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ do
99
insert, concat = _obj_0.insert, _obj_0.concat
1010
end
1111
local defaults = {
12-
"request",
13-
"db",
14-
"ngx",
15-
"router",
16-
"environment",
17-
"console"
12+
"luminary.panels.request",
13+
"luminary.panels.db",
14+
"luminary.panels.ngx",
15+
"luminary.panels.router",
16+
"luminary.panels.environment",
17+
"luminary.panels.console"
1818
}
1919
local LuminaryIndex
2020
do
@@ -28,7 +28,7 @@ do
2828
load_all = function(self, names)
2929
local conf = { }
3030
for i, name in ipairs(names) do
31-
local panel = self:load_panel("luminary.panels." .. tostring(name))
31+
local panel = self:load_panel(name)
3232
local id = "luminary-" .. tostring(i) .. "-" .. tostring(slugify(panel.title or panel.__name or 'DefaultPanel'))
3333
insert(conf, {
3434
id,

views/toolbar.moon

+7-8
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,13 @@
22
import slugify from require "lapis.util"
33
import insert, concat from table
44

5-
-- TODO: Add ability to override/extend defaults from config.moon
65
defaults = {
7-
"request"
8-
"db"
9-
"ngx"
10-
"router"
11-
"environment"
12-
"console"
6+
"luminary.panels.request"
7+
"luminary.panels.db"
8+
"luminary.panels.ngx"
9+
"luminary.panels.router"
10+
"luminary.panels.environment"
11+
"luminary.panels.console"
1312
}
1413

1514
class LuminaryIndex extends require "luminary.views.base"
@@ -21,7 +20,7 @@ class LuminaryIndex extends require "luminary.views.base"
2120
load_all: (names) =>
2221
conf = {}
2322
for i,name in ipairs names
24-
panel = @load_panel "luminary.panels.#{name}"
23+
panel = @load_panel name
2524
id = "luminary-#{i}-#{slugify panel.title or panel.__name or 'DefaultPanel'}"
2625
insert(conf, {id, panel.title, panel})
2726
conf

0 commit comments

Comments
 (0)