From: Radek Czajka Date: Tue, 31 Jan 2012 16:02:19 +0000 (+0100) Subject: download links in book text X-Git-Url: https://git.mdrn.pl/wolnelektury.git/commitdiff_plain/2b57c59f0caa7d096a2e17aec3377d2628377491?ds=sidebyside;hp=-c download links in book text --- 2b57c59f0caa7d096a2e17aec3377d2628377491 diff --git a/apps/ajaxable/utils.py b/apps/ajaxable/utils.py index ac8d5c6f9..79eca5298 100755 --- a/apps/ajaxable/utils.py +++ b/apps/ajaxable/utils.py @@ -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. diff --git a/apps/catalogue/views.py b/apps/catalogue/views.py index 168645009..6405a49a9 100644 --- a/apps/catalogue/views.py +++ b/apps/catalogue/views.py @@ -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 diff --git a/apps/social/views.py b/apps/social/views.py index d5362a436..abb2d9bef 100644 --- a/apps/social/views.py +++ b/apps/social/views.py @@ -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): diff --git a/apps/suggest/views.py b/apps/suggest/views.py index 8a8df5bdb..15b65f24d 100644 --- a/apps/suggest/views.py +++ b/apps/suggest/views.py @@ -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.') diff --git a/wolnelektury/settings.py b/wolnelektury/settings.py index 1608b5fad..54359513e 100644 --- a/wolnelektury/settings.py +++ b/wolnelektury/settings.py @@ -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': { diff --git a/wolnelektury/static/css/cite.css b/wolnelektury/static/css/cite.css index e23dee157..b015bc90e 100755 --- a/wolnelektury/static/css/cite.css +++ b/wolnelektury/static/css/cite.css @@ -32,7 +32,7 @@ #big-cite { - background-color: #45321f; /* average image color */ + background-color: #bd9a89; /* average image color */ color: white; padding: 0; margin: 0; diff --git a/wolnelektury/static/css/header.css b/wolnelektury/static/css/header.css index bdc2bff7a..e16a1bd40 100755 --- a/wolnelektury/static/css/header.css +++ b/wolnelektury/static/css/header.css @@ -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; @@ -51,10 +39,8 @@ } #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 index 000000000..c7e788299 --- /dev/null +++ b/wolnelektury/static/css/logo.css @@ -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; +} diff --git a/wolnelektury/static/css/master.book.css b/wolnelektury/static/css/master.book.css index 83bad314e..be5492726 100644 --- a/wolnelektury/static/css/master.book.css +++ b/wolnelektury/static/css/master.book.css @@ -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; diff --git a/wolnelektury/static/js/book.js b/wolnelektury/static/js/book.js index d6dfec9f8..335fe39c0 100644 --- a/wolnelektury/static/js/book.js +++ b/wolnelektury/static/js/book.js @@ -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'); diff --git a/wolnelektury/templates/catalogue/book_detail.html b/wolnelektury/templates/catalogue/book_detail.html index f2beb77cc..dd4d9078a 100644 --- a/wolnelektury/templates/catalogue/book_detail.html +++ b/wolnelektury/templates/catalogue/book_detail.html @@ -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 %} diff --git a/wolnelektury/templates/catalogue/book_text.html b/wolnelektury/templates/catalogue/book_text.html index c1331653c..1eaa2c967 100644 --- a/wolnelektury/templates/catalogue/book_text.html +++ b/wolnelektury/templates/catalogue/book_text.html @@ -5,7 +5,7 @@ - {% block title %}WolneLektury.pl{% endblock %} + {% trans "Wolne Lektury" %} :: {{ book.pretty_title }} {% compressed_css "book" %} @@ -18,18 +18,37 @@
{% book_info book %}
+
+ +
diff --git a/wolnelektury/views.py b/wolnelektury/views.py index 01fac4686..9a0a3f9e3 100755 --- a/wolnelektury/views.py +++ b/wolnelektury/views.py @@ -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'),