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.
|
|
|
|
|
2022-04-04 18:54:11 +02:00
|
|
|
import os
|
2022-03-29 14:44:03 +02:00
|
|
|
from modules import search
|
2022-04-02 00:10:18 +02:00
|
|
|
|
2022-03-29 14:44:03 +02:00
|
|
|
def html(page, json):
|
|
|
|
|
|
|
|
# This function adds a rendering of the json into the page
|
|
|
|
|
2022-04-01 21:59:32 +02:00
|
|
|
free = search.is_free(json)
|
2022-03-29 14:44:03 +02:00
|
|
|
page = page + "\n <h1>"
|
|
|
|
try:
|
2022-04-02 15:42:30 +02:00
|
|
|
page = page + '\n<img src="'+ json["links"]["icon"] + '" alt="Logo" style="height:50px;">'
|
2022-03-29 14:44:03 +02:00
|
|
|
except:
|
|
|
|
pass
|
|
|
|
name = json.get("names",["Unknown"])[0]
|
|
|
|
page = page + "\n" + name
|
|
|
|
page = page + "</h1>"
|
|
|
|
|
|
|
|
# Few words about it
|
2022-04-02 13:11:49 +02:00
|
|
|
comment = json.get("comment","")
|
2022-04-03 02:41:46 +02:00
|
|
|
not_foss = ['open source', 'open-source']
|
|
|
|
if "open source" or "open-source" in comment.lower():
|
2022-04-02 13:11:49 +02:00
|
|
|
# Well... Here is a thing. Free Software, not open source.
|
|
|
|
where = comment.lower().find("open source")
|
2022-04-03 02:41:46 +02:00
|
|
|
# In case it has a slash in it.
|
|
|
|
if where == -1:
|
|
|
|
where = comment.lower().find("open-source")
|
2022-04-04 18:54:11 +02:00
|
|
|
ops = comment[where:where+11]
|
|
|
|
comment = comment.replace(ops,
|
|
|
|
"<a href=\"https://www.gnu.org/philosophy/open-source-misses-the-point.en.html\">"+ops+"</a>")
|
2022-04-02 13:11:49 +02:00
|
|
|
page = page + "<p>"+comment+"</p>"
|
2022-03-29 14:44:03 +02:00
|
|
|
|
2022-03-31 20:08:42 +02:00
|
|
|
# I want to show nothing else from if it's proprietary
|
2022-04-04 18:54:11 +02:00
|
|
|
issues_files = list(os.listdir("data/issues"))
|
2022-04-02 17:28:29 +02:00
|
|
|
if "issues" in json:
|
2022-03-31 20:08:42 +02:00
|
|
|
l = json.get("issues", [])
|
|
|
|
page = page +"<h2>Anti-Features / Problems:</h2>"
|
|
|
|
|
|
|
|
for i in l:
|
2022-04-04 18:54:11 +02:00
|
|
|
if i+".html" not in issues_files:
|
|
|
|
page = page + " "+i+"<br>"
|
|
|
|
else:
|
|
|
|
page = page + '<details title="Read about '+i+'">'
|
|
|
|
page = page + "<summary>  "+i+"</summary>"
|
|
|
|
issuefile = open("data/issues/"+i+".html")
|
|
|
|
page = page + "<span><p>"+issuefile.read()+"</p></span>"
|
|
|
|
page = page + "</details>"
|
2022-04-02 17:28:29 +02:00
|
|
|
if not free:
|
2022-03-31 20:08:42 +02:00
|
|
|
return page
|
|
|
|
|
|
|
|
|
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-04-05 20:21:04 +02:00
|
|
|
linksfilter = {"git":"source"}
|
2022-03-31 20:08:42 +02:00
|
|
|
links = json.get("links", {})
|
|
|
|
for website in links:
|
|
|
|
if website in ["icon"]:
|
|
|
|
continue
|
|
|
|
link = links[website]
|
2022-03-31 19:16:16 +02:00
|
|
|
page = page + """
|
2022-03-31 20:08:42 +02:00
|
|
|
<th><form action=\""""+link+"""\">
|
2022-04-05 20:21:04 +02:00
|
|
|
<button title=\""""+link+"""\" type="submit">"""+linksfilter.get(website,website).upper()+"""</button>
|
2022-03-31 19:16:16 +02:00
|
|
|
</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",
|
2022-03-31 20:23:41 +02:00
|
|
|
"interface":"Interface",
|
|
|
|
"languages":"Programming Languages"}
|
2022-03-30 18:12:06 +02:00
|
|
|
|
|
|
|
for c in categories:
|
|
|
|
|
|
|
|
l = json.get(c, [])
|
|
|
|
if not l:
|
|
|
|
continue
|
|
|
|
|
|
|
|
page = page + "<details>"
|
2022-03-31 20:08:42 +02:00
|
|
|
page = page +"<summary>"+categories[c]+":</summary>"
|
2022-03-30 18:12:06 +02:00
|
|
|
|
|
|
|
for i in l:
|
2022-03-31 20:08:42 +02:00
|
|
|
page = page + " "+i+"<br>"
|
2022-03-30 18:12:06 +02:00
|
|
|
page = page + "</details>"
|
|
|
|
|
2022-03-29 14:44:03 +02:00
|
|
|
|
|
|
|
return page
|
|
|
|
|
|
|
|
def suggestions(page, json):
|
|
|
|
|
|
|
|
# This function will render suggestions
|
|
|
|
|
2022-04-01 21:08:29 +02:00
|
|
|
page = page + "<h1>Free Competitors:</h1>"
|
2022-03-29 14:44:03 +02:00
|
|
|
|
|
|
|
found = search.suggest(json)
|
2022-04-01 21:59:32 +02:00
|
|
|
|
|
|
|
biggest = 0
|
|
|
|
for i in found:
|
|
|
|
if i[0] > biggest:
|
|
|
|
biggest = i[0]
|
2022-04-02 17:28:29 +02:00
|
|
|
more = False
|
2022-03-29 14:44:03 +02:00
|
|
|
for i in found:
|
2022-04-01 21:59:32 +02:00
|
|
|
free = search.is_free(i[-1])
|
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
|
2022-04-02 17:28:29 +02:00
|
|
|
try:
|
|
|
|
frac = int(i[0]/biggest*100)
|
|
|
|
except:
|
|
|
|
frac = 0
|
|
|
|
|
|
|
|
if frac < 40 and not more: # Below 40% features match
|
|
|
|
page = page + """<hr><details>
|
|
|
|
<summary><h1 title="Click to show more / less.">Problematic Competitors:</h1></summary>"""
|
|
|
|
more = True
|
|
|
|
|
2022-04-03 05:26:54 +02:00
|
|
|
page = page + "<hr><br>Suggestion score: " + str(frac) + "%"
|
2022-03-29 14:44:03 +02:00
|
|
|
page = html(page, i[-1])
|
2022-04-02 17:28:29 +02:00
|
|
|
|
|
|
|
if more:
|
|
|
|
page = page + "</details>"
|
2022-03-30 18:12:06 +02:00
|
|
|
return page
|
|
|
|
|
2022-04-03 18:27:21 +02:00
|
|
|
def search_widget(page, address):
|
2022-03-30 18:12:06 +02:00
|
|
|
|
|
|
|
# Adds a search bar to the page
|
|
|
|
|
|
|
|
page = page + """
|
2022-04-03 18:27:21 +02:00
|
|
|
<form action="""
|
|
|
|
page = page + address
|
|
|
|
page = page + """search method="GET">
|
2022-03-30 18:12:06 +02:00
|
|
|
<input type="text" name="item" class="search" placeholder="Name of Software">
|
|
|
|
<button type="submit">Search</button>
|
|
|
|
</form>
|
|
|
|
"""
|
2022-04-03 18:27:21 +02:00
|
|
|
#page = page.format(ADDRESS)
|
2022-03-30 18:12:06 +02:00
|
|
|
|
|
|
|
return page
|
|
|
|
|
|
|
|
def source_code_link(page):
|
|
|
|
|
|
|
|
# Adds a source code link
|
|
|
|
|
2022-04-01 21:08:29 +02:00
|
|
|
page = page + "<br><br><hr><p>This website is under the GNU AGPL license.</p>"
|
2022-03-30 18:12:06 +02:00
|
|
|
page = page + """
|
2022-04-04 20:52:17 +02:00
|
|
|
<style>
|
|
|
|
table, th, td {
|
|
|
|
border-right:none;
|
|
|
|
border-left:none;
|
|
|
|
border-bottom:none;
|
|
|
|
border-top:none
|
|
|
|
}</style>
|
|
|
|
<table><tr>
|
|
|
|
|
|
|
|
<th><form action=https://notabug.org/jyamihud/FreeCompetitors>
|
2022-04-05 20:21:04 +02:00
|
|
|
<button title="See the full source code of the software that powers this website." type="submit">SOURCE</button>
|
|
|
|
</form></th>
|
2022-04-06 21:03:07 +02:00
|
|
|
|
|
|
|
<th><form action=/faq>
|
|
|
|
<button title="Frequently Asked Questions" type="submit">FAQ</button>
|
|
|
|
</form></th>
|
2022-04-05 20:21:04 +02:00
|
|
|
|
|
|
|
<th><form action=https://notabug.org/jyamihud/FreeCompetitors/issues>
|
|
|
|
<button title="Report a bug." type="submit">BUG?</button>
|
2022-04-04 20:52:17 +02:00
|
|
|
</form></th>
|
2022-04-05 20:21:04 +02:00
|
|
|
|
2022-04-04 20:52:17 +02:00
|
|
|
<th><form action=https://notabug.org/jyamihud/FreeCompetitors/issues/25>
|
2022-04-05 20:21:04 +02:00
|
|
|
<button title="Report a piece of software that's missing from the catalogue." type="submit">MISSING?</button>
|
2022-04-04 20:52:17 +02:00
|
|
|
</form></th>
|
|
|
|
|
|
|
|
<th><form action=https://notabug.org/jyamihud/FreeCompetitors/issues/24>
|
2022-04-05 20:21:04 +02:00
|
|
|
<button title="Report a mistake in data about software." type="submit">MISTAKE?</button>
|
2022-04-04 20:52:17 +02:00
|
|
|
</form></th></tr></table><br><br>
|
|
|
|
|
|
|
|
|
2022-03-30 18:12:06 +02:00
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-03-29 14:44:03 +02:00
|
|
|
return page
|