paul@161 | 1 | #!/usr/bin/env python |
paul@161 | 2 | |
paul@161 | 3 | """ |
paul@161 | 4 | A default theme for HTML output. |
paul@161 | 5 | |
paul@161 | 6 | Copyright (C) 2018 Paul Boddie <paul@boddie.org.uk> |
paul@161 | 7 | |
paul@161 | 8 | This program is free software; you can redistribute it and/or modify it under |
paul@161 | 9 | the terms of the GNU General Public License as published by the Free Software |
paul@161 | 10 | Foundation; either version 3 of the License, or (at your option) any later |
paul@161 | 11 | version. |
paul@161 | 12 | |
paul@161 | 13 | This program is distributed in the hope that it will be useful, but WITHOUT |
paul@161 | 14 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
paul@161 | 15 | FOR A PARTICULAR PURPOSE. See the GNU General Public License for more |
paul@161 | 16 | details. |
paul@161 | 17 | |
paul@161 | 18 | You should have received a copy of the GNU General Public License along with |
paul@161 | 19 | this program. If not, see <http://www.gnu.org/licenses/>. |
paul@161 | 20 | """ |
paul@161 | 21 | |
paul@161 | 22 | from moinformat.themes.common import Theme |
paul@161 | 23 | |
paul@161 | 24 | class DefaultHTMLTheme(Theme): |
paul@161 | 25 | |
paul@161 | 26 | "A default theme." |
paul@161 | 27 | |
paul@161 | 28 | name = "html" |
paul@161 | 29 | origin = __file__ |
paul@161 | 30 | |
paul@161 | 31 | def apply(self, text): |
paul@161 | 32 | |
paul@161 | 33 | "Apply this theme to the given 'text', returning a themed version." |
paul@161 | 34 | |
paul@161 | 35 | template = self.load_resource("template.html") |
paul@161 | 36 | subs = { |
paul@161 | 37 | "encoding" : self.output.encoding, |
paul@161 | 38 | "root" : self.linker.get_top_level() or ".", |
paul@161 | 39 | "text" : text, |
paul@161 | 40 | "title" : self.pagename, |
paul@161 | 41 | } |
paul@161 | 42 | return template % subs |
paul@161 | 43 | |
paul@161 | 44 | def install_resources(self): |
paul@161 | 45 | |
paul@161 | 46 | "Install resources for this theme." |
paul@161 | 47 | |
paul@161 | 48 | self.install_resource("css", "_css") |
paul@161 | 49 | |
paul@161 | 50 | theme = DefaultHTMLTheme |
paul@161 | 51 | |
paul@161 | 52 | # vim: tabstop=4 expandtab shiftwidth=4 |