download links in book text
authorRadek Czajka <radoslaw.czajka@nowoczesnapolska.org.pl>
Tue, 31 Jan 2012 16:02:19 +0000 (17:02 +0100)
committerRadek Czajka <radoslaw.czajka@nowoczesnapolska.org.pl>
Tue, 31 Jan 2012 16:02:19 +0000 (17:02 +0100)
13 files changed:
apps/ajaxable/utils.py
apps/catalogue/views.py
apps/social/views.py
apps/suggest/views.py
wolnelektury/settings.py
wolnelektury/static/css/cite.css
wolnelektury/static/css/header.css
wolnelektury/static/css/logo.css [new file with mode: 0644]
wolnelektury/static/css/master.book.css
wolnelektury/static/js/book.js
wolnelektury/templates/catalogue/book_detail.html
wolnelektury/templates/catalogue/book_text.html
wolnelektury/views.py

index ac8d5c6..79eca52 100755 (executable)
@@ -81,8 +81,8 @@ class AjaxableFormView(object):
     @method_decorator(vary_on_headers('X-Requested-With'))
     def __call__(self, request, *args, **kwargs):
         """A view displaying a form, or JSON if request is AJAX."""
-        #form_class = placeholdized(self.form_class) if self.placeholdize else self.form_class
-        form_args, form_kwargs = self.form_args(request, *args, **kwargs)
+        obj = self.get_object(request, *args, **kwargs)
+        form_args, form_kwargs = self.form_args(request, obj)
         if self.form_prefix:
             form_kwargs['prefix'] = self.form_prefix
 
@@ -124,12 +124,19 @@ class AjaxableFormView(object):
             form = self.form_class(*form_args, **form_kwargs)
             response_data = None
 
-        template = self.template if request.is_ajax() else self.full_template
+        title = self.title
+        if request.is_ajax():
+            template = self.template
+        else:
+            template = self.full_template
+            cd = self.context_description(request, obj)
+            if cd:
+                title += ": " + cd
         if self.placeholdize:
             form = placeholdized(form)
         context = {
                 self.formname: form, 
-                "title": self.title,
+                "title": title,
                 "placeholdize": self.placeholdize,
                 "submit": self.submit,
                 "response_data": response_data,
@@ -137,18 +144,26 @@ class AjaxableFormView(object):
                 "view_args": args,
                 "view_kwargs": kwargs,
             }
-        context.update(self.extra_context())
+        context.update(self.extra_context(request, obj))
         return render_to_response(template, context,
             context_instance=RequestContext(request))
 
-    def form_args(self, request, *args, **kwargs):
+    def get_object(self, request, *args, **kwargs):
+        """Override to parse view args and get some associated data."""
+        return None
+
+    def form_args(self, request, obj):
         """Override to parse view args and give additional args to the form."""
         return (), {}
 
-    def extra_context(self):
+    def extra_context(self, request, obj):
         """Override to pass something to template."""
         return {}
 
