2022-03-29 14:44:03 +02:00
|
|
|
# THIS SOFTWARE IS A PART OF FREE COMPETITOR PROJECT
|
|
|
|
# THE FOLLOWING SOURCE CODE I UNDER THE GNU
|
|
|
|
# AGPL LICENSE V3 OR ANY LATER VERSION.
|
|
|
|
|
|
|
|
# This project is not for simple users, but for
|
|
|
|
# web-masters and a like, so we are counting on
|
|
|
|
# your ability to set it up and running.
|
|
|
|
|
|
|
|
from modules import search
|
|
|
|
|
|
|
|
def html(page, json):
|
|
|
|
|
|
|
|
# This function adds a rendering of the json into the page
|
|
|
|
|
|
|
|
free = False
|
|
|
|
if "licenses" in json and json["licenses"]:
|
|
|
|
free = True
|
|
|
|
|
|
|
|
page = page + "\n <h1>"
|
|
|
|
try:
|
|
|
|
page = page + '\n<img src="'+ json["links"]["icon"] + '" alt="Logo" style="width:50px;">'
|
|
|
|
except:
|
|
|
|
pass
|
|
|
|
|
|
|
|
# Name / Website link
|
|
|
|
name = json.get("names",["Unknown"])[0]
|
|
|
|
|
|
|
|
|
|
|
|
page = page + "\n" + name
|
|
|
|
|
|
|
|
page = page + "</h1>"
|
|
|
|
|
|
|
|
# Few words about it
|
|
|
|
page = page + "<p>"+json.get("comment","")+"</p>"
|
|
|
|
|
2022-03-30 18:12:06 +02:00
|
|
|
|
|
|
|
|
2022-03-29 14:44:03 +02:00
|
|
|
# Links
|
2022-03-30 18:12:06 +02:00
|
|
|
|
|
|
|
# <table>
|
|
|
|
# <tr>
|
|
|
|
# <th>Company</th>
|
|
|
|
# <th>Contact</th>
|
|
|
|
# <th>Country</th>
|
|
|
|
#</tr>
|
|
|
|
|
|
|
|
page = page + """
|
|
|
|
<style>
|
|
|
|
table, th, td {
|
|
|
|
border-right:none;
|
|
|
|
border-left:none;
|
|
|
|
border-bottom:none;
|
|
|
|
border-top:none
|
|
|
|
}</style>
|
|
|
|
"""
|
|
|
|
|
|
|
|
page = page + "<table><tr>"
|
|
|
|
|
2022-03-29 14:44:03 +02:00
|
|
|
website = json.get("links",{}).get("website", "")
|
|
|
|
if free and website:
|
|
|
|
page = page + """
|
2022-03-30 18:12:06 +02:00
|
|
|
<th><form action=\""""+website+"""\">
|
2022-03-29 14:44:03 +02:00
|
|
|
<button type="submit">Website</button>
|
2022-03-30 18:12:06 +02:00
|
|
|
</form></th>
|
2022-03-29 14:44:03 +02:00
|
|
|
"""
|
|
|
|
|
|
|
|
git = json.get("links",{}).get("git", "")
|
|
|
|
if git:
|
|
|
|
page = page + """
|
2022-03-30 18:12:06 +02:00
|
|
|
<th><form action=\""""+git+"""\">
|
2022-03-29 14:44:03 +02:00
|
|
|
<button type="submit">Source Code</button>
|
2022-03-30 18:12:06 +02:00
|
|
|
</form></th>
|
2022-03-29 14:44:03 +02:00
|
|
|
"""
|
|
|
|
|
|
|
|
wikipedia = json.get("links",{}).get("wikipedia", "")
|
|
|
|
if wikipedia:
|
|
|
|
page = page + """
|
2022-03-30 18:12:06 +02:00
|
|
|
<th><form action=\""""+wikipedia+"""\">
|
2022-03-29 14:44:03 +02:00
|
|
|
<button type="submit">Wikipedia</button>
|
2022-03-30 18:12:06 +02:00
|
|
|
</form></th>
|
2022-03-29 14:44:03 +02:00
|
|
|
"""
|
|
|
|
|
2022-03-31 19:16:16 +02:00
|
|
|
documentation = json.get("links",{}).get("documentation", "")
|
|
|
|
if documentation:
|
|
|
|
page = page + """
|
|
|
|
<th><form action=\""""+documentation+"""\">
|
|
|
|
<button type="submit">Documentation</button>
|
|
|
|
</form></th>
|
|
|
|
"""
|
|
|
|
|
2022-03-30 18:12:06 +02:00
|
|
|
page = page + "</tr></table>"
|
|
|
|
|
|
|
|
# Details
|
|
|
|
|
|
|
|
categories = {"generic_name":"Features",
|
|
|
|
"licenses":"License(s)",
|
|
|
|
"platforms":"Platforms",
|
|
|
|
"networks_read":"Accesses Data from",
|
|
|
|
"networks_write":"Interacts / Publishes to",
|
|
|
|
"formats_read":"Opens from File-Formats",
|
|
|
|
"formats_write":"Saves to File-Formats",
|
|
|
|
"issues":"Anti-Features / Problems"}
|
|
|
|
|
|
|
|
for c in categories:
|
|
|
|
|
|
|
|
l = json.get(c, [])
|
|
|
|
if not l:
|
|
|
|
continue
|
|
|
|
|
|
|
|
page = page + "<details>"
|
|
|
|
page = page +"<summary>"+categories[c]+"</summary>"
|
|
|
|
|
|
|
|
for i in l:
|
|
|
|
page = page + "<span> "+i+"</span><br>"
|
|
|
|
page = page + "</details>"
|
|
|
|
|
2022-03-29 14:44:03 +02:00
|
|
|
|
|
|
|
return page
|
|
|
|
|
|
|
|
def suggestions(page, json):
|
|
|
|
|
|
|
|
# This function will render suggestions
|
|
|
|
|
|
|
|
page = page + "<br><br><h1>Replacements:</h1><br><br>"
|
|
|
|
|
|
|
|
found = search.suggest(json)
|
|
|
|
|
|
|
|
for i in found:
|
2022-03-29 16:53:17 +02:00
|
|
|
|
2022-03-29 14:44:03 +02:00
|
|
|
free = False
|
|
|
|
if "licenses" in i[-1] and i[-1]["licenses"]:
|
|
|
|
free = True
|
2022-03-30 19:52:36 +02:00
|
|
|
|
2022-03-29 14:44:03 +02:00
|
|
|
if not i[0] or i[-1] == json or not free:
|
|
|
|
continue
|
|
|
|
page = page + "<br><br>"
|
|
|
|
page = html(page, i[-1])
|
|
|
|
|
2022-03-30 18:12:06 +02:00
|
|
|
return page
|
|
|
|
|
|
|
|
def search_widget(page):
|
|
|
|
|
|
|
|
# Adds a search bar to the page
|
|
|
|
|
|
|
|
page = page + """
|
|
|
|
<form action="/search" method="GET">
|
|
|
|
<input type="text" name="item" class="search" placeholder="Name of Software">
|
|
|
|
<button type="submit">Search</button>
|
|
|
|
</form>
|
|
|
|
"""
|
|
|
|
|
|
|
|
return page
|
|
|
|
|
|
|
|
def source_code_link(page):
|
|
|
|
|
|
|
|
# Adds a source code link
|
|
|
|
|
|
|
|
page = page + "<br><br><p>This website is under the GNU AGPL license.</p>"
|
|
|
|
page = page + """
|
|
|
|
<form action=https://notabug.org/jyamihud/FreeCompetitors>
|
|
|
|
<button type="submit">Source Code</button>
|
|
|
|
</form><br><br>
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-03-29 14:44:03 +02:00
|
|
|
return page
|