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 @@ ...@@ -22,11 +22,6 @@
<attribute name="maven.pomderived" value="true"/> <attribute name="maven.pomderived" value="true"/>
</attributes> </attributes>
</classpathentry> </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"> <classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes> <attributes>
<attribute name="maven.pomderived" value="true"/> <attribute name="maven.pomderived" value="true"/>
...@@ -38,5 +33,10 @@ ...@@ -38,5 +33,10 @@
<attribute name="maven.pomderived" value="true"/> <attribute name="maven.pomderived" value="true"/>
</attributes> </attributes>
</classpathentry> </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"/> <classpathentry kind="output" path="target/classes"/>
</classpath> </classpath>
...@@ -59,9 +59,9 @@ author = u'Thorsten Vitt' ...@@ -59,9 +59,9 @@ author = u'Thorsten Vitt'
# built documents. # built documents.
# #
# The short X.Y version. # The short X.Y version.
version = '1.4.6' version = '1.4.7'
# The full version, including alpha/beta/rc tags. # The full version, including alpha/beta/rc tags.
release = version release = version + '-SNAPSHOT'
# The language for content autogenerated by Sphinx. Refer to documentation # The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages. # for a list of supported languages.
......
...@@ -139,6 +139,40 @@ Custom stylesheets will generally be able to resolve ``textgrid:`` URIs using fu ...@@ -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. - *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 Other options
^^^^^^^^^^^^^ ^^^^^^^^^^^^^
......
...@@ -18,5 +18,3 @@ Up-To-Date short usage ...@@ -18,5 +18,3 @@ Up-To-Date short usage
---------------------- ----------------------
http://textgrid-esx2.gwdg.de/1.0/aggregator/help 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. ...@@ -106,7 +106,9 @@ You export one or more objects/aggregations and everything that they aggregate.
Search results 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 | | parameter | value | description |
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>info.textgrid.services</groupId> <groupId>info.textgrid.services</groupId>
<artifactId>aggregator</artifactId> <artifactId>aggregator</artifactId>
<version>1.4.6</version> <version>1.4.8</version>
<packaging>war</packaging> <packaging>war</packaging>
<name>TextGrid Aggregator Service</name> <name>TextGrid Aggregator Service</name>
...@@ -209,8 +209,8 @@ ...@@ -209,8 +209,8 @@
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId> <artifactId>maven-compiler-plugin</artifactId>
<configuration> <configuration>
<source>1.5</source> <source>1.7</source>
<target>1.5</target> <target>1.7</target>
</configuration> </configuration>
</plugin> </plugin>
<plugin> <plugin>
...@@ -285,8 +285,8 @@ ...@@ -285,8 +285,8 @@
<artifactId>maven-compiler-plugin</artifactId> <artifactId>maven-compiler-plugin</artifactId>
<version>2.3.1</version> <version>2.3.1</version>
<configuration> <configuration>
<source>1.6</source> <source>1.7</source>
<target>1.6</target> <target>1.7</target>
</configuration> </configuration>
</plugin> </plugin>
<plugin> <plugin>
...@@ -451,64 +451,6 @@ ...@@ -451,64 +451,6 @@
</resources> </resources>
</build> </build>
<profiles> <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> <profile>
<id>esx1</id> <id>esx1</id>
<properties> <properties>
...@@ -571,12 +513,51 @@ ...@@ -571,12 +513,51 @@
</plugins> </plugins>
</build> </build>
</profile> </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> </profiles>
<organization> <organization>
<name>TextGrid</name> <name>TextGrid</name>
<url>http://www.textgrid.de/</url> <url>http://www.textgrid.de/</url>
</organization> </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> <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> <inceptionYear>2012</inceptionYear>
<scm> <scm>
<url>https://projects.gwdg.de/projects/aggregator/repository</url> <url>https://projects.gwdg.de/projects/aggregator/repository</url>
...@@ -584,12 +565,12 @@ ...@@ -584,12 +565,12 @@
<developerConnection>scm:git:ssh://git@git.projects.gwdg.de/aggregator.git</developerConnection> <developerConnection>scm:git:ssh://git@git.projects.gwdg.de/aggregator.git</developerConnection>
</scm> </scm>
<issueManagement> <issueManagement>
<system>Jira</system> <system>Redmine</system>
<url>https://pm.sub.uni-goettingen.de/</url> <url>https://projects.gwdg.de/projects/tg</url>
</issueManagement> </issueManagement>
<ciManagement> <ciManagement>
<system>Jenkins</system> <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> </ciManagement>
<url>https://projects.gwdg.de/projects/aggregator</url> <url>https://projects.gwdg.de/projects/aggregator</url>
</project> </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( ...@@ -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("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("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 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, @Context final Request request) throws ObjectNotFoundFault,
MetadataParseFault, IoFault, AuthFault, MetadataParseFault, IoFault, AuthFault,
ProtocolNotImplementedFault, WebApplicationException, IOException, ProtocolNotImplementedFault, WebApplicationException, IOException,
...@@ -140,6 +141,7 @@ public Response getHTML( ...@@ -140,6 +141,7 @@ public Response getHTML(
embedded, css, sid, mediaType, id, request); embedded, css, sid, mediaType, id, request);
writer.simulate(simulate); writer.simulate(simulate);
writer.linkUrlPattern(linkURLPattern); writer.linkUrlPattern(linkURLPattern);
writer.toc(toc);
return writer.createResponse().build(); return writer.createResponse().build();
} }
......
...@@ -99,6 +99,7 @@ public class HTMLWriter extends CorpusBasedExporter implements StreamingOutput { ...@@ -99,6 +99,7 @@ public class HTMLWriter extends CorpusBasedExporter implements StreamingOutput {
private final StylesheetManager stylesheetManager; private final StylesheetManager stylesheetManager;
private Optional<String> id = Optional.absent(); private Optional<String> id = Optional.absent();
private Optional<String> linkUrlPattern = Optional.absent(); private Optional<String> linkUrlPattern = Optional.absent();
private Optional<String> toc = Optional.absent();
private static final Logger logger = Logger.getLogger(HTMLWriter.class.getCanonicalName()); private static final Logger logger = Logger.getLogger(HTMLWriter.class.getCanonicalName());
...@@ -175,6 +176,7 @@ void detectEmbeddedStylesheet(final Source source) { ...@@ -175,6 +176,7 @@ void detectEmbeddedStylesheet(final Source source) {
.getAssociatedStylesheet(source, null, null, null); .getAssociatedStylesheet(source, null, null, null);
this.associatedStylesheetURI = Optional.of(new URI( this.associatedStylesheetURI = Optional.of(new URI(
associatedStylesheet.getSystemId())); associatedStylesheet.getSystemId()));
logger.log(Level.INFO, "Detected associated stylesheet {0}, URI {1}", new Object[] { associatedStylesheet, associatedStylesheetURI.get()});
} catch (final TransformerConfigurationException e) { } catch (final TransformerConfigurationException e) {
logger.log(Level.WARNING, "Failed to load stylesheet from <?xsl-stylesheet?> declaration", e); logger.log(Level.WARNING, "Failed to load stylesheet from <?xsl-stylesheet?> declaration", e);
...@@ -240,6 +242,9 @@ public XsltTransformer getTransformer() throws SaxonApiException, IOException { ...@@ -240,6 +242,9 @@ public XsltTransformer getTransformer() throws SaxonApiException, IOException {
if (id.isPresent()) if (id.isPresent())
transformer.setParameter(new QName("ID"), new XdmAtomicValue(id.get())); transformer.setParameter(new QName("ID"), new XdmAtomicValue(id.get()));
if (toc.isPresent())
transformer.setParameter(new QName("onlyTOC"), new XdmAtomicValue(toc.get()));
transformer.setSource(source); transformer.setSource(source);
...@@ -300,7 +305,8 @@ public ResponseBuilder createResponse() throws ObjectNotFoundFault, MetadataPars ...@@ -300,7 +305,8 @@ public ResponseBuilder createResponse() throws ObjectNotFoundFault, MetadataPars
if (isNotModified()) if (isNotModified())
return getResponseBuilder(); return getResponseBuilder();
getTransformer().setSource(getSource()); final Source source = getSource();
getTransformer().setSource(source);
if (requestedMediaType.isPresent()) { if (requestedMediaType.isPresent()) {
setMediaType(requestedMediaType.get()); setMediaType(requestedMediaType.get());
...@@ -312,4 +318,9 @@ public ResponseBuilder createResponse() throws ObjectNotFoundFault, MetadataPars ...@@ -312,4 +318,9 @@ public ResponseBuilder createResponse() throws ObjectNotFoundFault, MetadataPars
} }
return super.createResponse(); 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 @@ ...@@ -33,9 +33,10 @@
import javax.xml.stream.XMLOutputFactory; import javax.xml.stream.XMLOutputFactory;
import javax.xml.stream.XMLStreamException; import javax.xml.stream.XMLStreamException;
import javax.xml.stream.events.XMLEvent; import javax.xml.stream.events.XMLEvent;
import javax.xml.transform.stax.StAXResult; import javax.xml.transform.sax.SAXResult;
import javax.xml.ws.Holder; import javax.xml.ws.Holder;
import org.springframework.util.xml.StaxUtils;
import com.google.common.base.Joiner; import com.google.common.base.Joiner;
import com.google.common.base.Throwables; import com.google.common.base.Throwables;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
...@@ -168,7 +169,7 @@ protected void walkAggregation(final ObjectType object, final boolean again) { ...@@ -168,7 +169,7 @@ protected void walkAggregation(final ObjectType object, final boolean again) {
} }
// writeHeader(object); // writeHeader(object);
stack.writeHeader(new StAXResult(new XMLEventFilter(writer) { XMLEventFilter xmlEventFilter = new XMLEventFilter(writer) {
@Override @Override
public void add(final XMLEvent event) throws XMLStreamException { public void add(final XMLEvent event) throws XMLStreamException {
...@@ -176,8 +177,8 @@ public void add(final XMLEvent event) throws XMLStreamException { ...@@ -176,8 +177,8 @@ public void add(final XMLEvent event) throws XMLStreamException {
super.add(event); super.add(event);
} }
} };
)); stack.writeHeader(new SAXResult(StaxUtils.createContentHandler(xmlEventFilter)));
} }
super.walkAggregation(object, again); super.walkAggregation(object, again);
......
...@@ -156,7 +156,7 @@ protected Templates getStylesheet() ...@@ -156,7 +156,7 @@ protected Templates getStylesheet()
.getResourceAsStream("md2tei.xsl"); .getResourceAsStream("md2tei.xsl");
final StreamSource xslSource = new StreamSource(xslStream); 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); stylesheet = factory.newTemplates(xslSource);
} }
return stylesheet; return stylesheet;
......
...@@ -14,13 +14,18 @@ ...@@ -14,13 +14,18 @@
<xsl:output method="xhtml" omit-xml-declaration="yes" indent="no"/> <xsl:output method="xhtml" omit-xml-declaration="yes" indent="no"/>
<xsl:param name="extraclass"/> <xsl:param name="extraclass"/>
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="/"> <xsl:template match="/">
<xsl:choose> <xsl:choose>
<xsl:when test="//body"> <xsl:when test="//body">
<div class="body {$extraclass}"> <div class="body {$extraclass}">
<xsl:apply-templates select="//style"/> <xsl:apply-templates select="//style"/>
<xsl:copy-of select="//body/*"/> <xsl:apply-templates/>
</div> </div>
</xsl:when> </xsl:when>
<xsl:otherwise> <xsl:otherwise>
...@@ -29,6 +34,10 @@ ...@@ -29,6 +34,10 @@
</xsl:choose> </xsl:choose>
</xsl:template> </xsl:template>
<xsl:template match="html">
<xsl:apply-templates select="body/*"/>
</xsl:template>
<xsl:template match="style"> <xsl:template match="style">
<xsl:copy> <xsl:copy>
<xsl:copy-of select="@*"/> <xsl:copy-of select="@*"/>
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
--> -->
<xsl:output method="xhtml" /> <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:param name="extraclass"/>
<xsl:include href="tohtml.xsl"/> <xsl:include href="tohtml.xsl"/>
......
...@@ -63,6 +63,7 @@ ...@@ -63,6 +63,7 @@
<xsl:param name="autoHead">false</xsl:param> <xsl:param name="autoHead">false</xsl:param>
<xsl:param name="showTitleAuthor">false</xsl:param> <xsl:param name="showTitleAuthor">false</xsl:param>
<xsl:param name="cssFile"/> <xsl:param name="cssFile"/>
<xsl:param name="onlyTOC"/>
<xsl:output method="xhtml"/> <xsl:output method="xhtml"/>
...@@ -78,7 +79,57 @@ ...@@ -78,7 +79,57 @@
<xsl:template name="stdheader"> <xsl:template name="stdheader">
<xsl:param name="title">(no title)</xsl:param> <xsl:param name="title">(no title)</xsl:param>
</xsl:template> </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>