-
Notifications
You must be signed in to change notification settings - Fork 109
An app to detect licenses from the provided input license text #450
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
Draft
lf32
wants to merge
79
commits into
main
Choose a base branch
from
lf32-licensetext-devel
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 5 commits
Commits
Show all changes
79 commits
Select commit
Hold shift + click to select a range
0a4915a
create an app to detect licenses from input text
lf32 d5c4018
Merge branch 'main' into lf32-licensetext-devel
lf32 4c1483a
Merge branch 'main' of nexB/scancode.io into lf32-licensetext-devel
lf32 9c25575
Improved UI, Changed Scan Path
lf32 49fe7a5
changed card title from name to short_name
lf32 cb9de2d
Improved License Input and Details UI #450
lf32 d2bd8d0
Run License Detection On Text Submission with tempfile #450
lf32 a113c14
Rename license form, prevent text stripping, temp_file attr update #450
lf32 0fa7fbb
Detect unknown licenses and return matched text by default #450
lf32 ea6f4bb
Flush contents of the temfile before passing as an argument #450
lf32 947faaf
Flush contents of the tempfile before passing as an argument #450
lf32 dd62121
Merge branch 'lf32-licensetext-devel' of https://github.com/nexB/scan…
lf32 60af913
Deleted models.py and migrations #450
lf32 28d0dcf
Added comment related to flushing tempfile #450
lf32 e46107a
Commenting inside views with pound over docstring #450
lf32 4468085
Write comments in multiple lines inside views #450
lf32 8e7c72b
Input text is rendered inside the box over the textarea #450
lf32 a87ace7
Merge branch 'main' of https://github.com/nexB/scancode.io into lf32-…
lf32 91ca751
Display form errors, detect licenses for input text file #450
lf32 cfb7a37
Improve file error response in views #450
lf32 7eedf84
Moved license summary to details with new UI #450
lf32 2d4f7f6
Fixed broken short lines #450
lf32 bbe58d0
New line at the end of the page #450
lf32 5602a6e
Merge branch 'main' of nexB/scancode.io -> lf32-licensetext-devel
lf32 a19a762
Ace Editor Restored with improved UI #450
lf32 b77976d
Highlight and scroll down to matched text #450
lf32 0333932
Close all cards while opening a new one #450
lf32 b206145
Removed details option in the view #450
lf32 b53e45c
Restore details tab with matched text #450
lf32 fe66aa2
Merge remote-tracking branch 'origin' into lf32-licensetext-devel
lf32 ce9b294
Merge remote-tracking branch 'origin' into lf32-licensetext-devel
lf32 1293066
Highlight text with colors #450
lf32 dddb4ad
Merge branch 'main' of https://github.com/nexB/scancode.io into lf32-…
lf32 a6b34de
Fix failing text for `make valid` #450
lf32 1bdf9d1
Fix failing test for `make valid` #450
lf32 ab56010
Merge branch 'main' of into lf32-licensetext-devel
lf32 fda2356
Merge branch 'main' into lf32-licensetext-devel
lf32 b82d1a2
Merge branch 'main' into lf32-licensetext-devel
lf32 67462c5
Testing out new UI to match the projects page #450
lf32 0f675ff
Add match_text tests to scantext #450
lf32 76e8a03
Make scancode match text test pass
pombredanne 8727cb7
Add list of matches to Token
pombredanne 04b8d21
Merge branch 'main' into lf32-licensetext-devel
lf32 3f7b640
Add all detected values into the table #450
lf32 658df1f
Add details page to view matched license details #450
lf32 8edf207
Add a mini licenses file to test for development #450
lf32 787133a
Move import of Token to top #450
lf32 4a08ea9
Add `license_chart_data` to render charts #450
lf32 32c3931
Add eye friendly green color to match highlights #450
lf32 4442f7c
Highlight all detected licenses in one match #450
lf32 840b395
Fix tests by running make valid
lf32 60683d0
Match token args correction #450
lf32 68205f8
Add hyperlinks to urls in details #450
lf32 968c538
Update details, Improve UI #450
lf32 3108089
Merge v31.0.0 of 'main' into lf32-licensetext-devel
lf32 6cd0243
Ace editor upgraded from v1.4.12 to v1.9.5
lf32 65277f1
Improve details, highlights and tests
lf32 bdae386
Add report functionality to the summary
lf32 81d1c6d
Add new user interface and cleanup the old one
lf32 bd15385
Merge branch 'main' into lf32-licensetext-devel
lf32 5c88367
Remove unused tests and validate code format #450
lf32 57a1d62
Indent html, handle input, fix modules & tests#450
lf32 3def711
Add more licenses, highlight text properly #450
lf32 ebcb6e2
Set cursor style to help, add token attr desc #450
lf32 cda3a40
Connect left and right part of ui #450
lf32 9c404cc
Set predefined colors to 3 #450
lf32 6fab923
Add more colors & new test licenses
lf32 4760050
Add highlight color and get rid of modal #450
lf32 e3281f7
Merge branch 'main' into lf32-licensetext-devel
lf32 45acd64
Fix failing tests #450
lf32 b719948
Fix width for dropdown #450
lf32 e3c8d79
Merge branch 'main' into lf32-licensetext-devel
lf32 3bca8e7
Merge branch 'main' into lf32-licensetext-devel
lf32 a165bd1
Merge branch 'main' into lf32-licensetext-devel
lf32 73a6571
Merge branch 'main' into lf32-licensetext-devel
lf32 dd2e8ab
Write input file either in chunks or text #450
lf32 5c30510
Move scan to utility dropdown #450
lf32 a5fa2b4
Merge branch 'main' into lf32-licensetext-devel
lf32 9787f44
(tests) code format is vaildated #450
lf32 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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,21 @@ | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
# http://nexb.com and https://github.com/nexB/scancode.io | ||
# The ScanCode.io software is licensed under the Apache License version 2.0. | ||
# Data generated with ScanCode.io is provided as-is without warranties. | ||
# ScanCode is a trademark of nexB Inc. | ||
# | ||
# You may not use this software except in compliance with the License. | ||
# You may obtain a copy of the License at: http://apache.org/licenses/LICENSE-2.0 | ||
# Unless required by applicable law or agreed to in writing, software distributed | ||
# under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR | ||
# CONDITIONS OF ANY KIND, either express or implied. See the License for the | ||
# specific language governing permissions and limitations under the License. | ||
# | ||
# Data Generated with ScanCode.io is provided on an "AS IS" BASIS, WITHOUT WARRANTIES | ||
# OR CONDITIONS OF ANY KIND, either express or implied. No content created from | ||
# ScanCode.io should be considered or used as legal advice. Consult an Attorney | ||
# for any legal advice. | ||
# | ||
# ScanCode.io is a free software code scanning tool from nexB Inc. and others. | ||
# Visit https://github.com/nexB/scancode.io for support and download. |
This file contains hidden or 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,28 @@ | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
# http://nexb.com and https://github.com/nexB/scancode.io | ||
# The ScanCode.io software is licensed under the Apache License version 2.0. | ||
# Data generated with ScanCode.io is provided as-is without warranties. | ||
# ScanCode is a trademark of nexB Inc. | ||
# | ||
# You may not use this software except in compliance with the License. | ||
# You may obtain a copy of the License at: http://apache.org/licenses/LICENSE-2.0 | ||
# Unless required by applicable law or agreed to in writing, software distributed | ||
# under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR | ||
# CONDITIONS OF ANY KIND, either express or implied. See the License for the | ||
# specific language governing permissions and limitations under the License. | ||
# | ||
# Data Generated with ScanCode.io is provided on an "AS IS" BASIS, WITHOUT WARRANTIES | ||
# OR CONDITIONS OF ANY KIND, either express or implied. No content created from | ||
# ScanCode.io should be considered or used as legal advice. Consult an Attorney | ||
# for any legal advice. | ||
# | ||
# ScanCode.io is a free software code scanning tool from nexB Inc. and others. | ||
# Visit https://github.com/nexB/scancode.io for support and download. | ||
|
||
from django.apps import AppConfig | ||
|
||
|
||
class ScantextConfig(AppConfig): | ||
default_auto_field = "django.db.models.BigAutoField" | ||
tdruez marked this conversation as resolved.
Show resolved
Hide resolved
|
||
name = "scantext" |
This file contains hidden or 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,42 @@ | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
# http://nexb.com and https://github.com/nexB/scancode.io | ||
# The ScanCode.io software is licensed under the Apache License version 2.0. | ||
# Data generated with ScanCode.io is provided as-is without warranties. | ||
# ScanCode is a trademark of nexB Inc. | ||
# | ||
# You may not use this software except in compliance with the License. | ||
# You may obtain a copy of the License at: http://apache.org/licenses/LICENSE-2.0 | ||
# Unless required by applicable law or agreed to in writing, software distributed | ||
# under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR | ||
# CONDITIONS OF ANY KIND, either express or implied. See the License for the | ||
# specific language governing permissions and limitations under the License. | ||
# | ||
# Data Generated with ScanCode.io is provided on an "AS IS" BASIS, WITHOUT WARRANTIES | ||
# OR CONDITIONS OF ANY KIND, either express or implied. No content created from | ||
# ScanCode.io should be considered or used as legal advice. Consult an Attorney | ||
# for any legal advice. | ||
# | ||
# ScanCode.io is a free software code scanning tool from nexB Inc. and others. | ||
# Visit https://github.com/nexB/scancode.io for support and download. | ||
|
||
from django import forms | ||
|
||
|
||
class EditorForm(forms.Form): | ||
tdruez marked this conversation as resolved.
Show resolved
Hide resolved
|
||
input_text = forms.CharField( | ||
tdruez marked this conversation as resolved.
Show resolved
Hide resolved
|
||
widget=forms.Textarea( | ||
attrs={ | ||
"rows": 25, | ||
tdruez marked this conversation as resolved.
Show resolved
Hide resolved
|
||
"class": "textarea has-fixed-size", | ||
"placeholder": "Paste your license text here.", | ||
} | ||
), | ||
required=False, | ||
) | ||
input_file = forms.FileField( | ||
required=False, | ||
widget=forms.ClearableFileInput( | ||
attrs={"class": "file-input", "multiple": False}, | ||
), | ||
) |
Empty file.
This file contains hidden or 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,25 @@ | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
# http://nexb.com and https://github.com/nexB/scancode.io | ||
# The ScanCode.io software is licensed under the Apache License version 2.0. | ||
# Data generated with ScanCode.io is provided as-is without warranties. | ||
# ScanCode is a trademark of nexB Inc. | ||
# | ||
# You may not use this software except in compliance with the License. | ||
# You may obtain a copy of the License at: http://apache.org/licenses/LICENSE-2.0 | ||
# Unless required by applicable law or agreed to in writing, software distributed | ||
# under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR | ||
# CONDITIONS OF ANY KIND, either express or implied. See the License for the | ||
# specific language governing permissions and limitations under the License. | ||
# | ||
# Data Generated with ScanCode.io is provided on an "AS IS" BASIS, WITHOUT WARRANTIES | ||
# OR CONDITIONS OF ANY KIND, either express or implied. No content created from | ||
# ScanCode.io should be considered or used as legal advice. Consult an Attorney | ||
# for any legal advice. | ||
# | ||
# ScanCode.io is a free software code scanning tool from nexB Inc. and others. | ||
# Visit https://github.com/nexB/scancode.io for support and download. | ||
|
||
from django.db import models | ||
|
||
# Create your models here. |
27 changes: 27 additions & 0 deletions
27
scantext/templates/scantext/includes/license_summary_level.html
This file contains hidden or 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 @@ | ||
{% load humanize %} | ||
<nav class="level is-mobile"> | ||
<div class="level-item has-text-centered"> | ||
<div> | ||
<p class="heading">Percentage Of License Text</p> | ||
<p class="title"> | ||
<span>{{ expr.percentage_of_license_text }}</span> | ||
</p> | ||
</div> | ||
</div> | ||
<div class="level-item has-text-centered"> | ||
<div> | ||
<p class="heading">License Expressions</p> | ||
<p class="title"> | ||
<span>{{ expr.license_expressions|length }}</span> | ||
</p> | ||
</div> | ||
</div> | ||
<div class="level-item has-text-centered"> | ||
<div> | ||
<p class="heading">Licenses</p> | ||
<p class="title"> | ||
<span>{{ expr.licenses|length }}</span> | ||
</p> | ||
</div> | ||
</div> | ||
</nav> |
This file contains hidden or 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,99 @@ | ||
{% extends 'scanpipe/base.html' %} | ||
{% load static humanize %} | ||
|
||
{% block content %} | ||
<div class="container is-widescreen"> | ||
{% include 'scanpipe/includes/navbar_header.html' %} | ||
<div class="mx-5 mb-2">{% include 'scanpipe/includes/messages.html' %}</div> | ||
|
||
<section class="section p-0"> | ||
<div class="is-flex is-justify-content-space-between is-align-items-center mb-2"> | ||
<div class="mb-2"> | ||
<h1 class="title is-4">License Detection Summary</h1> | ||
</div> | ||
<div> | ||
<a href="{% url 'license_scan' %}" class="button is-link">Scan Again</a> | ||
tdruez marked this conversation as resolved.
Show resolved
Hide resolved
|
||
</div> | ||
</div> | ||
</section> | ||
|
||
<hr class="mx-5"> | ||
{% include "scantext/includes/license_summary_level.html" with expr=expr %} | ||
tdruez marked this conversation as resolved.
Show resolved
Hide resolved
|
||
<hr class="mx-5"> | ||
|
||
<div class="columns mb-5"> | ||
<div class="column is-half"> | ||
<p class="title is-4">Input License Text</p> | ||
<pre>{{ text }}</pre> | ||
</div> | ||
<div class="column is-half"> | ||
<p class="title is-4">Detected Licenses</p> | ||
<div class="card"> | ||
{% for license in expr.licenses %} | ||
<div class="licenses-card"> | ||
tdruez marked this conversation as resolved.
Show resolved
Hide resolved
|
||
<div class="card-header is-flex is-justify-content-space-between"> | ||
<div class="card-header-title" title="{{ license.short_name }}"> | ||
{% if license.homepage_url %} | ||
<a href="{{ license.homepage_url }}" title="{{ license.name }} ({{ license.short_name }})">{{ license.short_name }}</a> | ||
{% else %} {{ license.short_name }} {% endif %} | ||
</div> | ||
<div class="is-flex is-justify-content-row is-align-items-center"> | ||
<p class="lines tag is-6 mx-1 is-light is-info"> | ||
{% if license.start_line == license.end_line %} Line {{ license.start_line }} {% else %} Lines {{ license.start_line }} - {{ license.end_line }} {% endif %} | ||
</p> | ||
<p class="tag is-6 mx-1 is-light | ||
{% if license.score == 100 %} is-success {% else %} is-warning {% endif %}">{{ license.score }}</p> | ||
<p class="card-header-icon" aria-label="more options"> | ||
<span class="icon"> | ||
<i class="fas fa-angle-down" aria-hidden="true"></i> | ||
</span> | ||
</p> | ||
</div> | ||
</div> | ||
<div class="card-content is-hidden"> | ||
<div class="content"> | ||
<div class="is-flex is-justify-content-space-between"> | ||
<div> | ||
<p class="subtitle is-5">Matched Text</p> | ||
</div> | ||
<div> | ||
<p class="tag is-6 mx-1 is-light is-primary">{{ license.category }}</p> | ||
<a class="tag is-6 mx-1 is-light is-link" href="{{ license.reference_url }}">ref</a> | ||
<p class="tag is-6 mx-1 is-light is-info"> | ||
{% if license.start_line == license.end_line %} Line {{ license.start_line }} {% else %} Lines {{ license.start_line }} - {{ license.end_line }} {% endif %} | ||
</p> | ||
</div> | ||
</div> | ||
<pre>{{ license.matched_text }}</pre> | ||
</div> | ||
</div> | ||
</div> | ||
{% endfor %} | ||
</div> | ||
</div> | ||
</div> | ||
|
||
</div> | ||
{% endblock %} | ||
|
||
{% block scripts %} | ||
<script type="text/javascript"> | ||
const cards = document.querySelectorAll('.card-header-icon') | ||
|
||
cards.forEach(card => { | ||
card.addEventListener('click', (event) => { | ||
event.preventDefault() | ||
content = card.parentElement.parentElement.parentElement.querySelector('.card-content').classList | ||
lineTag= card.parentElement.querySelector('.lines').classList | ||
if (content.contains('is-hidden')) { | ||
content.remove('is-hidden') | ||
lineTag.add('is-hidden') | ||
} else { | ||
content.add('is-hidden') | ||
lineTag.remove('is-hidden') | ||
} | ||
}) | ||
}) | ||
|
||
</script> | ||
{% endblock %} |
This file contains hidden or 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,50 @@ | ||
{% extends "scanpipe/base.html" %} | ||
tdruez marked this conversation as resolved.
Show resolved
Hide resolved
|
||
{% load static humanize %} | ||
|
||
{% block content %} | ||
<div class="container is-max-desktop"> | ||
{% include 'scanpipe/includes/navbar_header.html' %} | ||
<div class="mx-5 mb-2">{% include 'scanpipe/includes/messages.html' %}</div> | ||
|
||
<section class="section pt-0"> | ||
<div class="is-flex is-justify-content-space-between is-align-items-center mb-2"> | ||
<div class="mb-2"> | ||
<h1 class="title is-5">Scan License</h1> | ||
</div> | ||
<div> | ||
<a href="{% url 'project_list' %}" class="button is-link">Go to Projects</a> | ||
tdruez marked this conversation as resolved.
Show resolved
Hide resolved
|
||
</div> | ||
</div> | ||
<form method="post" action="{% url 'license_scan' %}"> | ||
{% csrf_token %} | ||
{{ form.input_text }} | ||
<div class="columns mt-1"> | ||
<div class="file has-name is-fullwidth column is-half"> | ||
<label class="file-label"> | ||
{{ form.input_file }} | ||
<span class="file-cta"> | ||
<span class="file-icon"> | ||
<i class="fas fa-upload"></i> | ||
</span> | ||
<span class="file-label">Choose a file to scan…</span> | ||
</span> | ||
<span class="file-name">/home/user/dev/license-text.txt</span> | ||
tdruez marked this conversation as resolved.
Show resolved
Hide resolved
|
||
</label> | ||
</div> | ||
<div class="column is-half"> | ||
<input type="submit" class="button is-fullwidth is-link" value="Scan License"> | ||
</div> | ||
</div> | ||
</form> | ||
</section> | ||
</div> | ||
{% endblock %} {% block scripts %} | ||
<script> | ||
let form = document.querySelector('form'); | ||
|
||
// form.addEventListener('submit', (event) => { | ||
|
||
// if (!form["id_input_file"].files.length && !form["id_input_text"].value.length) return false; | ||
// }); | ||
</script> | ||
{% endblock %} --> |
This file contains hidden or 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,21 @@ | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
# http://nexb.com and https://github.com/nexB/scancode.io | ||
# The ScanCode.io software is licensed under the Apache License version 2.0. | ||
# Data generated with ScanCode.io is provided as-is without warranties. | ||
# ScanCode is a trademark of nexB Inc. | ||
# | ||
# You may not use this software except in compliance with the License. | ||
# You may obtain a copy of the License at: http://apache.org/licenses/LICENSE-2.0 | ||
# Unless required by applicable law or agreed to in writing, software distributed | ||
# under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR | ||
# CONDITIONS OF ANY KIND, either express or implied. See the License for the | ||
# specific language governing permissions and limitations under the License. | ||
# | ||
# Data Generated with ScanCode.io is provided on an "AS IS" BASIS, WITHOUT WARRANTIES | ||
# OR CONDITIONS OF ANY KIND, either express or implied. No content created from | ||
# ScanCode.io should be considered or used as legal advice. Consult an Attorney | ||
# for any legal advice. | ||
# | ||
# ScanCode.io is a free software code scanning tool from nexB Inc. and others. | ||
# Visit https://github.com/nexB/scancode.io for support and download. |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.