Commit a0d48ed2904e262cf067d7605438879920462433
- Diff rendering mode:
- inline
- side by side
locale/cs/LC_MESSAGES/django.po
(11 / 8)
|   | |||
| 7 | 7 | msgstr "" | |
| 8 | 8 | "Project-Id-Version: PACKAGE VERSION\n" | |
| 9 | 9 | "Report-Msgid-Bugs-To: \n" | |
| 10 | "POT-Creation-Date: 2009-09-13 14:12+0200\n" | ||
| 10 | "POT-Creation-Date: 2009-10-12 19:53+0200\n" | ||
| 11 | 11 | "PO-Revision-Date: 2009-09-13 14:11+0100\n" | |
| 12 | 12 | "Last-Translator: Miloš Kozák <milos.kozak@lejmr.com>\n" | |
| 13 | 13 | "Language-Team: LANGUAGE <LL@li.org>\n" | |
| … | … | ||
| 15 | 15 | "Content-Type: text/plain; charset=UTF-8\n" | |
| 16 | 16 | "Content-Transfer-Encoding: 8bit\n" | |
| 17 | 17 | ||
| 18 | #: gallery/templates/image.html:6 gallery/templates/list_gallery.html:14 | ||
| 18 | #: gallery/templates/image.html:6 gallery/templates/list_gallery.html:11 | ||
| 19 | #: gallery/templates/list_gallery.html:12 | ||
| 19 | 20 | msgid "Image:" | |
| 20 | 21 | msgstr "Obrázek:" | |
| 21 | 22 | ||
| … | … | ||
| 24 | 24 | msgid "Adresar" | |
| 25 | 25 | msgstr "Adresář" | |
| 26 | 26 | ||
| 27 | #: gallery/templates/list_gallery.html:11 | ||
| 28 | msgid "Directory:" | ||
| 29 | msgstr "Adresář:" | ||
| 27 | #: templates/base.html:87 | ||
| 28 | msgid "Foto galerie" | ||
| 29 | msgstr "" | ||
| 30 | 30 | ||
| 31 | #: gallery/templates/list_gallery.html:11 | ||
| 32 | msgid "Folder" | ||
| 33 | msgstr "Složka:" | ||
| 31 | #~ msgid "Directory:" | ||
| 32 | #~ msgstr "Adresář:" | ||
| 33 | |||
| 34 | #~ msgid "Folder" | ||
| 35 | #~ msgstr "Složka:" |
menu.py
(51 / 0)
|   | |||
| 1 | from django.http import HttpResponse | ||
| 2 | import settings,os | ||
| 3 | from django.shortcuts import render_to_response | ||
| 4 | from django.template import RequestContext | ||
| 5 | from django.utils.encoding import * | ||
| 6 | from django.template.loader import render_to_string | ||
| 7 | |||
| 8 | def create(request): | ||
| 9 | |||
| 10 | tree={} | ||
| 11 | this_dir=[] | ||
| 12 | for dirname, dirs, files in os.walk(settings.GALLERY_ROOT): | ||
| 13 | pdir = dirname.replace(settings.GALLERY_ROOT,"") | ||
| 14 | |||
| 15 | if len(pdir)!=0: | ||
| 16 | sep=pdir.split(os.path.sep) | ||
| 17 | tmptree=tree | ||
| 18 | for dir in sep: | ||
| 19 | if not dir in tmptree: | ||
| 20 | tmptree[dir]={} | ||
| 21 | tmptree=tmptree[dir] | ||
| 22 | |||
| 23 | def makeItem(dir,array,path=''): | ||
| 24 | out=[] | ||
| 25 | if len(array)!=0: | ||
| 26 | for subdir in array: | ||
| 27 | out.append(makeItem(subdir,array[subdir],os.path.join(path,dir))) | ||
| 28 | |||
| 29 | return render_to_string('menu/item.html',{'dir':dir,'subdir':''.join(out),'path':os.path.join(path,dir)}) | ||
| 30 | |||
| 31 | out=[] | ||
| 32 | for dir in tree.keys(): | ||
| 33 | if len(tree[dir])!=0: | ||
| 34 | out.append(makeItem(dir,tree[dir])) | ||
| 35 | |||
| 36 | return render_to_string('menu/menu.html' , {'tree':''.join(out)}, context_instance=RequestContext(request), ) | ||
| 37 | return render_to_response('menu/menu.html' , {'tree':''.join(out)}, context_instance=RequestContext(request), ) | ||
| 38 | |||
| 39 | |||
| 40 | class MyMiddleware(object): | ||
| 41 | #def process_view(self, request, view_func, view_args, view_kwargs): | ||
| 42 | def process_request(self, request): | ||
| 43 | request.menu=create(request) | ||
| 44 | return None | ||
| 45 | |||
| 46 | |||
| 47 | def ContextProcesor(request): | ||
| 48 | if hasattr(request, 'menu'): | ||
| 49 | return {'MENU': request.menu } | ||
| 50 | else: | ||
| 51 | return {'MENU': {} } |
settings.py
(5 / 0)
|   | |||
| 63 | 63 | 'django.middleware.common.CommonMiddleware', | |
| 64 | 64 | 'django.contrib.sessions.middleware.SessionMiddleware', | |
| 65 | 65 | 'django.contrib.auth.middleware.AuthenticationMiddleware', | |
| 66 | 'dphoto.menu.MyMiddleware', | ||
| 67 | ) | ||
| 68 | |||
| 69 | TEMPLATE_CONTEXT_PROCESSORS = ( | ||
| 70 | 'dphoto.menu.ContextProcesor', | ||
| 66 | 71 | ) | |
| 67 | 72 | ||
| 68 | 73 | ROOT_URLCONF = 'dphoto.urls' |
templates/base.html
(8 / 3)
|   | |||
| 1 | {% load webdesign %}<?xml version="1.0" encoding="UTF-8"?> | ||
| 1 | {% load webdesign i18n %}<?xml version="1.0" encoding="UTF-8"?> | ||
| 2 | 2 | <!-- | |
| 3 | 3 | To change this template, choose Tools | Templates | |
| 4 | 4 | and open the template in the editor. | |
| … | … | ||
| 74 | 74 | <script src="/media/js/jquery-1.3.2.js"></script> | |
| 75 | 75 | <script src="/media/js/layout.js"></script> | |
| 76 | 76 | <script type="text/javascript"> | |
| 77 | |||
| 78 | 77 | ||
| 78 | |||
| 79 | 79 | ||
| 80 | 80 | </script> | |
| 81 | 81 | ||
| 82 | 82 | </head> | |
| 83 | 83 | <body> | |
| 84 | 84 | <div id="album"> | |
| 85 | <div id="left">{% block menu %}Menu{% endblock %}</div> | ||
| 85 | <div id="left"> | ||
| 86 | <ul> | ||
| 87 | <li class="gallery"><a href="{% url gallery.views.list_dir "" %}">{% trans 'Foto galerie' %}</a></li> | ||
| 88 | {{MENU}} | ||
| 89 | </ul> | ||
| 90 | </div> | ||
| 86 | 91 | <div id="content"><div class="padding"> | |
| 87 | 92 | {% block content %}Fotky{% endblock %} | |
| 88 | 93 |
templates/menu/item.html
(7 / 0)
|   | |||
| 1 | {% autoescape off%} | ||
| 2 | <li><a href="{% url gallery.views.list_dir path %}">{{dir}}</a></li> | ||
| 3 | {% if subdir %} | ||
| 4 | <ul> | ||
| 5 | {{subdir}}</ul> | ||
| 6 | {% endif %} | ||
| 7 | {% endautoescape%} |
templates/menu/menu.html
(3 / 0)
|   | |||
| 1 | <ul> | ||
| 2 | {{tree|safe}} | ||
| 3 | </ul> |
urls.py
(2 / 1)
|   | |||
| 16 | 16 | ||
| 17 | 17 | # Uncomment the next line to enable the admin: | |
| 18 | 18 | # (r'^admin/(.*)', admin.site.root), | |
| 19 | (r'^menu/$', 'menu.create'), | ||
| 19 | 20 | (r'^media/(.*)$', 'django.views.static.serve', {'document_root': settings.MEDIA_ROOT,'show_indexes':True}), | |
| 20 | 21 | (r'^data/gallery/(.*)$', 'django.views.static.serve', {'document_root': settings.GALLERY_ROOT,'show_indexes':True}), | |
| 21 | 22 | (r'^data/previews/(.*)$', 'django.views.static.serve', {'document_root': settings.PREVIEWS_ROOT,'show_indexes':True}), | |
| … | … | ||
| 25 | 25 | (r'^thumbnails/(?P<file>.*).png', gallery.thumbnail ), | |
| 26 | 26 | (r'^previews/(?P<file>.*).*', gallery.preview ), | |
| 27 | 27 | (r'^original/(?P<file>.*).*', gallery.original ), | |
| 28 | (r'^(?P<path>.*)', gallery.list_dir), | ||
| 28 | (r'^(?P<path>.*)$', gallery.list_dir), | ||
| 29 | 29 | ||
| 30 | 30 | ||
| 31 | 31 |

