1.1 --- a/moinformat/themes/default/html.py Mon Nov 26 16:10:17 2018 +0100
1.2 +++ b/moinformat/themes/default/html.py Mon Nov 26 16:52:43 2018 +0100
1.3 @@ -19,69 +19,15 @@
1.4 this program. If not, see <http://www.gnu.org/licenses/>.
1.5 """
1.6
1.7 -from moinformat.themes.common import Theme
1.8 -from os import listdir
1.9 -from os.path import splitext
1.10 +from moinformat.themes.html import HTMLTheme
1.11
1.12 -class DefaultHTMLTheme(Theme):
1.13 +class DefaultHTMLTheme(HTMLTheme):
1.14
1.15 - "A default theme."
1.16 + "A default HTML theme."
1.17
1.18 name = "html"
1.19 origin = __file__
1.20
1.21 - link = '<link rel="stylesheet" type="text/css" charset="utf-8" media="%(media)s" href="%(root)s/_css/%(filename)s" />\n'
1.22 -
1.23 - def get_links(self, subs):
1.24 -
1.25 - "Using 'subs', return a string containing markup linking to resources."
1.26 -
1.27 - d = {}
1.28 - d.update(subs)
1.29 -
1.30 - links = []
1.31 -
1.32 - for filename in listdir(self.get_resource("css")):
1.33 -
1.34 - # Only link to CSS files.
1.35 -
1.36 - if splitext(filename)[-1] != ".css":
1.37 - continue
1.38 -
1.39 - # Filenames can have the form <media>_<name>.css to set the media
1.40 - # type.
1.41 -
1.42 - t = filename.split("_")
1.43 -
1.44 - d["media"] = len(t) > 1 and t[0] or "all"
1.45 - d["filename"] = filename
1.46 -
1.47 - links.append(self.link % d)
1.48 -
1.49 - return "".join(links)
1.50 -
1.51 - # Public methods.
1.52 -
1.53 - def apply(self, text):
1.54 -
1.55 - "Apply this theme to the given 'text', returning a themed version."
1.56 -
1.57 - template = self.load_resource("template.html")
1.58 - subs = {
1.59 - "encoding" : self.output.encoding,
1.60 - "root" : self.linker.get_top_level() or ".",
1.61 - "text" : text,
1.62 - "title" : self.metadata.get("pagename"),
1.63 - }
1.64 - subs["links"] = self.get_links(subs)
1.65 - return template % subs
1.66 -
1.67 - def install_resources(self):
1.68 -
1.69 - "Install resources for this theme."
1.70 -
1.71 - self.install_resource("css", "_css")
1.72 -
1.73 theme = DefaultHTMLTheme
1.74
1.75 # vim: tabstop=4 expandtab shiftwidth=4