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
9624c00d
Commit
9624c00d
authored
Jun 01, 2021
by
Pascal
Browse files
fix config path
parent
8cbdc0b0
Changes
3
Hide whitespace changes
Inline
Side-by-side
README.md
View file @
9624c00d
...
...
@@ -25,7 +25,7 @@ When writing ``admin-pages``, consider extending the default
### Adding buttons via configuration
In the file
``configs/admin
_
extra.ini``
In the file
``configs/admin
-
extra.ini``
with the following syntax
```
[button.help]
...
...
@@ -39,6 +39,7 @@ html = x
index = 0
scope = dash
```
(these buttons are automatically added)
Use
``scope=server``
to display the button only on display mode,
or
``scope=dash``
to show it only in admin panel (default both)
...
...
lektor_admin_extra.py
View file @
9624c00d
...
...
@@ -60,16 +60,18 @@ class AdminExtraPlugin(Plugin):
self
.
parse_config
()
@
serve
.
bp
.
before_app_first_request
def
setup_blueprint
():
app
=
current_app
app
.
register_blueprint
(
utilsbp
)
# only if no help pages defined
if
self
.
help_dir
is
not
None
:
self
.
add_button
(
self
.
help_dir
,
'help'
,
'?'
,
index
=
0
)
print
(
"[admin-extra] use %s help pages"
%
self
.
help_dir
)
self
.
add_button
(
self
.
help_dir
,
'help'
,
'?'
)
else
:
self
.
add_button
(
url_for
(
'admin_utils.help'
),
'help'
,
'?'
,
index
=
0
)
print
(
"[admin-extra] use default page"
)
self
.
add_button
(
url_for
(
'admin_utils.help'
),
'help'
,
'?'
)
print
(
"[admin-extra] buttons = %s"
%
self
.
right_buttons
)
@
serve
.
bp
.
after_request
#pylint: disable=unused-variable
...
...
@@ -112,7 +114,17 @@ class AdminExtraPlugin(Plugin):
self
.
help_data
[
'index'
].
append
(
(
url
,
item
)
)
def
parse_config
(
self
):
""" register buttons defined in configs/admin-extra.ini """
"""
register buttons defined in configs/admin-extra.ini
Example
```
[button.addpage]
url = /admin/root:add-child
title = nouvelle page
html = +
```
"""
config
=
self
.
get_config
()
self
.
help_dir
=
config
.
get
(
'help_pages'
,
None
)
prefix
=
'button.'
...
...
@@ -124,5 +136,3 @@ class AdminExtraPlugin(Plugin):
if
get
(
'scope'
):
scope
=
[
s
for
s
in
get
(
'scope'
).
split
(
','
)
if
s
in
[
'serve'
,
'dash'
]]
self
.
add_button
(
url
,
title
,
html
,
bp
=
scope
,
index
=
index
)
test/conftest.py
View file @
9624c00d
...
...
@@ -20,6 +20,9 @@ def onlybranch(branch):
return
inner
def
pytest_configure
(
config
):
"""
keep name of current test repo
"""
pytest
.
current_branch
=
None
pytest
.
onlybranch
=
onlybranch
...
...
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