Merge lp:~franku/widelands-website/handle_great_images into lp:widelands-website

Proposed by kaputtnik
Status: Merged
Merged at revision: 396
Proposed branch: lp:~franku/widelands-website/handle_great_images
Merge into: lp:widelands-website
Diff against target: 184 lines (+69/-19)
6 files modified
mainpage/templatetags/wl_markdown.py (+19/-2)
media/css/forum.css (+1/-0)
media/css/maps.css (+8/-3)
media/css/wiki.css (+12/-0)
templates/wiki/edit.html (+27/-12)
templates/wlmaps/index.html (+2/-2)
To merge this branch: bzr merge lp:~franku/widelands-website/handle_great_images
Reviewer Review Type Date Requested Status
Widelands Developers Pending
Review via email: mp+254988@code.launchpad.net

Description of the change

In continuation of https://code.launchpad.net/~franku/widelands-website/handle_big_images/+merge/247235

This branch contain css related changes to prevend that big images destroy the layout of the website.

In Forum all external images gets clickable and big images where automatically limited in size so that they never break the website layout.

In Wiki the changes affects the edit site: Each Image gets an own table with two columns. The "Code to include" is changed in "Code to use in article:" and is found at the bottom of each image table. The "Code to use in article:" depends on the image width: If it is to big, the "Code to use in article:" shows the syntax for a clickable image. See http://home.arcor.de/frank.ue/article_edit.jpg for a comparison to current state.

This branch only works correct, if some former failures to the image path are corrected. So the changes do only work, if the branch https://code.launchpad.net/~franku/widelands-website/admin_action_correct_image_path is merged and the containing admin action is executed.

There is also the branch https://code.launchpad.net/~franku/widelands-website/correct_image_paths which contains little changes to correct the image path for future uploads.

To post a comment you must log in.
Revision history for this message
SirVer (sirver) wrote :

kaputtnik, are all of the prerequisites of this branch now met? Can we merge this?

Revision history for this message
kaputtnik (franku) wrote :

Yes :-)

Revision history for this message
SirVer (sirver) wrote :

Merged!!! Thanks for your hard work!

Revision history for this message
kaputtnik (franku) wrote :

