Umstellung von Beschreibung auf README aus Repository

This commit is contained in:
klaas 2024-09-09 16:12:29 +02:00
parent 046cfaeff0
commit cf4c3cb8ad
5 changed files with 82 additions and 5 deletions

View File

@ -0,0 +1 @@
# WebApp

22
app.js
View File

@ -6,6 +6,8 @@ const nodemailer = require("nodemailer");
const { Pool } = require("pg");
const path = require("path");
const moment = require("moment");
const marked = require("marked");
const axios = require("axios");
require("dotenv").config();
const log = require("node-file-logger");
const QRCode = require("qrcode");
@ -409,12 +411,24 @@ app.get("/project/:id", async (req, res) => {
id,
]);
const projekt = result.rows[0];
console.log(`${projekt.repository_link}/raw/branch/main/README.md`);
const url = `${projekt.repository_link}/raw/branch/main/README.md`;
// Abrufen der Datei
// const response = await axios.get(url);
// Markdown-Inhalt in HTML umwandeln
// const htmlContent = marked(response.data);
const htmlContent = "Testdata";
if (!projekt) {
return res.status(404).send("Projekt nicht gefunden");
}
res.render("project", { projekt, session: req.session });
res.render("project", {
projekt,
session: req.session,
content: htmlContent,
});
} catch (err) {
console.error(err);
res.send("Fehler beim Abrufen des Projekts");
@ -423,11 +437,11 @@ app.get("/project/:id", async (req, res) => {
app.post("/projectedit", async (req, res) => {
req.session.message = ["", "", "none"];
const { id, name, beschreibung } = req.body;
const { id, name, beschreibung, repository_link } = req.body;
try {
await pool.query(
"UPDATE projects SET name = $1, beschreibung = $2 WHERE id = $3",
[name, beschreibung, id]
"UPDATE projects SET name = $1, beschreibung = $2 repository_link =$3 WHERE id = $4",
[name, beschreibung, repository_link, id]
);
} catch (err) {
console.error(err);

60
package-lock.json generated
View File

@ -9,6 +9,7 @@
"version": "1.0.0",
"license": "ISC",
"dependencies": {
"axios": "^1.7.7",
"bcrypt": "^5.1.1",
"crypto": "^1.0.1",
"dotenv": "^16.4.5",
@ -16,6 +17,7 @@
"express": "^4.19.2",
"express-session": "^1.18.0",
"fs": "^0.0.1-security",
"marked": "^14.1.2",
"moment": "^2.30.1",
"node-file-logger": "^0.9.5",
"nodemailer": "^6.9.13",
@ -196,6 +198,29 @@
"integrity": "sha512-3AungXC4I8kKsS9PuS4JH2nc+0bVY/mjgrephHTIi8fpEeGsTHBUJeosp0Wc1myYMElmD0B3Oc4XL/HVJ4PV2g==",
"license": "MIT"
},
"node_modules/axios": {
"version": "1.7.7",
"resolved": "https://registry.npmjs.org/axios/-/axios-1.7.7.tgz",
"integrity": "sha512-S4kL7XrjgBmvdGut0sN3yJxqYzrDOnivkBiN0OFs6hLiUam3UPvswUo0kqGyhqUZGEOytHyumEdXsAkgCOUf3Q==",
"dependencies": {
"follow-redirects": "^1.15.6",
"form-data": "^4.0.0",
"proxy-from-env": "^1.1.0"
}
},
"node_modules/axios/node_modules/form-data": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz",
"integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==",
"dependencies": {
"asynckit": "^0.4.0",
"combined-stream": "^1.0.8",
"mime-types": "^2.1.12"
},
"engines": {
"node": ">= 6"
}
},
"node_modules/balanced-match": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz",
@ -743,6 +768,25 @@
"node": ">=8"
}
},
"node_modules/follow-redirects": {
"version": "1.15.9",
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.9.tgz",
"integrity": "sha512-gew4GsXizNgdoRyqmyfMHyAmXsZDk6mHkSxZFCzW9gwlbtOW44CDtYavM+y+72qD/Vq2l550kMF52DT8fOLJqQ==",
"funding": [
{
"type": "individual",
"url": "https://github.com/sponsors/RubenVerborgh"
}
],
"engines": {
"node": ">=4.0"
},
"peerDependenciesMeta": {
"debug": {
"optional": true
}
}
},
"node_modules/forever-agent": {
"version": "0.6.1",
"resolved": "https://registry.npmjs.org/forever-agent/-/forever-agent-0.6.1.tgz",
@ -1193,6 +1237,17 @@
"semver": "bin/semver.js"
}
},
"node_modules/marked": {
"version": "14.1.2",
"resolved": "https://registry.npmjs.org/marked/-/marked-14.1.2.tgz",
"integrity": "sha512-f3r0yqpz31VXiDB/wj9GaOB0a2PRLQl6vJmXiFrniNwjkKdvakqJRULhjFKJpxOchlCRiG5fcacoUZY5Xa6PEQ==",
"bin": {
"marked": "bin/marked.js"
},
"engines": {
"node": ">= 18"
}
},
"node_modules/media-typer": {
"version": "0.3.0",
"resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz",
@ -1665,6 +1720,11 @@
"node": ">= 0.10"
}
},
"node_modules/proxy-from-env": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz",
"integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg=="
},
"node_modules/psl": {
"version": "1.9.0",
"resolved": "https://registry.npmjs.org/psl/-/psl-1.9.0.tgz",

View File

@ -11,6 +11,7 @@
"author": "",
"license": "ISC",
"dependencies": {
"axios": "^1.7.7",
"bcrypt": "^5.1.1",
"crypto": "^1.0.1",
"dotenv": "^16.4.5",
@ -18,6 +19,7 @@
"express": "^4.19.2",
"express-session": "^1.18.0",
"fs": "^0.0.1-security",
"marked": "^14.1.2",
"moment": "^2.30.1",
"node-file-logger": "^0.9.5",
"nodemailer": "^6.9.13",

View File

@ -3,7 +3,7 @@
<div id="view" class="mt-5">
<h1><%= projekt.name %></h1>
<p><%= projekt.kurzbeschreibung %></p>
<p><%= projekt.beschreibung %></p>
<p><%= content %></p>
<p>
<a href="<%= projekt.repository_link %>" target="_blank">Repository Link</a>
</p>