Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
eoa2-xmldb/src/website/views.py
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
87 lines (76 sloc)
2.86 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from xsl.xsl_lib import xslt | |
from django.http import HttpResponse | |
# from .settings import RES_DIR | |
from django.conf import settings | |
from django.template import loader | |
from pyexistdb import db | |
from pathlib import Path | |
def res_path_to_xmldb_resources( path : Path ): | |
return "/db/apps/eoa/xml" / path . relative_to( settings.XML_DIR ) | |
def res_path_to_xmldb_publications( path : Path ): | |
return "/db/apps/eoa/publications" / path . relative_to( settings.PUBL_XML_DIR ) | |
publication_collection = \ | |
res_path_to_xmldb_publications( settings.PUBL_XML_DIR ) | |
# Path( "/db/publications" ) | |
tei2html_index_stylesheet = \ | |
res_path_to_xmldb_resources( | |
settings.XML_STYLESHEET_DIR / "tei2html/tei2html_publ_frontpage.xsl" | |
) | |
# Path( "/db/stylesheets/tei2html/tei2html_publ_frontpage.xsl" ) | |
tei2html_chapter_stylesheet = \ | |
res_path_to_xmldb_resources( | |
settings.XML_STYLESHEET_DIR / "tei2html/tei2html_chapter.xsl" | |
) | |
# Path( "/db/stylesheets/tei2html/tei2html_chapter.xsl" ) | |
platform_name = "dummy-platform" | |
platform_uri = "www.dummy-platform.com" | |
aux_uri = "/db/apps/eoa/xml/aux" | |
def publication( | |
request, | |
series, | |
publication_nr | |
): | |
webdesign_url = str( Path(settings.STATIC_URL) ) | |
publ_static_url = str( Path(settings.STATIC_URL) / series / str(publication_nr) ) | |
ret_doc = \ | |
xslt( | |
input = f"collection('{publication_collection}/{series}/{publication_nr}/')", | |
stylesheet = 'doc("{file}")'.format( | |
file = tei2html_index_stylesheet | |
), | |
params = [ | |
("webdesign_url", webdesign_url), | |
("publ_static_url", publ_static_url), | |
("platform_name", platform_name), | |
("platform_uri", platform_uri), | |
("aux_uri", aux_uri), | |
], | |
ns_prefixes = [ ("tei", "http://www.tei-c.org/ns/1.0") ] | |
) | |
# print( "type: {}".format( str(type( html ) ) ) ) | |
return HttpResponse( ret_doc ) | |
def chapter( | |
request, | |
series, | |
publication_nr, | |
chapter_nr | |
): | |
webdesign_url = str( Path(settings.STATIC_URL) ) | |
publ_static_url = str( Path(settings.STATIC_URL) / series / str(publication_nr) ) | |
ret_doc = \ | |
xslt( | |
input = f"collection('{publication_collection}/{series}/{publication_nr}/')", | |
stylesheet = 'doc("{file}")'.format( | |
file = tei2html_chapter_stylesheet | |
), | |
params = [ | |
("webdesign_url", webdesign_url), | |
("publ_static_url", publ_static_url), | |
("platform_name", platform_name), | |
("platform_uri", platform_uri), | |
("aux_uri", aux_uri), | |
("chapter_nr", chapter_nr ), | |
], | |
ns_prefixes = [ ("tei", "http://www.tei-c.org/ns/1.0") ] | |
) | |
return HttpResponse( ret_doc ) |