Commit f61a89c0 authored by Mathias Goebel's avatar Mathias Goebel 🎠
Browse files

feat: allow for robots.txt

parent bf857181
......@@ -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)
Markdown is supported
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