restructure files for ejs support

moved style to index.ejs
render views
This commit is contained in:
Aljaz S
2021-11-23 12:56:30 +01:00
parent 74c9519e08
commit abb7476f26
4 changed files with 100 additions and 69 deletions

View File

@@ -9,6 +9,11 @@ const app = express()
const __dirname = dirname(fileURLToPath(import.meta.url)) const __dirname = dirname(fileURLToPath(import.meta.url))
app.use(cors()) app.use(cors())
app.set('views', path.join(__dirname, 'views'))
app.set('view engine', 'ejs')
app.get('/', (req, res) => res.render('index'))
app.get('/form/:data', (req, res) => res.render('form'))
app.get('/api/qrcode', async (req, res) => { app.get('/api/qrcode', async (req, res) => {
const errors = [] const errors = []
@@ -81,7 +86,4 @@ ${String(req.query.issuer_city).toUpperCase()}`
}) })
app.get('/', (req, res) => res.sendFile(path.join(__dirname, 'index.html')))
app.get('/style.css', (req, res) => res.sendFile(path.join(__dirname, 'style.css')))
app.listen(process.env.PORT || 80, () => console.log(`UPN-QR started on port ${process.env.PORT || 80}`)) app.listen(process.env.PORT || 80, () => console.log(`UPN-QR started on port ${process.env.PORT || 80}`))

View File

@@ -1,64 +0,0 @@
body,
html {
margin: 0;
padding: 0;
max-width: 100vw;
overflow-x: hidden;
--c-dark: #202124;
--c-darkish: #303134;
--c-primary: #e8eaed;
--c-accent: #C58AF9;
}
html {
padding: 0 0;
width: 100vw;
display: grid;
grid-template-columns: auto minmax(50vw, 650px) auto;
background-color: var(--c-dark);
}
body {
grid-column: 2;
padding: 15px;
margin: 30px 10px;
display: grid;
grid-template-columns: auto;
grid-auto-rows: auto;
row-gap: 2rem;
border-radius: 1rem;
background-color: var(--c-darkish);
color: var(--c-primary);
font-family: monospace;
font-size: 16px;
line-height: 1.6em;
word-break: normal;
}
a {
color: var(--c-accent);
text-decoration: none;
}
code,
pre {
background-color: var(--c-dark);
padding: 6px 4px 2px 4px;
word-break: break-all;
}
pre {
overflow-x: scroll;
}
section div {
padding-left: 25px;
display: grid;
}
.credits {
display: grid;
align-items: center;
justify-content: center;
text-align: center;
}

20
src/views/form.ejs Normal file
View File

@@ -0,0 +1,20 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>UPN-QR :: FORM</title>
</head>
<style>
</style>
<body>
<div>
</div>
</body>
<script>
</script>
</html>

View File

@@ -5,8 +5,73 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>UPN-QR | Open generator for UPN QR codes</title> <title>UPN-QR | Open generator for UPN QR codes</title>
<link rel="stylesheet" href="/style.css">
</head> </head>
<style>
body,
html {
margin: 0;
padding: 0;
max-width: 100vw;
overflow-x: hidden;
--c-dark: #202124;
--c-darkish: #303134;
--c-primary: #e8eaed;
--c-accent: #C58AF9;
}
html {
padding: 0 0;
width: 100vw;
display: grid;
grid-template-columns: auto minmax(50vw, 650px) auto;
background-color: var(--c-dark);
}
body {
grid-column: 2;
padding: 15px;
margin: 30px 10px;
display: grid;
grid-template-columns: auto;
grid-auto-rows: auto;
row-gap: 2rem;
border-radius: 1rem;
background-color: var(--c-darkish);
color: var(--c-primary);
font-family: monospace;
font-size: 16px;
line-height: 1.6em;
word-break: normal;
}
a {
color: var(--c-accent);
text-decoration: none;
}
code,
pre {
background-color: var(--c-dark);
padding: 6px 4px 2px 4px;
word-break: break-all;
}
pre {
overflow-x: scroll;
}
section div {
padding-left: 25px;
display: grid;
}
.credits {
display: grid;
align-items: center;
justify-content: center;
text-align: center;
}
</style>
<body> <body>
<section> <section>
<h1>About</h1> <h1>About</h1>
@@ -21,7 +86,15 @@
<p>Because Public Payments Administration <a href="https://www.gov.si/zbirke/storitve/vkljucitev-v-izdajanje-upn-s-kodo-qr/" target="_blank">prohibits</a> the generation and use of UPN-QR codes by any unapthorized party, you must be <a href="https://www.upn-qr.si/sl/registracija-izdajatelja">authorized</a> in order to use this application and publish the content that it generates.</p> <p>Because Public Payments Administration <a href="https://www.gov.si/zbirke/storitve/vkljucitev-v-izdajanje-upn-s-kodo-qr/" target="_blank">prohibits</a> the generation and use of UPN-QR codes by any unapthorized party, you must be <a href="https://www.upn-qr.si/sl/registracija-izdajatelja">authorized</a> in order to use this application and publish the content that it generates.</p>
</section> </section>
<section> <section>
<h1>API</h1> <h1 id="maker"><a href="#maker">&#128279;</a> Form maker</h1>
<div class="maker">
<div>
</div>
</div>
<h1 id="api"><a href="#api">&#128279;</a> API</h1>
<h4 id="api-qrcode"><a href="#api-qrcode">&#128279;</a> <code>GET /api/qrcode</code></h4> <h4 id="api-qrcode"><a href="#api-qrcode">&#128279;</a> <code>GET /api/qrcode</code></h4>
<div> <div>
<span>Returns a <code>image/png</code> image if successful (OK 200), else returns the following JSON <code>{ ok: false, errors: String[] }</code> where <code>errors</code> is an array of descriptive strings.</span> <span>Returns a <code>image/png</code> image if successful (OK 200), else returns the following JSON <code>{ ok: false, errors: String[] }</code> where <code>errors</code> is an array of descriptive strings.</span>