Re: [Widelands-dev] [Merge] lp:~franku/widelands-website/handle_big_images into lp:widelands-website

2015-04-01 Thread kaputtnik
I splitted it into three branches:

The branch 
https://code.launchpad.net/~franku/widelands-website/handle_great_images 
contains the css related things and the stuff to wl_markdown.py for handling 
big images which break the layout

The branch 
https://code.launchpad.net/~franku/widelands-website/correct_image_paths 
contains little changes to prevent failures on future image uploads

The branch 
https://code.launchpad.net/~franku/widelands-website/admin_action_correct_image_path
 contains the admin-action to repair old values for images from a absolute path 
to a relative path. Once the admin action is made, this branch could be 
reverted.

The merge proposals to each branch i will make subsequently.
-- 
https://code.launchpad.net/~franku/widelands-website/handle_big_images/+merge/247235
Your team Widelands Developers is subscribed to branch lp:widelands-website.

___
Mailing list: https://launchpad.net/~widelands-dev
Post to : widelands-dev@lists.launchpad.net
Unsubscribe : https://launchpad.net/~widelands-dev
More help   : https://help.launchpad.net/ListHelp


[Widelands-dev] [Merge] lp:~franku/widelands-website/handle_great_images into lp:widelands-website

2015-04-01 Thread kaputtnik
kaputtnik has proposed merging lp:~franku/widelands-website/handle_great_images 
into lp:widelands-website.

Requested reviews:
  Widelands Developers (widelands-dev)

For more details, see:
https://code.launchpad.net/~franku/widelands-website/handle_great_images/+merge/254988

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.
-- 
Your team Widelands Developers is requested to review the proposed merge of 
lp:~franku/widelands-website/handle_great_images into lp:widelands-website.
=== modified file 'mainpage/templatetags/wl_markdown.py'
--- mainpage/templatetags/wl_markdown.py	2015-02-26 20:25:39 +
+++ mainpage/templatetags/wl_markdown.py	2015-04-01 20:41:52 +
@@ -145,6 +145,17 @@
 
 return None
 
+def _clickable_image( tag ):
+# is external link?
+if tag["src"].startswith("http"):
+# is allways a link?
+if tag.parent.name != 'a':
+# add link to image
+text = ""
+return text
+return None
+
+
 custom_filters = {
 # Wikiwordification
 # Match a wiki page link LikeThis. All !WikiWords (with a !
@@ -202,13 +213,19 @@
 soup = BeautifulSoup(unicode(soup)) # What a waste of cycles :(
 
 # We have to go over this to classify links
-
 for tag in soup.findAll("a"):
 rv = _classify_link(tag)
 if rv:
 for attribute in rv.iterkeys():
 tag[attribute] = rv.get(attribute)
-
+
+# All external images gets clickable
+# This applies only in forum
+for tag in soup.findAll("img"):
+link = _clickable_image(tag)
+if link:
+tag.replaceWith(link)
+
 return unicode(soup)
 
 

=== modified file 'media/css/forum.css'
--- media/css/forum.css	2015-02-24 20:24:59 +
+++ media/css/forum.css	2015-04-01 20:41:52 +
@@ -12,6 +12,7 @@
 .forum {
 	border: none; 
 	border-collapse: collapse;
+	table-layout: fixed;
 	width: 100%;
 }
 

=== modified file 'media/css/maps.css'
--- media/css/maps.css	2012-05-08 21:52:15 +
+++ media/css/maps.css	2015-04-01 20:41:52 +
@@ -1,3 +1,7 @@
+table.maps {
+	border-collapse: collapse;
+}
+
 img.minimap {
 	max-height: 250px;
 }
@@ -6,15 +10,16 @@
 	margin: 0px 10px 10px 0px;
 }
 
-.forum table td {
+.maps table td{
 	padding: 2px;
 }
 
-.forum td {
+.maps td {
 	vertical-align: top;
+	padding: 8px;
 }
 
-.forum .spacer {
+.maps .spacer {
 	width: 15px;
 }
 

=== modified file 'media/css/wiki.css'
--- media/css/wiki.css	2015-01-07 13:49:21 +
+++ media/css/wiki.css	2015-04-01 20:41:52 +
@@ -73,6 +73,18 @@
 	height: 100px;
 }
 
+table.images {
+	table-layout: fixed;
+}
+
+table.images .first-column {
+	width: 7em;
+}
+
+table.images td {
+	padding: 4px;
+}
+
 /***/
 /* Headers */
 /***/

=== modified file 'templates/wiki/edit.html'
--- templates/wiki/edit.html	2015-02-18 22:30:08 +
+++ templates/wiki/edit.html	2015-04-01 20:41:52 +
@@ -95,25 +95,40 @@
 	{% else %}
 		{% if images.count %}
 		Images attached to this article:
-		
+		
+		{% for img in images %}
+		
 		
 			
-Image Title
-Image
-Code to include
+Name:
+{{ img.name}}
 			
 		
 		
-			{% for img in images %}
-			
-{{ img.name }}
-
-![{{img.name}}]({{ img.url }})
-			
-			{% endfor %}
+			
+
+	Properties:
+	Width:
+	{{ img.image.width }} px
+	Height:
+	{{ img.image.height }} px
+	Filesize:
+	{{ img.image.size|filesizeformat }}
+
+			
+			
+Code to use in article:
+{% if img.image.width > 700 %}
+	[![{{img.name}}]({{ img.url }})]({{ img.url }})
+{% else %}
+	![{{img.name}}]({{ img.url }})
+{% endif %}
+			
+		
 		
 		
-		{%endif%}
+		{% endfor %}
+		{% endif %}
 
 		{% get_upload_form as iform %}
 		

=== modified file 'templates/wlmaps/index.html'
--- templates/wlm

[Widelands-dev] [Merge] lp:~franku/widelands-website/correct_image_paths into lp:widelands-website

2015-04-01 Thread kaputtnik
kaputtnik has proposed merging lp:~franku/widelands-website/correct_image_paths 
into lp:widelands-website.

Requested reviews:
  Widelands Developers (widelands-dev)

For more details, see:
https://code.launchpad.net/~franku/widelands-website/correct_image_paths/+merge/254990

This branch contains two little changes to prevent failures to future image 
uploads in wiki and correct the upload_to value for the admin site.

To read why this is needed see: 
https://code.launchpad.net/~franku/widelands-website/handle_big_images/+merge/247235/comments/625062

This is part of 
https://code.launchpad.net/~franku/widelands-website/handle_great_images/+merge/254988
-- 
Your team Widelands Developers is requested to review the proposed merge of 
lp:~franku/widelands-website/correct_image_paths into lp:widelands-website.
=== modified file 'wlimages/models.py'
--- wlimages/models.py	2015-03-15 18:01:51 +
+++ wlimages/models.py	2015-04-01 20:46:34 +
@@ -44,7 +44,7 @@
 for chunk in image.chunks():
 destination.write(chunk)
 
-im.image = path
+im.image = "wlimages/%s" % (name)
 im.url = url
 
 im.save()
@@ -72,7 +72,7 @@
 
 # Date Fields
 date_submitted = models.DateTimeField(_('date/time submitted'), default = datetime.now)
-image = models.ImageField(upload_to="images/")
+image = models.ImageField(upload_to="wlimages/")
 url = models.CharField(max_length=250)
 
 

___
Mailing list: https://launchpad.net/~widelands-dev
Post to : widelands-dev@lists.launchpad.net
Unsubscribe : https://launchpad.net/~widelands-dev
More help   : https://help.launchpad.net/ListHelp


[Widelands-dev] [Merge] lp:~franku/widelands-website/admin_action_correct_image_path into lp:widelands-website

2015-04-01 Thread kaputtnik
kaputtnik has proposed merging 
lp:~franku/widelands-website/admin_action_correct_image_path into 
lp:widelands-website.

Requested reviews:
  Widelands Developers (widelands-dev)

For more details, see:
https://code.launchpad.net/~franku/widelands-website/admin_action_correct_image_path/+merge/254993

This branch add an "admin action" to the site 
https://wl.widelands.org/admin/wlimages/image/

The "action" changes the path form the "image"value from an absolute path to a 
relative path in a convenient way. See 
https://code.launchpad.net/~franku/widelands-website/handle_big_images/+merge/247235/comments/628869
 for a reason why this is needed.

See also:
1. 
https://code.launchpad.net/~franku/widelands-website/correct_image_paths/+merge/254990
2. 
https://code.launchpad.net/~franku/widelands-website/handle_great_images/+merge/254988
-- 
Your team Widelands Developers is requested to review the proposed merge of 
lp:~franku/widelands-website/admin_action_correct_image_path into 
lp:widelands-website.
=== modified file 'wlimages/admin.py'
--- wlimages/admin.py	2015-03-15 18:01:51 +
+++ wlimages/admin.py	2015-04-01 20:51:58 +
@@ -13,6 +13,17 @@
 from django.utils.translation import ugettext_lazy as _
 from models import Image
 
+# A function to correct the image paths to a relative path
+# This function could be removed if all old image paths are modified
+# to "wlimages/name_of_image.extension"
+def correct_image_path(modeladmin, request, queryset):
+for obj in queryset:
+# use original value of image because of CaSes
+path = unicode(obj.image)
+f_name =  path.rpartition("/")[2]
+obj.image = "wlimages/%s" % (f_name)
+obj.save()
+
 class ImageAdmin(admin.ModelAdmin):
 fieldsets = (
 (None, {'fields': ( ('image', 'name'), 'date_submitted', 'url','revision')}),
@@ -23,5 +34,6 @@
 list_filter = ('date_submitted',)
 date_hierarchy = 'date_submitted'
 search_fields = ('image', 'user__username')
+actions = [correct_image_path]
 
 admin.site.register(Image, ImageAdmin)

___
Mailing list: https://launchpad.net/~widelands-dev
Post to : widelands-dev@lists.launchpad.net
Unsubscribe : https://launchpad.net/~widelands-dev
More help   : https://help.launchpad.net/ListHelp