Skip to content

Commit

Permalink
Merge pull request #141 from eeditiones/printcss
Browse files Browse the repository at this point in the history
Print CSS improvements
  • Loading branch information
wolfgangmm authored Feb 12, 2023
2 parents 65fc218 + ae08f8a commit e0ed5af
Show file tree
Hide file tree
Showing 234 changed files with 25,328 additions and 6,159 deletions.
33 changes: 28 additions & 5 deletions .devcontainer/Dockerfile.dev
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ FROM mcr.microsoft.com/vscode/devcontainers/java:dev-8

ARG EXIST_VERSION=6.0.1
ARG TEMPLATING_VERSION=1.0.4
ARG PUBLISHER_LIB_VERSION=2.10.1
ARG ROUTER_VERSION=1.7.3
ARG PUBLISHER_LIB_VERSION=master
ARG ROUTER_VERSION=1.7.6
ARG EDITOR_VERSION=1.0.1

ARG HTTP_PORT=8080
Expand All @@ -16,6 +16,8 @@ ARG MAVEN_VERSION=""
ARG INSTALL_GRADLE="false"
ARG GRADLE_VERSION=""

ARG INSTALL_TEXLIVE="false"

RUN if [ "${INSTALL_MAVEN}" = "true" ]; then su vscode -c "source /usr/local/sdkman/bin/sdkman-init.sh && sdk install maven \"${MAVEN_VERSION}\""; fi \
&& if [ "${INSTALL_GRADLE}" = "true" ]; then su vscode -c "source /usr/local/sdkman/bin/sdkman-init.sh && sdk install gradle \"${GRADLE_VERSION}\""; fi

Expand All @@ -37,6 +39,19 @@ RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
&& apt-get -y install --no-install-recommends python3-pip \
&& pip3 install --upgrade pip

RUN if [ "${INSTALL_TEXLIVE}" = "true" ]; then \
apt-get -y install --no-install-recommends \
texlive-xetex \
texlive-latex-extra \
texlive-fonts-recommended \
texlive-lang-german \
texlive-lang-european \
texlive-humanities \
texlive-plain-generic \
fonts-junicode \
latexmk; \
fi

# [Optional] Uncomment this line to install global node packages.
# RUN su vscode -c "source /usr/local/share/nvm/nvm.sh && npm install -g <your-package-here>" 2>&1

Expand All @@ -55,9 +70,17 @@ RUN curl -L -o exist-distribution-${EXIST_VERSION}-unix.tar.bz2 https://github.c
&& rm exist-distribution-${EXIST_VERSION}-unix.tar.bz2 \
&& mv /usr/local/exist-distribution-${EXIST_VERSION} /usr/local/exist

RUN curl -L -o /usr/local/exist/autodeploy/roaster-${ROUTER_VERSION}.xar http://exist-db.org/exist/apps/public-repo/public/roaster-${ROUTER_VERSION}.xar
RUN curl -L -o /usr/local/exist/autodeploy/tei-publisher-lib-${PUBLISHER_LIB_VERSION}.xar http://exist-db.org/exist/apps/public-repo/public/tei-publisher-lib-${PUBLISHER_LIB_VERSION}.xar
RUN curl -L -o /usr/local/exist/autodeploy/templating-${TEMPLATING_VERSION}.xar http://exist-db.org/exist/apps/public-repo/public/templating-${TEMPLATING_VERSION}.xar
RUN if [ "${PUBLISHER_LIB_VERSION}" = "master" ]; then \
git clone https://github.com/eeditiones/tei-publisher-lib.git \
&& cd tei-publisher-lib \
&& ant \
&& cp build/*.xar /usr/local/exist/autodeploy; \
else \
curl -L -o /usr/local/exist/autodeploy/tei-publisher-lib-${PUBLISHER_LIB_VERSION}.xar https://exist-db.org/exist/apps/public-repo/public/tei-publisher-lib-${PUBLISHER_LIB_VERSION}.xar; \
fi

RUN curl -L -o /usr/local/exist/autodeploy/roaster-${ROUTER_VERSION}.xar https://exist-db.org/exist/apps/public-repo/public/roaster-${ROUTER_VERSION}.xar
RUN curl -L -o /usr/local/exist/autodeploy/templating-${TEMPLATING_VERSION}.xar https://exist-db.org/exist/apps/public-repo/public/templating-${TEMPLATING_VERSION}.xar
RUN curl -L -o /usr/local/exist/autodeploy/atom-editor-${EDITOR_VERSION}.xar https://github.com/wolfgangmm/existdb-langserver/raw/master/resources/atom-editor-${EDITOR_VERSION}.xar

WORKDIR /usr/local/exist
Expand Down
3 changes: 2 additions & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"dockerfile": "Dockerfile.dev",
"args": {
"HTTP_PORT": "8080",
"HTTPS_PORT": "8443"
"HTTPS_PORT": "8443",
"INSTALL_TEXLIVE": "false"
}
},
"runArgs": ["--name=TEIPublisherDev"],
Expand Down
2 changes: 2 additions & 0 deletions .existdb.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
},
"sync": {
"server": "localhost",
"polling": true,
"interval": 500,
"ignore": [
".existdb.json",
".git/**",
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ resources/scripts/*.map
resources/lib/
resources/css/leaflet/
resources/css/prismjs
resources/css/pagedjs
resources/css/gridjs
resources/css/tom-select
resources/css/components.css
resources/images/openseadragon
resources/images/leaflet
resources/i18n/common
13 changes: 11 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ ENV PATH ${PATH}:${ANT_HOME}/bin
FROM builder as tei

ARG TEMPLATING_VERSION=1.0.4
ARG PUBLISHER_LIB_VERSION=2.10.1
ARG PUBLISHER_LIB_VERSION=master
ARG ROUTER_VERSION=1.7.3
ARG SHARED_RESOURCES_VERSION=0.9.1
ARG SHAKESPEARE_VERSION=1.1.2
Expand All @@ -51,13 +51,22 @@ RUN git clone https://github.com/eeditiones/vangogh.git \
&& git checkout ${VANGOGH_VERSION} \
&& ant

# Build tei-publisher-lib
RUN if [ "${PUBLISHER_LIB_VERSION}" = "master" ]; then \
git clone https://github.com/eeditiones/tei-publisher-lib.git \
&& cd tei-publisher-lib \
&& ant \
&& cp build/*.xar /tmp; \
else \
curl -L -o /tmp/tei-publisher-lib-${PUBLISHER_LIB_VERSION}.xar https://exist-db.org/exist/apps/public-repo/public/tei-publisher-lib-${PUBLISHER_LIB_VERSION}.xar; \
fi

# Build tei-publisher-app
COPY . tei-publisher-app/
RUN cd tei-publisher-app \
&& ant

RUN curl -L -o /tmp/roaster-${ROUTER_VERSION}.xar http://exist-db.org/exist/apps/public-repo/public/roaster-${ROUTER_VERSION}.xar
RUN curl -L -o /tmp/tei-publisher-lib-${PUBLISHER_LIB_VERSION}.xar http://exist-db.org/exist/apps/public-repo/public/tei-publisher-lib-${PUBLISHER_LIB_VERSION}.xar
RUN curl -L -o /tmp/templating-${TEMPLATING_VERSION}.xar http://exist-db.org/exist/apps/public-repo/public/templating-${TEMPLATING_VERSION}.xar
RUN curl -L -o /tmp/shared-resources-${SHARED_RESOURCES_VERSION}.xar http://exist-db.org/exist/apps/public-repo/public/shared-resources-${SHARED_RESOURCES_VERSION}.xar

Expand Down
2 changes: 1 addition & 1 deletion build.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
# but could be changed if you extended this in your own library
scripts.dir=node_modules/@teipublisher/pb-components/dist
# path to npm executable
npm=/usr/local/bin/npm
npm=npm
18 changes: 10 additions & 8 deletions build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,19 @@
<include name="*.map" />
</fileset>
</copy>
<copy file="node_modules/leaflet/dist/leaflet.css" todir="resources/css/leaflet" />
<copy todir="resources/images/leaflet">
<fileset dir="node_modules/leaflet/dist/images" />
<copy todir="resources/images">
<fileset dir="node_modules/@teipublisher/pb-components/images">
<include name="leaflet/*"/>
<include name="openseadragon/*"/>
</fileset>
</copy>
<copy todir="resources/images/openseadragon">
<fileset dir="node_modules/openseadragon/build/openseadragon/images" />
<copy todir="resources/css">
<fileset dir="node_modules/@teipublisher/pb-components/css"/>
</copy>
<copy file="node_modules/openseadragon/build/openseadragon/openseadragon.min.js" todir="resources/lib" />
<copy todir="resources/css/prismjs">
<fileset dir="node_modules/prismjs/themes" />
<copy todir="resources/lib">
<fileset dir="node_modules/@teipublisher/pb-components/lib"/>
</copy>

<copy todir="resources/i18n/common">
<fileset dir="${scripts.dir}/../i18n/common" />
</copy>
Expand Down
9 changes: 4 additions & 5 deletions controller.xql
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,10 @@ else if (matches($exist:path, "^.*/(resources|transform|templates)/.*$")
<set-header name="Cache-Control" value="no-cache"/>
else if (contains($exist:path, "/resources/fonts/")) then
<set-header name="Cache-Control" value="max-age=31536000"/>
else (
<set-header name="Cache-Control" value="max-age=31536000"/>,
<set-header name="Access-Control-Allow-Origin" value="{$allowOrigin}"/>,
if ($allowOrigin = "*") then () else <set-header name="Access-Control-Allow-Credentials" value="true"/>
)
else
(),
<set-header name="Access-Control-Allow-Origin" value="{$allowOrigin}"/>,
if ($allowOrigin = "*") then () else <set-header name="Access-Control-Allow-Credentials" value="true"/>
}
</forward>
</dispatch>
Expand Down
75 changes: 55 additions & 20 deletions data/doc/documentation.xml
Original file line number Diff line number Diff line change
@@ -1,25 +1,10 @@
<?teipublisher odd="docbook.odd" template="documentation.html" depth="5" fill="2" ?>
<?teipublisher odd="docbook.odd" template="documentation.html" depth="5" fill="2" media="latex,print,fo,epub"?>
<?xml-model href="https://docbook.org/xml/5.0/xsd/docbook.xsd" type="application/xml" schematypens="http://www.w3.org/2001/XMLSchema" ?>
<article xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" version="5.0">
<article xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" version="5.0" xml:lang="en">
<info>
<title>TEI Publisher Documentation</title>
<author>
<personname>
<firstname>Wolfgang</firstname>
<surname>Meier</surname>
</personname>
<affiliation>
<orgname>eXist Solutions GmbH</orgname>
</affiliation>
</author>
<author>
<personname>
<firstname>Magdalena</firstname>
<surname>Turska</surname>
</personname>
<affiliation>
<orgname>eXist Solutions GmbH</orgname>
</affiliation>
<orgname>TEI Publisher Community</orgname>
</author>
<keywordset vocab="#genre">
<keyword>Documentation</keyword>
Expand Down Expand Up @@ -3056,13 +3041,13 @@
<varlistentry>
<term>print</term>
<listitem>
<para>An alias which applies to both: fo and latex modes.</para>
<para>Extends web output with a focus on Print and Paged Media</para>
</listitem>
</varlistentry>
<varlistentry>
<term>epub</term>
<listitem>
<para>Similar to web concerning features, but targetted at epub documents</para>
<para>A specialization of the web output mode targetted at epub documents</para>
</listitem>
</varlistentry>
</variablelist>
Expand Down Expand Up @@ -3201,6 +3186,56 @@
hyphenation, font sizes etc.
</para>
</section>
<section xml:id="output-print-css">
<title>Print CSS</title>
<para>This output mode targets printed HTML. Browser support for the corresponding CSS specifications is not very good, but there are various tools to improve this. If you select the print CSS download option for any of the documents in TEI Publisher, which support it, you will be directed to a preview page. This page uses a library called <link xlink:href="https://pagedjs.org/">paged.js</link> to "teach" the browser how to handle certain layout aspects. Thanks to this, using the <command>print page</command> dialog of your browser will result in a much nicer page layout than if you just tried to print TEI Publisher's document view.</para>
<para>The preview page uses TEI Publisher's <code>pb-print-preview</code> web component. This component will retrieve the full HTML of the document, enhanced with additional CSS stylesheets for print, and passes it to paged.js for the page formatting. For testing purposes you can also click on the bottom-most button with the <guibutton>eye</guibutton> icon to see the raw HTML (without paged.js applied).</para>
<para>To generate the HTML of the document, the component calls Publisher's API endpoint:</para>

