diff --git a/licenses.json b/licenses.json new file mode 100644 index 0000000..5ad845d --- /dev/null +++ b/licenses.json @@ -0,0 +1,8 @@ +{ + "licenses": [ + "GNU GPL v3.0", + "GPL3", + "GPL3+", + "MIT" + ] +} diff --git a/modules/__pycache__/render.cpython-310.pyc b/modules/__pycache__/render.cpython-310.pyc new file mode 100644 index 0000000..63f88cd Binary files /dev/null and b/modules/__pycache__/render.cpython-310.pyc differ diff --git a/modules/__pycache__/search.cpython-310.pyc b/modules/__pycache__/search.cpython-310.pyc new file mode 100644 index 0000000..c466df3 Binary files /dev/null and b/modules/__pycache__/search.cpython-310.pyc differ diff --git a/modules/render.py b/modules/render.py index 40db75c..485f32b 100644 --- a/modules/render.py +++ b/modules/render.py @@ -7,16 +7,13 @@ # your ability to set it up and running. from modules import search +import json def html(page, json): # This function adds a rendering of the json into the page - - free = search.is_free(json) - - page = page + "\n <h1>" try: page = page + '\n<img src="'+ json["links"]["icon"] + '" alt="Logo" style="width:50px;">' @@ -118,7 +115,6 @@ def suggestions(page, json): biggest = i[0] for i in found: - free = search.is_free(i[-1]) if not i[0] or i[-1] == json or not free: diff --git a/modules/search.py b/modules/search.py index eebf869..a8fcf50 100644 --- a/modules/search.py +++ b/modules/search.py @@ -101,14 +101,16 @@ def suggest(json_data): return found -def is_free(data): - - # TODO: Add a more complex algorithm of checking if software is - # free or not. There are plenty of semi-free software like - # Unreal Engine. They have licenses but they do not give the users - # the four essential freedoms. - - free = False - if "licenses" in data and data["licenses"]: - free = True - return free +def is_free(app): + if "licenses" in app and app["licenses"]: + matches = 0 + with open("licenses.json", "r") as data: + all_licenses = json.load(data) + for license in app["licenses"]: + for license2 in all_licenses["licenses"]: + if license2 == license: + matches = matches + 1 + break + if matches == len(app["licenses"]): + return True + return False