Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a universal navigation bar which can be modified by plugins #540

Closed
simonw opened this issue Jul 5, 2019 · 8 comments
Closed

Add a universal navigation bar which can be modified by plugins #540

simonw opened this issue Jul 5, 2019 · 8 comments

Comments

@simonw
Copy link
Owner

simonw commented Jul 5, 2019

Needed by simonw/datasette-auth-github#5

We already have a navigation breadcrumbs header on some pages, I can extend that to be present on every page and make it easy to modify with custom templates.

fixtures__facetable

@simonw
Copy link
Owner Author

simonw commented Jul 5, 2019

Need to figure out a sensible mobile version of this too.

@simonw
Copy link
Owner Author

simonw commented Jul 5, 2019

I think I'll start with something ridiculously simple along these lines:

fixtures__roadside_attraction_characteristics

@simonw
Copy link
Owner Author

simonw commented Jul 5, 2019

Having this be customized by a single plugin seems easy enough - define a named block region in the template, the plugin can then provide a template which extends the base template, over-rides the named block, adds some stuff, then calls super to include the default content.

But... how would this work if there are multiple plugins that want to add to the menu area?

@simonw
Copy link
Owner Author

simonw commented Jul 5, 2019

For the moment I'm going to ignore the multiple plugins case. I shall revisit that at some point in the future, once I actually have multiple plugins that want to be able to customize the navigation at the same time.

@simonw
Copy link
Owner Author

simonw commented Jul 5, 2019

@simonw
Copy link
Owner Author

simonw commented Jul 5, 2019

Here's an example custom base.html template that appears to have the desired effect:

{% extends "default:base.html" %}

{% block extra_head %}
<style type="text/css">
.hd .logout {
    float: right;
    text-align: right;
    padding-left: 1em;
}
</style>
{% endblock %}

{% block nav %}
    {{ super() }}
    <p class="logout">
        <a href="/-/logout">Log out</a>
    </p>
{% endblock %}

@simonw
Copy link
Owner Author

simonw commented Jul 6, 2019

This is now being used successfully by https://datasette-auth-demo.now.sh/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant