fix: Properly display ISC license in plain text and correctly parse requested license from URL.

Signed-off-by: Richie Bendall <richiebendall@gmail.com>
This commit is contained in:
Richie Bendall 2019-06-23 12:45:43 +12:00
parent fd54e7198d
commit 8a47aa09f8
No known key found for this signature in database
GPG key ID: 1C6A99DFA9D306FC
5 changed files with 55 additions and 53 deletions

View file

@ -1,27 +1,26 @@
<!DOCTYPE html> <!DOCTYPE html>
<html id="home" lang="en"> <html id="home" lang="en">
<% include components/header %> <% include components/header %>
<body> <body>
<article> <article>
<%- gravatar %> <%- gravatar %>
<h1>The ISC License (ISC)</h1> <h1>The ISC License (ISC)</h1>
<p>Copyright © <%- info %></p>
<p>Permission to use, copy, modify, and/or distribute this software for any <p>Copyright © <%- info %></p>
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.</p>
<p>THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES <p>Permission to use, copy, modify, and/or distribute this software for any
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF purpose with or without fee is hereby granted, provided that the above
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR copyright notice and this permission notice appear in all copies.</p>
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN <p>THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.</p> MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
</article> ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
<% include components/footer %> WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.</p>
</article>
<% include components/footer %>
</body> </body>
</html> </html>

View file

@ -1,3 +1,3 @@
<footer> <footer>
<p><a target="_blank" rel="noopener" href="https://github.com/remy/mit-license">Fork this project to create your own MIT license that you can always link to.</a></p> <p><a target="_blank" rel="noopener" href="https://github.com/remy/mit-license">Fork this project to create your own MIT license that you can always link to.</a></p>
</footer> </footer>

View file

@ -1,40 +1,38 @@
<head> <head>
<title>MIT License</title> <title>MIT License</title>
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge"> <meta http-equiv="X-UA-Compatible" content="ie=edge">
<meta name="description" <meta name="description" content="The MIT License is a permissive free software license originating at the Massachusetts Institute of Technology. As a permissive license, it puts only very limited restriction on reuse and has, therefore, an excellent license compatibility.">
content="The MIT License is a permissive free software license originating at the Massachusetts Institute of Technology. As a permissive license, it puts only very limited restriction on reuse and has, therefore, an excellent license compatibility."> <!--
<!-- Welcome fellow open source developer. This project is here for you to
Welcome fellow open source developer. This project is here for you to link to if you're like me and keep forgetting to include the
link to if you're like me and keep forgetting to include the MIT-license.txt file.
MIT-license.txt file.
Fork this project and send a pull request on: Fork this project and send a pull request on:
https://github.com/remy/mit-license https://github.com/remy/mit-license
By adding a new JSON file to the users directory, it will yield an By adding a new JSON file to the users directory, it will yield an
MIT License on a CNAME, for example: MIT License on a CNAME, for example:
{ "copyright": "Remy Sharp, https://remysharp.com" } { "copyright": "Remy Sharp, https://remysharp.com" }
Means visiting https://rem.mit-license.org/ shows "Remy Sharp" as the Means visiting https://rem.mit-license.org/ shows "Remy Sharp" as the
copyright holder. Namespaces will be on a first come first serve basis, copyright holder. Namespaces will be on a first come first serve basis,
and I'm open to folk joining the GitHub project. and I'm open to folk joining the GitHub project.
For more options (including linking and license version targeting) For more options see the README in the github hosted project.
see the README in the github hosted project.
Hope you find this useful too! Hope you find this useful too!
- @rem - @rem
--> -->
<!-- for HTML5 el styling --> <!-- for HTML5 el styling -->
<script> <script>
document.createElement('article'); document.createElement('article');
document.createElement('footer'); document.createElement('footer');
</script> </script>
<link rel="stylesheet" href="/themes/<%= theme %>.css"> <link rel="stylesheet" href="/themes/<%= theme %>.css">
</head> </head>

View file

@ -5,14 +5,12 @@ module.exports = (req, res, next) => {
res.locals.options = parts.reduce( res.locals.options = parts.reduce(
(acc, curr) => { (acc, curr) => {
if (!curr) { if (!curr) return acc;
return acc;
}
let match = curr.match(/^@?(\d{4})$/) || []; let match = curr.match(/^@?(\d{4})$/) || [];
if (match.length) { if (match.length) {
// pinned year // Pinned year
if (curr.startsWith('@')) { if (curr.startsWith('@')) {
acc.pinnedYear = parseInt(curr.substr(1), 10); acc.pinnedYear = parseInt(curr.substr(1), 10);
} else { } else {
@ -38,6 +36,13 @@ module.exports = (req, res, next) => {
return acc; return acc;
} }
if (curr.startsWith('+')) {
acc.license = curr
.substr(1)
.toUpperCase();
return acc;
}
acc.sha = curr; // not actually supported now - 2019-06-19 acc.sha = curr; // not actually supported now - 2019-06-19
return acc; return acc;
}, },

View file

@ -58,7 +58,7 @@ module.exports = (req, res) => {
const year = options.pinnedYear const year = options.pinnedYear
? options.pinnedYear ? options.pinnedYear
: [options.startYear, options.endYear].filter(Boolean).join('-'); : [options.startYear, options.endYear].filter(Boolean).join('-');
const license = (user.license || 'MIT').toUpperCase(); const license = (options.license || user.license || 'MIT').toUpperCase();
const format = options.format || user.format || 'html'; const format = options.format || user.format || 'html';
const args = { const args = {