Skip to content

Commit f4cec0d

Browse files
author
Roberto Alsina
committedMay 4, 2017
Make the gallery directive less of a hack
1 parent 531429a commit f4cec0d

File tree

2 files changed

+42
-4
lines changed

2 files changed

+42
-4
lines changed
 

‎v7/gallery_directive/README.md

+41-1
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,44 @@ Usage::
55
.. gallery:: demo
66

77
This should embed the gallery found in galleries/demo in your post.
8-
Keep in mind that this is a horrible, horrible hack.
8+
Keep in mind that this is sort of a hack.
9+
10+
Caveats:
11+
12+
* The styling of the displayed gallery is meant to sort-of-work
13+
with the bootstrap-based themes
14+
15+
* It will **not** have the fancy rows/columns layout of the regular
16+
gallery in bootstrap, either.
17+
18+
* It will look bad in most other themes. But you can customize it by
19+
creating your own gallery_fancy.tmpl. Here's the one that comes with
20+
the plugin for inspiration:
21+
22+
```html
23+
## -*- coding: utf-8 -*-
24+
25+
%if post:
26+
<p>
27+
${post.text()}
28+
</p>
29+
%endif
30+
31+
<div id="gallery_container"></div>
32+
%if photo_array:
33+
<div class="row">
34+
%for image in photo_array:
35+
<div class="col-xs-6 col-md-3">
36+
<a href="${image['url']}" class="thumbnail image-reference" title="${image['title']|h}">
37+
<img src="${image['url_thumb']}" alt="${image['title']|h}" />
38+
</a>
39+
</div>
40+
%endfor
41+
</div>
42+
43+
<ul class="thumbnails">
44+
<li>
45+
</ul>
46+
%endif
47+
```
48+

‎v7/gallery_directive/gallery_directive.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,8 @@ def run(self):
9191
context.update(self.site.GLOBAL_CONTEXT)
9292
context.update(kw)
9393
output = self.site.template_system.render_template(
94-
'gallery.tmpl',
94+
'gallery_fancy.tmpl',
9595
None,
9696
context
9797
)
98-
# This magical comment makes everything work. Try removing it!
99-
output = '\n<!-- foo -->\n%s\n\n\n' % output
10098
return [nodes.raw('', output, format='html')]

0 commit comments

Comments
 (0)