--- /dev/null
+[submodule "lib/librarian"]
+ path = lib/librarian
+ url = git://github.com/fnp/librarian.git
{% block leftcolumn %}
- <h1>{{ object.title }}</h1>
+ <h1>{{ book.title }}</h1>
- <table>
- {% for chunk in object.chunk_set.all %}
- <tr><td>{{ chunk.number }}</td><td>{{ chunk.slug }}</td></tr>
+<p>
+ {% for chunk in book.chunk_set.all %}
+ <a target="_blank" href="{% url wiki_editor book.slug chunk.slug %}">{{ chunk.comment }}</a><br/>
{% endfor %}
- </table>
+</p>
+
+<p>
+<a href="{% url wiki_book_xml book.slug %}">{% trans "Full XML" %}</a><br/>
+<a target="_blank" href="{% url wiki_book_html book.slug %}">{% trans "HTML version" %}</a><br/>
+<a href="{% url wiki_book_txt book.slug %}">{% trans "TXT version" %}</a><br/>
+{% comment %}
+<a href="{% url wiki_book_epub book.slug %}">{% trans "EPUB version" %}</a><br/>
+<a href="{% url wiki_book_pdf book.slug %}">{% trans "PDF version" %}</a><br/>
+{% endcomment %}
+</p>
+
+<p style='width:200px; height: 75px; border: 1px dotted gray; border-corners: 4px;'></p>
{% endblock leftcolumn %}
{% block rightcolumn %}
+
+
{% endblock rightcolumn %}
url(r'^diff/(?P<slug>[^/]+)/(?:(?P<chunk>[^/]+)/)?$', 'diff', name="wiki_diff"),
#url(r'^(?P<name>[^/]+)/tags$', 'add_tag', name="wiki_add_tag"),
- url(r'^full/(?P<slug>[^/]+)/$', 'compiled', name="wiki_compiled"),
+ url(r'^book/(?P<slug>[^/]+)/$', 'book', name="wiki_book"),
+ url(r'^book/(?P<slug>[^/]+)/xml$', 'book_xml', name="wiki_book_xml"),
+ url(r'^book/(?P<slug>[^/]+)/txt$', 'book_txt', name="wiki_book_txt"),
+ url(r'^book/(?P<slug>[^/]+)/html$', 'book_html', name="wiki_book_html"),
+ #url(r'^book/(?P<slug>[^/]+)/epub$', 'book_epub', name="wiki_book_epub"),
+ #url(r'^book/(?P<slug>[^/]+)/pdf$', 'book_pdf', name="wiki_book_pdf"),
- url(r'^book/(?P<slug>[^/]+)/$', object_detail,
- {"queryset": Book.objects.all()}, name="wiki_book"),
)
import os
+from StringIO import StringIO
import logging
logger = logging.getLogger("fnp.wiki")
+from lxml import etree
+
from django.conf import settings
from django.views.generic.simple import direct_to_template
from django.utils.decorators import decorator_from_middleware
from django.middleware.gzip import GZipMiddleware
+import librarian.html
+import librarian.text
#
# Quick hack around caching problems, TODO: use ETags
@never_cache
-def compiled(request, slug):
- text = get_object_or_404(Book, slug=slug).materialize()
+def book_xml(request, slug):
+ xml = get_object_or_404(Book, slug=slug).materialize()
- response = http.HttpResponse(text, content_type='application/xml', mimetype='application/wl+xml')
+ response = http.HttpResponse(xml, content_type='application/xml', mimetype='application/wl+xml')
response['Content-Disposition'] = 'attachment; filename=%s.xml' % slug
return response
+@never_cache
+def book_txt(request, slug):
+ xml = get_object_or_404(Book, slug=slug).materialize()
+ output = StringIO()
+ # errors?
+ librarian.text.transform(StringIO(xml), output)
+ text = output.getvalue()
+ response = http.HttpResponse(text, content_type='text/plain', mimetype='text/plain')
+ response['Content-Disposition'] = 'attachment; filename=%s.txt' % slug
+ return response
+
+
+@never_cache
+def book_html(request, slug):
+ xml = get_object_or_404(Book, slug=slug).materialize()
+ output = StringIO()
+ # errors?
+ librarian.html.transform(StringIO(xml), output, parse_dublincore=False,
+ flags=['full-page'])
+ html = output.getvalue()
+ response = http.HttpResponse(html, content_type='text/html', mimetype='text/html')
+ return response
+
+
@never_cache
@require_POST
def revert(request, slug, chunk=None):
return JSONResponse(changes)
+def book(request, slug):
+ book = get_object_or_404(Book, slug=slug)
+
+ return direct_to_template(request, "wiki/book_detail.html", extra_context={
+ "book": book,
+ })
+
+
"""
import wlapi
--- /dev/null
+Subproject commit 28878296bacad453735a520f350ba5a971f8ffc8
sys.path = [
'$APP_DIR',
'$APP_DIR/lib',
+ '$APP_DIR/lib/librarian',
'$APP_DIR/apps',
] + sys.path
sys.path += [os.path.realpath(os.path.join(*x)) for x in (
(PROJECT_ROOT, '..'),
(PROJECT_ROOT, '..', 'apps'),
+ (PROJECT_ROOT, '..', 'lib/librarian'),
(PROJECT_ROOT, '..', 'lib')
)]
var base_path = "/documents";
if (vname == "ajax_document_text") {
- var path = "/text/" + arguments[1];
+ var path = "/text/" + arguments[1] + '/';
if (arguments[2] !== undefined)
- path += "/" + arguments[2];
+ path += arguments[2] + '/';
return base_path + path;
}
if (vname == "ajax_document_revert") {
- return base_path + "/revert/" + arguments[1];
+ return base_path + "/revert/" + arguments[1] + '/';
}
if (vname == "ajax_document_history") {
- return base_path + "/history/" + arguments[1];
+ return base_path + "/history/" + arguments[1] + '/';
}
if (vname == "ajax_document_gallery") {
- return base_path + "/gallery/" + arguments[1];
+ return base_path + "/gallery/" + arguments[1] + '/';
}
if (vname == "ajax_document_diff")
- return base_path + "/diff/" + arguments[1];
+ return base_path + "/diff/" + arguments[1] + '/';
if (vname == "ajax_document_rev")
- return base_path + "/rev/" + arguments[1];
+ return base_path + "/rev/" + arguments[1] + '/';
if (vname == "ajax_document_addtag")
- return base_path + "/tags/" + arguments[1];
+ return base_path + "/tags/" + arguments[1] + '/';
if (vname == "ajax_publish")
- return base_path + "/publish/" + arguments[1];
+ return base_path + "/publish/" + arguments[1] + '/';
console.log("Couldn't reverse match:", vname);
return "/404.html";
## Python libraries
-lxml>=2.2
+lxml>=2.2.2
mercurial>=1.6,<1.7
PyYAML>=3.0
PIL>=1.1