~sampablokuper/mnemosyne-proj/css

« back to all changes in this revision

Viewing changes to mnemosyne/mnemosyne/libmnemosyne/renderers/html_css.py

  • Committer: Sam Pablo Kuper
  • Date: 2016-06-17 22:08:30 UTC
  • Revision ID: sampablokuper@uclmail.net-20160617220830-098udsagiwnip6l3
Add normalize.css with font stack, to enable preformatted text.

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
#
4
4
 
5
5
from mnemosyne.libmnemosyne.renderer import Renderer
 
6
import os
6
7
 
7
8
# Css table wizardry based on info from
8
9
# http://apptools.com/examples/tableheight.php
26
27
        # We cache the css creation to save some time, especially on mobile
27
28
        # devices.
28
29
        self._css = {} # {card_type.id: render_args: css}
 
30
        # Calculate the path to our CSS file(s).
 
31
        path = os.path.dirname(os.path.abspath(__file__))
 
32
        self.csspath = os.path.join(path, "css") + os.sep
29
33
 
30
34
    def body_css(self, **render_args):
31
35
        return "html, body { margin: 0px; height: 100%;  width: 100%;}\n"
88
92
 
89
93
    def update(self, card_type, **render_args):
90
94
        if card_type.id not in self._css:
91
 
            self._css[card_type.id] = {}    
 
95
            self._css[card_type.id] = {}
92
96
        self._css[card_type.id][repr(sorted(render_args.items()))] =\
93
97
            self.body_css(**render_args) + \
94
98
            self.card_type_css(card_type, **render_args)
95
 
            
 
99
 
96
100
    def css(self, card_type, **render_args):
97
101
        render_args_hash = repr(sorted(render_args.items()))
98
102
        if not card_type.id in self._css or \
123
127
        <!DOCTYPE html>
124
128
        <html>
125
129
        <head>
126
 
        <meta charset="utf-8">
127
 
        <style type="text/css">
128
 
        %s
129
 
        </style>
 
130
          <meta charset="utf-8">
 
131
          <!--
 
132
          <style type="text/css">
 
133
          %s
 
134
          </style>
 
135
          -->
 
136
          <style type="text/css">
 
137
          pre { color: blue; }
 
138
          </style>
 
139
          <link media="all" rel="stylesheet"
 
140
          href="file:%snormalize.css"
 
141
          type="text/css">
130
142
        </head>
131
143
        <body>
132
144
          <table id="mnem1" class="mnem">
134
146
              <td>%s</td>
135
147
            </tr>
136
148
          </table>
 
149
          <script type="text/javascript" src="https://getfirebug.com/firebug-lite.js"></script>
137
150
        </body>
138
 
        </html>""" % (css, body)
139
 
 
 
151
        </html>""" % (css, self.csspath, body)