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

feat: add demo site landing page, with sponsor logo in footer #14

Merged
merged 5 commits into from Apr 17, 2022

Conversation

hydrosquall
Copy link
Owner

Motivation

Image 2022-04-16 at 8 20 16 PM

To host the demo for free as part of the open source sponsorship program, we have to add a banner to the README and the site footer. This will help fulfill #7 .

Changes

  • Creates a custom datasette plugin that adds the footer as a client-side script.
  • Factors out common arguments into the local dev and deployment step so that the demo site can have custom plugins and metadata.
  • Adds a banner to the site footer

Notes

  • It would be nice to have an alternate server side rendering API for modifying the header/footer of every page. Alternately, we could have a hook that let you modify any template's response before returning it to the client.
  • As it stands, this appears to be the easiest way to get a banner onto every page, since the base.html template isn't extensible (I left it checked into the repo for posterity in case the datasette API is changed in the future).

@hydrosquall hydrosquall self-assigned this Apr 17, 2022
run-demo:
datasette -i demo/happy_planet_index.db \
${DATASETTE_DEMO_FLAGS}
# --template-dir=demo/demo-templates
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Commented this out because overriding base.html had no effect. Only full pages or the "row" partial can be overridden.

https://docs.datasette.io/en/stable/custom_templates.html#custom-templates

@@ -0,0 +1,28 @@
// Append footer with the Vercel logo to every page.
// TODO: Check if there a way to server-side render this someday?
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be much better to run all of this once on the server side at compile time, but the execution cost is negligible so I'll leave it as is for now. Note that the resulting HTML string is constant every time, so we could technically preval sponsorContainer once, and use it the same string everywhere.

{% block content %}
{{ super() }}
<footer>
<h1>Unused: theoretically this could be a custom footer</h1>
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This didn't work, but I'd imagine a future extension to the Datasette API might look something like this.

@@ -0,0 +1 @@
<h1>hello world - a custom template</h1>
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This template does work (it'll replace your homepage).

title:
Datasette Nteract Data Explorer Demo

description_html:
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really like this string by default with an optional _html extension API. If these blocks get longer, I'll store the description in markdown somewhere, and convert them to HTML in a build step.

@hydrosquall hydrosquall force-pushed the cameron.yick/add-sponsor-logo-to-footer branch from 3a04702 to 5c019df Compare April 17, 2022 00:40
@hydrosquall hydrosquall merged commit c0ab70a into main Apr 17, 2022
@hydrosquall hydrosquall deleted the cameron.yick/add-sponsor-logo-to-footer branch April 17, 2022 00:41
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.

None yet

1 participant