+    def context_description(self, request, obj):
+        """Description to appear in standalone form, but not in AJAX form."""
+        return ""
+
     def success(self, form, request):
         """What to do when the form is valid.
         
index 1686450..6405a49 100644 (file)
@@ -558,10 +558,15 @@ class CustomPDFFormView(AjaxableFormView):
         from copy import copy
         if request.method == 'POST':
             request.GET = copy(request.GET)
-            request.GET['next'] = "%s?%s" % (reverse('catalogue.views.download_custom_pdf', args=[request.GET['slug']]),
+            request.GET['next'] = "%s?%s" % (reverse('catalogue.views.download_custom_pdf', args=[request.GET.get('slug')]),
                                              request.POST.urlencode())
         return super(CustomPDFFormView, self).__call__(request)
 
+    def get_object(self, request):
+        return get_object_or_404(models.Book, slug=request.GET.get('slug'))
+
+    def context_description(self, request, obj):
+        return obj.pretty_title()
 
     def success(self, *args):
         pass
index d5362a4..abb2d9b 100644 (file)
@@ -51,9 +51,14 @@ class ObjectSetsFormView(AjaxableFormView):
     ajax_redirect = True
     POST_login = True
 
-    def form_args(self, request, slug):
-        book = get_object_or_404(Book, slug=slug)
-        return (book, request.user), {}
+    def get_object(self, request, slug):
+        return get_object_or_404(Book, slug=slug)
+
+    def context_description(self, request, obj):
+        return obj.pretty_title()
+
+    def form_args(self, request, obj):
+        return (obj, request.user), {}
 
 
 def unlike_book(request, slug):
index 8a8df5b..15b65f2 100644 (file)
@@ -18,7 +18,6 @@ class PublishingSuggestionFormView(AjaxableFormView):
 
 class SuggestionFormView(AjaxableFormView):
     form_class = forms.SuggestForm
-    placeholdize = True
     title = _('Report a bug or suggestion')
     submit = _('Send report')
     success_message = _('Report was sent successfully.')
index 1608b5f..5435951 100644 (file)
@@ -198,6 +198,7 @@ COMPRESS_CSS = {
             'css/book_box.css',
             'css/catalogue.css',
             'css/sponsors.css',
+            'css/logo.css',
 
             'css/social/shelf_tags.css',
             'css/ui-lightness/jquery-ui-1.8.16.custom.css',
@@ -211,7 +212,10 @@ COMPRESS_CSS = {
         'output_filename': 'css/ie.min?.css',
     },
     'book': {
-        'source_filenames': ('css/master.book.css',),
+        'source_filenames': [
+            'css/logo.css',
+            'css/master.book.css',
+        ],
         'output_filename': 'css/book.min?.css',
     },
     'player': {
index e23dee1..b015bc9 100755 (executable)
@@ -32,7 +32,7 @@
 
 
 #big-cite {
-    background-color: #45321f; /* average image color */
+    background-color: #bd9a89; /* average image color */
     color: white;
     padding: 0;
     margin: 0;
index bdc2bff..e16a1bd 100755 (executable)
@@ -1,15 +1,3 @@
-/* Logo font */
-@font-face {
-    /* IE version */
-    font-family: WL-Logo;
-    src: url(/static/fonts/WL.eot);
-}
-@font-face {
-  font-family: WL-Logo;
-  src: url(/static/fonts/WL.ttf) format("truetype");
-}
-
-
 #header-bg {
        z-index: -1;
        background: #191919;
 }
 
 #logo a {
-    font-family: WL-Logo;
-    font-size: 2.05em;
     color:#f7f7f7;
-    line-height: 7em;
+    font-size: 2.05em;
 }
 
 #tagline {
diff --git a/wolnelektury/static/css/logo.css b/wolnelektury/static/css/logo.css
new file mode 100644 (file)
index 0000000..c7e7882
--- /dev/null
@@ -0,0 +1,15 @@
+/* Logo font */
+@font-face {
+    /* IE version */
+    font-family: WL-Logo;
+    src: url(/static/fonts/WL.eot);
+}
+@font-face {
+  font-family: WL-Logo;
+  src: url(/static/fonts/WL.ttf) format("truetype");
+}
+
+#logo a {
+    font-family: WL-Logo;
+    line-height: 7em;
+}
index 83bad31..be54927 100644 (file)
@@ -26,6 +26,12 @@ img {
     border: none;
 }
 
+#logo {
+    font-size: 1.5em;
+}
+#logo a {
+    color: black;
+}
 
 #menu {
     position: fixed;
@@ -48,19 +54,22 @@ img {
 #menu li a {
     display: block;
     float: left;
-    width: 7.5em;
     height: 1.5em;
     margin-left: 0.5em;
     text-align: center;
     color: #FFF;
+    padding: 0 1em;
+}
+#menu li a.menu {
+    padding-right: 1.5em;
 }
 
-#menu li a:hover, #menu li a:active {
+#menu li a.menu:hover, #menu li a.menu:active {
     color: #000;
     background: #FFF url(/static/img/arrow-down.png) no-repeat center right;
 }
 
-#menu li a.selected {
+#menu li a.menu.selected {
     color: #000;
     background: #FFF url(/static/img/arrow-up.png) no-repeat center right;
 }
@@ -96,6 +105,22 @@ img {
     opacity: 0.9;
     z-index: 99;
 }
+#download {
+    position: fixed;
+    left: 0em;
+    top: 1.5em;
+    width: 37em;
+    padding: 1.5em;
+    background: #FFF;
+    border-bottom: 0.25em solid #DDD;
+    border-right: 0.25em solid #DDD;
+    display: none;
+    height: 10em;
+    overflow-x: hidden;
+    overflow-y: auto;
+    opacity: 0.9;
+    z-index: 99;
+}
 
 #toc ol, #themes ol {
     list-style: none;
index d6dfec9..335fe39 100644 (file)
@@ -32,7 +32,7 @@ $(function() {
         scrollToAnchor($(this).attr('href'));
     });
 
-    $('#menu li a').toggle(function() {
+    $('#menu li a.menu').toggle(function() {
         $('#menu li a.selected').click();
         $(this).addClass('selected');
         $($(this).attr('href')).slideDown('fast');
index f2beb77..dd4d907 100644 (file)
@@ -2,7 +2,7 @@
 {% load cache i18n %}
 {% load catalogue_tags pagination_tags %}
 
-{% block titleextra %}{{ book.title }}{% endblock %}
+{% block titleextra %}{{ book.pretty_title }}{% endblock %}
 
 {% block metadescription %}{% book_title book %}. {{ block.super }}{% endblock %}
 
index c133165..1eaa2c9 100644 (file)
@@ -5,7 +5,7 @@
 <html xmlns="http://www.w3.org/1999/xhtml">
     <head>
         <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
-        <title>{% block title %}WolneLektury.pl{% endblock %}</title>
+        <title>{% trans "Wolne Lektury" %} :: {{ book.pretty_title }}</title>
         <link rel="icon" href="{{ STATIC_URL }}img/favicon.png" type="image/x-icon" />
         {% compressed_css "book" %}
         <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
     <body>
         <div id="menu">
             <ul>
-                <li><a href="#toc">{% trans "Table of contents" %}</a></li>
-                <li><a href="#themes">{% trans "Themes" %}</a></li>
-                <li><a href="#nota_red">{% trans "Edit. note" %}</a></li>
-                <li><a href="#info">{% trans "Infobox" %}</a></li>
+                <li><a class="menu" href="#toc">{% trans "Table of contents" %}</a></li>
+                <li><a class="menu" href="#themes">{% trans "Themes" %}</a></li>
+                <li><a class="menu" href="#nota_red">{% trans "Edit. note" %}</a></li>
+                <li><a class="menu" href="#info">{% trans "Infobox" %}</a></li>
+                <li><a href="{{ book.get_absolute_url }}">{% trans "Book's page" %}</a></li>
+                <li><a class="menu" href="#download">{% trans "Download" %}</a></li>
             </ul>
         </div>
         <div id="info">
             {% book_info book %}
         </div>
+        <div id="download">
+            <ul>
+            {% if book.pdf_file %}
+            <li><a href="{{ book.pdf_file.url}}">PDF</a> do wydruku</li>
+            {% endif %}
+            {% if  book.epub_file %}
+            <li><a href="{{ book.epub_file.url}}">EPUB</a> na czytnik</li>
+            {% endif %}
+            {% if  book.mobi_file %}
+            <li><a href="{{ book.mobi_file.url}}">MOBI</a> na Kindle</li>
+            {% endif %}
+            {% if  book.txt_file %}
+            <li><a href="{{ book.txt_file.url}}">TXT</a> do zadaƄ specjalnych</li>
+            {% endif %}
+            <li><a href="{% url custom_pdf_form %}?slug={{ book.slug }}">PDF?</a></li>
+            </ul>
+        </div>
         <div id="header">
             <div id="logo">
-                <a href="/"><img src="{{ STATIC_URL }}img/logo.png" alt="WolneLektury.pl - logo" /></a>
+                <a href="/">Wolne Lektury</a>
             </div>
         </div>
         <div id="themes">
index 01fac46..9a0a3f9 100755 (executable)
@@ -67,7 +67,7 @@ class LoginRegisterFormView(LoginFormView):
     template = 'auth/login_register.html'
     title = _('You have to be logged in to continue')
 
-    def extra_context(self):
+    def extra_context(self, request, obj):
         return {
             "register_form": placeholdized(UserCreationForm(prefix='register')),
             "register_submit": _('Register'),