diff options
author | Luis R. Rodriguez <mcgrof@do-not-panic.com> | 2012-10-25 10:14:40 -0700 |
---|---|---|
committer | Luis R. Rodriguez <mcgrof@do-not-panic.com> | 2012-10-25 10:14:40 -0700 |
commit | 1898c53e645e3c2a82bf35fa1b7b0140fa5d7f42 (patch) | |
tree | adb3093fc873600d39e860efb80e3c56e26bfc66 | |
parent | fcd91ca5bb660d015cdab902271d3af8acb8ced6 (diff) | |
download | rel-html-1898c53e645e3c2a82bf35fa1b7b0140fa5d7f42.tar.gz |
rel-html: add license print support
Signed-off-by: Luis R. Rodriguez <mcgrof@do-not-panic.com>
-rw-r--r-- | html/template.html | 2 | ||||
-rwxr-xr-x | rel-html.py | 29 |
2 files changed, 30 insertions, 1 deletions
diff --git a/html/template.html b/html/template.html index aa1048b..84d2bac 100644 --- a/html/template.html +++ b/html/template.html @@ -89,7 +89,7 @@ <div class="footer-container"> <footer class="wrapper"> - <h3>footer</h3> + <h3 id="license"></h3> </footer> </div> diff --git a/rel-html.py b/rel-html.py index df4c22d..b2bb3df 100755 --- a/rel-html.py +++ b/rel-html.py @@ -22,6 +22,12 @@ import urllib import ConfigParser import re, sys +def rel_html_license(): + return "ISC" + +def rel_html_href(): + return '<a href="https://github.com/mcgrof/rel-html">rel-html</a>' + class index_parser(HTMLParser): "HTML index parser for software releases class." def parse(self, html): @@ -153,6 +159,16 @@ class html_base(HTMLParser): def __init__(self): HTMLParser.__init__(self) +def license_url(license): + if (license == 'GPLv2'): + return "http://www.gnu.org/licenses/gpl-2.0.html" + elif (license == 'ISC'): + return "http://opensource.org/licenses/ISC" + elif (license == 'AGPL'): + return "http://www.gnu.org/licenses/agpl-3.0.html" + else: + return "http://opensource.org/licenses/alphabetical" + class rel_html_gen(HTMLParser): "HTML 5 generator from parsed index parser content." def handle_title(self, tag, attributes): @@ -195,6 +211,17 @@ class rel_html_gen(HTMLParser): self.skip_endtag = True sys.stdout.write('%s</h1>\n' % (self.parser.html_about_title)) sys.stdout.write('<p>%s</p>\n' % (self.parser.html_about)) + def handle_h_license(self, tag, attributes): + self.skip_endtag = True + sys.stdout.write('License</h1>\n') + sys.stdout.write('\t\t<p>%s is licensed under the <a href="%s">%s</a>. \n' % + (self.parser.rel_html_proj, + license_url(self.parser.rel_license), + self.parser.rel_license)) + sys.stdout.write('This page was generated by %s licensed under the <a href="%s">%s</a></p>\n' % + (rel_html_href(), + license_url(rel_html_license()), + rel_html_license())) def handle_h1_pass(self, tag, attributes): pass def handle_h(self, tag, attributes): @@ -208,6 +235,8 @@ class rel_html_gen(HTMLParser): def_run = self.handle_h1_release elif (value == 'about'): def_run = self.handle_h1_about + elif (value == 'license'): + def_run = self.handle_h_license sys.stdout.write('<%s' % tag) for name, value in attributes: |