From 26c6b5fbfa58112935237e35f0543423c0e4ce8d Mon Sep 17 00:00:00 2001 From: Yarmo Mackenbach Date: Sat, 8 Aug 2020 09:20:33 +0200 Subject: [PATCH] Migrate util pages to pug and add routes --- index.js | 1 + routes/util.js | 50 +++++++++++++++--------------------- views/util/profile-url.php | 52 -------------------------------------- views/util/profile-url.pug | 46 +++++++++++++++++++++++++++++++++ views/util/qr.php | 41 ------------------------------ views/util/qr.pug | 9 +++++++ views/util/qrfp.php | 40 ----------------------------- views/util/qrfp.pug | 15 +++++++++++ views/util/wkd.php | 47 ---------------------------------- views/util/wkd.pug | 21 +++++++++++++++ 10 files changed, 113 insertions(+), 209 deletions(-) delete mode 100644 views/util/profile-url.php create mode 100644 views/util/profile-url.pug delete mode 100644 views/util/qr.php create mode 100644 views/util/qr.pug delete mode 100644 views/util/qrfp.php create mode 100644 views/util/qrfp.pug delete mode 100644 views/util/wkd.php create mode 100644 views/util/wkd.pug diff --git a/index.js b/index.js index 90e930e..02f52f0 100644 --- a/index.js +++ b/index.js @@ -17,6 +17,7 @@ app.use('/', require('./routes/main')); app.use('/encrypt', require('./routes/encrypt')); app.use('/verify', require('./routes/verify')); app.use('/proofs', require('./routes/proofs')); +app.use('/util', require('./routes/util')); app.use('/', require('./routes/profile')); app.listen(port, () => { diff --git a/routes/util.js b/routes/util.js index e69ee10..e11ecd3 100644 --- a/routes/util.js +++ b/routes/util.js @@ -1,39 +1,31 @@ var router = require('express').Router(); -router.get('/', function(req, res) { - res.render('encrypt', { mode: "auto" }) +router.get('/profile-url', function(req, res) { + res.render('util/profile-url') +}); +router.get('/profile-url/:input', function(req, res) { + res.render('util/profile-url', { input: req.params.input }) +}); + +router.get('/qr', function(req, res) { + res.render('util/qr') +}); +router.get('/qr/:input', function(req, res) { + res.render('util/qr', { input: req.params.input }) +}); + +router.get('/qrfp', function(req, res) { + res.render('util/qrfp') +}); +router.get('/qrfp/:input', function(req, res) { + res.render('util/qrfp', { input: req.params.input }) }); router.get('/wkd', function(req, res) { - res.render('encrypt', { mode: "wkd" }) + res.render('util/wkd') }); router.get('/wkd/:input', function(req, res) { - res.render('encrypt', { mode: "wkd", input: req.params.input }) -}); - -router.get('/hkp', function(req, res) { - res.render('encrypt', { mode: "hkp" }) -}); -router.get('/hkp/:input', function(req, res) { - res.render('encrypt', { mode: "hkp", input: req.params.input }) -}); - -router.get('/plaintext', function(req, res) { - res.render('encrypt', { mode: "plaintext" }) -}); - -router.get('/keybase', function(req, res) { - res.render('encrypt', { mode: "keybase" }) -}); -router.get('/keybase/:username', function(req, res) { - res.render('encrypt', { mode: "keybase", username: req.params.username }) -}); -router.get('/keybase/:username/:fingerprint', function(req, res) { - res.render('encrypt', { mode: "keybase", username: req.params.username, fingerprint: req.params.fingerprint }) -}); - -router.get('/:input', function(req, res) { - res.render('encrypt', { mode: "auto", input: req.params.input }) + res.render('util/wkd', { input: req.params.input }) }); module.exports = router; diff --git a/views/util/profile-url.php b/views/util/profile-url.php deleted file mode 100644 index 92f2fd8..0000000 --- a/views/util/profile-url.php +++ /dev/null @@ -1,52 +0,0 @@ -. -// -// Also add information on how to contact you by electronic and paper mail. -// -// If your software can interact with users remotely through a computer network, -// you should also make sure that it provides a way for users to get its source. -// For example, if your program is a web application, its interface could display -// a "Source" link that leads users to an archive of the code. There are many -// ways you could offer source, and different solutions will be better for different -// programs; see section 13 for the specific requirements. -// -// You should also get your employer (if you work as a programmer) or school, -// if any, to sign a "copyright disclaimer" for the program, if necessary. For -// more information on this, and how to apply and follow the GNU AGPL, see . -?> -layout('template.base', ['title' => $title]) ?> - -
-

Profile URL

-
-

This tool generates an URL for your Keyoxide profile page.

-

Public key

- - -
- -

Profile URL

- Waiting for input... -

Help

-

When using the Web Key Directory source, the Input looks like username@domain.org.

-

When using the keys.openpgp.org source, the Input is either the fingerprint of your public key, or the main identity's email address.

-

When using the Keybase source, the Input is the URL obtained by going to your Keybase profile page, clicking on the key id of your keypair and copying the URL of the this key link.

-
-
diff --git a/views/util/profile-url.pug b/views/util/profile-url.pug new file mode 100644 index 0000000..fac936c --- /dev/null +++ b/views/util/profile-url.pug @@ -0,0 +1,46 @@ +extends ../template.base.pug + +block content + .content + h1 Profile URL + form#form-util-profile-url(method='post') + p This tool generates an URL for your Keyoxide profile page. + h3 Public key + label(for='source') Source: + select#source.source(name='source') + option(value='wkd') Web Key Directory + option(value='hkp') keys.openpgp.org + option(value='keybase') Keybase + br + input#input(type='text' name='input' placeholder='Input' value='') + h3 Profile URL + code#output Waiting for input... + h3 Help + p + | When using the + strong Web Key Directory + | source, the + strong Input + | looks like + strong username@domain.org + | . + p + | When using the + strong keys.openpgp.org + | source, the + strong Input + | is either the + strong fingerprint + | of your public key, or the main identity's + strong email address + | . + p + | When using the + strong Keybase + | source, the + strong Input + | is the URL obtained by going to your Keybase profile page, clicking on the + strong key id + | of your keypair and copying the URL of the + strong this key + | link. diff --git a/views/util/qr.php b/views/util/qr.php deleted file mode 100644 index d3c1c64..0000000 --- a/views/util/qr.php +++ /dev/null @@ -1,41 +0,0 @@ -. -// -// Also add information on how to contact you by electronic and paper mail. -// -// If your software can interact with users remotely through a computer network, -// you should also make sure that it provides a way for users to get its source. -// For example, if your program is a web application, its interface could display -// a "Source" link that leads users to an archive of the code. There are many -// ways you could offer source, and different solutions will be better for different -// programs; see section 13 for the specific requirements. -// -// You should also get your employer (if you work as a programmer) or school, -// if any, to sign a "copyright disclaimer" for the program, if necessary. For -// more information on this, and how to apply and follow the GNU AGPL, see . -?> -layout('template.base', ['title' => $title]) ?> - -
-

QR Code

-
- - - escape($input)?> -
-
- Press this link to directly open the URI -
diff --git a/views/util/qr.pug b/views/util/qr.pug new file mode 100644 index 0000000..b07b2a0 --- /dev/null +++ b/views/util/qr.pug @@ -0,0 +1,9 @@ +extends ../template.base.pug + +block content + .content + h1 QR Code + form#form-util-qr(method='post') + code#input.full-width !{input} + #qrcode + a#qrcode--altLink(href='#') Press this link to directly open the URI diff --git a/views/util/qrfp.php b/views/util/qrfp.php deleted file mode 100644 index 3a1f06e..0000000 --- a/views/util/qrfp.php +++ /dev/null @@ -1,40 +0,0 @@ -. -// -// Also add information on how to contact you by electronic and paper mail. -// -// If your software can interact with users remotely through a computer network, -// you should also make sure that it provides a way for users to get its source. -// For example, if your program is a web application, its interface could display -// a "Source" link that leads users to an archive of the code. There are many -// ways you could offer source, and different solutions will be better for different -// programs; see section 13 for the specific requirements. -// -// You should also get your employer (if you work as a programmer) or school, -// if any, to sign a "copyright disclaimer" for the program, if necessary. For -// more information on this, and how to apply and follow the GNU AGPL, see . -?> -layout('template.base', ['title' => $title]) ?> - -
-

QR Code

-
-

This tool generates a QR code containing the fingerprint of your public key (format). This QR code can be scanned by apps like OpenKeyChain.

-

Fingerprint

- -
-
-
diff --git a/views/util/qrfp.pug b/views/util/qrfp.pug new file mode 100644 index 0000000..2ce15e0 --- /dev/null +++ b/views/util/qrfp.pug @@ -0,0 +1,15 @@ +extends ../template.base.pug + +block content + .content + h1 QR Code + form#form-util-qrfp(method='post') + p + | This tool generates a QR code containing the fingerprint of your public key ( + a(href='https://github.com/open-keychain/open-keychain/wiki/QR-Codes') format + | ). This QR code can be scanned by apps like + a(href='https://www.openkeychain.org/') OpenKeyChain + | . + h3 Fingerprint + input#input(type='text' name='input' placeholder='Fingerprint' value=input) + #qrcode diff --git a/views/util/wkd.php b/views/util/wkd.php deleted file mode 100644 index e440282..0000000 --- a/views/util/wkd.php +++ /dev/null @@ -1,47 +0,0 @@ -. -// -// Also add information on how to contact you by electronic and paper mail. -// -// If your software can interact with users remotely through a computer network, -// you should also make sure that it provides a way for users to get its source. -// For example, if your program is a web application, its interface could display -// a "Source" link that leads users to an archive of the code. There are many -// ways you could offer source, and different solutions will be better for different -// programs; see section 13 for the specific requirements. -// -// You should also get your employer (if you work as a programmer) or school, -// if any, to sign a "copyright disclaimer" for the program, if necessary. For -// more information on this, and how to apply and follow the GNU AGPL, see . -?> -layout('template.base', ['title' => $title]) ?> - -
-

Web Key Directory generator

-
-

This tool computes the part of the WKD URL that corresponds to the username when uploading keys using web key directory.

-

If you enter the entire WKD identifier (username@domain.org), this tool will also generate the complete URLs.

-

Input

- -

Output

-

Local part

- Waiting for input... -

Direct URL

- Waiting for input... -

Advanced URL

- Waiting for input... -
-
diff --git a/views/util/wkd.pug b/views/util/wkd.pug new file mode 100644 index 0000000..275bbd3 --- /dev/null +++ b/views/util/wkd.pug @@ -0,0 +1,21 @@ +extends ../template.base.pug + +block content + .content + h1 Web Key Directory generator + form#form-util-wkd(method='post') + p + | This tool computes the part of the WKD URL that corresponds to the username when + a(href='https://keyoxide.org/guides/web-key-directory') uploading keys using web key directory + | . + p + | If you enter the entire WKD identifier (username@domain.org), this tool will also generate the complete URLs. + h3 Input + input#input(type='text' name='input' placeholder='WKD username or identifier' value=input) + h3 Output + h4 Local part + code#output.full-width Waiting for input... + h4 Direct URL + code#output_url_direct.full-width Waiting for input... + h4 Advanced URL + code#output_url_advanced.full-width Waiting for input...