Skip to content

Instantly share code, notes, and snippets.

@cwittern
Created April 6, 2022 11:06
Show Gist options
  • Save cwittern/034746923d7a33684f70a4b4c567b324 to your computer and use it in GitHub Desktop.
Save cwittern/034746923d7a33684f70a4b4c567b324 to your computer and use it in GitHub Desktop.
Authentication with Fore

The file edit-KR5c0057.html is read from the exist-db, the user already authenticated with username/password. However, when I post the result back, the result is a 404 Unauthorized and the PUT fails.

<html lang="en">
<head>
<meta charset="utf-8">
<meta content="width=device-width, minimum-scale=1, initial-scale=1, user-scalable=yes"
name="viewport">
<title>XML Fragment editor</title>
<link href="resources/fore/demo.css" rel="stylesheet">
<link href="resources/fore/vars.css" rel="stylesheet">
<style>
html {
/*--inspector-bg:var(--paper-grey-700);*/
/*--inspector-pre-bg:var(--paper-grey-100);*/
/*--inspector-color:var(--paper-grey-800);*/
/*--inspector-pre-bg:blue;*/
}
body {
background: var(--paper-light-blue-200);
color: var(--paper-light-blue-900)
}
.card {
background: white;
padding: 1rem;
border-radius: 0.5rem;
}
#changes fx-repeatitem {
display: grid;
grid-template-columns: auto min-content;
grid-column-gap: 1rem;
}
#changes fx-repeatitem fx-output {
white-space: nowrap;
}
.deleteIcon button {
border: none;
cursor: pointer;
background: transparent;
color: red;
}
details {
padding: 1rem;
margin: 1rem 0;
/*background: white;*/
}
details[open] {
/*background: var(--paper-grey-100);*/
/*background-color: rgba(255, 255, 255, 0.5);*/
}
fx-case {
margin-top: 1px;
border: 1px solid var(--paper-light-blue-900);
padding: 2rem;
background-color: rgba(255, 255, 255, 0.5);
}
fx-control,
input,
textarea {
width: 100%;
margin: 0.3rem 0;
}
input {
padding: 0.3rem;
}
label {
display: block;
color: var(--paper-blue-900);
}
fx-control {
/*margin-top: 1rem;*/
}
fx-group {
margin-top: 1rem;
padding: 1rem;
}
h3,
fx-output,
input {
border: none;
}
h3,
h4 {
margin-bottom: 0;
margin-top: 1rem;
}
fx-repeat {
display: block;
}
fx-repeatitem {
display: block;
}
fx-repeatitem {
display: grid;
grid-template-columns: auto 30px;
width: 100%;
align-items: baseline;
}
details.log {
background: var(--paper-light-blue-100);
}
pre {
overflow: auto;
}
#langs fx-repeatitem,
#terms fx-repeatitem {
display: inline-block;
width: auto;
}
#langs fx-repeatitem fx-control,
#terms fx-repeatitem fx-control {
width: 2.5rem;
}
.wrapper {
overflow: scroll;
}
fx-inspector pre {
/*max-height:200px;*/
}</style>
</head>
<body unresolved="unresolved">
<div class="wrapper">
<h1>Editing an TEI header</h1>
<fx-fore xpath-default-namespace="http://www.tei-c.org/ns/1.0">
<fx-model>
<fx-instance
src="http://localhost:8080/exist/apps/tls-tp/tls/edit/teiheader/KR5c0057"></fx-instance>
<fx-instance id="templates" src="resources/fragments/teiheader.xml"></fx-instance>
<fx-instance id="result"></fx-instance>
<fx-submission id="save"
url="http://localhost:8080/exist/apps/tls-tp/tls/edit/teiheader/KR5c0057"
method="put" replace="all"></fx-submission>
</fx-model>
<fx-group ref="teiHeader">
<fx-trigger>
<paper-button raised="raised">fileDesc</paper-button>
<fx-toggle case="fileDesc"></fx-toggle>
</fx-trigger>
<fx-switch>
<fx-case id="fileDesc">
<h2>fileDesc</h2>
<details>
<summary>titleStmt</summary>
<fx-group ref=".//titleStmt">
<h4>title</h4>
<fx-repeat ref="title" id="titles">
<template>
<fx-control ref="."></fx-control>
<fx-trigger class="deleteIcon">
<button>x</button>
<fx-delete ref="."></fx-delete>
</fx-trigger>
</template>
</fx-repeat>
<fx-trigger>
<button>add title</button>
<fx-insert ref="title" repeat="titles"></fx-insert>
</fx-trigger>
<h4>author</h4>
<fx-repeat ref="author" id="authors">
<template>
<fx-control ref="."></fx-control>
<fx-trigger class="deleteIcon">
<button>x</button>
<fx-delete ref="."></fx-delete>
</fx-trigger>
</template>
</fx-repeat>
<fx-trigger>
<button>add author</button>
<fx-insert ref="titleStmt/author" repeat="authors"
origin="instance('templates')//author"></fx-insert>
</fx-trigger>
</fx-group>
</details>
<details>
<summary>editionStmt</summary>
<fx-group ref=".//editionStmt">
<edition>
<idno type="kanripo">KR5c0057</idno>
</edition>
</fx-group>
</details>
<details>
<summary>publicationStmt</summary>
<fx-group ref=".//publicationStmt">
<fx-control ref="p">
<label>p</label>
</fx-control>
</fx-group>
</details>
<details>
<summary>sourceDesc</summary>
<fx-group ref=".//sourceDesc">
<fx-control ref="p">
<label>p</label>
</fx-control>
</fx-group>
</details>
</fx-case>
</fx-switch>
</fx-group>
<fx-trigger>
<button>save</button>
<fx-send submission="save"></fx-send>
</fx-trigger>
</fx-fore>
</div>
<!-- this is served from my local Fore installation -->
<script type="module" src="http://localhost:8090/demo/demo.js"></script>
</body>
</html>
<!-- this is what gets loaded from the exist-db in line 147 above -->
<TEI xmlns="http://www.tei-c.org/ns/1.0"><teiHeader>
<fileDesc>
<titleStmt>
<title>老子</title>
</titleStmt>
<editionStmt>
<edition>
<idno type="kanripo">KR5c0057</idno>
</edition>
</editionStmt>
<publicationStmt>
<p>Published electronically</p>
</publicationStmt>
<sourceDesc>
<p>Generated from the TLS textfiles in Kanripo format on 2019-03-20</p>
</sourceDesc>
</fileDesc>
</teiHeader></TEI>
<!-- this is the file with templates for missing author, editor etc., used in line 148 and 191 -->
<TEI xmlns="http://www.tei-c.org/ns/1.0">
<teiHeader>
<fileDesc>
<titleStmt>
<title></title>
<title type="sub"></title>
<author></author>
<editor></editor>
</titleStmt>
<publicationStmt>
<publisher></publisher>
<date when="2021-06-03"/>
<availability>
<licence target="http://creativecommons.org/licenses/by/3.0/">Creative Commons Attribution
ShareAlike 3.0 License
</licence>
</availability>
</publicationStmt>
<sourceDesc>
<p>A free text paragraph describing the source</p>
</sourceDesc>
</fileDesc>
<profileDesc>
<langUsage>
<language ident="lzh"/>
</langUsage>
<textClass>
<keywords>
<term>XML</term>
<term>TEI</term>
</keywords>
</textClass>
</profileDesc>
<revisionDesc>
<change when="2021-05-31T09:04:25+02:00">teiHeader was automatically produced from the database</change>
</revisionDesc>
</teiHeader>
<text>
<body>
<p>Some text here.</p>
</body>
</text>
</TEI>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment