Skip to content

Commit 4b2ffa5

Browse files
authored
Merge pull request #53 from joewiz/separate-data-from-app
version 2.0
2 parents 54198c6 + 118f19e commit 4b2ffa5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+1786
-994
lines changed

admin.html

Lines changed: 64 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,71 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<div xmlns="http://www.w3.org/1999/xhtml" class="templates:surround?with=templates/page.html&amp;at=container-body">
2+
<div xmlns="http://www.w3.org/1999/xhtml" data-template="templates:surround" data-template-with="templates/page.html" data-template-at="container-body">
33
<div class="row">
44
<div class="col-md-12">
5-
<h1>Package Upload</h1>
6-
<p>Upload xar packages to the public repository. New packages will not appear in the list of
7-
available packages immediately. Instead you will have to trigger an update afterwards, using
8-
the "publish" button below. This way you can upload multiple packages before publishing them.</p>
5+
<h1>Admin</h1>
6+
<p>View administrative information about packages and upload new ones.</p>
97
</div>
108
</div>
119
<div class="row">
12-
<div class="col-md-6">
10+
<div class="col-md-8">
11+
<div>
12+
<h2>Statistics</h2>
13+
<h3>Top 5 packages</h3>
14+
<ol data-template="app:load-get-package-logs-for-admin-table" data-template-top-n="5">
15+
<li data-template="templates:each" data-template-from="package-logs" data-template-to="package-log">
16+
<span data-template="app:get-package-stats"/>
17+
</li>
18+
</ol>
19+
</div>
20+
<div data-template="app:load-package-groups">
21+
<h2>All package groups</h2>
22+
<div data-template="templates:each" data-template-from="package-groups" data-template-to="package-group">
23+
<h3><span data-template="app:package-group-abbrev"/></h3>
24+
<dl>
25+
<dt>Abbrev</dt>
26+
<dd><span data-template="app:package-group-abbrev"/></dd>
27+
<dt>Name</dt>
28+
<dd><span data-template="app:package-group-name"/></dd>
29+
<dt>Title</dt>
30+
<dd><span data-template="app:package-group-title"/></dd>
31+
</dl>
32+
<table data-template="app:load-packages" class="table table-bordered">
33+
<thead>
34+
<tr>
35+
<th>Version</th>
36+
<th>eXist Requirement</th>
37+
<th>Date Published</th>
38+
</tr>
39+
</thead>
40+
<tbody>
41+
<tr data-template="templates:each" data-template-from="packages" data-template-to="package">
42+
<td><span data-template="app:package-version"/></td>
43+
<td><span data-template="app:package-requires"/></td>
44+
<td><span data-template="app:package-date-published"/></td>
45+
</tr>
46+
</tbody>
47+
</table>
48+
</div>
49+
</div>
50+
</div>
51+
<div class="col-md-4">
52+
<p>
53+
<a href="index.html" class="btn btn-primary">
54+
<i class="glyphicon glyphicon-share"/> Return to list
55+
</a>
56+
</p>
57+
<p>
58+
<a href="?rebuild-package-groups-metadata=true" class="btn btn-default">
59+
<i class="glyphicon glyphicon-repeat"/> Rebuild package-groups metadata
60+
</a>
61+
</p>
62+
<a href="index.html?logout=true" class="btn btn-default">
63+
<i class="glyphicon glyphicon-log-out"/> Log out</a>
64+
<h2>Upload Packages</h2>
65+
<p>Upload xar packages to the public repository. New packages will appear in the list of
66+
available packages immediately upon upload.</p>
67+
<p data-template="app:rebuild-package-groups-metadata"/>
68+
1369
<span class="btn btn-success fileinput-button">
1470
<i class="glyphicon glyphicon-plus"/>
1571
<span>Select files...</span>
@@ -28,16 +84,6 @@ <h1>Package Upload</h1>
2884
<tbody id="files"/>
2985
</table>
3086
</div>
31-
<div class="col-md-6">
32-
<p>
33-
<a href="index.html" class="btn btn-primary">
34-
<i class="glyphicon glyphicon-share"/> Return to list
35-
</a>
36-
</p>
37-
<p>Publishing will take a while to process apps.</p>
38-
<a href="index.html?logout=true" class="btn btn-default">
39-
<i class="glyphicon glyphicon-log-out"/> Log out</a>
40-
</div>
4187
</div>
4288
<script type="text/javascript" src="resources/scripts/jquery.ui.widget.js"/>
4389
<script type="text/javascript" src="resources/scripts/jquery.iframe-transport.js"/>
@@ -46,7 +92,7 @@ <h1>Package Upload</h1>
4692
$(function () {
4793
'use strict';
4894
$('#fileupload').fileupload({
49-
url: "modules/upload.xql",
95+
url: "put-package",
5096
dataType: 'json',
5197
done: function (e, data) {
5298
$.each(data.result.files, function (index, file) {
@@ -68,4 +114,4 @@ <h1>Package Upload</h1>
68114
.parent().addClass($.support.fileInput ? undefined : 'disabled');
69115
});
70116
</script>
71-
</div>
117+
</div>

build.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44
#
55

66
project.name=public-repo
7-
project.version=1.1.0
7+
project.version=2.0.0

collection.xconf

Lines changed: 0 additions & 6 deletions
This file was deleted.

controller.xql

Lines changed: 34 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
xquery version "3.1";
22

3+
import module namespace config="http://exist-db.org/xquery/apps/config" at "modules/config.xqm";
34
import module namespace login="http://exist-db.org/xquery/login" at "resource:org/exist/xquery/modules/persistentlogin/login.xql";
45

6+
declare namespace sm="http://exist-db.org/xquery/securitymanager";
7+
58
declare variable $exist:path external;
69
declare variable $exist:resource external;
710
declare variable $exist:controller external;
811
declare variable $exist:prefix external;
912
declare variable $exist:root external;
1013

1114
declare variable $app-root-absolute-url :=
12-
(request:get-header("X-Forwarded-Proto"), request:get-scheme())[1]
13-
|| "://"
14-
|| (request:get-header("X-Forwarded-Server"), request:get-server-name())[1]
15-
|| request:get-context-path()
15+
request:get-context-path()
1616
|| $exist:prefix
1717
|| $exist:controller
1818
;
@@ -30,33 +30,21 @@ else if ($exist:path eq "/") then
3030
<redirect url="index.html"/>
3131
</dispatch>
3232

33-
else if ($exist:path eq "/public/apps.xml") then (
34-
response:set-header('Content-Type', 'application/xml'),
33+
else if ($exist:path eq "/public/apps.xml") then
3534
<dispatch xmlns="http://exist.sourceforge.net/NS/exist">
36-
<forward url="{$exist:controller}/modules/list.xql"/>
35+
<forward url="{$exist:controller}/modules/list.xq"/>
3736
</dispatch>
38-
)
39-
else if ($exist:resource eq "update.xql") then
40-
<dispatch xmlns="http://exist.sourceforge.net/NS/exist">
41-
<forward url="{$exist:controller}/modules/update.xql"/>
42-
<view>
43-
<forward url="{$exist:controller}/index.html"/>
44-
<forward url="{$exist:controller}/modules/view.xql">
45-
<set-header name="Cache-Control" value="no-cache"/>
46-
</forward>
47-
</view>
48-
</dispatch>
49-
37+
5038
(: Protected resource: user is required to log in with valid credentials.
5139
If the login fails or no credentials were provided, the request is redirected
5240
to the login.html page. :)
5341
else if ($exist:path eq "/admin.html") then
5442
let $user := request:get-attribute("org.exist.public-repo.login.user")
5543
return
56-
if ($user and (sm:is-dba($user) or "repo" = sm:get-user-groups($user))) then
44+
if (exists($user) and sm:get-user-groups($user) = config:repo-permissions()?group) then
5745
<dispatch xmlns="http://exist.sourceforge.net/NS/exist">
5846
<view>
59-
<forward url="{$exist:controller}/modules/view.xql">
47+
<forward url="{$exist:controller}/modules/view.xq">
6048
<set-header name="Cache-Control" value="no-cache"/>
6149
</forward>
6250
</view>
@@ -65,47 +53,62 @@ else if ($exist:path eq "/admin.html") then
6553
<dispatch xmlns="http://exist.sourceforge.net/NS/exist">
6654
<forward url="login.html"/>
6755
<view>
68-
<forward url="{$exist:controller}/modules/view.xql">
56+
<forward url="{$exist:controller}/modules/view.xq">
6957
<set-header name="Cache-Control" value="no-cache"/>
7058
</forward>
7159
</view>
7260
</dispatch>
7361

62+
(: Protected resource :)
63+
else if ($exist:path eq "/put-package") then
64+
<dispatch xmlns="http://exist.sourceforge.net/NS/exist">
65+
<forward url="{$exist:controller}/modules/put-package.xq"/>
66+
</dispatch>
67+
7468
else if (ends-with($exist:resource, ".html") and starts-with($exist:path, "/packages")) then
7569
<dispatch xmlns="http://exist.sourceforge.net/NS/exist">
7670
<forward url="{concat($exist:controller, '/packages.html')}"/>
7771
<view>
78-
<forward url="{concat($exist:controller, '/modules/view.xql')}">
72+
<forward url="{concat($exist:controller, '/modules/view.xq')}">
7973
<add-parameter name="abbrev" value="{substring-before($exist:resource, '.html')}"/>
8074
</forward>
8175
</view>
8276
</dispatch>
8377

8478
else if (ends-with($exist:resource, ".html")) then
85-
(: the html page is run through view.xql to expand templates :)
79+
(: the html page is run through view.xq to expand templates :)
8680
<dispatch xmlns="http://exist.sourceforge.net/NS/exist">
8781
<view>
88-
<forward url="modules/view.xql">
82+
<forward url="modules/view.xq">
8983
<set-header name="Cache-Control" value="no-cache"/>
9084
</forward>
9185
</view>
9286
</dispatch>
9387

94-
else if (contains($exist:path, "/public/") and ends-with($exist:resource, ".zip")) then
88+
else if (contains($exist:path, "/public/") and ends-with($exist:resource, ".xar") or ends-with($exist:resource, ".zip")) then
89+
<dispatch xmlns="http://exist.sourceforge.net/NS/exist">
90+
<forward url="{$exist:controller}/modules/get-package.xq">
91+
<add-parameter name="filename" value="{$exist:resource}"/>
92+
</forward>
93+
</dispatch>
94+
95+
else if (contains($exist:path, "/public/") and (ends-with($exist:resource, ".png") or ends-with($exist:resource, ".svg"))) then
9596
<dispatch xmlns="http://exist.sourceforge.net/NS/exist">
96-
<forward url="../modules/download-xar-zip.xq"/>
97+
<forward url="{$exist:controller}/modules/get-icon.xq">
98+
<add-parameter name="filename" value="{$exist:resource}"/>
99+
</forward>
97100
</dispatch>
98101

99-
else if ($exist:path eq "/find" or ends-with($exist:resource, ".zip")) then
102+
else if ($exist:path eq "/find") then
100103
<dispatch xmlns="http://exist.sourceforge.net/NS/exist">
101-
<forward url="modules/find.xql">
104+
<forward url="modules/find.xq">
102105
<add-parameter name="app-root-absolute-url" value="{$app-root-absolute-url}"/>
103106
</forward>
104107
</dispatch>
105108

106109
else if ($exist:resource eq "feed.xml") then
107110
<dispatch xmlns="http://exist.sourceforge.net/NS/exist">
108-
<forward url="modules/feed.xql"/>
111+
<forward url="modules/feed.xq"/>
109112
</dispatch>
110113

111114
else if (contains($exist:path, "/$shared/")) then
@@ -117,16 +120,9 @@ else if (contains($exist:path, "/$shared/")) then
117120

118121
else if (contains($exist:path, "/resources/")) then
119122
<dispatch xmlns="http://exist.sourceforge.net/NS/exist">
120-
<forward url="{$exist:controller}/resources/{substring-after($exist:path, '/resources/')}">
121-
<set-header name="Cache-Control" value="max-age=3600, must-revalidate"/>
122-
</forward>
123+
<set-header name="Cache-Control" value="max-age=3600, must-revalidate"/>
123124
</dispatch>
124125

125-
else if (ends-with($exist:path, ".xml")) then
126-
<dispatch xmlns="http://exist.sourceforge.net/NS/exist">
127-
<set-header name="Cache-Control" value="no-cache"/>
128-
</dispatch>
129-
130126
else
131127
(: everything else is passed through :)
132128
<dispatch xmlns="http://exist.sourceforge.net/NS/exist">

expath-pkg.xml.tmpl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<package xmlns="http://expath.org/ns/pkg" name="http://exist-db.org/apps/public-repo" abbrev="@project.name@" version="@project.version@" spec="1.0">
33
<title>eXist-db Public Application Repository</title>
4-
<dependency processor="http://exist-db.org" semver-min="4.7.0"/>
5-
<dependency package="http://expath.org/ns/crypto" semver-min="0.7"/>
4+
<dependency processor="http://exist-db.org" semver-min="5.0.0"/>
65
<dependency package="http://exist-db.org/xquery/semver-xq" semver-min="2.2.1"/>
6+
<dependency package="http://exist-db.org/apps/shared" semver-min="0.9.1"/>
77
</package>

index.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<div class="templates:surround?with=templates/page.html&amp;at=container-body">
2+
<div data-template="templates:surround" data-template-with="templates/page.html" data-template-at="container-body">
33
<div class="row">
44
<div class="col-md-12">
55
<h1>Public Application Repository</h1>
@@ -10,7 +10,7 @@ <h1>Public Application Repository</h1>
1010
Package Manager app.</li>
1111
<li>Install the package directly from the Dashboard's Package Manager app. (By default the
1212
Package Manager is configured to access the eXist-db public application repository feed,
13-
at <a href="http://demo.exist-db.org/exist/apps/public-repo/public/apps.xml">http://demo.exist-db.org/exist/apps/public-repo/public/apps.xml</a>. To check or
13+
at <a href="https://exist-db.org/exist/apps/public-repo/public/apps.xml">https://exist-db.org/exist/apps/public-repo/public/apps.xml</a>. To check or
1414
edit the repository URL your Package Manager is using, go to your Dashboard, click on
1515
the gear icon beneath the eXist-db icon, and you will see a field, "Public Repository
1616
URL.")</li>
@@ -24,7 +24,7 @@ <h1>Public Application Repository</h1>
2424
<div id="listWrapper" class="col-md-8">
2525
<h2>Packages</h2>
2626
<ul class="packages">
27-
<li class="app:list-packages"/>
27+
<li data-template="app:list-packages"/>
2828
</ul>
2929
</div>
3030
<div class="col-md-4">
@@ -36,4 +36,4 @@ <h2>Admin</h2>
3636
<p>(requires login)</p>
3737
</div>
3838
</div>
39-
</div>
39+
</div>

login.html

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<div xmlns="http://www.w3.org/1999/xhtml" class="templates:surround?with=templates/page.html&amp;at=content">
2+
<div xmlns="http://www.w3.org/1999/xhtml" data-template="templates:surround" data-template-with="templates/page.html" data-template-at="container-body">
33
<h1 class="rounded">Administrator Login</h1>
44
<div class="alert alert-success">
5-
Please login. The user has to be a member of the "repo" or "dba" group.
5+
Please login. The user has to be a member of the "repo" group.
66
</div>
77
<form method="POST" class="form form-horizontal">
88
<div class="form-group">
99
<label class="control-label col-md-1" for="user">User:</label>
1010
<div class="col-md-3">
11-
<input type="text" name="user" required="required" class="form-control" autofocus="autofocus"/>
11+
<input type="text" name="user" required="required" autofocus="autofocus"/>
1212
</div>
1313
</div>
1414
<div class="form-group">
1515
<label class="control-label col-md-1" for="password">Password:</label>
1616
<div class="col-md-3">
17-
<input type="password" name="password" class="form-control"/>
17+
<input type="password" name="password"/>
1818
</div>
1919
</div>
2020
<div class="form-group">
@@ -23,4 +23,4 @@ <h1 class="rounded">Administrator Login</h1>
2323
</div>
2424
</div>
2525
</form>
26-
</div>
26+
</div>

meta/apps.xml

Lines changed: 0 additions & 1 deletion
This file was deleted.

meta/packages.xml

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)