I thank you for taking your time :-)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'mainpage/templatetags/wl_markdown.py'
2--- mainpage/templatetags/wl_markdown.py 2015-02-26 20:25:39 +0000
3+++ mainpage/templatetags/wl_markdown.py 2015-04-01 20:41:52 +0000
4@@ -145,6 +145,17 @@
5
6 return None
7
8+def _clickable_image( tag ):
9+ # is external link?
10+ if tag["src"].startswith("http"):
11+ # is allways a link?
12+ if tag.parent.name != 'a':
13+ # add link to image
14+ text = "<a href=" + tag["src"] +"><img src=" + tag["src"] + "></a>"
15+ return text
16+ return None
17+
18+
19 custom_filters = {
20 # Wikiwordification
21 # Match a wiki page link LikeThis. All !WikiWords (with a !
22@@ -202,13 +213,19 @@
23 soup = BeautifulSoup(unicode(soup)) # What a waste of cycles :(
24
25 # We have to go over this to classify links
26-
27 for tag in soup.findAll("a"):
28 rv = _classify_link(tag)
29 if rv:
30 for attribute in rv.iterkeys():
31 tag[attribute] = rv.get(attribute)
32-
33+
34+ # All external images gets clickable
35+ # This applies only in forum
36+ for tag in soup.findAll("img"):
37+ link = _clickable_image(tag)
38+ if link:
39+ tag.replaceWith(link)
40+
41 return unicode(soup)
42
43
44
45=== modified file 'media/css/forum.css'
46--- media/css/forum.css 2015-02-24 20:24:59 +0000
47+++ media/css/forum.css 2015-04-01 20:41:52 +0000
48@@ -12,6 +12,7 @@
49 .forum {
50 border: none;
51 border-collapse: collapse;
52+ table-layout: fixed;
53 width: 100%;
54 }
55
56
57=== modified file 'media/css/maps.css'
58--- media/css/maps.css 2012-05-08 21:52:15 +0000
59+++ media/css/maps.css 2015-04-01 20:41:52 +0000
60@@ -1,3 +1,7 @@
61+table.maps {
62+ border-collapse: collapse;
63+}
64+
65 img.minimap {
66 max-height: 250px;
67 }
68@@ -6,15 +10,16 @@
69 margin: 0px 10px 10px 0px;
70 }
71
72-.forum table td {
73+.maps table td{
74 padding: 2px;
75 }
76
77-.forum td {
78+.maps td {
79 vertical-align: top;
80+ padding: 8px;
81 }
82
83-.forum .spacer {
84+.maps .spacer {
85 width: 15px;
86 }
87
88
89=== modified file 'media/css/wiki.css'
90--- media/css/wiki.css 2015-01-07 13:49:21 +0000
91+++ media/css/wiki.css 2015-04-01 20:41:52 +0000
92@@ -73,6 +73,18 @@
93 height: 100px;
94 }
95
96+table.images {
97+ table-layout: fixed;
98+}
99+
100+table.images .first-column {
101+ width: 7em;
102+}
103+
104+table.images td {
105+ padding: 4px;
106+}
107+
108 /***********/
109 /* Headers */
110 /***********/
111
112=== modified file 'templates/wiki/edit.html'
113--- templates/wiki/edit.html 2015-02-18 22:30:08 +0000
114+++ templates/wiki/edit.html 2015-04-01 20:41:52 +0000
115@@ -95,25 +95,40 @@
116 {% else %}
117 {% if images.count %}
118 Images attached to this article:
119- <table width="100%">
120+
121+ {% for img in images %}
122+ <table width="100%" class="images">
123 <thead>
124 <tr>
125- <th>Image Title</th>
126- <th>Image</th>
127- <th>Code to include</th>
128+ <th class="first-column" style="text-align: right;">Name:</th>
129+ <th>{{ img.name}}</th>
130 </tr>
131 </thead>
132 <tbody>
133- {% for img in images %}
134- <tr>
135- <td>{{ img.name }}</td>
136- <td><img src="{{ img.url }}"></td>
137- <td>![{{img.name}}]({{ img.url }})</td>
138- </tr>
139- {% endfor %}
140+ <tr>
141+ <td>
142+ <span>Properties:</span><br />
143+ <span class="grey">Width:</span><br />
144+ {{ img.image.width }} px<br />
145+ <span class="grey">Height:</span><br />
146+ {{ img.image.height }} px<br />
147+ <span class="grey">Filesize:</span><br />
148+ {{ img.image.size|filesizeformat }}
149+ <td style="vertical-align: middle; text-align: center;"><img src="{{ img.url }}"></td>
150+ </tr>
151+ <tr>
152+ <td class="grey" style="text-align: right;">Code to use in article:</td>
153+ {% if img.image.width > 700 %}
154+ <td style="text-align: center;">[![{{img.name}}]({{ img.url }})]({{ img.url }})</td>
155+ {% else %}
156+ <td style="text-align: center;">![{{img.name}}]({{ img.url }})</td>
157+ {% endif %}
158+ </tr>
159+
160 </tbody>
161 </table>
162- {%endif%}
163+ {% endfor %}
164+ {% endif %}
165
166 {% get_upload_form as iform %}
167 <form enctype="multipart/form-data" action="/images/upload/{{content_type}}/{{object_id}}/{{request.path|iriencode}}" method="POST">
168
169=== modified file 'templates/wlmaps/index.html'
170--- templates/wlmaps/index.html 2015-02-18 22:30:08 +0000
171+++ templates/wlmaps/index.html 2015-04-01 20:41:52 +0000
172@@ -19,10 +19,10 @@
173 {% autopaginate maps maps_per_page %}
174 {% paginate %}
175 <br />
176- <table class="forum">
177+ <table class="maps">
178 {% for map in maps %}
179 <tr class="{% cycle "odd" "even" %}">
180- <td><a href="{{ map.get_absolute_url }}"><img class="minimap" src="{{ MEDIA_URL }}{{ map.minimap.url }}" alt="{{ map.name }}" /></a></td>
181+ <td class="first-column"><a href="{{ map.get_absolute_url }}"><img class="minimap" src="{{ MEDIA_URL }}{{ map.minimap.url }}" alt="{{ map.name }}" /></a></td>
182 <td>
183 <h3><a class="invertedColor" href="{{ map.get_absolute_url }}">{{ map.name }}</a></h3>
184 <table>

Subscribers

People subscribed via source and target branches