theming.rst 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. Theme your pagure
  2. =================
  3. Pagure via `flask-multistatic <https://pagure.io/flask-multistatic>`_
  4. offers the possibility to override the default theme allowing to customize
  5. the style of your instance.
  6. By default pagure looks for its templates and static files in the folders
  7. ``pagure/templates`` and ``pagure/static``, but you can ask pagure to look
  8. for templates and static files in another folder.
  9. By specifying the configuration keys ``THEME_TEMPLATE_FOLDER`` and
  10. ``THEME_STATIC_FOLDER`` in pagure's configuration file, you tell pagure to
  11. look for templates and static files first in these folders, then in its
  12. usual folders.
  13. .. note: The principal is that pagure will look in the folder specified in
  14. the configuration file first and then in its usual folder, so the
  15. **file names must be identical**.
  16. Example
  17. -------
  18. Let's take an example, you wish to replace the pagure logo at the top right
  19. of all the pages.
  20. This logo is part of the ``master.html`` template which all pages inherit
  21. from. So what you want to do is replace this ``master.html`` by your own.
  22. * First, create the folder where your templates and static files will be stored:
  23. ::
  24. mkdir /var/www/mypaguretheme/templates
  25. mkdir /var/www/mypaguretheme/static
  26. * Place your own logo in the static folder
  27. ::
  28. cp /path/to/your/my-logo.png /var/www/mypaguretheme/static
  29. * Place in there the original ``master.html``
  30. ::
  31. cp /path/to/original/pagure/templates/master.html /var/www/mypaguretheme/templates
  32. * Edit it and replace the url pointing to the pagure logo (around line 27)
  33. ::
  34. - <img height=40px src="{{ url_for('static', filename='pagure-logo.png') }}"
  35. + <img height=40px src="{{ url_for('static', filename='my-logo.png') }}"
  36. * Adjust pagure's configuration file:
  37. + THEME_TEMPLATE_FOLDER='/var/www/mypaguretheme/templates'
  38. + THEME_STATIC_FOLDER='/var/www/mypaguretheme/static'
  39. * Restart pagure
  40. .. note: you could just have replaced the `pagure-logo.png` file with your
  41. own logo which would have avoided overriding the template.
  42. In production
  43. -------------
  44. Serving static files via flask is fine for development but in production
  45. you will probably want to have apache server them. This will allow caching
  46. either on the server side or on the client side.
  47. You can ask apache to behave in a similar way as does flask-multistatic with
  48. flask here, ie: search in one folder and if you don't find the file look
  49. in another one.
  50. `An example apache configuration <https://pagure.io/flask-multistatic/blob/master/f/example.conf>`_
  51. is provided as part of the sources of `flask-multistatic <https://pagure.io/flask-multistatic/>`_.