Skip to content

Commit d964a49

Browse files
committed
deepzoom-tile: Generate HTML index file if -r specified
1 parent 001fd94 commit d964a49

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

examples/deepzoom/deepzoom-tile.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ def run(self):
126126
if self._with_viewer:
127127
for name in self._slide.associated_images:
128128
self._run_image(name)
129+
self._write_html()
129130
self._write_static()
130131
self._shutdown()
131132

@@ -144,6 +145,19 @@ def _run_image(self, associated=None):
144145
DeepZoomImageTiler(dz, basename, self._format, associated,
145146
self._queue).run()
146147

148+
def _write_html(self):
149+
import jinja2
150+
env = jinja2.Environment(loader=jinja2.PackageLoader(__name__),
151+
autoescape=True)
152+
template = env.get_template('index.html')
153+
associated_urls = dict((n, '%s.dzi' % self._slugify(n))
154+
for n in self._slide.associated_images)
155+
data = template.render(slide_url='slide.dzi',
156+
associated=associated_urls,
157+
properties=self._slide.properties)
158+
with open(os.path.join(self._basename, 'index.html'), 'w') as fh:
159+
fh.write(data)
160+
147161
def _write_static(self):
148162
basesrc = os.path.join(os.path.dirname(os.path.abspath(__file__)),
149163
'static')

0 commit comments

Comments
 (0)