diff --git a/front-end/src/components/app.js b/front-end/src/components/app.js
deleted file mode 100644
index 91ef881..0000000
--- a/front-end/src/components/app.js
+++ /dev/null
@@ -1,33 +0,0 @@
-import define from '../utils/define.js';
-import addResult from "./molecules/add-result.js";
-import save from "./organisms/save.js";
-
-const template = () => /*html*/`
-
-
-
-
-
-
-`;
-
-export default define('app', class extends HTMLElement {
- constructor() {
- super();
- this.__setup();
- }
-
- __setup() {
- this.innerHTML = template();
- }
-});
\ No newline at end of file
diff --git a/front-end/src/components/molecules/add-result.js b/front-end/src/components/molecules/add-result.js
index 6e9ce17..b6a790a 100644
--- a/front-end/src/components/molecules/add-result.js
+++ b/front-end/src/components/molecules/add-result.js
@@ -3,7 +3,7 @@ import config from "../../../config.js";
import {globalBus} from "../../utils/events.js";
-const FETCH_URL = `${config['publicApiURL']}crawler/fetch?`
+const FETCH_URL = '/app/fetch?'
const template = () => /*html*/`
@@ -56,7 +56,7 @@ export default define('add-result', class extends HTMLDivElement {
const url = `${FETCH_URL}url=${encodeURIComponent(value)}&query=${encodeURIComponent(query)}`;
const response = await fetch(url);
if (response.status === 200) {
- const data = await response.json();
+ const data = await response.text();
console.log("Data", data);
const addResultEvent = new CustomEvent('curate-add-result', {detail: data});
diff --git a/front-end/src/components/molecules/result.js b/front-end/src/components/molecules/result.js
index 2a2859e..9ab38ee 100644
--- a/front-end/src/components/molecules/result.js
+++ b/front-end/src/components/molecules/result.js
@@ -1,26 +1,7 @@
import define from '../../utils/define.js';
import escapeString from '../../utils/escapeString.js';
import { globalBus } from '../../utils/events.js';
-import deleteButton from "./delete-button.js";
-import validateButton from "./validate-button.js";
-import addButton from "./add-button.js";
-const template = ({ data }) => /*html*/`
-
-`;
export default define('result', class extends HTMLLIElement {
constructor() {
@@ -30,11 +11,6 @@ export default define('result', class extends HTMLLIElement {
}
__setup() {
- this.innerHTML = template({ data: {
- url: this.dataset.url,
- title: this.__handleBold(JSON.parse(this.dataset.title)),
- extract: this.__handleBold(JSON.parse(this.dataset.extract))
- }});
this.__events();
}
diff --git a/front-end/src/components/organisms/results.js b/front-end/src/components/organisms/results.js
index 9cd9993..7a0e6b4 100644
--- a/front-end/src/components/organisms/results.js
+++ b/front-end/src/components/organisms/results.js
@@ -1,21 +1,13 @@
-import define from '../../utils/define.js';
import {globalBus} from '../../utils/events.js';
-// Components
-import result from '../molecules/result.js';
-import emptyResult from '../molecules/empty-result.js';
-import home from './home.js';
-import escapeString from '../../utils/escapeString.js';
-const template = () => /*html*/`
-
-`;
+document.body.addEventListener('htmx:load', function(evt) {
-export default define('results', class extends HTMLElement {
+});
+
+
+class ResultsHandler {
constructor() {
- super();
this.results = null;
this.oldIndex = null;
this.curating = false;
@@ -23,50 +15,12 @@ export default define('results', class extends HTMLElement {
}
__setup() {
- this.innerHTML = template();
- this.results = this.querySelector('.results');
this.__events();
}
__events() {
- globalBus.on('search', (e) => {
- this.results.innerHTML = '';
- let resultsHTML = '';
- if (!e.detail.error) {
- // If there is no details the input is empty
- if (!e.detail.results) {
- resultsHTML = /*html*/`
-
- `;
- }
- // If the details array has results display them
- else if (e.detail.results.length > 0) {
- for(const resultData of e.detail.results) {
- resultsHTML += /*html*/`
-
- `;
- }
- }
- // If the details array is empty there is no result
- else {
- resultsHTML = /*html*/`
-
- `;
- }
- }
- else {
- // If there is an error display an empty result
- resultsHTML = /*html*/`
-
- `;
- }
- // Bind HTML to the DOM
- this.results.innerHTML = resultsHTML;
+ document.body.addEventListener('htmx:load', e => {
+ this.results = document.querySelector('.results');
// Allow the user to re-order search results
$(".results").sortable({
@@ -142,15 +96,7 @@ export default define('results', class extends HTMLElement {
console.log("Add result", e);
this.__beginCurating();
const resultData = e.detail;
- const resultHTML = /*html*/`
-
- `;
- this.results.insertAdjacentHTML('afterbegin', resultHTML);
+ this.results.insertAdjacentHTML('afterbegin', resultData);
const newResults = this.__getResults();
@@ -236,4 +182,6 @@ export default define('results', class extends HTMLElement {
});
globalBus.dispatch(curationMoveEvent);
}
-});
\ No newline at end of file
+}
+
+const resultsHandler = new ResultsHandler();
diff --git a/front-end/src/index.html b/front-end/src/index.html
index 65bacda..a08e557 100644
--- a/front-end/src/index.html
+++ b/front-end/src/index.html
@@ -48,6 +48,8 @@
+
+
+
+
+
+
+
+
+
+
+
+
+