Changeset 346
- Timestamp:
- 06/21/08 22:04:03 (4 years ago)
- Files:
-
- 1 modified
-
hodgestar/Talks/PythonObjects/slides.py (modified) (13 diffs)
Legend:
- Unmodified
- Added
- Removed
-
hodgestar/Talks/PythonObjects/slides.py
r342 r346 1 1 # Slides, a HTML slide generator 2 2 # Copyright (C) 2002 Moshe Zadka, Itamar Shtull-Trauring 3 # Minor modifications (C) 2008 Simon Cross 3 4 # 4 5 # This library is free software; you can redistribute it and/or … … 14 15 # License along with this library; if not, write to the Free Software 15 16 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 # 18 # History: 19 # 20 # 2008-06-21, Simon Cross 21 # Version 1.0.2 22 # Minor changes to move prev/next links to bottom. Clean-up tabs. 23 # 24 # 2002, Moshe Zadka and Itamar Shtull-Traurin 25 # Version 1.0.1 26 # Original implementation 16 27 17 28 """Slides, a HTML slide generator.""" … … 32 43 When you're done call renderHTML(). 33 44 """ 34 45 35 46 css = None 36 47 37 48 def __init__(self, name, *slides): 38 49 self.name = name 39 self.slides = slides40 50 self.slides = slides 51 41 52 def renderHTML(self, directory, basename, css=None): 42 53 """Render all slides and their index. … … 61 72 result += '<link rel="stylesheet" type="text/css" href="%s" />\n' % self.css 62 73 return result + '</head>\n<body>\n' 63 74 64 75 def getFooter(self): 65 76 """Return the footer for HTML pages.""" … … 78 89 for i in range(len(self.slides)): 79 90 fp.write("<li><a href='%s'>%s</a></li>\n" % 80 (basename % (i+1), self.slides[i].title))91 (basename % (i+1), self.slides[i].title)) 81 92 fp.write('</ol>\n') 82 93 fp.write(self.getIndexFooter()) … … 98 109 index = '<a href="%s">Index</a>' % (basename % 0) 99 110 result = (self.getHeader() + html 100 + " | ".join([prev, index, next]) + self.getFooter())111 + " | ".join([prev, index, next]) + self.getFooter()) 101 112 fp = open(os.path.join(directory, basename % i), 'w') 102 113 fp.write(result) … … 111 122 *bullets -- Bullet instances. 112 123 """ 113 124 114 125 start = "<ul>\n" 115 126 end = "</ul>\n" 116 127 117 128 def __init__(self, title, *bullets): 118 129 self.title = title … … 134 145 *bullets -- Bullet instances. 135 146 """ 136 147 137 148 start = "<ol>\n" 138 149 end = "</ol>\n" … … 145 156 *bullets -- Bullet instances. 146 157 """ 147 158 148 159 def __init__(self, *bullets): 149 160 self.bullets = bullets … … 158 169 class Bullet: 159 170 """A bullet.""" 160 171 161 172 def __init__(self, *texts): 162 173 self.texts = texts 163 174 164 def toHTML(self): 175 def toHTML(self): 165 176 return '<li>'+ "".join(map(toHTML, self.texts)) + '</li>\n' 166 177 … … 168 179 class PRE: 169 180 """A quoted text.""" 170 181 171 182 def __init__(self, text): 172 183 self.text = text … … 205 216 class Center: 206 217 """Center an item.""" 207 218 208 219 def __init__(self, text): 209 220 self.text = text … … 215 226 class Image: 216 227 """An image.""" 217 228 218 229 def __init__(self, image, description=""): 219 230 self.image = image 220 231 self.description = description 221 232 222 233 def toHTML(self): 223 234 return "<img src='%s' alt='%s' />" % (self.image, self.description)
