richard icon indicating copy to clipboard operation
richard copied to clipboard

Ability to easily customize the base template

Open squiddy opened this issue 13 years ago • 1 comments

I'm using pyvideo's project for developing, so I had problems when I modified the base template in richard. Right now, pyvideo has a copy of richard's base.html because it added things like tracking code.

My proposal:

site_base.html

<!DOCTYPE html>
<head>
  ...
  {% block additional_head %}{% endblock %}
</head>
<body>
  ...
  {% block additional_body %}{% endblock %}
</body>

default base.html

{% extends 'site_base.html' %}

adding tracking code (change base.html)

{% extends 'site_base.html' %}

{% block additional_head %}
  {{ super() }}
  <script>
    (function() {
        var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
        ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
        var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
     })();
  </script>
{% endblock %}

That means the current base.html becomes site_base.html, we add a couple of hooks (blocks) to it where necessary (head, body, footer, ..). These can be extended by the project.

Projects like pinax do something similar. And I'm pretty sure I've read a post describing a nice layout for that, don't ask me where though. :-)

squiddy avatar Mar 27 '12 17:03 squiddy

Mmm... So I see both the problem and what you're suggesting changes-wise, but I'm on the fence as to whether the additional complexity here makes sense. pyvideo is kind of a special case because I built pyvideo, then extracted richard, then kept going. I haven't had a chance to do some of the things with pyvideo that I want to do. One of which is put a real style in place.

I suspect that the common use case is to grab richard and then re-skin it not using Twitter Bootstrap. Given that, the changes here don't help much.

I think I'd want to see more people use it and see how they handle templating before making these changes.

I'll think about it some more.

willkg avatar Apr 11 '12 13:04 willkg