diff options
-rwxr-xr-x | setup.py | 3 | ||||
-rwxr-xr-x | weblog/static/weblog/js/weblog.js | 2 | ||||
-rwxr-xr-x | weblog/templates/weblog/post.html | 13 | ||||
-rwxr-xr-x | weblog/views.py | 1 |
4 files changed, 13 insertions, 6 deletions
@@ -1,3 +1,4 @@ +#!/usr/bin/env python import os from setuptools import find_packages, setup @@ -9,7 +10,7 @@ os.chdir(os.path.normpath(os.path.join(os.path.abspath(__file__), os.pardir))) setup( name='django-weblog', - version='0.3-postlang.2', + version='0.3-postlang.6', packages=find_packages(), include_package_data=True, license='BSD License', diff --git a/weblog/static/weblog/js/weblog.js b/weblog/static/weblog/js/weblog.js index b802841..164cc3b 100755 --- a/weblog/static/weblog/js/weblog.js +++ b/weblog/static/weblog/js/weblog.js @@ -10,4 +10,4 @@ function toggleNode(caller){ $(caller).attr('node-state', 'closed'); } $('#'+target).toggle(); -}
\ No newline at end of file +} diff --git a/weblog/templates/weblog/post.html b/weblog/templates/weblog/post.html index 5a389f8..0459744 100755 --- a/weblog/templates/weblog/post.html +++ b/weblog/templates/weblog/post.html @@ -5,13 +5,13 @@ <div class="container-fluid blogpost"> <h2>{% if post_translation %}{{ post_translation.title }}{% else %}{{ post.title }}{% endif %}</h2> <p class="publish-info">{% blocktrans with publish_date=post.publish_date %}Published on {{ publish_date }}{% endblocktrans %}{% if post_author %}{% blocktrans with author=post_author context 'Written by (Author)' %}, by {{ author }}{% endblocktrans %}{% endif %}</p> - {% if languages %} + {% if post_languages %} <form> <div class="form-group"> - <label for="post-languages">{% trans 'Read in another language' %}</label> - <select class="form-control" id="post-languages" name="post-language"> + <select class="form-control" id="post-languages" name="post-language" onchange="changeLang(this.value)"> + <option disabled selected>{% trans 'Read in another language' %}</option> {% for lang in post_languages %} - <option value="{{ lang[0] }}">{{ lang[1] }}</option> + <option value="{{ lang.0 }}">{{ lang.1 }}</option> {% endfor %} </select> </div> @@ -76,5 +76,10 @@ {% endif %} {% endif %} </div> +<script> + function changeLang(lang){ + window.location = "{{ post_url }}"+lang; + } +</script> {% endblock %} diff --git a/weblog/views.py b/weblog/views.py index 922e8c5..95558fc 100755 --- a/weblog/views.py +++ b/weblog/views.py @@ -159,6 +159,7 @@ def PostView(request, category_slug, post_slug, language=None): post = get_object_or_404(BlogPost, slug=post_slug) context_dict = blog_settings.copy() context_dict['comment_form'] = PostCommentForm() + context_dict['post_url'] = post.get_absolute_url() post_translations = Translation.objects.filter(post=post) category = None current_language = translation.get_language() |