summaryrefslogtreecommitdiff
path: root/website
diff options
context:
space:
mode:
authorA. Gordon <assafgordon@gmail.com>2014-08-21 01:15:08 (GMT)
committerA. Gordon <assafgordon@gmail.com>2014-08-21 01:15:08 (GMT)
commit4c0b5e4af2fd2059afe2e2db8b043617c5595e16 (patch)
treedb675f98c1b19637a86c0c2a7f2b0e005da18e8c /website
parent8c1fcc7160da0745e81496f1ec06a9a2326bbd44 (diff)
downloadgsv-eval-4c0b5e4af2fd2059afe2e2db8b043617c5595e16.zip
gsv-eval-4c0b5e4af2fd2059afe2e2db8b043617c5595e16.tar.gz
gsv-eval-4c0b5e4af2fd2059afe2e2db8b043617c5595e16.tar.bz2
Website + perl script: much improved
Diffstat (limited to 'website')
-rwxr-xr-xwebsite/gnu_eval_flask.py48
-rw-r--r--website/gnu_eval_worker.py77
-rw-r--r--website/templates/detect_license.html340
-rw-r--r--website/templates/home.html46
4 files changed, 483 insertions, 28 deletions
diff --git a/website/gnu_eval_flask.py b/website/gnu_eval_flask.py
index b682559..eca2312 100755
--- a/website/gnu_eval_flask.py
+++ b/website/gnu_eval_flask.py
@@ -30,11 +30,17 @@ import os
import csv
import datetime
import httplib
+import pprint
from redis import Redis
from subprocess import Popen,PIPE
from rq import Queue
-from gnu_eval_worker import do_gnu_eval
+from gnu_eval_worker import do_gnu_eval, sanitize_project_name, \
+ acceptable_source_url, \
+ get_current_active_job_num, \
+ get_current_submitted_job_num, \
+ allocate_new_submitted_job_num, \
+ get_completed_jobs
app = Flask(__name__)
app.debug = True
@@ -42,29 +48,39 @@ app.debug = True
redis_connection=Redis()
q = Queue(connection=redis_connection)
+pp = pprint.PrettyPrinter()
+
results_dir = "/tmp/"
@app.route("/")
-def splash():
- return render_template("home.html")
+def index():
+ submitted_jobs_count = get_current_submitted_job_num()
+ completed_jobs_count = get_current_active_job_num()
+ pending_jobs_count = int(submitted_jobs_count - completed_jobs_count)
+ completed_jobs = get_completed_jobs()
+ print "pending = ", pending_jobs_count
+ print "submitted = ", submitted_jobs_count
+ print "completed = ", completed_jobs_count
+ return render_template("home.html",
+ completed_jobs = completed_jobs,
+ submitted_jobs_count = submitted_jobs_count,
+ pending_jobs_count = pending_jobs_count)
@app.route("/eval", methods=['POST'])
def eval():
if not 'project_name' in request.form:
return "Error: missing project name"
project_name = request.form['project_name'].strip()
- project_name = re.sub(r"[^A-Za-z0-9\.\-\_]","",project_name);
+ project_name = sanitize_project_name(str(project_name))
if not 'source_url' in request.form:
return "Error: missing source URL"
source_url = request.form['source_url'].strip()
-
- tarball_url_re = re.compile ('^(http|ftp|https)://[A-Za-z0-9\-]+\.[A-Za-z0-9\.]+/[A-Za-z0-9\/\-\_\.]+(\.tar\.(gz|bz2|xz)|\.git)$')
- git_url_re = re.compile('^git://[A-Za-z0-9\-]+\.[A-Za-z0-9\.]+/[A-Za-z0-9\/\-\_\.]+$');
- if not tarball_url_re.match(source_url) and not git_url_re.match(source_url):
+ if acceptable_source_url(source_url):
return "Error: Source URL (%s) does not match allowed patternas. Only simple URLs are allowed (no CGI parameters)" % (source_url)
- job_id = redis_connection.incr("gnu_eval_job_num");
+ job_id = allocate_new_submitted_job_num()
+
job = q.enqueue(do_gnu_eval, job_id, results_dir, project_name, source_url)
link = url_for('show',jobid=job_id)
@@ -77,16 +93,24 @@ def show(jobid):
except:
return "error: invalid ID"
- max_job = redis_connection.get("gnu_eval_job_num");
- print "max_job = %s, job_id = %s\n" % ( max_job, jobid)
- if int(jobid) > int(max_job):
+ max_job = get_current_submitted_job_num()
+ if jobid > int(max_job):
return "error: no such job"
+ processed_jobs = get_current_active_job_num()
+
result_file = results_dir + "/" + str(jobid) + ".html"
if not os.path.isfile(result_file) or os.path.getsize(result_file)==0:
+ if jobid < processed_jobs:
+ return "job failed, please try to re-run it, or file a bug report"
+
return render_template('not_ready.html')
return send_file(result_file)
+@app.route("/detect")
+def detect():
+ return render_template("detect_license.html");
+
if __name__ == "__main__":
app.run(host='0.0.0.0',port=5106)
diff --git a/website/gnu_eval_worker.py b/website/gnu_eval_worker.py
index 8092310..0e478ed 100644
--- a/website/gnu_eval_worker.py
+++ b/website/gnu_eval_worker.py
@@ -19,6 +19,71 @@ import re
from subprocess import Popen, PIPE
import os
import pprint
+import json
+from redis import Redis
+
+tarball_url_re = re.compile ('^(http|ftp|https)://[A-Za-z0-9\-]+\.[A-Za-z0-9\.]+/[A-Za-z0-9\/\-\_\.]+(\.tar\.(gz|bz2|xz)|\.git)$')
+git_url_re = re.compile('^git://[A-Za-z0-9\-]+\.[A-Za-z0-9\.]+/[A-Za-z0-9\/\-\_\.]+$');
+
+redis_connection=Redis()
+
+def get_current_active_job_num():
+ num = redis_connection.get("gnu_eval_current_active_job")
+ try:
+ num = int(num)
+ except:
+ num = 0
+ return num
+
+def set_current_active_job_num(num):
+ try:
+ num = int(num)
+ except:
+ num = 0
+ redis_connection.set("gnu_eval_current_active_job", num);
+
+def get_current_submitted_job_num():
+ num = redis_connection.get("gnu_eval_current_submitted_job")
+ try:
+ num = int(num)
+ except:
+ num = 0
+ return num
+
+def allocate_new_submitted_job_num():
+ num = redis_connection.incr("gnu_eval_current_submitted_job");
+ try:
+ num = int(num)
+ except:
+ num = 0
+ return num
+
+def acceptable_source_url(url):
+ if tarball_url_re.match(url) and git_url_re.match(url):
+ return True
+ return False
+
+def add_complete_job(idnum,project_name,source_url):
+ try:
+ job_data = [ str(idnum), str(project_name), str(source_url) ]
+ job_data_json = json.dumps(job_data)
+ redis_connection.lpush("gnu-eval-completed-jobs", job_data_json)
+ except:
+ pass
+
+def get_completed_jobs():
+ jobs = []
+ try:
+ jobs_json = redis_connection.lrange("gnu-eval-completed-jobs",0,100)
+ for j in jobs_json:
+ job = json.loads(j)
+ jobs.append(job)
+ except:
+ pass
+ return jobs
+
+def sanitize_project_name(name):
+ return re.sub(r"[^A-Za-z0-9\.\-\_ ]","",name);
def do_gnu_eval(idnum,output_dir,project_name,source_url):
try:
@@ -31,11 +96,10 @@ def do_gnu_eval(idnum,output_dir,project_name,source_url):
return "error: output directory is empty"
if not os.path.isdir(output_dir):
return "error: output directory (%s) is not a valid directory" % (output_dir)
- p = re.compile ('^(http|ftp|https|git)://[A-Za-z0-9\-]+\.[A-Za-z0-9\.]+/')
- if not p.match(source_url):
+ if acceptable_source_url(source_url):
return "error: Source URL (%s) does not match allowed pattern" % (source_url)
- project_name = str(project_name)
+ project_name = sanitize_project_name(str(project_name))
source_url = str(source_url)
idnum = str(idnum)
@@ -43,10 +107,13 @@ def do_gnu_eval(idnum,output_dir,project_name,source_url):
args = [ eval_script, output_dir, idnum, project_name, source_url ]
child = Popen(args, shell=False, stdout=PIPE, stderr=PIPE)
+
output = child.communicate();
- pp = pprint.PrettyPrinter(indent=4)
exitcode = child.returncode
+
if exitcode == 0:
- return "ok"
+ set_current_active_job_num (idnum)
+ add_complete_job (idnum, project_name, source_url)
+ return "ok";
else:
return output[1] # stderr
diff --git a/website/templates/detect_license.html b/website/templates/detect_license.html
new file mode 100644
index 0000000..082e5a7
--- /dev/null
+++ b/website/templates/detect_license.html
@@ -0,0 +1,340 @@
+<html>
+<head>
+<script>
+/*
+@licstart The following is the entire license notice for the JavaScript code in this page.
+
+Copyright (C) 2014 Assaf Gordon (agn@gnu.org)
+
+The JavaScript code in this page is free software: you can
+redistribute it and/or modify it under the terms of the GNU
+General Public License (GNU GPL) as published by the Free Software
+Foundation, either version 3 of the License, or (at your option)
+any later version. The code is distributed WITHOUT ANY WARRANTY;
+without even the implied warranty of MERCHANTABILITY or FITNESS
+FOR A PARTICULAR PURPOSE. See the GNU GPL for more details.
+
+As additional permission under GNU GPL version 3 section 7, you
+may distribute non-source (e.g., minimized or compacted) forms of
+that code without the copy of the GNU GPL normally required by
+section 4, provided you include this license notice and a URL
+through which recipients can access the Corresponding Source.
+
+@licend The above is the entire license notice for the JavaScript code in this page.
+
+See here:
+ http://www.gnu.org/philosophy/javascript-trap.html
+For details about the above license section.
+*/
+
+"use strict;"
+
+function detect_license(raw_text)
+{
+ var cxx_comments_re = /^ *\/\//m;
+ var bad_chars_re = /[^A-Za-z0-9\;\,\:\/ \.\_]+/g;
+ var spaces_re = /[ \t]+/g;
+ var newlines_re = /[\r\n]+/g;
+
+ /* Remove common prefixes and other non-core characters */
+ var text = raw_text.replace(cxx_comments_re,"")
+ .replace(newlines_re," ")
+ .replace(bad_chars_re,"")
+ .replace(spaces_re," ");
+
+ /* GNU licenses, with their variants */
+ var gpl1_re = /is free software[:;\.] you can redistribute it and\/or modify it under the terms of the GNU (Lesser|Affero)? *General Public License/i;
+ var gpl2_re = /is free software\. You may redistribute copies of it under the terms of the GNU General Public License/i;
+ var possible_gpl_text = gpl1_re.test(text) || gpl2_re.test(text);
+
+ var gpl_v2_re = / version 2[, ]/i;
+ var gpl_v21_re = / version 2\.1[, ]/i;
+ var gpl_v3_re = / version 3[, ]/i;
+ var gpl_lesser_re = /lesser general public license/i;
+ var gpl_affero_re = /affero general public license/i;
+ var gpl_or_later_re = /any later version/i;
+
+ var possible_gpl_v2 = possible_gpl_text && gpl_v2_re.test(text);
+ var possible_gpl_v21 = possible_gpl_text && gpl_v21_re.test(text);
+ var possible_gpl_v3 = possible_gpl_text && gpl_v3_re.test(text);
+ var possible_gpl_lesser = possible_gpl_text && gpl_lesser_re.test(text);
+ var possible_gpl_affero = possible_gpl_text && gpl_affero_re.test(text);
+ var possible_gpl_or_later = possible_gpl_text && gpl_or_later_re.test(text);
+
+ var possible_gpl;
+ var gpl_info_url;
+ if ( possible_gpl_affero && possible_gpl_v3 ) {
+ possible_gpl = "AGPLv3";
+ gpl_info_url = "http://www.gnu.org/licenses/license-list.html#AGPLv3.0";
+ } else if ( possible_gpl_affero && possible_gpl_v2 ) {
+ possible_gpl = "AGPLv2";
+ // No specific link to Affero v2 on the list
+ gpl_info_url = "http://www.gnu.org/licenses/license-list.html#AGPLv3.0";
+ } else if ( possible_gpl_lesser && possible_gpl_v3 ) {
+ possible_gpl = "LGPLv3";
+ gpl_info_url = "http://www.gnu.org/licenses/license-list.html#LGPL";
+ } else if ( possible_gpl_lesser && possible_gpl_v21 ) {
+ possible_gpl = "LGPLv21";
+ gpl_info_url = "http://www.gnu.org/licenses/license-list.html#LGPLv2.1";
+ } else if ( possible_gpl_lesser && possible_gpl_v2 ) {
+ possible_gpl = "LGPLv2";
+ // No specific link to LGPL v2 on the list
+ gpl_info_url = "http://www.gnu.org/licenses/license-list.html#LGPLv2.1";
+ } else if ( possible_gpl_v3 ) {
+ possible_gpl = "GPLv3";
+ gpl_info_url = "http://www.gnu.org/licenses/license-list.html#GNUGPL";
+ } else if ( possible_gpl_v2 ) {
+ possible_gpl = "GPLv2";
+ gpl_info_url = "http://www.gnu.org/licenses/license-list.html#GPLv2";
+ } else if ( possible_gpl_text ) {
+ possible_gpl = "GPL(unknown type)";
+ gpl_info_url = "http://www.gnu.org/licenses/license-list.html#GPLCompatibleLicenses";
+ }
+ if ( possible_gpl && possible_gpl_or_later ) {
+ possible_gpl = possible_gpl + "-or-later";
+ }
+ /* End of GNU licenses part */
+
+
+ /*** Permissive Licenses found in the wild *** /
+
+ /* This very permissive license statement is recommended by FSF/GNU
+ for non-core files, such as "Makefile.am" */
+ var special_expection_re = /is free software; as a special exception the author gives unlimited permission/i;
+ var possible_special_exception = special_expection_re.test(text);
+
+ /* This very permissive license statement appears in some small FSF/GNU files
+ (e.g GNU Hello's ./tests/greeting-1).
+ Details here:
+ http://www.gnu.org/licenses/license-list.html#GNUAllPermissive */
+ var gnu_all_permissive_re = /Copying and distribution of this file, with or without modification, are permitted in any medium without royalty provided the copyright notice and this notice are preserved/i;
+ var possible_gnu_all_permissive = gnu_all_permissive_re.test(text);
+
+ /* These permissive licenses variations appear in some autotools-generate files
+ (e.g. 'Makefile.in' and 'configure') */
+ var autotools_permissive_header_re = /This [A-Za-z \.]{4,25} is free software[:;] the Free Software Foundation gives unlimited permission/i;
+ var autotools_permissive_form1_re = /the Free Software Foundation gives unlimited permission to copy, distribute and modify it, with or without modifications, as long as this notice is preserved/i;
+ var autotools_permissive_form2_re = /the Free Software Foundation gives unlimited permission to copy and\/or distribute it, with or without modifications, as long as this notice is preserved/i;
+ // This short form appears in some autogenerated 'configure' files.
+ var autotools_permissive_form3_re = /the Free Software Foundation gives unlimited permission to copy, distribute and modify it\./;
+ var possible_autotools_permissive =
+ autotools_permissive_header_re.test(text)
+ &&
+ (autotools_permissive_form1_re.test(text)
+ ||
+ autotools_permissive_form2_re.test(text)
+ ||
+ autotools_permissive_form3_re.test(text));
+
+ // This syntax appears on some openBSD files
+ var bsd_permissive = /Permission to use, copy, modify, and 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/i;
+ var possible_bsd_permissive = bsd_permissive.test(text);
+
+ /** End of permissive part */
+
+ /******* BSD licenses *****/
+ var bsd_prefix_re = /Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and\/or other materials provided with the distribution/;
+ var bsd_item1_re = /Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer/;
+ var bsd_item2_re = /Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and\/or other materials provided with the distribution/;
+ // The 3rd ('no endorsement') clause in "Clear BSD"
+ var bsd_clear_item3_re = /Neither the name of .{4,30} nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission\./;
+ // The 3rd ('no endosrsment') clause in 'Modified BSD (3-clause)'
+ var bsd_modified_item3_re = /The name of .{4,30} may not be used to endorse or promote products derived from this software without specific prior written permission/;
+ // The Clear-BSD has a specific mention of patents, see
+ // http://www.gnu.org/licenses/license-list.html#clearbsd
+ var bsd_patents_re = /PATENT/i;
+ // The advertisment caluse
+ var bsd_item4_re = /All advertising materials mentioning features or use of this software must display the following acknowledgement/;
+
+ var possible_bsd_prefix = bsd_prefix_re.test(text);
+ var possible_bsd_item1 = bsd_item1_re.test(text);
+ var possible_bsd_item2 = bsd_item2_re.test(text);
+ var possible_bsd_clear_item3 = bsd_clear_item3_re.test(text);
+ var possible_bsd_item4 = bsd_item4_re.test(text);
+ var possible_bsd_modified_item3 = bsd_modified_item3_re.test(text);
+ var possible_bsd_patents = bsd_patents_re.test(text);
+
+ var possible_bsd;
+ var bsd_info_url;
+ if (possible_bsd_prefix && possible_bsd_item1 && possible_bsd_item2
+ && (possible_bsd_clear_item3 || possible_bsd_modified_item3)
+ && possible_bsd_item4) {
+ possible_bsd = "Original-BSD (4-Clause)";
+ bsd_info_url = "http://www.gnu.org/licenses/license-list.html#OriginalBSD";
+ } else if (possible_bsd_prefix && possible_bsd_item1 && possible_bsd_item2
+ && possible_bsd_clear_item3 && possible_bsd_patents) {
+ possible_bsd = "Clear-BSD (3-Clause, with patents!)";
+ bsd_info_url = "http://www.gnu.org/licenses/license-list.html#clearbsd";
+ } else if (possible_bsd_prefix && possible_bsd_item1 && possible_bsd_item2
+ && possible_bsd_clear_item3 && !possible_bsd_patents) {
+ possible_bsd = "Clear-BSD (3-Clause, w/o patents)";
+ bsd_info_url = "http://www.gnu.org/licenses/license-list.html#clearbsd";
+ } else if (possible_bsd_prefix && possible_bsd_item1 && possible_bsd_item2
+ && possible_bsd_modified_item3 && !possible_bsd_patents) {
+ possible_bsd = "Modified-BSD (3-Clause)";
+ bsd_info_url = "http://www.gnu.org/licenses/license-list.html#ModifiedBSD";
+ } else if (possible_bsd_prefix && possible_bsd_item1 && possible_bsd_item2
+ && !possible_bsd_clear_item3 && !possible_bsd_modified_item3 && !possible_bsd_patents) {
+ possible_bsd = "Free-BSD (2-Clause)";
+ bsd_info_url = "http://www.gnu.org/licenses/license-list.html#FreeBSD";
+ }
+ // There could be other BSD combinations, but they are not considerd "recognized".
+ // better not to name them and give false impression to the user.
+
+ /***** End of BSD part ****/
+
+ /* zLib License */
+ var zlib_part1_re = /Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:/;
+ var zlib_part2_re = /The origin of this software must not be misrepresented/;
+ var zlib_part3_re = /Altered source versions must be plainly marked as such/;
+ var zlib_part4_re = /This notice may not be removed or altered from any source distribution/;
+ var possible_zlib = zlib_part1_re.test(text) &&
+ zlib_part2_re.test(text) &&
+ zlib_part3_re.test(text) &&
+ zlib_part4_re.test(text);
+
+
+ /* X11 / MIT */
+ var x11_part1_re = /Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files/;
+ var x11_part2_re = /The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software/;
+ var possible_x11 = x11_part1_re.test(text) && x11_part2_re.test(text);
+
+ /* Apache 2.0 */
+ var apache2_part1_re = /Licensed under the Apache License, Version 2.0/;
+ var apache2_part2_re = /you may not use this file except in compliance with the License/;
+ var possible_apache2 = apache2_part1_re.test(text) && apache2_part2_re.test(text);
+
+
+ /* Boost License. Is there a full statement form, or just a paragraph with a link? */
+ var boost_v1_part1_re = /Use, modification, and distribution are subject to the Boost Software License, Version 1\.0/i;
+ var boost_v1_part2_re = /http:\/\/www\.boost\.org\/LICENSE_1_0\.txt/i;
+ var possible_boost_v1 = boost_v1_part1_re.test(text) && boost_v1_part2_re.test(text);
+
+ /* MPL-2.0. Is there a full statement form, or just a paragraph with a link? */
+ var mpl2_part1_re = /This Source Code Form is subject to the terms of the Mozilla Public License, v. 2\.0\./i;
+ var mpl2_part2_re = /If a copy of the MPL was not distributed with this file, You can obtain one at http:\/\/mozilla\.org\/MPL\/2\.0/i;
+ var possible_mpl2 = mpl2_part1_re.test(text) && mpl2_part2_re.test(text);
+
+
+ /* Add any detected licenses to the resulting list */
+ var licenses = {} ;
+ if (possible_gpl) { licenses[possible_gpl] = gpl_info_url ; }
+ if (possible_bsd) { licenses[possible_bsd] = bsd_info_url ; }
+ if (possible_special_exception) { licenses["permissive(special-exception)"] = "http://www.gnu.org/licenses/license-list.html#GNUAllPermissive" ; }
+ if (possible_gnu_all_permissive) { licenses["permissive(GNU)"] = "http://www.gnu.org/licenses/license-list.html#GNUAllPermissive" ; }
+ if (possible_bsd_permissive) { licenses["permissive(BSD)"] = "http://www.gnu.org/licenses/license-list.html#GNUAllPermissive" ; }
+ if (possible_autotools_permissive) { licenses["permissive(Autotools)"] = "http://www.gnu.org/licenses/license-list.html#GNUAllPermissive" ; }
+ if (possible_zlib) { licenses["zlib"] = "http://www.gnu.org/licenses/license-list.html#ZLib" ; }
+ if (possible_x11) { licenses["X11/MIT"] = "http://www.gnu.org/licenses/license-list.html#X11License" ; }
+ if (possible_apache2) { licenses["Apache2.0"] = "http://www.gnu.org/licenses/license-list.html#apache2" ; }
+ if (possible_boost_v1) { licenses["Boost-1.0"] = "http://www.gnu.org/licenses/license-list.html#boost" ; }
+ if (possible_mpl2) { licenses["MPL-2.0"] = "http://www.gnu.org/licenses/license-list.html#MPL-2.0" ; }
+
+ return licenses;
+}
+
+function reset()
+{
+ var result = document.getElementById("result");
+ result.innerHTML = "";
+
+ var txtarea = document.getElementById("content");
+ txtarea.value = "";
+}
+
+function example()
+{
+ var result = document.getElementById("result");
+ result.innerHTML = "";
+
+ var txtarea = document.getElementById("content");
+ txtarea.value =
+ "/*\n" +
+ " * This is Foo Bar Program\n" +
+ " *\n" +
+ " * Copyright (C) 2014 Foo Bar\n" +
+ " *\n" +
+ " * This program is free software: you can redistribute it and/or modify\n" +
+ " * it under the terms of the GNU General Public License as published by\n" +
+ " * the Free Software Foundation, either version 3 of the License, or\n" +
+ " * (at your option) any later version.\n" +
+ " *\n" +
+ " * This program is distributed in the hope that it will be useful,\n" +
+ " * but WITHOUT ANY WARRANTY; without even the implied warranty of\n" +
+ " * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n" +
+ " * GNU General Public License for more details.\n" +
+ " *\n" +
+ " * You should have received a copy of the GNU General Public License\n" +
+ " * along with this program. If not, see <http://www.gnu.org/licenses/>.\n" +
+ " */\n" +
+ "\n" +
+ "int main()\n" +
+ "{\n" +
+ " printf(\"hello world\\n\");\n" +
+ " return 0;\n" +
+ "}\n" ;
+}
+
+function go()
+{
+ var result = document.getElementById("result");
+ result.innerHTML = "";
+
+ var txtarea = document.getElementById("content");
+ var txt = txtarea.value;
+ var lic = detect_license(txt);
+
+ console.log(lic);
+
+ if (Object.keys(lic).length === 0) {
+
+ result.innerHTML = "No recognizable license statement detected.<br/>" +
+ "<b>NOTE</b>:</br>" +
+ "This script <i>does not</i> detect informal statements, such as:<br/>" +
+ "<pre>" +
+ "This file is part of PACKAGE and is released under the same license;\n" +
+ "released under GPLv2;\n" +
+ "This PACKAGE is MIT license;\n";
+ "See LICENSE file for license information;\n" +
+ "</pre><br/>";
+
+ } else {
+
+ var res = "The following licenses were detected (click on license for more information):<br/>";
+ for (var k in lic) {
+ var v = lic[k];
+ res = res + ' <a href="' + v + '" target="_blank">' + k + '</a><br/>' ;
+ };
+ result.innerHTML = res;
+
+ }
+}
+
+</script>
+
+</head>
+<body>
+<h1>Free-Software License Detector</h1>
+
+Paste a file (or just the license part from the file) to try and detect the license.
+<br/>
+<strong>NOTE:</strong> This project is in alpha-stage. Mis-detection is possible and likely.
+<br/>
+<br/>
+<div id="result">
+</div>
+<br/>
+<input type="button" value="analyze" onclick="go();"/>
+<input type="button" value="clear" onclick="reset();"/>
+<input type="button" value="example" onclick="example();"/>
+<br/>
+<textarea id="content" rows="30" cols="80">
+</textarea>
+<br/>
+<br/>
+The following licences are currently detected:
+GPL (most variants), BSD (most variants), X11/MIT, Apache 2.0, MPL 2.0, Boost V1, zlib, few permissive licenses.
+<br/>
+For a comments, questions and suggestions please contact agn@gnu.org .
+</body>
+</html>
diff --git a/website/templates/home.html b/website/templates/home.html
index e67cb5c..efbd011 100644
--- a/website/templates/home.html
+++ b/website/templates/home.html
@@ -5,28 +5,52 @@
<h1>Online Free-Software Copyright and License Evalutor</h1>
Designed for GNU Savannah proejct evaluation, but useful for general copyright and license evaluation of any project.
<br/>
-
<strong>THIS PROJECT IS IN ALPHA STAGE.</strong><br/>
-<br/>
-
-To review a project, enter a URL of a tarball or GIT repostory.</br>
-Example: <code>git://git.savannah.gnu.org/hello.git</code>
-<br/>
-<br/>
NOTE:</br>
-All information will be made public for everyone to see.</br>
-<br/>
+All information submitted here will be made public for everyone to see.</br>
<br/>
-
+<h2>Review a Project</h2>
+To review a project, enter a URL of a tarball or GIT repostory.<br/>
+Example: <code>git://git.savannah.gnu.org/hello.git</code><br/>
+<code>http://ftp.gnu.org/gnu/hello/hello-2.9.tar.gz</code><br/>
<form method="post" action="{{ url_for("eval") }}" enctype="multipart/form-data">
Remote Source URL (git/tarball):
<input type=text name="source_url" size="50" />
<br/>
-Project Name (optional):
+Project Name:
<input type=text name="project_name" />
<br/>
<input type=submit value="Go" />
</form>
+<h2>Detect Free-Software License</h2>
+Have a source code file but not sure which license it has (and, don't feel like reading and analyzing it)?
+<br/>
+Then use the <a href="/detect">Free-Software License Detector</a>.
+<br/>
+
+
+{% if completed_jobs %}
+<h2>Recently Completed Reviews</h2>
+(click to view results)<br/>
+<table>
+<thead>
+<th>Name</th>
+<th>Source</th>
+</thead>
+<tbody>
+{% for i in completed_jobs %}
+<tr>
+ <td><a href="{{ url_for("show", jobid=i[0] ) }}">{{ i[1] }}</a></td>
+ <td><a href="{{ url_for("show", jobid=i[0] ) }}">{{ i[2] }}</a></td>
+</tr>
+{% endfor %}
+</tbody>
+</table>
+{% endif %}
+<br/>
+<br/>
+Please send comments or questions to agn@gnu.org
+<br/>
</body>
</html>