Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
fontane-notizbuecher
SADE
Commits
f61a89c0
Commit
f61a89c0
authored
Nov 17, 2021
by
Mathias Goebel
Browse files
feat: allow for robots.txt
parent
bf857181
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
controller.xql
View file @
f61a89c0
...
...
@@ -12,6 +12,18 @@ declare variable $exist:controller external;
declare variable $exist:prefix external;
declare variable $exist:root external;
declare function local:everything($project) {
let $path := "/../sade-projects/"|| $project || "/" || config:get("data-dir") || "/" || substring-after($exist:path, $project)
let $path := if( doc-available( $path ) ) then $path else "/../sade-projects/"|| $project || config:get("template") || substring-after($exist:path, $project)
return
<dispatch xmlns="http://exist.sourceforge.net/NS/exist">
<cache-control cache="yes"/>
<forward url="{$path}">
<set-header name="Cache-Control" value="max-age=3600, must-revalidate"/>
</forward>
</dispatch>
};
let $project := tokenize( $exist:path, "/" )[. != ""][not(ends-with(., "html"))][1]
let $listproject := config:list-projects()[1]
return
...
...
@@ -28,6 +40,8 @@ else if (empty($project)) then
<redirect url="{config:list-projects()[1]}/index.html"/>
</dispatch>
else if($exist:resource eq "robots.txt") then local:everything($project)
(: forward requests without resources to index.html :)
else if (ends-with($exist:path, "/") or empty($exist:resource)) then
<dispatch xmlns="http://exist.sourceforge.net/NS/exist">
...
...
@@ -150,18 +164,9 @@ else if (contains($exist:path, "/doc/api/") or contains($exist:path, "/openapi/"
<add-parameter name="register" value="false"/>
</forward>
</dispatch>
else
(: check if the resource comes from the template or the data
we try to leave the template manipulation as minimal as
possible
:)
let $path := "/../sade-projects/"|| $project || "/" || config:get("data-dir") || "/" || substring-after($exist:path, $project)
let $path := if( doc-available( $path ) ) then $path else "/../sade-projects/"|| $project || config:get("template") || substring-after($exist:path, $project)
return
<dispatch xmlns="http://exist.sourceforge.net/NS/exist">
<cache-control cache="yes"/>
<forward url="{$path}">
<set-header name="Cache-Control" value="max-age=3600, must-revalidate"/>
</forward>
</dispatch>
local:everything($project)
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment