diff --git a/apps/ktb-static/script.js b/apps/ktb-static/script.js
index 2dbe3f8..5dfc6e4 100644
--- a/apps/ktb-static/script.js
+++ b/apps/ktb-static/script.js
@@ -80,16 +80,26 @@ document.addEventListener("alpine:init", () => {
localStorage.setItem("prefs", JSON.stringify(this.prefs));
this.update_css_variables();
},
-
- async fetch_all_lects() {
- try {
- const res = await axios.get("http://localhost:1225/lects");
- console.log(JSON.stringify(res.data));
- return res.data;
- } catch (e) {
- console.error(e);
- }
- },
+
+ async fetch_all_lects() {
+ try {
+ const res = await axios.get("http://localhost:1225/lects");
+ return res.data;
+ } catch (e) {
+ console.error(e);
+ }
+ },
+
+ async post_lect(lect_name) {
+ try {
+ const res = await axios.post("http://localhost:1225/lect", {
+ lect_name,
+ });
+ return res.data.lect;
+ } catch (e) {
+ console.error(e);
+ }
+ },
async fetch_all_terms(search_term) {
try {
@@ -180,13 +190,17 @@ document.addEventListener("alpine:init", () => {
filter_results(search_term) {
if (!search_term) return this.search_results.results;
- return this.search_results.results.filter(
- (item) =>
- item.word_forms
- .map((wf) => wf.word_form.toLowerCase())
- .join()
- .includes(search_term.toLowerCase()),
+ return this.search_results.results.filter((item) =>
+ item.word_forms
+ .map((wf) => wf.word_form.toLowerCase())
+ .join()
+ .includes(search_term.toLowerCase()),
);
},
+
+ md(text){
+ console.log(marked.parse(text));
+ return DOMPurify.sanitize(marked.parse(text), {ALLOWED_TAGS: ['br', 'em', 'strong', 'code', '#text']});
+ },
});
});
diff --git a/apps/ktb-static/search.html b/apps/ktb-static/search.html
index b85f973..cb50c3f 100644
--- a/apps/ktb-static/search.html
+++ b/apps/ktb-static/search.html
@@ -6,6 +6,8 @@
Dictionary Cards
+
+
@@ -16,7 +18,10 @@
x-data="{
search_term: '',
showPrefs: false,
- lects: []
+ lects: [],
+ md(text){
+ return $store.dictionary.md(text);
+ },
}"
x-init="$store.dictionary.fetch_all_lects().then((lects_response)=>{
if(!!lects_response.lects) {
@@ -169,6 +174,9 @@
Trofal
Imi
@@ -241,7 +257,7 @@
editing: false,
edited_text: def.definition_text.toString()
}" @click.outside="editing = false">
-
+
@@ -292,7 +308,7 @@
edited_text: ex.example_text.toString()
}"
@click.outside="editing = false">
-
+
diff --git a/apps/ktb-static/styles.css b/apps/ktb-static/styles.css
index afaf90a..581fdef 100644
--- a/apps/ktb-static/styles.css
+++ b/apps/ktb-static/styles.css
@@ -47,7 +47,7 @@
}
body {
- font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
+ font-family: 'Verdana', -apple-system, BlinkMacSystemFont, sans-serif;
background-color: var(--color-main-bg);
color: var(--color-text);
line-height: 1.5;
@@ -72,15 +72,19 @@ ul {
}
li {
- margin-top: calc(var(--space-xs)/2);
+ margin-top: calc(var(--space-xs));
margin-bottom: calc(var(--space-xs)/2);
margin-left: var(--space-md);
}
-table {
+tbody {
table-layout: fixed;
}
+tfoot {
+ table-layout: auto;
+}
+
.float-right {
float: right;
}
diff --git a/apps/vdb-backend/src/index.ts b/apps/vdb-backend/src/index.ts
index 76fb12b..d3d592e 100644
--- a/apps/vdb-backend/src/index.ts
+++ b/apps/vdb-backend/src/index.ts
@@ -79,6 +79,21 @@ function initExpress() {
res.status(200).send({ lect });
});
+ app.post("/lect", (req, res) => {
+ const lect_name = req.query.lect_name?.toString();
+
+ if (!lect_name) {
+ return void res.sendStatus(400);
+ }
+
+ const lect = new Lect();
+ lect.name = lect_name;
+ lect.save().then((lect)=>{
+ res.status(200).send({ lect })
+ });
+
+ });
+
app.get("/lects", async (_req, res) => {
const lects = await Lect.find();
res.status(200).send({ lects });
@@ -261,13 +276,27 @@ function initExpress() {
let word_form = new WordForm();
let lemma = await Lemma.findOne({where:{lemma_name}});
- let lect = await Lect.findOne({where:{name:lect_name}});
-
- if(!lect || !lemma){
+ let lect;
+ try{
+ lect = await Lect.findOne({where:{name:lect_name}});
+ } catch {
+ console.info(`Lect ${lect_name} not found.`);
+ }
+
+ if(!lemma){
console.error(`Error: ${JSON.stringify({lect:lect, lemma:lemma})}`);
return void res.status(400).send();
}
+ if(!lect) {
+ lect = new Lect();
+ lect.name = lect_name;
+ await lect
+ .save()
+ .then((l)=>{console.info(`Created lect: ${JSON.stringify(l)}`)});
+ }
+
+
word_form.word_form = word_form_text;
word_form.lemma = lemma;
word_form.lect = lect;