Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions controller.xql
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,13 @@ console:log('exist:path: ' || $exist:path)
,
:)

let $if-modified-since := request:get-header("If-Modified-Since")
return
if ($if-modified-since) then
request:set-attribute("if-modified-since", $if-modified-since)
else
(),

if ($exist:path eq '') then
<dispatch xmlns="http://exist.sourceforge.net/NS/exist">
<redirect url="{local:get-uri()}/"/>
Expand Down
16 changes: 15 additions & 1 deletion modules/app.xqm
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
xquery version "3.0";
xquery version "3.1";

module namespace app="http://history.state.gov/ns/site/hsg/templates";

Expand Down Expand Up @@ -151,6 +151,20 @@ function app:handle-error($node as node(), $model as map(*), $code as xs:int?) {
()
};

declare function app:format-http-date($dateTime as xs:dateTime) as xs:string {
$dateTime
=> adjust-dateTime-to-timezone(xs:dayTimeDuration("PT0H"))
=> format-dateTime("[FNn,*-3], [D01] [MNn,*-3] [Y0001] [H01]:[m01]:[s01] [Z0000]", "en", (), ())
};

declare function app:set-last-modified($last-modified as xs:dateTime) {
response:set-header("Last-Modified", app:format-http-date($last-modified))
};

declare function app:set-created($created as xs:dateTime) {
response:set-header("Created", app:format-http-date($created))
};

declare function app:uri($node as node(), $model as map(*)) {
<code>{request:get-attribute("hsg-shell.path")}</code>
};
Expand Down
Loading