<synopsis>/api/document/doc%2Fdocumentation.xml/print</synopsis>
<para>The following (optional) parameters are supported:</para>
<variablelist>
<varlistentry>
<term>base</term>
<listitem>
<para>specifies the base URI for resolving relative links, e.g. to locate images</para>
</listitem>
</varlistentry>
<varlistentry>
<term>style</term>
<listitem>
<para>one or more additional CSS stylesheet URLs to be imported into the page.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>script</term>
<listitem>
<para>one or more Javascript files to be loaded via <tag>script</tag>.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>wc</term>
<listitem>
<para>if set, include TEI Publisher's web component libraries. You may need this if you are using components like <tag>pb-code-highlight</tag> (as in the documentation)</para>
</listitem>
</varlistentry>
</variablelist>

<para>For sure, being an open source project, paged.js does not support every fancy layout you may wish for. For example, support for formatting footnotes will be limited. There are other, mainly commercial tools, which you may use to generate PDF out of your HTML. Those include e.g. <link xlink:href="https://www.princexml.com/">Prince XML</link>, <link xlink:href="https://www.pdfreactor.com/">PDF Reactor</link> or <link xlink:href="https://antennahouse.com/">Antennahouse</link>. Each of those may have different strengths and weaknesses. Please try yourself.</para>

