Commit 3fe2f481 authored by thorsten.vitt's avatar thorsten.vitt
Browse files

Merge branch 'release/1.4.8'

parents 192aa288 71279a4d
......@@ -22,11 +22,6 @@
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
......@@ -38,5 +33,10 @@
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7">
<attributes>
<attribute name="owner.project.facets" value="java"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
</classpath>
......@@ -59,9 +59,9 @@ author = u'Thorsten Vitt'
# built documents.
#
# The short X.Y version.
version = '1.4.6'
version = '1.4.7'
# The full version, including alpha/beta/rc tags.
release = version
release = version + '-SNAPSHOT'
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
......
......@@ -139,6 +139,40 @@ Custom stylesheets will generally be able to resolve ``textgrid:`` URIs using fu
- *ID* might be an ``xml:id``. If this is passed, your stylesheet should *only* render the XML fragment with the given ID.
Generating a Table of Contents
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
You can also only generate a table of contents instead of a full HTML document.
+--------------------------+--------------------------+---------------------------+
| parameter | value | description |
+==========================+==========================+===========================+
| **toc** | string | If given, generate a table|
| | | of contents instead of a |
| | | full HTML document |
+--------------------------+--------------------------+---------------------------+
Currently, the value of the ``toc`` argument is ignored. If it is present with any value, an XHTML *fragment* will be generated that contains a table of contents for the current document as a list of local links. Example::
<?xml version="1.0" encoding="UTF-8"?>
<ul xmlns="http://www.w3.org/1999/xhtml" class="toc">
<li>
<a href="#tg4.jmzc.0">Auf das schöne Geschlecht</a>
<ul/>
</li>
<li>
<a href="#tg5.jmxf.0">Auf Amorn</a>
<ul/>
</li>
<!-- You see the point ... -->
<li>
<a href="#tg19.jmxp.0">[Venus, die die Göttinnen beherrschet]</a>
<ul/>
</li>
</ul>
There will probably more options, and the HTML will probably be a little tidied up (empty ``<ul/>`` removed etc.).
Other options
^^^^^^^^^^^^^
......
......@@ -18,5 +18,3 @@ Up-To-Date short usage
----------------------
http://textgrid-esx2.gwdg.de/1.0/aggregator/help
......@@ -106,7 +106,9 @@ You export one or more objects/aggregations and everything that they aggregate.
Search results
~~~~~~~~~~~~~~
Or you specify a query to TG-search. You have the full power of the query language, but only a limited set of parameters that will be passed to TG-search:
Alternatively, specify a query to TG-search. To do so, specify an (unused) object string plus query parameters, so a possible URL may look like <https://textgridlab.org/1.0/aggregator/zip/query?query=waldeinsamkeit>.
You have the full power of the query language, but only a limited set of parameters that will be passed to TG-search:
+--------------------------+--------------------------+--------------------------+
| parameter | value | description |
......
......@@ -5,7 +5,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>info.textgrid.services</groupId>
<artifactId>aggregator</artifactId>
<version>1.4.6</version>
<version>1.4.8</version>
<packaging>war</packaging>
<name>TextGrid Aggregator Service</name>
......@@ -209,8 +209,8 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.5</source>
<target>1.5</target>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
......@@ -285,8 +285,8 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.1</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
......@@ -451,64 +451,6 @@
</resources>
</build>
<profiles>
<profile>
<id>wue</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat6-maven-plugin</artifactId>
<configuration>
<url>http://wrzh075.rzhousing.uni-wuerzburg.de:8180/manager</url>
<server>wrzh075</server>
</configuration>
</plugin>
</plugins>
</build>
<properties>
<aggregator.endpoint.published>http://test1.digital-humanities.de/services/aggregator</aggregator.endpoint.published>
<aggregator.classifier>wue</aggregator.classifier>
</properties>
</profile>
<profile>
<id>services</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat6-maven-plugin</artifactId>
<configuration>
<url>http://services:8080/manager</url>
<server>services</server>
</configuration>
</plugin>
</plugins>
</build>
<properties>
<aggregator.endpoint.published>https://textgridlab.org/1.0/aggregator</aggregator.endpoint.published>
<aggregator.classifier>services</aggregator.classifier>
</properties>
</profile>
<profile>
<id>tgbackend2</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat6-maven-plugin</artifactId>
<configuration>
<url>http://tgbackend2.gwdg.de:8080/manager</url>
<server>tgbackend2</server>
</configuration>
</plugin>
</plugins>
</build>
<properties>
<aggregator.endpoint.published>http://textgridrep.de/beta-es/services/aggregator</aggregator.endpoint.published>
<aggregator.textgridrep.default>http://tgbackend-2.gwdg.de/confserv</aggregator.textgridrep.default>
<aggregator.classifier>tgbackend2</aggregator.classifier>
</properties>
</profile>
<profile>
<id>esx1</id>
<properties>
......@@ -571,12 +513,51 @@
</plugins>
</build>
</profile>
<profile>
<id>textgrid.deb</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<artifactId>jdeb</artifactId>
<groupId>org.vafer</groupId>
<version>1.4</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>jdeb</goal>
</goals>
<configuration>
<snapshotExpand>true</snapshotExpand>
<dataSet>
<data>
<type>directory</type>
<src>${project.build.directory}/${project.build.finalName}</src>
<mapper>
<type>perm</type>
<prefix>/var/textgrid/webapps/${project.artifactId}</prefix>
<user>root</user>
<group>tomcat7</group>
<filemode>755</filemode>
</mapper>
</data>
</dataSet>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
<organization>
<name>TextGrid</name>
<url>http://www.textgrid.de/</url>
</organization>
<description>The TextGrid Aggregator is an experimental service that can walk aggregations (including editions and collections) and export the objects therein to various formats, e.g., TEI corpus, EPUB, and (experimentally) PDF.</description>
</organization>
<description>The TextGrid Aggregator is a service that can walk aggregations (including editions and collections) and export the objects therein to various formats, e.g., HTML, TEI corpus, EPUB, and ZIP. It can also be used to transform single files (it is the component that is responsible for HTML rendering of TEI objects in TextGrid) and export search results as ZIP files.</description>
<inceptionYear>2012</inceptionYear>
<scm>
<url>https://projects.gwdg.de/projects/aggregator/repository</url>
......@@ -584,12 +565,12 @@
<developerConnection>scm:git:ssh://git@git.projects.gwdg.de/aggregator.git</developerConnection>
</scm>
<issueManagement>
<system>Jira</system>
<url>https://pm.sub.uni-goettingen.de/</url>
<system>Redmine</system>
<url>https://projects.gwdg.de/projects/tg</url>
</issueManagement>
<ciManagement>
<system>Jenkins</system>
<url>http://dev.digital-humanities.de/ci/job/aggregator-git-2/</url>
<url>http://dev.digital-humanities.de/ci/job/Aggregator/</url>
</ciManagement>
<url>https://projects.gwdg.de/projects/aggregator</url>
</project>
Package: [[artifactId]]
Version: [[version]]
Section: misc
Priority: low
Architecture: all
Description: [[description]]
Maintainer: info@textgrid.de
#!/bin/bash
invoke-rc.d tomcat-aggregator start
# return success, even if service not installed
exit 0
#!/bin/bash
invoke-rc.d tomcat-aggregator stop
# return success, even if service not installed
exit 0
......@@ -130,6 +130,7 @@ public Response getHTML(
@Description("The requested content type. E.g., text/html or text/xml") @QueryParam("mediatype") final String mediaType,
@Description("An XML ID. If given, only this element will be transformed.") @QueryParam("id") final String id,
@Description("If true, a full webpage that looks similar to textgridrep.de's browse view will be returned") @QueryParam("simulate") @DefaultValue("false") final boolean simulate,
@Description("If given, generate a table of contents instead of a full HTML document") @QueryParam("toc") final String toc,
@Context final Request request) throws ObjectNotFoundFault,
MetadataParseFault, IoFault, AuthFault,
ProtocolNotImplementedFault, WebApplicationException, IOException,
......@@ -140,6 +141,7 @@ public Response getHTML(
embedded, css, sid, mediaType, id, request);
writer.simulate(simulate);
writer.linkUrlPattern(linkURLPattern);
writer.toc(toc);
return writer.createResponse().build();
}
......
......@@ -99,6 +99,7 @@ public class HTMLWriter extends CorpusBasedExporter implements StreamingOutput {
private final StylesheetManager stylesheetManager;
private Optional<String> id = Optional.absent();
private Optional<String> linkUrlPattern = Optional.absent();
private Optional<String> toc = Optional.absent();
private static final Logger logger = Logger.getLogger(HTMLWriter.class.getCanonicalName());
......@@ -175,6 +176,7 @@ void detectEmbeddedStylesheet(final Source source) {
.getAssociatedStylesheet(source, null, null, null);
this.associatedStylesheetURI = Optional.of(new URI(
associatedStylesheet.getSystemId()));
logger.log(Level.INFO, "Detected associated stylesheet {0}, URI {1}", new Object[] { associatedStylesheet, associatedStylesheetURI.get()});
} catch (final TransformerConfigurationException e) {
logger.log(Level.WARNING, "Failed to load stylesheet from <?xsl-stylesheet?> declaration", e);
......@@ -240,6 +242,9 @@ public XsltTransformer getTransformer() throws SaxonApiException, IOException {
if (id.isPresent())
transformer.setParameter(new QName("ID"), new XdmAtomicValue(id.get()));
if (toc.isPresent())
transformer.setParameter(new QName("onlyTOC"), new XdmAtomicValue(toc.get()));
transformer.setSource(source);
......@@ -300,7 +305,8 @@ public ResponseBuilder createResponse() throws ObjectNotFoundFault, MetadataPars
if (isNotModified())
return getResponseBuilder();
getTransformer().setSource(getSource());
final Source source = getSource();
getTransformer().setSource(source);
if (requestedMediaType.isPresent()) {
setMediaType(requestedMediaType.get());
......@@ -312,4 +318,9 @@ public ResponseBuilder createResponse() throws ObjectNotFoundFault, MetadataPars
}
return super.createResponse();
}
public HTMLWriter toc(final String toc) {
this.toc = Optional.fromNullable(toc);
return this;
}
}
\ No newline at end of file
......@@ -33,9 +33,10 @@
import javax.xml.stream.XMLOutputFactory;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.events.XMLEvent;
import javax.xml.transform.stax.StAXResult;
import javax.xml.transform.sax.SAXResult;
import javax.xml.ws.Holder;
import org.springframework.util.xml.StaxUtils;
import com.google.common.base.Joiner;
import com.google.common.base.Throwables;
import com.google.common.collect.ImmutableList;
......@@ -168,7 +169,7 @@ protected void walkAggregation(final ObjectType object, final boolean again) {
}
// writeHeader(object);
stack.writeHeader(new StAXResult(new XMLEventFilter(writer) {
XMLEventFilter xmlEventFilter = new XMLEventFilter(writer) {
@Override
public void add(final XMLEvent event) throws XMLStreamException {
......@@ -176,8 +177,8 @@ public void add(final XMLEvent event) throws XMLStreamException {
super.add(event);
}
}
));
};
stack.writeHeader(new SAXResult(StaxUtils.createContentHandler(xmlEventFilter)));
}
super.walkAggregation(object, again);
......
......@@ -156,7 +156,7 @@ protected Templates getStylesheet()
.getResourceAsStream("md2tei.xsl");
final StreamSource xslSource = new StreamSource(xslStream);
final TransformerFactory factory = TransformerFactory.newInstance("com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl", getClass().getClassLoader());
final TransformerFactory factory = TransformerFactory.newInstance();
stylesheet = factory.newTemplates(xslSource);
}
return stylesheet;
......
......@@ -14,13 +14,18 @@
<xsl:output method="xhtml" omit-xml-declaration="yes" indent="no"/>
<xsl:param name="extraclass"/>
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="/">
<xsl:choose>
<xsl:when test="//body">
<div class="body {$extraclass}">
<xsl:apply-templates select="//style"/>
<xsl:copy-of select="//body/*"/>
<xsl:apply-templates/>
</div>
</xsl:when>
<xsl:otherwise>
......@@ -29,6 +34,10 @@
</xsl:choose>
</xsl:template>
<xsl:template match="html">
<xsl:apply-templates select="body/*"/>
</xsl:template>
<xsl:template match="style">
<xsl:copy>
<xsl:copy-of select="@*"/>
......
......@@ -11,7 +11,7 @@
-->
<xsl:output method="xhtml" />
<xsl:param name="repurl">http://textgridrep.de</xsl:param>
<xsl:param name="repurl">https://textgridrep.de</xsl:param>
<xsl:param name="extraclass"/>
<xsl:include href="tohtml.xsl"/>
......
......@@ -63,6 +63,7 @@
<xsl:param name="autoHead">false</xsl:param>
<xsl:param name="showTitleAuthor">false</xsl:param>
<xsl:param name="cssFile"/>
<xsl:param name="onlyTOC"/>
<xsl:output method="xhtml"/>
......@@ -78,7 +79,57 @@
<xsl:template name="stdheader">
<xsl:param name="title">(no title)</xsl:param>
</xsl:template>
<xsl:template match="/">
<xsl:choose>
<xsl:when test="$onlyTOC">
<xsl:message>Tunelling ...</xsl:message>
<ul class="toc">
<xsl:apply-templates mode="toc">
<xsl:with-param name="currentDepth" tunnel="yes" select="0"/>
</xsl:apply-templates>
</ul>
</xsl:when>
<xsl:otherwise>
<xsl:next-match/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template mode="toc" match="node()">
<xsl:apply-templates mode="#current"/>
</xsl:template>
<xsl:template mode="toc" match="div[head]">
<xsl:param name="currentDepth" tunnel="yes"/>
<li>
<a href="#{if (@xml:id) then (@xml:id) else (head/@xml:id)[1]}">
<xsl:apply-templates select="head[1]/node()"/>
</a>
<xsl:if test="$currentDepth &lt; $tocDepth and (descendant::div[head] or descendant::TEI)">
<ul>
<xsl:apply-templates>
<xsl:with-param name="currentDepth" tunnel="yes" select="$currentDepth + 1"/>
</xsl:apply-templates>
</ul>
</xsl:if>
</li>
</xsl:template>
<xsl:template mode="toc" match="TEI[parent::teiCorpus][@xml:id]|teiCorpus[parent::teiCorpus][@xml:id]">
<xsl:param name="currentDepth" as="xs:integer" tunnel="yes"></xsl:param>
<li>
<a href="#{@xml:id}">
<xsl:call-template name="generateTitle"/>
</a>
<xsl:if test="$currentDepth &lt; $tocDepth and (descendant::div[head] or descendant::TEI)">
<ul>
<xsl:apply-templates mode="#current">
<xsl:with-param name="currentDepth" tunnel="yes" select="$currentDepth + 1"/>
</xsl:apply-templates>
</ul>
</xsl:if>
</li>
</xsl:template>
<xsl:template name="generateTitle">
<xsl:variable name="result">
......
......@@ -53,17 +53,24 @@ public class HtmlRegressionTest extends XMLTestCase {
private final StylesheetManager stylesheets = new StylesheetManager(null,
TextGridRepProvider.getInstance());
protected void writeHtmlTo(final String uris, final OutputStream target)
protected void writeHtmlTo(final String uris, final OutputStream target, boolean embedded)
throws WebApplicationException, IOException, ObjectNotFoundFault,
MetadataParseFault, IoFault, ProtocolNotImplementedFault,
AuthFault, SaxonApiException {
final HTMLWriter htmlWriter = new HTMLWriter(rep, stylesheets, uris, null,
false, false, false, null, null, null, null, null);
false, false, embedded, null, null, null, null, null);
htmlWriter.createResponse();
htmlWriter.write(target);
}
public void compareHtml(final String uris, final String compareFilename)
throws WebApplicationException, IOException, SAXException,
ObjectNotFoundFault, MetadataParseFault, IoFault,
ProtocolNotImplementedFault, AuthFault, SaxonApiException {
compareHtml(uris, compareFilename, false);
}
public void compareHtml(final String uris, final String compareFilename, boolean embedded)
throws WebApplicationException, IOException, SAXException,
ObjectNotFoundFault, MetadataParseFault, IoFault,
ProtocolNotImplementedFault, AuthFault, SaxonApiException {
......@@ -80,7 +87,7 @@ public void compareHtml(final String uris, final String compareFilename)
System.out.println(MessageFormat.format(
"### Writing the current result for {0} to {1}", uris,
targetFile));
writeHtmlTo(uris, target);
writeHtmlTo(uris, target, embedded);
target.close();
System.out.println("[[ATTACHMENT|"+targetFile.getAbsolutePath()+"]]");
} else {
......@@ -91,7 +98,7 @@ public void compareHtml(final String uris, final String compareFilename)
.format("### Comparing HTML output for {0} to reference document {1}",
uris, compareFilename));
writeHtmlTo(uris, target);
writeHtmlTo(uris, target, embedded);
target.close();
final InputSource control = new InputSource(getClass().getClassLoader()
......@@ -106,37 +113,42 @@ public void compareHtml(final String uris, final String compareFilename)
@Test
public void testPoem() throws WebApplicationException, IOException, SAXException, ObjectNotFoundFault, MetadataParseFault, IoFault, ProtocolNotImplementedFault, AuthFault, SaxonApiException {
compareHtml("textgrid:mr47.0", "mr47.0.html");
compareHtml("textgrid:mr47.0", "mr47.0.html", false);
}
@Test
public void testDrama() throws WebApplicationException, IOException, SAXException, ObjectNotFoundFault, MetadataParseFault, IoFault, ProtocolNotImplementedFault, AuthFault, SaxonApiException {
compareHtml("textgrid:msdd.0", "msdd.0.html");
compareHtml("textgrid:msdd.0", "msdd.0.html", false);
}
@Test
public void testNovel() throws WebApplicationException, IOException, SAXException, ObjectNotFoundFault, MetadataParseFault, IoFault, ProtocolNotImplementedFault, AuthFault, SaxonApiException {
compareHtml("textgrid:mr23.0", "mr23.0.html");
compareHtml("textgrid:mr23.0", "mr23.0.html", false);
}
@Test
public void testPoems() throws WebApplicationException, IOException, SAXException, ObjectNotFoundFault, MetadataParseFault, IoFault, ProtocolNotImplementedFault, AuthFault, SaxonApiException {
compareHtml("textgrid:mjr3.0", "mjr3.0.html");
compareHtml("textgrid:mjr3.0", "mjr3.0.html", false);
}
@Test
public void testEmbedded() throws WebApplicationException, IOException, SAXException, ObjectNotFoundFault, MetadataParseFault, IoFault, ProtocolNotImplementedFault, AuthFault, SaxonApiException {
compareHtml("textgrid:mjr3.0", "mjr3.0-embedded.html", true);
}
@Test
public void testBiography() throws WebApplicationException, IOException, SAXException, ObjectNotFoundFault, MetadataParseFault, IoFault, ProtocolNotImplementedFault, AuthFault, SaxonApiException {
compareHtml("textgrid:nbvb.0", "nbvb.0.html");
compareHtml("textgrid:nbvb.0", "nbvb.0.html", false);
}
@Test
public void testDescs() throws WebApplicationException, IOException, SAXException, ObjectNotFoundFault, MetadataParseFault, IoFault, ProtocolNotImplementedFault, AuthFault, SaxonApiException {
compareHtml("textgrid:n2kf.0", "n2kf.0.html");
compareHtml("textgrid:n2kf.0", "n2kf.0.html", false);
}
@Test
public void testLetter() throws WebApplicationException, IOException, SAXException, ObjectNotFoundFault, MetadataParseFault, IoFault, ProtocolNotImplementedFault, AuthFault, SaxonApiException {
compareHtml("textgrid:11sqw.0", "11sqw.0.html");
compareHtml("textgrid:11sqw.0", "11sqw.0.html", false);
}
}
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment