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

ENH: include the sidebar from the sidebar plugin when building the pages #375

Open
mattip opened this issue Feb 2, 2021 · 3 comments
Open

Comments

@mattip
Copy link

mattip commented Feb 2, 2021

Rather than generate a sidebar-en.inc file as a task, perhaps the sidebar plugin could add a set_site method and add the sidebar as a blinker.signal callback, like static_comments does. This would make the snippet more useful since no server-side or javascript would be needed to include it. Did I understand correctly the sequence of processes?

@mattip
Copy link
Author

mattip commented Feb 2, 2021

It might be sufficient to add the 'public' path to the python code in sidebar.py:

    def set_site(self, site):
        """Set site."""
        site.template_system.inject_directory('public')   # add this line
        super(RenderSidebar, self).set_site(site)

Then I can include the snippet in my templates

{% include 'sidebar-en.inc' %}

@felixfontein
Copy link
Contributor

@mattip the problem with the sidebar is that its contents depend on essentially the whole site. So if the sidebar would already be included during the build in every page, every change to the site would require re-creating all pages. For small pages that's ok, for larger ones it's pretty excessive. That's why it generates a separate file that needs to be included in another step.

I personally use a substitution script / two-phase deployment to create a final version of the site with the sidebar included, to avoid the use of JavaScript to include it.

@mattip
Copy link
Author

mattip commented Feb 2, 2021

I personally use a substitution script / two-phase deployment to create a final version

With sed via a marker in the post template? I guess that could work too. My site (www.pypy.org after importing blog posts + comments from https://morepypy.blogspot.com in this MR) has ~500 posts and the strategy I outlined above requires about 3 seconds to recreate the pages, so I am not to worried about rebuilding once a week or so when we have new blog posts.

@mattip mattip changed the title ENH: add a blinker event for the sidebar plugin ENH: include the sidebar from the sidebar plugin when building the pages Feb 2, 2021
zhangliwen pushed a commit to hg-mirrors/pypy_pypy.org that referenced this issue Sep 29, 2021
Note the sidebar needs to be "included", use sed instead of Jinja2
getnikola/plugins#375
zhangliwen pushed a commit to hg-mirrors/pypy_pypy.org that referenced this issue Sep 29, 2021
Note the sidebar needs to be "included", use sed instead of Jinja2
getnikola/plugins#375
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

No branches or pull requests

2 participants