@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
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,
"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.
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
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):
class SuggestionFormView(AjaxableFormView):
form_class = forms.SuggestForm
- placeholdize = True
title = _('Report a bug or suggestion')
submit = _('Send report')
success_message = _('Report was sent successfully.')
'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',
'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': {
#big-cite {
- background-color: #45321f; /* average image color */
+ background-color: #bd9a89; /* average image color */
color: white;
padding: 0;
margin: 0;
-/* 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 {
--- /dev/null
+/* 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;
+}
border: none;
}
+#logo {
+ font-size: 1.5em;
+}
+#logo a {
+ color: black;
+}
#menu {
position: fixed;
#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;
}
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;
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');
{% 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 %}
<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">
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'),