mirror of
https://github.com/samsonjs/mit-license.git
synced 2026-04-20 13:45:47 +00:00
fixed merge conflict and updated to read from json file as well as url
This commit is contained in:
commit
ad46848031
3 changed files with 106 additions and 60 deletions
19
.htaccess
Normal file
19
.htaccess
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
<IfModule mod_rewrite.c>
|
||||
|
||||
# $Id: .htaccess,v 1.3 2006/11/09 09:08:14 remy Exp $
|
||||
Options +FollowSymLinks +ExecCGI
|
||||
RewriteEngine On
|
||||
RewriteBase /
|
||||
|
||||
# strip www. from the domain
|
||||
RewriteCond %{HTTP_HOST} ^www\.mit-license\.org$ [NC]
|
||||
RewriteRule ^(.*)$ http://mit-license.org/$1 [R=301,L]
|
||||
|
||||
# if the file or directory exists
|
||||
RewriteCond %{REQUEST_FILENAME} -d [OR]
|
||||
RewriteCond %{REQUEST_FILENAME} -f
|
||||
RewriteRule .* - [L]
|
||||
|
||||
# using 'index.php' because it forces a '/' request to the handler
|
||||
RewriteRule ^(.*)$ index.php [QSA,L]
|
||||
</IfModule>
|
||||
57
LICENSE.html
Normal file
57
LICENSE.html
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
<!DOCTYPE html>
|
||||
<html id="home" lang="en">
|
||||
<head>
|
||||
<meta charset=utf-8>
|
||||
<meta name=viewport content="width=device-width, initial-scale=0.70;">
|
||||
<!--
|
||||
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 record to users.json will yeild an MIT License on a
|
||||
CNAME, for example:
|
||||
|
||||
{ "rem": "Remy Sharp" }
|
||||
|
||||
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.
|
||||
|
||||
Hope you find this useful too!
|
||||
|
||||
- @rem
|
||||
|
||||
-->
|
||||
<style>
|
||||
html { background: #eee; }
|
||||
body { margin: 0; font-family: monospace; font-size: 1.4em; }
|
||||
article, footer {
|
||||
display: block; margin: 1em auto; min-width: 320px; width: 90%;
|
||||
}
|
||||
article { display: block; margin: 1em auto; min-width: 320px; width: 90%; border: 1px solid #ddd; padding: 1em; background: #fff; }
|
||||
h1 { margin-top: 0; }
|
||||
p:last-child { margin-bottom: 0; }
|
||||
footer a { color: #999; font-weight: bold; }
|
||||
footer a:hover { color: #333; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<article>
|
||||
<h1>The MIT License (MIT)</h1>
|
||||
<p>Copyright (c) {{info}}</p>
|
||||
<p>Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:</p>
|
||||
|
||||
<p>The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.</p>
|
||||
|
||||
<p>THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.</p>
|
||||
</article>
|
||||
<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>
|
||||
<script>var _gaq=[['_setAccount','UA-1656750-28'],['_trackPageview']];(function(d,t){var g=d.createElement(t),s=d.getElementsByTagName(t)[0];g.src='//www.google-analytics.com/ga.js';s.parentNode.insertBefore(g,s)})(document,'script')</script>
|
||||
<body>
|
||||
</html>
|
||||
90
index.php
90
index.php
|
|
@ -2,12 +2,11 @@
|
|||
|
||||
date_default_timezone_set('Europe/London'); // stop php from whining
|
||||
|
||||
$user = preg_replace('/\.mit-license\.org$/', '', $_SERVER["HTTP_HOST"]);
|
||||
$user = preg_replace('/\.mit-license\..*$/', '', $_SERVER["HTTP_HOST"]);
|
||||
|
||||
// sanitise user (not for DNS, but for file reading, I don't know
|
||||
// just in case it's hacked about with or something bananas.
|
||||
$user = preg_replace('/[^a-z0-9\-]/', '', $user);
|
||||
|
||||
$user_file = 'users/'.$user.'.json';
|
||||
|
||||
if (file_exists($user_file)) {
|
||||
|
|
@ -17,63 +16,34 @@
|
|||
$holder = '<a href="'.$user->url.'">' . $holder . '</a>';
|
||||
}
|
||||
} else {
|
||||
$holder = "<copyright holders>";
|
||||
$holder = "<copyright holders>";
|
||||
}
|
||||
|
||||
// grab sha from request uri
|
||||
$request = $_SERVER["REQUEST_URI"];
|
||||
if ($request != "" && $request != "/" && $request != "/index.php") {
|
||||
$sha = preg_replace('/[^a-f0-9]/', '', $_SERVER["REQUEST_URI"]);
|
||||
} else if (isset($user) && property_exists($user, 'version')) {
|
||||
$sha = preg_replace('/[^a-f0-9]/', '', $user->version);
|
||||
}
|
||||
|
||||
// if sha specified, use that revision of licence
|
||||
if ($sha != "") {
|
||||
$out = array();
|
||||
// preg_replace should save us - but: please help me Obi Wan...
|
||||
exec("git show " . $sha . ":LICENSE.html", $out, $r);
|
||||
if ($r == 0) {
|
||||
$license = implode("\n", $out);
|
||||
}
|
||||
}
|
||||
|
||||
// if we didn't manage to read one in, use latest
|
||||
if ($license == "") {
|
||||
$license = file_get_contents('LICENSE.html');
|
||||
}
|
||||
|
||||
// replace info tag and display
|
||||
$info = date('Y') . ' ' . $holder;
|
||||
echo str_replace('{{info}}', $info, $license);
|
||||
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html id="home" lang="en">
|
||||
<head>
|
||||
<meta charset=utf-8>
|
||||
<meta name=viewport content="width=device-width, initial-scale=0.70;">
|
||||
<!--
|
||||
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 yeild an
|
||||
MIT License on a CNAME, for example:
|
||||
|
||||
{ "host": "rem", "copyright": "Remy Sharp" }
|
||||
|
||||
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.
|
||||
|
||||
Hope you find this useful too!
|
||||
|
||||
- @rem
|
||||
|
||||
-->
|
||||
<style>
|
||||
html { background: #eee; }
|
||||
body { margin: 0; font-family: monospace; font-size: 1.4em; }
|
||||
article, footer {
|
||||
display: block; margin: 1em auto; min-width: 320px; width: 90%;
|
||||
}
|
||||
article { display: block; margin: 1em auto; min-width: 320px; width: 90%; border: 1px solid #ddd; padding: 1em; background: #fff; }
|
||||
h1 { margin-top: 0; }
|
||||
p:last-child { margin-bottom: 0; }
|
||||
footer a { color: #999; font-weight: bold; }
|
||||
footer a:hover { color: #333; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<article>
|
||||
<h1>The MIT License (MIT)</h1>
|
||||
<p>Copyright (c) <?php echo date('Y') . ' ' . $holder; ?></p>
|
||||
<p>Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:</p>
|
||||
|
||||
<p>The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.</p>
|
||||
|
||||
<p>THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.</p>
|
||||
</article>
|
||||
<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>
|
||||
<script>var _gaq=[['_setAccount','UA-1656750-28'],['_trackPageview']];(function(d,t){var g=d.createElement(t),s=d.getElementsByTagName(t)[0];g.src='//www.google-analytics.com/ga.js';s.parentNode.insertBefore(g,s)})(document,'script')</script>
|
||||
<body>
|
||||
</html>
|
||||
|
|
|
|||
Loading…
Reference in a new issue