fnp
/
wolnelektury.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
197f766
)
download links in book text
author
Radek Czajka
<radoslaw.czajka@nowoczesnapolska.org.pl>
Tue, 31 Jan 2012 16:02:19 +0000
(17:02 +0100)
committer
Radek Czajka
<radoslaw.czajka@nowoczesnapolska.org.pl>
Tue, 31 Jan 2012 16:02:19 +0000
(17:02 +0100)
13 files changed:
apps/ajaxable/utils.py
patch
|
blob
|
history
apps/catalogue/views.py
patch
|
blob
|
history
apps/social/views.py
patch
|
blob
|
history
apps/suggest/views.py
patch
|
blob
|
history
wolnelektury/settings.py
patch
|
blob
|
history
wolnelektury/static/css/cite.css
patch
|
blob
|
history
wolnelektury/static/css/header.css
patch
|
blob
|
history
wolnelektury/static/css/logo.css
[new file with mode: 0644]
patch
|
blob
wolnelektury/static/css/master.book.css
patch
|
blob
|
history
wolnelektury/static/js/book.js
patch
|
blob
|
history
wolnelektury/templates/catalogue/book_detail.html
patch
|
blob
|
history
wolnelektury/templates/catalogue/book_text.html
patch
|
blob
|
history
wolnelektury/views.py
patch
|
blob
|
history
diff --git
a/apps/ajaxable/utils.py
b/apps/ajaxable/utils.py
index
ac8d5c6
..
79eca52
100755
(executable)
--- 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."""
@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
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
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,
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,
"placeholdize": self.placeholdize,
"submit": self.submit,
"response_data": response_data,
@@
-137,18
+144,26
@@
class AjaxableFormView(object):
"view_args": args,
"view_kwargs": kwargs,
}
"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))
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 (), {}
"""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 {}
"""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.
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
1686450
..
6405a49
100644
(file)
--- 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)
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)
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
def success(self, *args):
pass
diff --git
a/apps/social/views.py
b/apps/social/views.py
index
d5362a4
..
abb2d9b
100644
(file)
--- a/
apps/social/views.py
+++ b/
apps/social/views.py
@@
-51,9
+51,14
@@
class ObjectSetsFormView(AjaxableFormView):
ajax_redirect = True
POST_login = True
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):
def unlike_book(request, slug):
diff --git
a/apps/suggest/views.py
b/apps/suggest/views.py
index
8a8df5b
..
15b65f2
100644
(file)
--- a/
apps/suggest/views.py
+++ b/
apps/suggest/views.py
@@
-18,7
+18,6
@@
class PublishingSuggestionFormView(AjaxableFormView):
class SuggestionFormView(AjaxableFormView):
form_class = forms.SuggestForm
class SuggestionFormView(AjaxableFormView):
form_class = forms.SuggestForm
- placeholdize = True
title = _('Report a bug or suggestion')
submit = _('Send report')
success_message = _('Report was sent successfully.')
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
1608b5f
..
5435951
100644
(file)
--- 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/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',
'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': {
'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': {
'output_filename': 'css/book.min?.css',
},
'player': {
diff --git
a/wolnelektury/static/css/cite.css
b/wolnelektury/static/css/cite.css
index
e23dee1
..
b015bc9
100755
(executable)
--- a/
wolnelektury/static/css/cite.css
+++ b/
wolnelektury/static/css/cite.css
@@
-32,7
+32,7
@@
#big-cite {
#big-cite {
- background-color: #
45321f
; /* average image color */
+ background-color: #
bd9a89
; /* average image color */
color: white;
padding: 0;
margin: 0;
color: white;
padding: 0;
margin: 0;
diff --git
a/wolnelektury/static/css/header.css
b/wolnelektury/static/css/header.css
index
bdc2bff
..
e16a1bd
100755
(executable)
--- 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;
#header-bg {
z-index: -1;
background: #191919;
@@
-51,10
+39,8
@@
}
#logo a {
}
#logo a {
- font-family: WL-Logo;
- font-size: 2.05em;
color:#f7f7f7;
color:#f7f7f7;
-
line-height: 7
em;
+
font-size: 2.05
em;
}
#tagline {
}
#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
+++ 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
83bad31
..
be54927
100644
(file)
--- a/
wolnelektury/static/css/master.book.css
+++ b/
wolnelektury/static/css/master.book.css
@@
-26,6
+26,12
@@
img {
border: none;
}
border: none;
}
+#logo {
+ font-size: 1.5em;
+}
+#logo a {
+ color: black;
+}
#menu {
position: fixed;
#menu {
position: fixed;
@@
-48,19
+54,22
@@
img {
#menu li a {
display: block;
float: left;
#menu li a {
display: block;
float: left;
- width: 7.5em;
height: 1.5em;
margin-left: 0.5em;
text-align: center;
color: #FFF;
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;
}
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;
}
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;
}
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;
#toc ol, #themes ol {
list-style: none;
diff --git
a/wolnelektury/static/js/book.js
b/wolnelektury/static/js/book.js
index
d6dfec9
..
335fe39
100644
(file)
--- a/
wolnelektury/static/js/book.js
+++ b/
wolnelektury/static/js/book.js
@@
-32,7
+32,7
@@
$(function() {
scrollToAnchor($(this).attr('href'));
});
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');
$('#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
f2beb77
..
dd4d907
100644
(file)
--- 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 %}
{% 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 %}
{% 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
c133165
..
1eaa2c9
100644
(file)
--- a/
wolnelektury/templates/catalogue/book_text.html
+++ b/
wolnelektury/templates/catalogue/book_text.html
@@
-5,7
+5,7
@@
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<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>
<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>
@@
-18,18
+18,37
@@
<body>
<div id="menu">
<ul>
<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>
</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">
<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">
</div>
</div>
<div id="themes">
diff --git
a/wolnelektury/views.py
b/wolnelektury/views.py
index
01fac46
..
9a0a3f9
100755
(executable)
--- 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')
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'),
return {
"register_form": placeholdized(UserCreationForm(prefix='register')),
"register_submit": _('Register'),