Commit f1b59a24 authored by mrodzis's avatar mrodzis 🐸
Browse files

Merge branch 'bugfix/#6' into 'develop'

Bugfix/#6

Closes #6

See merge request !18
parents 1988e368 80bbb074
build/
test/
local.build.properties
expath-pkg.xml
......@@ -14,16 +14,9 @@ in the first panel (1).
![Forking step 1](http://localhost:8080/exist/apps/sade/templates/img/publisher-1.png]
Click on "create" (2) and wait until you get redirected to your own instance.
[Enter a new secure password!]
To continue you have to enter new credentials to the SADE Plugin configuration:
* URL: append -ProjectName to "/sade
* User: ProjectName
* Password:
The username will be the same as the project name and you have to enter the
formerly typed password here as well.
The resulting view should present new credentials at the top. Again you have to
set these credentials in the [preferences in TextGridLab](publish.md#configuration).
# Download & Tracking changes
You can download any application by clicking on the download button at the SADE
......
......@@ -28,6 +28,15 @@ declare function app:title($node as node(), $model as map(*)) {
config:get("project-title")
};
(:~
: Get the target of this app by using the repo.xml.
: @param $node the HTML node with the attribute which triggered this call
: @param $model a map containing arbitrary data - used to pass information between template calls
:)
declare function app:target($node as node(), $model as map(*)) {
config:repoget("target")
};
(:~
: Provides dynamic CSS based on the requested resource name :)
declare function app:css-injection($node as node(), $model as map(*), $exist-resource) {
......@@ -380,3 +389,15 @@ element { node-name($node) } {
$model("function")/xqdoc:comment/xqdoc:return/text()
}
};
declare function app:fork-successfull($node as node(), $model as map(*), $newpw as xs:string?) {
if(not($newpw)) then () else
<div class="alert alert-success fade in" id="fork-successfull">
Sucessfully created a new package. You may now set the following parameters in the TextGrid Laboratory:
<ul>
<li>URL: <span>{request:get-url()}</span></li>
<li>Username: <span>{app:target($node, $model)}</span></li>
<li>Password: <span>{request:get-parameter("newpw", "")}</span></li>
</ul>
</div>
};
......@@ -60,3 +60,11 @@ declare function config:get($key as xs:string, $module-key as xs:string?) {
declare function config:key-available($key as xs:string) as xs:boolean {
$config:file/cf:config//*/string(@key) = $key
};
(:~
: A function to query the app repo config.
: @param $key – the name of the element to query for
: :)
declare function config:repoget($key as xs:string){
$config:repo-descriptor//*[local-name() = $key] ! string(.)
};
......@@ -6,7 +6,7 @@ xquery version "3.1";
: but in the new application.
:
: @author Mathias Göbel
: @version 0.1
: @version 0.2
: :)
import module namespace dbutil="http://exist-db.org/xquery/dbutil";
......@@ -16,7 +16,32 @@ declare namespace cf="https://sade.textgrid.de/ns/configfile";
declare namespace expath="http://expath.org/ns/pkg";
declare namespace repo="http://exist-db.org/xquery/repo";
(:~
: Generate a password in the given length.
:
: @param $length the length of the resulting password
: @author Mathias Göbel
: @since 0.2
: :)
declare function local:passwordGenerator($length as xs:integer) {
if($length lt 10)
then error( QName("https://sade.textgrid.de/ns/error", "FORK04"), "Short password. use at least 10 chars")
else
(: charmap must not contain characters that do not evaluate against xs:anyURI
or a regular expression REPLACEMENT. :)
let $charset := string-to-codepoints('ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz') => codepoints-to-string()
let $charsetLength := string-length($charset)
let $password :=
for $i in 1 to $length
let $num := util:random($charsetLength)
return
substring($charset, $num, 1)
return
string-join($password)
};
declare variable $target := request:get-parameter("target", "koma");
declare variable $password := local:passwordGenerator(15);
declare variable $referer := request:get-header("Referer");
declare variable $dry-run := request:get-parameter("dry", "false");
......@@ -40,7 +65,7 @@ declare variable $repoConf :=
<copyright>true</copyright>
<type>application</type>
<target>sade-{ $target }</target>
<permissions password="sade{ $target }" user="{ $target }" group="sade{ $target }" mode="rw-r--r--"/>
<permissions password="{ $password }" user="{ $target }" group="sade{ $target }" mode="rw-r--r--"/>
<prepare>pre-install.xq</prepare>
<finish>post-install.xq</finish>
<deployed>{ current-dateTime() }</deployed>
......@@ -119,6 +144,8 @@ return
return
if( $complete/@result = "ok" )
then
let $uri := replace($referer, "apps/.+/publish\.html", "apps/"||replace($name, "SADE", "sade")||"/publish.html")
return response:redirect-to(xs:anyURI($uri))
let $replacement := "apps/" || replace($name, "SADE", "sade") || "/publish.html?newpw=" || $password
let $uri := replace(tokenize($referer, "\?")[1], "apps/.+/publish\.html", $replacement)
return
response:redirect-to(xs:anyURI($uri))
else $complete
......@@ -79,8 +79,6 @@ as xs:string {
local:format-test-rate-output($coverage)
};
let $project-name := tokenize($target, "/")[last()]
let $log := util:log-system-out("installing " || $project-name)
......@@ -94,8 +92,8 @@ let $data-xconf := $target || "/textgrid/data/collection.xconf"
(: prepare empty Lucene Config files :)
let $prepare-config := (
util:eval("file:serialize-binary( xs:base64Binary(util:base64-encode(""# empty config file&#10;ä,ae&#10;ö,oe&#10;ü,ue"")), $system-path || $project-name || '-charmap.txt')"),
util:eval("file:serialize-binary( xs:base64Binary(util:base64-encode(""# empty config file&#10;Backfisch, Tochter, Mädchen"")), $system-path || $project-name || '-synonyms.txt')")
util:eval("file:serialize-binary( xs:base64Binary(util:base64-encode(""# default config file&#10;ä,ae&#10;ö,oe&#10;ü,ue"")), $system-path || $project-name || '-charmap.txt')"),
util:eval("file:serialize-binary( xs:base64Binary(util:base64-encode(""# default config file&#10;Backfisch, Tochter, Mädchen"")), $system-path || $project-name || '-synonyms.txt')")
)
let $print-message :=
if($project-name != "sade") then true() else
......@@ -115,12 +113,14 @@ let $rewrite-synonyms := update value
//xconf:lucene/xconf:analyzer/xconf:param[@name="synonyms"]
/@value
with $system-path || $project-name || "-synonyms.txt"
let $store-xconf := xmldb:store("/db/system/config"||$target||"/textgrid/data", "collection.xconf", doc( $data-xconf ))
let $reindex := xmldb:reindex($target||"/textgrid/data")
let $store-xconf := xmldb:store("/db/system/config" || $target || "/textgrid/data", "collection.xconf", doc( $data-xconf ))
let $reindex := xmldb:reindex($target || "/textgrid/data")
(: we have to test for writable path :)
let $path := $system-path
let $path := $system-path
let $user := util:system-property("user.name")
let $message1 := $path || " is not available. Create it and make sure "||$user||" can write there."
let $message1 := $path || " is not available. Create it and make sure "
|| $user || " can write there."
let $message2 := "Could not write to " || $path || "."
return (
if
......
<div data-template="templates:surround" data-template-with="templates/page_index.html" data-template-at="content-container">
<div data-template="app:fork-successfull"/>
<div class="container">
<div class="panel panel-default">
<div class="panel-heading">
......
......@@ -108,9 +108,9 @@ function tests:multiviewer-idResolver($id) {
};
declare
%test:arg("id", "/data/10qd4.xml") %test:assertEquals("/db/apps/sade/textgrid/data/10qd4.xml")
%test:arg("id", "/docs/about.md") %test:assertEquals("/db/apps/sade/docs/about.md")
%test:arg("id", "docs/about.md") %test:assertEquals("/db/apps/sade/docs/about.md")
%test:arg("id", "/data/10qd4.xml") %test:assertXPath(" matches( $result, '^/db/apps/sade-?[a-zA-Z0-9\-\.]*/textgrid/data/10qd4.xml')")
%test:arg("id", "/docs/about.md") %test:assertXPath(" matches( $result, '^/db/apps/sade-?[a-zA-Z0-9\-\.]*/docs/about.md')")
%test:arg("id", "docs/about.md") %test:assertXPath(" matches( $result, '^/db/apps/sade-?[a-zA-Z0-9\-\.]*/docs/about.md')")
function tests:multiviewer-getPath($id) {
util:eval("multiviewer:getPath($id)")
};
......@@ -127,14 +127,6 @@ function tests:multiviewer-markdown($docpath) {
util:eval( "multiviewer:markdown($docpath)" )
};
declare
%test:arg("id", "textgrid:10qd4") %test:assertXPath('$result/@class = "teixslt"')
%test:arg("id", "textgrid:10qd4") %test:assertXPath('$result//*:h1[@class="maintitle"]/text() = "480. Der Lieper Haidebaum bei Hohenrode"')
%test:arg("id", "docs/about.md") %test:assertXPath('$result/@class = "markdown"')
function tests:multiviewer-show($id) {
util:eval("multiviewer:show($tests:node, $tests:model, $id, ())")
};
(: ************** :)
(: * NAVIGATION * :)
(: ************** :)
......
Supports Markdown
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