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

Template slot family of plugin hooks - top_homepage() and others #2238

Merged
merged 13 commits into from
Jan 31, 2024
Merged

Conversation

simonw
Copy link
Owner

@simonw simonw commented Jan 30, 2024

Refs:

TODO:

  • top_homepage
  • top_database
  • top_table
  • top_row
  • top_query
  • top_canned_query

📚 Documentation preview 📚: https://datasette--2238.org.readthedocs.build/en/2238/

@simonw
Copy link
Owner Author

simonw commented Jan 30, 2024

@simonw
Copy link
Owner Author

simonw commented Jan 30, 2024

Should these be wrapped in a <div> with a known ID or class I wonder? HTML currently looks like this:

{% extends "base.html" %}
{% block title %}{{ metadata.title or "Datasette" }}: {% for database in databases %}{{ database.name }}{% if not loop.last %}, {% endif %}{% endfor %}{% endblock %}
{% block body_class %}index{% endblock %}
{% block content %}
<h1>{{ metadata.title or "Datasette" }}{% if private %} 🔒{% endif %}</h1>
{{ top_homepage() }}
{% block description_source_license %}{% include "_description_source_license.html" %}{% endblock %}

@simonw
Copy link
Owner Author

simonw commented Jan 31, 2024

Also am I right putting these above the description/metadata section, or should they be below it?

I think above. Conceptually that information is strongly related to the table that is being displayed.

I'm going to standardize on having these blocks appear directly below the <h1>.

Copy link

codecov bot commented Jan 31, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (7a5adb5) 92.33% compared to head (eb13117) 92.67%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2238      +/-   ##
==========================================
+ Coverage   92.33%   92.67%   +0.33%     
==========================================
  Files          41       40       -1     
  Lines        6134     6116      -18     
==========================================
+ Hits         5664     5668       +4     
+ Misses        470      448      -22     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@simonw
Copy link
Owner Author

simonw commented Jan 31, 2024

I thought about maybe using a {{ slot("top_homepage") }} template function instead of the {{ top_homepage() }} thing that gets injected in to the context, but different slots take different arguments (e.g. the row one takes top_row(datasette, request, database, table, row)) so actually it's better to feed them in from the view function after all.

@simonw simonw changed the title top_homepage() family of plugin hooks Template slots family of plugin hooks - top_homepage() and 5 others Jan 31, 2024
@simonw simonw changed the title Template slots family of plugin hooks - top_homepage() and 5 others Template slots family of plugin hooks - top_homepage() and others Jan 31, 2024
@simonw simonw changed the title Template slots family of plugin hooks - top_homepage() and others Template slot family of plugin hooks - top_homepage() and others Jan 31, 2024
@simonw simonw marked this pull request as ready for review January 31, 2024 03:45
@simonw simonw merged commit c3caf36 into main Jan 31, 2024
19 checks passed
@simonw simonw deleted the top branch January 31, 2024 03:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant