Skip to content

Commit

Permalink
Use ejs template engine to pass variable to upload page #18
Browse files Browse the repository at this point in the history
sroertgen committed Feb 14, 2024
1 parent c28558d commit b4e191f
Showing 5 changed files with 401 additions and 362 deletions.
743 changes: 388 additions & 355 deletions package-lock.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -21,6 +21,7 @@
"@elastic/elasticsearch": "^8.6.0",
"@frogcat/ttl2jsonld": "^0.0.9",
"dotenv": "^16.0.3",
"ejs": "^3.1.9",
"elastic-builder": "^2.18.0",
"express": "^4.18.2",
"jsonld": "^8.1.1",
4 changes: 2 additions & 2 deletions public/.gitignore
Original file line number Diff line number Diff line change
@@ -3,9 +3,9 @@

# Except this file
!.gitignore
!index.html
!index.ejs
!processing.html
!log/
!img/
!fonts/
!css/
!css/
6 changes: 3 additions & 3 deletions public/index.html → public/index.ejs
Original file line number Diff line number Diff line change
@@ -70,8 +70,9 @@ <h1>Unleash the full potential of controlled vocabularies in reconciliation</h1>
</section>
<section class="keyvisual-content">
<p>Test out these URLs as examples in your favorite reconcile spec compliant service (click to copy):</p>
<input data-url="https://reconcile-test.skohub.io/reconcile?language=de&account=kim&dataset=https://w3id.org/kim/hochschulfaechersystematik/scheme" type="button" value="Hochschulfächersystematik (german)" class="btn example-url"/>
<input data-url="https://reconcile-test.skohub.io/reconcile?language=en&account=nalt-test&dataset=https://lod.nal.usda.gov/nalt-core" type="button" value="AgroVoc (english)" class="btn example-url" />
<input data-url="https://reconcile-test.skohub.io/reconcile?language=de&account=kim&dataset=https://w3id.org/kim/hochschulfaechersystematik/scheme" type="button" value="Hochschulfächersystematik (german)" class="btn example-url"/>
<input data-url="https://reconcile-test.skohub.io/reconcile?language=en&account=nalt-test&dataset=https://lod.nal.usda.gov/nalt-core" type="button" value="AgroVoc (english)" class="btn example-url" />
<p>or see <a href="<%= data.reconcileUrl %>/vocabs">all uploaded vocabularies</a>.</p>
</section>

</main>
@@ -117,7 +118,6 @@ <h1>Unleash the full potential of controlled vocabularies in reconciliation</h1>
const checkmark = document.querySelector("#checkmark")
const result = document.querySelector("#result")
const exampleUrlButton = document.querySelectorAll("input.btn.example-url")
console.log(exampleUrlButton)
const url = new URL(window.location.href)
const idParam = url.searchParams.get("id")
9 changes: 7 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -5,7 +5,9 @@ import { publishToReconciliation } from "./publishToReconciliation/index.js";
import { config } from "./config.js";

const app = express();

// Serve static files from the public directory
app.set('view engine', 'ejs');
app.set('views', './public');
// check if uploads directory exists and create it if not
if (!fs.existsSync("uploads")) {
fs.mkdirSync("uploads");
@@ -31,7 +33,10 @@ const upload = multer({ storage: storage, });
app.use(express.static("public"));

app.get("/", (req, res) => {
res.sendFile("index.html");
const data = {
reconcileUrl: config.reconcile_service_url
}
res.render("index", { data });
});

app.post(

0 comments on commit b4e191f

Please sign in to comment.