<para>For command line tools, you can use the API endpoint described above to retrieve the full HTML of the page and feed this to PrinceXML or whatever you want to use. To simplify this, the preview page includes a button at the bottom: clicking it will copy the API endpoint URL (excluding the page.js components, which would interfere with external tools). The screenshot below shows princeXML's dialog into which you can paste the URL provided by the preview page:</para>

<figure>
<title>
Processing Print HTML with PrinceXML
</title>
<mediaobject>
<imageobject>
<imagedata fileref="prince-screenshot.png" />
</imageobject>
</mediaobject>
</figure>
</section>
</section>


Expand Down
Binary file added data/doc/prince-screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion data/test/F-rom.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<?teipublisher template="facsimile.html" odd="shakespeare.odd" view="page"?>
<?teipublisher template="facsimile.html" odd="shakespeare.odd" view="page" media="pdf,epub,print"?>
<TEI xmlns="http://www.tei-c.org/ns/1.0">
<teiHeader>
<fileDesc>
Expand Down
2 changes: 1 addition & 1 deletion data/test/IDL10.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<?teipublisher template="dantiscus.html" odd="dantiscus2.odd" view="page"?>
<?teipublisher template="dantiscus.html" odd="dantiscus2.odd" view="page" media="print"?>
<TEI xmlns="http://www.tei-c.org/ns/1.0">
<teiHeader>
<fileDesc>
Expand Down
2 changes: 1 addition & 1 deletion data/test/cortes_to_dantiscus.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<?teipublisher template="cortez-with-translation.html" odd="dantiscus.odd" view="page"?>
<?teipublisher template="cortez-with-translation.html" odd="dantiscus.odd" view="page" media="epub"?>
<TEI xmlns="http://www.tei-c.org/ns/1.0" xml:id="CIDTC5772">
<teiHeader>
<fileDesc>
Expand Down
2 changes: 1 addition & 1 deletion data/test/cortes_to_dantiscus_Mexico.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<?teipublisher template="cortez.html" odd="dantiscus.odd" view="page"?>
<?teipublisher template="cortez.html" odd="dantiscus.odd" view="page" media="epub"?>
<TEI xmlns="http://www.tei-c.org/ns/1.0" xml:id="CIDTC3823">
<teiHeader>
<fileDesc>
Expand Down
2 changes: 1 addition & 1 deletion data/test/euler_algebra02_1770.TEI-P5.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?><?teipublisher view="page" odd="dta.odd" template="dta.html"?><?xml-model href="http://www.deutschestextarchiv.de/basisformat.rng" type="application/xml" schematypens="http://relaxng.org/ns/structure/1.0"?><TEI xmlns="http://www.tei-c.org/ns/1.0"> <teiHeader>
<?xml version="1.0" encoding="UTF-8"?><?teipublisher view="page" odd="dta.odd" template="dta.html" media="epub,print"?><?xml-model href="http://www.deutschestextarchiv.de/basisformat.rng" type="application/xml" schematypens="http://relaxng.org/ns/structure/1.0"?><TEI xmlns="http://www.tei-c.org/ns/1.0"> <teiHeader>
<fileDesc>
<titleStmt>
<title type="main">Vollständige Anleitung zur Algebra</title>
Expand Down
2 changes: 1 addition & 1 deletion data/test/graves6.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<?teipublisher odd="graves.odd" template="letter.html"?>
<?teipublisher odd="graves.odd" template="letter.html" media="latex epub print fo"?>
<TEI xmlns="http://www.tei-c.org/ns/1.0" xmlns:xi="http://www.w3.org/2001/XInclude">
<teiHeader>
<fileDesc>
Expand Down
2 changes: 1 addition & 1 deletion data/test/kant_rvernunft_1781.TEI-P5.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?><?oxygen RNGSchema="http://www.deutschestextarchiv.de/basisformat.rng" type="xml"?>
<?teipublisher view="page" odd="dta.odd" template="dta.html"?>
<?teipublisher view="page" odd="dta.odd" template="dta.html" media="epub,print"?>
<TEI xmlns="http://www.tei-c.org/ns/1.0">
<teiHeader>
<fileDesc>
Expand Down
2 changes: 1 addition & 1 deletion data/test/let695.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<!-- Last Changed Date: 2018-07-18 12:32:41 +0200 (Wed, 18 Jul 2018) | SVN Revision: 2206 -->
<!--Licensed under Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0)-->
<?xml-model href="https://xmlschema.huygens.knaw.nl/vgodd.rng" type="application/xml" schematypens="http://relaxng.org/ns/structure/1.0"?>
<?teipublisher odd="vangogh.odd" template="vangogh.html" view="page"?>
<?teipublisher odd="vangogh.odd" template="vangogh.html" view="page" media="latex"?>
<TEI xmlns:vg="http://www.vangoghletters.org/ns/" xmlns="http://www.tei-c.org/ns/1.0">
<teiHeader xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<fileDesc>
Expand Down
2 changes: 1 addition & 1 deletion data/test/orlik_to_serafin.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?teipublisher template="translation.html" odd="serafin.odd" view="div"?>
<?teipublisher template="translation.html" odd="serafin.odd" view="div" media="print,latex,epub"?>
<TEI xmlns="http://www.tei-c.org/ns/1.0" xml:id="MS2">
<teiHeader>
<fileDesc>
Expand Down
2 changes: 1 addition & 1 deletion data/test/osinski.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<?teipublisher template="osinski.html" odd="osinski.odd" view="page"?>
<?teipublisher template="osinski.html" odd="osinski.odd" view="page" media="epub,print"?>
<TEI xmlns="http://www.tei-c.org/ns/1.0">
<teiHeader>
<fileDesc>
Expand Down
1 change: 1 addition & 0 deletions data/test/pb-mei-app.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<?teipublisher media="print"?>
<?xml-model href="bolz_example.rng" type="application/xml" schematypens="http://relaxng.org/ns/structure/1.0"?>
<?xml-model href="bolz_example.rng" type="application/xml" schematypens="http://purl.oclc.org/dsdl/schematron"?>
<TEI xmlns="http://www.tei-c.org/ns/1.0">
Expand Down
Loading

0 comments on commit e0ed5af

Please sign in to comment.