Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Pascal MOLIN
lektor-admin-extra
Commits
1e728f26
Commit
1e728f26
authored
Mar 31, 2021
by
Pascal
Browse files
buttons via config
parent
0c0abd11
Changes
2
Hide whitespace changes
Inline
Side-by-side
README.md
View file @
1e728f26
# admin-extra
Add facilities for the lektor development server.
This plugin adds buttons and messages facilities to the
[
lektor
](
https://www.getlektor.com/
)
development server
and admin panel.
## Flash messages
Flask flash messages are displayed on top of the pages.
## Help pages
...
...
@@ -17,9 +23,31 @@ If ``content/admin-pages`` is not found, the default
When writing
``admin-pages``
, consider extending the default
``template/help.html``
.
Add extra buttons and messages to lektor admin panel.
### Adding buttons via configuration
Warning: in fact this is not yet implemented.
In the file
``configs/admin_extra.ini``
with the following syntax
```
[button.help]
url = /admin-pages/
tooltip =
html = ?
[button.logout]
url = /logout
tooltip = logout
html = x
index = 0
scope = dash
```
Use
``scope=server``
to display the button only on display mode,
or
``scope=dash``
to show it only in admin panel (default both)
Use
``index=1``
to show the button in position 1 (index start at 0).
## Adding
custom butto
ns
## Adding
buttons with plugi
ns
Besides the default
``?``
help button, the plugin makes it possible
to register other links. For example, the
``lektor-login``
...
...
@@ -45,6 +73,7 @@ started. An option is to register under ``before_app_first_request``
admin_extra.add_button( '/secret/url', 'hidden diary', ':-/' )
```
##
Adding help page
s
##
How it work
s
All
The plugin uses the flask
``after_request``
entrypoint to inject extra html
in all served pages.
lektor_admin_extra.py
View file @
1e728f26
...
...
@@ -60,6 +60,14 @@ class AdminExtraPlugin(Plugin):
config
=
self
.
get_config
()
help_dir
=
config
.
get
(
'help_pages'
,
None
)
for
k
,
v
in
config
.
section_as_dict
(
'button'
):
url
=
v
.
get
(
'url'
)
html
=
v
.
get
(
'html'
)
title
=
v
.
get
(
'title'
)
index
=
v
.
get
(
'index'
,
None
)
scope
=
[
s
for
s
in
v
.
get
(
'scope'
).
split
(
','
)
if
s
in
[
'serve'
,
'dash'
]]
self
.
add_button
(
url
,
title
,
html
,
scope
,
index
=
index
)
@
serve
.
bp
.
before_app_first_request
def
setup_blueprint
():
app
=
current_app
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment