forked from remy/mit-license
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ISC Support, added some option integrations, minificaiton
- Loading branch information
Showing
65 changed files
with
13,755 additions
and
3,618 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"env": { | ||
"browser": true, | ||
"es6": true, | ||
"node": true | ||
}, | ||
"parser": "@typescript-eslint/parser", | ||
"plugins": ["@typescript-eslint"], | ||
"extends": "google", | ||
"globals": { | ||
"Atomics": "readonly", | ||
"SharedArrayBuffer": "readonly" | ||
}, | ||
"parserOptions": { | ||
"ecmaVersion": 2018, | ||
"sourceType": "module" | ||
}, | ||
"rules": { | ||
"indent": ["error", 4], | ||
"semi": ["error", "never"], | ||
"brace-style": 0, | ||
"max-len": 0 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
language: node_js | ||
sudo: false | ||
node_js: | ||
- "stable" | ||
sudo: false | ||
node_js: lts/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
web: node server.js | ||
web: yarn start |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<!DOCTYPE html> | ||
<html id="home" lang="en"> | ||
|
||
<% include components/header %> | ||
|
||
<body> | ||
<article> | ||
<%- gravatar %> | ||
<h1>The ISC License (ISC)</h1> | ||
<p>Copyright © <%= info %></p> | ||
|
||
<p>Permission to use, copy, modify, and/or distribute this software for any | ||
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 | ||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | ||
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
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> | ||
|
||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<footer> | ||
<p><a 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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<head> | ||
<title>MIT License</title> | ||
<meta charset="utf-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=0.7"> | ||
<!-- | ||
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 | ||
MIT-license.txt file. | ||
Fork this project and send a pull request on: | ||
https://github.com/remy/mit-license | ||
By adding a new JSON file to the users directory, it will yield an | ||
MIT License on a CNAME, for example: | ||
{ "copyright": "Remy Sharp, http://remysharp.com" } | ||
Means visiting http://rem.mit-license.org/ shows "Remy Sharp" as the | ||
copyright holder. Namespaces will be on a first come first serve basis, | ||
and I'm open to folk joining the GitHub project. | ||
For more options (including linking and license version targeting) | ||
see the README in the github hosted project. | ||
Hope you find this useful too! | ||
- @rem | ||
--> | ||
<!-- for HTML5 el styling --> | ||
<script> | ||
document.createElement('article'); | ||
document.createElement('footer'); | ||
</script> | ||
<link rel="stylesheet" href="/themes/<%= theme %>.css"> | ||
</head> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,44 @@ | ||
{ | ||
"author": "Remy Sharp <[email protected]> (http://remysharp.com/)", | ||
"name": "mit-licence", | ||
"description": "Hosted MIT License with details controlled through this repo", | ||
"version": "1.0.0", | ||
"repository": { | ||
"type": "git", | ||
"url": "[email protected]:remy/mit-license.git" | ||
}, | ||
"scripts": { | ||
"start": "node server.js", | ||
"dev": "nodemon server.js", | ||
"test": "node test.js" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/remy/mit-license/issues" | ||
}, | ||
"license": "SEE LICENSE IN LICENSE", | ||
"dependencies": { | ||
"compression": "^1.7.4", | ||
"dayjs": "^1.8.14", | ||
"express": "^4.17.1", | ||
"express-res-html": "^0.2.3", | ||
"humanize-list": "^1.0.1", | ||
"md5": "^2.2.1", | ||
"mustache": "^3.0.1", | ||
"mustache-express": "^1.2.8" | ||
}, | ||
"devDependencies": { | ||
"@types/bluebird": "^3.5.27", | ||
"@types/compression": "^0.0.36", | ||
"@types/express": "^4.16.1", | ||
"@types/md5": "^2.1.33", | ||
"nodemon": "^1.19.1" | ||
} | ||
"author": "Remy Sharp <[email protected]> (http://remysharp.com/)", | ||
"name": "mit-licence", | ||
"description": "Hosted MIT License with details controlled through this repo", | ||
"version": "1.0.0", | ||
"repository": { | ||
"type": "git", | ||
"url": "[email protected]:remy/mit-license.git" | ||
}, | ||
"scripts": { | ||
"start": "tsc server.ts && node server.js", | ||
"dev": "ts-node-dev --respawn --transpileOnly server.ts", | ||
"test": "node test.js", | ||
"lint": "eslint . --color --fix" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/remy/mit-license/issues" | ||
}, | ||
"license": "SEE LICENSE IN LICENSE", | ||
"dependencies": { | ||
"compression": "^1.7.4", | ||
"dayjs": "^1.8.14", | ||
"ejs": "^2.6.1", | ||
"express": "^4.17.1", | ||
"express-minify": "^1.0.0", | ||
"humanize-list": "^1.0.1", | ||
"is-number": "^7.0.0", | ||
"md5": "^2.2.1", | ||
"tmp": "^0.1.0", | ||
"typescript": "^3.4.5" | ||
}, | ||
"devDependencies": { | ||
"@types/compression": "^0.0.36", | ||
"@types/express": "^4.16.1", | ||
"@types/express-minify": "^0.1.34", | ||
"@types/is-number": "^3.0.1", | ||
"@types/md5": "^2.1.33", | ||
"@types/tmp": "^0.1.0", | ||
"@typescript-eslint/eslint-plugin": "^1.9.0", | ||
"eslint": "^5.16.0", | ||
"eslint-config-google": "^0.13.0", | ||
"ts-node-dev": "^1.0.0-pre.39" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,66 +1,68 @@ | ||
const express = require('express') | ||
const path = require('path') | ||
const fs = require('fs') | ||
const PORT = process.env.PORT || 80 | ||
const mustache = require('mustache') | ||
const compression = require('compression') | ||
const dayjs = require('dayjs') | ||
const md5 = require('md5') | ||
const humanizeList = require('humanize-list') | ||
|
||
// Read License file | ||
const template = fs.readFileSync('LICENSE.html', "utf8") | ||
mustache.parse(template); | ||
|
||
var express = require('express'); | ||
var path = require('path'); | ||
var fs = require('fs'); | ||
var PORT = process.env.PORT || 80; | ||
var compression = require('compression'); | ||
var dayjs = require('dayjs'); | ||
var md5 = require('md5'); | ||
var humanizeList = require('humanize-list'); | ||
var minify = require('express-minify'); | ||
// Prepare application | ||
const app = express() | ||
app.use(compression()) | ||
app.use(require('express-res-html')) | ||
|
||
var app = express(); | ||
app.use(compression()); | ||
app.use(minify({ | ||
cache: require('tmp').dirSync().name | ||
})); | ||
app.set('view engine', 'ejs'); | ||
// Setup static files | ||
app.use('/themes', express.static('themes')); | ||
app.use('/users', express.static('users')); | ||
app.use('/favicon.ico', express.static(__dirname + '/favicon.ico')); | ||
// Setup useful variables | ||
const year = dayjs().year() | ||
|
||
// Any theme request | ||
app.get('/themes/:file', (req, res) => res.sendFile(path.join(__dirname, 'themes', req.params.file))) | ||
|
||
// Any user request | ||
app.get('/users/:file', (req, res) => res.sendFile(path.join(__dirname, 'users', req.params.file))) | ||
|
||
var yearNow = dayjs().year(); | ||
// HTTP POST API | ||
app.post('/', function (req, res) { | ||
res.end(); | ||
}); | ||
// Any other HTTP GET request | ||
app.get('*', (req, res) => { | ||
app.get('*', function (req, res) { | ||
// Get user id (example: 'rem.mit-license.org/@2019' -> 'rem') | ||
const id = req.hostname.split('.')[0] | ||
|
||
var id = req.hostname.split('.')[0]; | ||
// Get params (example: 'rem.mit-license.org/@2019' -> ['@2019']) | ||
var params = req.path.split('/'); | ||
params.shift(); | ||
// | ||
var year = yearNow; | ||
// Load the user data (example: from 'rem.mit-license.org/@2019' -> 'users/rem.json') | ||
fs.readFile(path.join('users', `${id}.json`), 'utf8', (err, data) => { | ||
fs.readFile(path.join('users', id + ".json"), 'utf8', function (err, data) { | ||
var info, theme, gravatar; | ||
// If error opening | ||
if (err) { | ||
if (err.code === 'ENOENT') { | ||
// File not found | ||
info = `${year} <copyright holders>` | ||
theme = `default` | ||
gravatar = `` | ||
} else { | ||
info = year + " <copyright holders>"; | ||
theme = 'default'; | ||
gravatar = ''; | ||
} | ||
else { | ||
// Other error | ||
res.status(500).end() | ||
res.status(500).end(); | ||
} | ||
} else { | ||
} | ||
else { | ||
// No error | ||
const user = JSON.parse(data) | ||
info = `${year} ${typeof user.copyright === "string" ? user.copyright : humanizeList(user.copyright)}` | ||
theme = user.theme || "default" | ||
gravatar = user.gravatar ? `<img id="gravatar" alt="Profile image" src="https://www.gravatar.com/avatar/${md5(user.email.trim().toLowerCase())}" />` : `` | ||
var user = JSON.parse(data); | ||
info = year + " " + (typeof user.copyright === 'string' ? user.copyright : humanizeList(user.copyright)); | ||
theme = user.theme || 'default'; | ||
gravatar = user.gravatar ? "<img id=\"gravatar\" alt=\"Profile image\" src=\"https://www.gravatar.com/avatar/" + md5(user.email.trim().toLowerCase()) + "\" />" : ''; | ||
} | ||
|
||
// Parse the options specified in the URL | ||
res.set('Content-Type', 'text/html'); | ||
res.send(new Buffer.from(mustache.render(template, { | ||
info, | ||
theme, | ||
gravatar | ||
}))); | ||
res.render(path.join(__dirname, 'licenses', 'MIT.ejs'), { | ||
info: info, | ||
theme: theme, | ||
gravatar: gravatar | ||
}); | ||
}); | ||
}) | ||
|
||
}); | ||
// Start listening for HTTP requests | ||
app.listen(PORT) | ||
app.listen(PORT); |
Oops, something went wrong.