Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

design-needed: Create app to display licenses and license rules #32

Closed
pombredanne opened this issue Oct 22, 2020 · 6 comments
Closed
Labels
design-needed enhancement New feature or request
Milestone

Comments

@pombredanne
Copy link
Member

These should be the scancode-toolkit licenses.
Ideally we should also have an easy to add new records which should then trigger a PR in scancode-toolkit
There should also ideally be a simple API that could be use d by aboutcde-toolkit to fetch license texts for attribution generation

@pombredanne pombredanne added design-needed enhancement New feature or request labels Oct 27, 2020
@pombredanne pombredanne added this to the 1.1 milestone Oct 27, 2020
@pombredanne pombredanne changed the title Create app to display licenses and license rules design-needed: Create app to display licenses and license rules Oct 27, 2020
@tdruez
Copy link
Contributor

tdruez commented Oct 27, 2020

For a local Webserver available in ScanCode-toolkit to consult license data:

$ pip install bottle
import webbrowser
from bottle import route, run, template
from licensedcode.models import load_licenses

licenses = load_licenses()

webbrowser.open("http://localhost:8080/license")

@route('/license')
def license_list():
    return '<br>'.join([f'<a href="/license/{key}">{key}</a>' for key in licenses.keys()])

@route('/license/<key>')
def license_text(key):
    try:
        text = licenses[key].text
    except KeyError:
        return template('License {{key}} not found.', key=key)
    return template('<pre>{{text}}</pre>', text=text)

run(host='localhost', port=8080)

This could also be a new Django app module in ScanCode.io with publicly available views.

@pombredanne
Copy link
Member Author

Here is an updated version:

import saneyaml
import webbrowser
from bottle import route, run, template
from licensedcode.models import load_licenses

licenses = load_licenses()

webbrowser.open("http://localhost:8080/license")

@route('/license')
def license_list():
    return '<br>'.join([f'<a href="/license/{key}">{key}</a>' for key in licenses.keys()])

@route('/license/<key>')
def license_text(key):
    try:
        data = saneyaml.dump(licenses[key].to_dict())
        text = licenses[key].text
    except KeyError:
        return template('License {{key}} not found.', key=key)
    return template('<pre>{{data}}</pre>\n=====================\n<pre>{{text}}</pre>', data=data, text=text)

run(host='localhost', port=8080)

@tdruez
Copy link
Contributor

tdruez commented Nov 4, 2020

A similar approach generating a static HTML site that could be available through GitHub pages for example:

# pip install dominate

import pathlib
import saneyaml
from licensedcode.models import load_licenses
from dominate.tags import *

licenses = load_licenses()

output_path = pathlib.Path("static/")
output_path.mkdir(parents=False, exist_ok=True)

index = html(body(ul(li(a(key, href=f"{key}.html")) for key in licenses.keys())))
(output_path / "index.html").open('w').write(index.render())

for license in licenses.values():
    data = saneyaml.dump(license.to_dict())
    content = html(body(pre(data), hr(), pre(license.text)))
    (output_path / f"{license.key}.html").open('w').write(content.render())

tdruez added a commit that referenced this issue Nov 11, 2020
Signed-off-by: Thomas Druez <tdruez@nexb.com>
tdruez added a commit that referenced this issue Nov 13, 2020
Signed-off-by: Thomas Druez <tdruez@nexb.com>
tdruez added a commit that referenced this issue Nov 13, 2020
Signed-off-by: Thomas Druez <tdruez@nexb.com>
@tdruez
Copy link
Contributor

tdruez commented Nov 13, 2020

@pombredanne This PR about making the licenses data available from the ScanCode.io server UI is ready for review: #47

For the publicly available license data, see an example using the GitHub pages feature with a generated static HTML from the load_licenses():
Code @ https://github.com/tdruez/licenses and rendered @ https://tdruez.github.io/licenses/

Let me know your take on those 2 approches and if we should migrate the GitHub pages app into a reference nexB repo.

@pombredanne
Copy link
Member Author

@tdruez IMHO both approaches are worthy. The statically generated pages are easy and can make deployment as Github pages or else with minimal fuss quite easy. And the Django mini app allows clean integration in scancode.io in one step.

tdruez added a commit that referenced this issue Dec 7, 2020
Signed-off-by: Thomas Druez <tdruez@nexb.com>
@tdruez
Copy link
Contributor

tdruez commented Dec 7, 2020

Minimal license views are now available in ScanCode.io.
Also, the new LicenseDB is published at https://scancode-licensedb.aboutcode.org/ from the code at https://github.com/nexB/scancode-licensedb

@tdruez tdruez closed this as completed Dec 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
design-needed enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants