changes from server
authorJan Szejko <j-sz@o2.pl>
Mon, 14 Mar 2016 10:21:11 +0000 (11:21 +0100)
committerJan Szejko <j-sz@o2.pl>
Mon, 14 Mar 2016 10:21:11 +0000 (11:21 +0100)
apps/catalogue/templates/catalogue/base.html
apps/catalogue/views.py
redakcja/static/js/wiki/xslt.js
scripts/dump-book.py [new file with mode: 0755]

index d2af462..cb2304e 100644 (file)
@@ -9,6 +9,7 @@
     {% block add_css %}{% endblock %}
 </head>
 <body>
+<!--#include file="/pozor.html"-->
 
 <div id="tabs-nav">
 
index e1dc2a3..5f20380 100644 (file)
@@ -252,7 +252,7 @@ def book_pdf(request, slug):
     # TODO: move to celery
     doc = book.wldocument()
     # TODO: error handling
-    pdf_file = doc.as_pdf()
+    pdf_file = doc.as_pdf(cover=True, ilustr_path=os.path.join(settings.MEDIA_ROOT, settings.IMAGE_DIR, book.gallery))
     from catalogue.ebook_utils import serve_file
     return serve_file(pdf_file.get_filename(),
                 book.slug + '.pdf', 'application/pdf')
index 618dcd0..cc71b28 100644 (file)
@@ -366,7 +366,7 @@ HTMLSerializer.prototype._serializeElement = function(node) {
                };
 
                self.result += ' ' + self._join(nsData.prefix, node.getAttribute('x-attr-name-'+this));
-               self.result += '="'+node.getAttribute('x-attr-value-'+this) +'"';
+                self.result += '="'+node.getAttribute('x-attr-value-'+this).replace(/&/g, '&amp;').replace(/</g, '&lt;')+'"';
        });
 
        /* print new namespace declarations */
diff --git a/scripts/dump-book.py b/scripts/dump-book.py
new file mode 100755 (executable)
index 0000000..9f84f50
--- /dev/null
@@ -0,0 +1,36 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+# This file is part of Wolnelektury, licensed under GNU Affero GPLv3 or later.
+# Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
+#
+import sys
+sys.path.append('.')
+sys.path.append('./apps')
+sys.path.append('./lib')
+
+from django.core.management import setup_environ
+from redakcja import settings
+
+setup_environ(settings)
+
+from catalogue.models import Book, Chunk
+import re
+
+if len(sys.argv) != 3:
+    print "dump-book slug-part filename"
+    sys.exit(-1)
+
+term = sys.argv[1]
+
+books = Book.objects.filter(slug__contains=term)
+if len(books) > 1:
+    for b in range(len(books)):
+        print "%d) %s" % (b+1, books[b].slug)
+    print "Which one? "
+    ch = int(raw_input())
+    book = books[ch-1]
+else:
+    book = books[0]
+
+open(sys.argv[2], "w").write(book.materialize().encode('utf-8'))
+