Verified Commit cdb3bc28 authored by Thomas Friese's avatar Thomas Friese
Browse files

Initial commit

parents
Loading
Loading
Loading
Loading

README.md

0 → 100644
+20 −0
Original line number Diff line number Diff line
# Module to do Git Operations in eXist-db

Provides a mudule for manual or automated git operations.

## Documentation

Copy the `configuration.xml` example into the root of your application and edit it to your needs.

Do the same with `modules/trigger-versioning.xqm` and modules `config.xqm`.

`test-git-push.xql` is an example file generating entries for getting a collection automatically triggered to git pushes.

## Build

Building a XAR package with ant:

```shell
ant
```
 No newline at end of file

build.xml

0 → 100644
+12 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="UTF-8"?>
<project default="xar" name="git">
    <xmlproperty file="expath-pkg.xml"/>
    <property name="project.version" value="${package(version)}"/>
    <property name="project.app" value="git"/>
    <property name="build.dir" value="build"/>
    <target name="xar">
        <mkdir dir="${build.dir}"/>
        <zip basedir="." destfile="${build.dir}/${project.app}-${project.version}.xar" excludes="${build.dir}/*"/>
    </target>
</project>
 No newline at end of file

collection.xconf

0 → 100644
+26 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="UTF-8"?>
<collection xmlns="http://exist-db.org/collection-config/1.0">
    <index xmlns:xs="http://www.w3.org/2001/XMLSchema">
        <fulltext default="none" attributes="false"/>
    </index>

    <!-- Triggers to get changes automatically pushed to the git repository -->
    <!-- triggers>
        <trigger event="create" class="org.exist.collections.triggers.XQueryTrigger">
            <parameter name="url" value="xmldb:exist://db/apps/lgpn-ling-data/modules/trigger-versioning.xqm"/>
        </trigger>
        <trigger event="update" class="org.exist.collections.triggers.XQueryTrigger">
            <parameter name="url" value="xmldb:exist://db/apps/lgpn-ling-data/modules/trigger-versioning.xqm"/>
        </trigger>
        <trigger event="move" class="org.exist.collections.triggers.XQueryTrigger">
            <parameter name="url" value="xmldb:exist://db/apps/lgpn-ling-data/modules/trigger-versioning.xqm"/>
        </trigger>
        <trigger event="copy" class="org.exist.collections.triggers.XQueryTrigger">
            <parameter name="url" value="xmldb:exist://db/apps/lgpn-ling-data/modules/trigger-versioning.xqm"/>
        </trigger>
        <trigger event="delete" class="org.exist.collections.triggers.XQueryTrigger">
            <parameter name="url" value="xmldb:exist://db/apps/lgpn-ling-data/modules/trigger-versioning.xqm"/>
        </trigger>
    </triggers -->
</collection>
 No newline at end of file

configuration.xml

0 → 100644
+12 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <admin name="admin" password=""/>
    <exist-collection data="data"/>
    <git
        user-name="John Doe"
        email="john.doe@example.com"
        file-path="/var/tmp/git"
        source-url="git@gitlab.existsolutions.com:git.git"
        branch="master"/>
</configuration>
 No newline at end of file

controller.xql

0 → 100644
+42 −0
Original line number Diff line number Diff line
xquery version "3.0";

declare variable $exist:path external;
declare variable $exist:resource external;
declare variable $exist:controller external;
declare variable $exist:prefix external;
declare variable $exist:root external;

if ($exist:path eq '') then
    <dispatch xmlns="http://exist.sourceforge.net/NS/exist">
        <redirect url="{request:get-uri()}/"/>
    </dispatch>

else if ($exist:path eq "/") then
    (: forward root path to index.xql :)
    <dispatch xmlns="http://exist.sourceforge.net/NS/exist">
        <redirect url="index.html"/>
    </dispatch>

else if (ends-with($exist:resource, ".html")) then
    (: the html page is run through view.xql to expand templates :)
    <dispatch xmlns="http://exist.sourceforge.net/NS/exist">
        <view>
            <forward url="{$exist:controller}/modules/view.xql"/>
        </view>
		<error-handler>
			<forward url="{$exist:controller}/error-page.html" method="get"/>
			<forward url="{$exist:controller}/modules/view.xql"/>
		</error-handler>
    </dispatch>
(: Resource paths starting with $shared are loaded from the shared-resources app :)
else if (contains($exist:path, "/$shared/")) then
    <dispatch xmlns="http://exist.sourceforge.net/NS/exist">
        <forward url="/shared-resources/{substring-after($exist:path, '/$shared/')}">
            <set-header name="Cache-Control" value="max-age=3600, must-revalidate"/>
        </forward>
    </dispatch>
else
    (: everything else is passed through :)
    <dispatch xmlns="http://exist.sourceforge.net/NS/exist">
        <cache-control cache="yes"/>
    </dispatch>