# HG changeset patch # User cavaliet # Date 1359481344 -3600 # Node ID 38611b2c278288961785959c9b9a82692816bc5d # Parent 984dd63957641e54cb0c7abf7390dca948229d71 upgrade home template with thumbnail. diff -r 984dd6395764 -r 38611b2c2782 .hgignore --- a/.hgignore Tue Jan 29 12:53:18 2013 +0100 +++ b/.hgignore Tue Jan 29 18:42:24 2013 +0100 @@ -10,4 +10,4 @@ ^\.project$ ^\.settings/org\.eclipse\.core\.resources\.prefs$ ^\.settings/org\.eclipse\.core\.runtime\.prefs$ - +^web/static/media/cache$ diff -r 984dd6395764 -r 38611b2c2782 src/egonomy/config.py.tmpl --- a/src/egonomy/config.py.tmpl Tue Jan 29 12:53:18 2013 +0100 +++ b/src/egonomy/config.py.tmpl Tue Jan 29 18:42:24 2013 +0100 @@ -34,15 +34,13 @@ BASE_STATIC_ROOT = os.path.abspath(BASE_DIR + "../../web/static/").rstrip("/")+"/" MEDIA_ROOT = BASE_STATIC_ROOT + "media/" +MEDIA_URL = BASE_URL + "static/media/" # Absolute path to the directory that static files (js, css, swf...) # DO NOT forget to do command line ./manage.py collectstatic to gather static media into the web/static folder STATIC_ROOT = BASE_STATIC_ROOT + "site/" - -# URL that handles the media served from MEDIA_ROOT. Make sure to use a -# trailing slash. -# Examples: "http://example.com/media/", "http://media.example.com/" -MEDIA_URL = '' +# Local path to rmn pictures +RMN_PICT_ROOT = STATIC_ROOT + 'rmn/' # Make this unique, and don't share it with anybody. diff -r 984dd6395764 -r 38611b2c2782 src/egonomy/settings.py --- a/src/egonomy/settings.py Tue Jan 29 12:53:18 2013 +0100 +++ b/src/egonomy/settings.py Tue Jan 29 18:42:24 2013 +0100 @@ -118,6 +118,7 @@ 'django.contrib.staticfiles', 'django.contrib.admin', 'django.contrib.admindocs', + 'sorl.thumbnail', 'egonomy', ) diff -r 984dd6395764 -r 38611b2c2782 src/egonomy/templates/egonomy_home.html --- a/src/egonomy/templates/egonomy_home.html Tue Jan 29 12:53:18 2013 +0100 +++ b/src/egonomy/templates/egonomy_home.html Tue Jan 29 18:42:24 2013 +0100 @@ -1,6 +1,7 @@ {% extends "egonomy_base.html" %} {% load static %} {% load i18n %} +{% load thumbnail %} {% block title %}{% trans "Home" %}{% endblock %} @@ -11,38 +12,32 @@

{% trans "Last annotated pictures" %}

diff -r 984dd6395764 -r 38611b2c2782 src/egonomy/urls.py --- a/src/egonomy/urls.py Tue Jan 29 12:53:18 2013 +0100 +++ b/src/egonomy/urls.py Tue Jan 29 18:42:24 2013 +0100 @@ -1,4 +1,6 @@ +from django.conf import settings from django.conf.urls import patterns, include, url +from django.conf.urls.static import static from django.contrib.staticfiles.urls import staticfiles_urlpatterns # Uncomment the next two lines to enable the admin: @@ -16,4 +18,5 @@ # Uncomment the next line to enable the admin: url(r'^admin/', include(admin.site.urls)), ) -urlpatterns += staticfiles_urlpatterns() \ No newline at end of file +urlpatterns += staticfiles_urlpatterns() +urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) \ No newline at end of file diff -r 984dd6395764 -r 38611b2c2782 src/egonomy/views.py --- a/src/egonomy/views.py Tue Jan 29 12:53:18 2013 +0100 +++ b/src/egonomy/views.py Tue Jan 29 18:42:24 2013 +0100 @@ -3,13 +3,22 @@ #from django.core.paginator import Paginator, InvalidPage, EmptyPage from django.shortcuts import render_to_response from django.template import RequestContext +from sorl.thumbnail.images import ImageFile +from django.core.files.storage import FileSystemStorage def home(request): + + im1 = ImageFile(open(settings.RMN_PICT_ROOT+"0/00-004125.jpg", 'r'), FileSystemStorage(location=settings.RMN_PICT_ROOT)) + im2 = ImageFile(open(settings.RMN_PICT_ROOT+"1/00-007590.jpg", 'r'), FileSystemStorage(location=settings.RMN_PICT_ROOT)) + im3 = ImageFile(open(settings.RMN_PICT_ROOT+"2/00-001283.jpg", 'r'), FileSystemStorage(location=settings.RMN_PICT_ROOT)) + im4 = ImageFile(open(settings.RMN_PICT_ROOT+"3/00-000023.jpg", 'r'), FileSystemStorage(location=settings.RMN_PICT_ROOT)) + img_list = [im1,im2,im3,im4] + return render_to_response("egonomy_home.html", - {'any_var': "coucou"}, + {'img_list': img_list}, context_instance=RequestContext(request)) diff -r 984dd6395764 -r 38611b2c2782 web/static/media/.keepme