|
@@ -15,14 +15,36 @@ def html(page, json):
|
|
# This function adds a rendering of the json into the page
|
|
# This function adds a rendering of the json into the page
|
|
|
|
|
|
free = search.is_free(json)
|
|
free = search.is_free(json)
|
|
- page = page + "\n <h1>"
|
|
|
|
|
|
+ name = json.get("names",["Unknown"])[0]
|
|
|
|
+ page = page + """
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ <!-- For each software in the list we do mostly the same things.
|
|
|
|
+ And here it is. First we show it's name as a link to be able
|
|
|
|
+ to search Free Competitors to what is found. -->
|
|
|
|
+
|
|
|
|
+ """
|
|
|
|
+
|
|
|
|
+ page = page + "\n <a href=\"/"+name.replace(" ", "+").lower()+"\">"
|
|
|
|
+ page = page + "\n <h1>"
|
|
try:
|
|
try:
|
|
- page = page + '\n<img src="'+ json["links"]["icon"] + '" alt="Logo" style="height:50px;">'
|
|
|
|
|
|
+ page = page + '\n <img src="'+ json["links"]["icon"] + '" alt="[LOGO]" style="height:50px;"> <!-- The logo of the software in question.-->\n'
|
|
except:
|
|
except:
|
|
pass
|
|
pass
|
|
- name = json.get("names",["Unknown"])[0]
|
|
|
|
- page = page + "\n" + name
|
|
|
|
- page = page + "</h1>"
|
|
|
|
|
|
+
|
|
|
|
+ page = page + " "+ name +" <!-- The title of the program -->\n"
|
|
|
|
+ page = page + " </h1>\n </a>\n\n"
|
|
|
|
+
|
|
|
|
+ page = page + """
|
|
|
|
+
|
|
|
|
+ <!-- Next there is a short paragraph about the program.
|
|
|
|
+ ( Often Copypasted from some official page about it ).
|
|
|
|
+ Which means, it may contain the terrible words "Open Source"
|
|
|
|
+ that hide the fact that Free Software is about User Freedom
|
|
|
|
+ first of all. So we are trying to link to a special page on
|
|
|
|
+ GNU.ORG if such a thing is found -->
|
|
|
|
+
|
|
|
|
+ """
|
|
|
|
|
|
# Few words about it
|
|
# Few words about it
|
|
comment = json.get("comment","")
|
|
comment = json.get("comment","")
|
|
@@ -34,9 +56,10 @@ def html(page, json):
|
|
if where == -1:
|
|
if where == -1:
|
|
where = comment.lower().find("open-source")
|
|
where = comment.lower().find("open-source")
|
|
ops = comment[where:where+11]
|
|
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>")
|
|
|
|
- page = page + "<p>"+comment+"</p>"
|
|
|
|
|
|
+ if ops:
|
|
|
|
+ comment = comment.replace(ops,
|
|
|
|
+ "<a href=\"https://www.gnu.org/philosophy/open-source-misses-the-point.en.html\">"+ops+"</a>")
|
|
|
|
+ page = page + "\n <p>\n "+comment+"\n </p>\n\n"
|
|
|
|
|
|
# I want to show nothing else from if it's proprietary
|
|
# I want to show nothing else from if it's proprietary
|
|
issues_files = list(os.listdir("data/issues"))
|
|
issues_files = list(os.listdir("data/issues"))
|
|
@@ -59,21 +82,26 @@ def html(page, json):
|
|
|
|
|
|
# Links
|
|
# Links
|
|
|
|
|
|
- # <table>
|
|
|
|
- # <tr>
|
|
|
|
- # <th>Company</th>
|
|
|
|
- # <th>Contact</th>
|
|
|
|
- # <th>Country</th>
|
|
|
|
- #</tr>
|
|
|
|
|
|
+ page = page + """
|
|
|
|
+ <!-- To organize the buttons with the main links we are using
|
|
|
|
+ a table. But since I don't know what CSS file the maintainer
|
|
|
|
+ will choose. And I want the table to be invisible. I insert here
|
|
|
|
+ a bit of CSS code. -->
|
|
|
|
+
|
|
|
|
+ """
|
|
|
|
|
|
page = page + """
|
|
page = page + """
|
|
<style>
|
|
<style>
|
|
- table, th, td {
|
|
|
|
- border-right:none;
|
|
|
|
- border-left:none;
|
|
|
|
- border-bottom:none;
|
|
|
|
- border-top:none
|
|
|
|
- }</style>
|
|
|
|
|
|
+ table, th, td {
|
|
|
|
+ border-right:none;
|
|
|
|
+ border-left:none;
|
|
|
|
+ border-bottom:none;
|
|
|
|
+ border-top:none
|
|
|
|
+ }
|
|
|
|
+ </style>
|
|
|
|
+
|
|
|
|
+ <!-- And now the table itself. -->
|
|
|
|
+
|
|
"""
|
|
"""
|
|
|
|
|
|
page = page + "<table><tr>"
|
|
page = page + "<table><tr>"
|
|
@@ -84,13 +112,26 @@ def html(page, json):
|
|
continue
|
|
continue
|
|
link = links[website]
|
|
link = links[website]
|
|
page = page + """
|
|
page = page + """
|
|
- <th><form action=\""""+link+"""\">
|
|
|
|
- <button title=\""""+link+"""\" type="submit">"""+linksfilter.get(website,website).upper()+"""</button>
|
|
|
|
- </form></th>
|
|
|
|
|
|
+
|
|
|
|
+ <!-- Here's how to do a simple button -->
|
|
|
|
+
|
|
|
|
+ <th>
|
|
|
|
+ <form action=\""""+link+"""\"> <!-- You make a form with a link -->
|
|
|
|
+ <button title=\""""+link+"""\" type="submit">"""+linksfilter.get(website,website).upper()+"""</button> <!-- And you activare that form with a button -->
|
|
|
|
+ </form>
|
|
|
|
+ </th>
|
|
"""
|
|
"""
|
|
|
|
|
|
page = page + "</tr></table>"
|
|
page = page + "</tr></table>"
|
|
|
|
|
|
|
|
+ page = page + """
|
|
|
|
+
|
|
|
|
+ <!-- Details are those little collapsable things that I like to
|
|
|
|
+ use very much. It's very simple really. Just read the code
|
|
|
|
+ carefully and you will get it -->
|
|
|
|
+
|
|
|
|
+ """
|
|
|
|
+
|
|
# Details
|
|
# Details
|
|
|
|
|
|
categories = {"generic_name":"Features",
|
|
categories = {"generic_name":"Features",
|
|
@@ -128,8 +169,8 @@ def html(page, json):
|
|
matchtext = "<i>( "+str(matches)+" )</i>"
|
|
matchtext = "<i>( "+str(matches)+" )</i>"
|
|
else:
|
|
else:
|
|
matchtext = ""
|
|
matchtext = ""
|
|
- page = page + "<details>"
|
|
|
|
- page = page +"<summary>"+categories[c]+": "+matchtext+"</summary>"
|
|
|
|
|
|
+ page = page + "\n\n <details>"
|
|
|
|
+ page = page +"\n <summary>"+categories[c]+": "+matchtext+"</summary>"
|
|
|
|
|
|
for i in l:
|
|
for i in l:
|
|
matchtext = ""
|
|
matchtext = ""
|
|
@@ -138,10 +179,29 @@ def html(page, json):
|
|
matchtext = " <i>( match )</i> "
|
|
matchtext = " <i>( match )</i> "
|
|
if i+".html" in allfiles:
|
|
if i+".html" in allfiles:
|
|
datapage = open("data/"+folder+"/"+i+".html")
|
|
datapage = open("data/"+folder+"/"+i+".html")
|
|
- page = page + "<details><summary> "+matchtext+i+"</summary><span><p>"+datapage.read()+"<p></span></details>"
|
|
|
|
|
|
+ page = page + """
|
|
|
|
+
|
|
|
|
+ <!-- Just so happened that about \""""+i+"""\" we had a file
|
|
|
|
+ in data/"""+folder+""" folder. So why not make a detail inside a detail,
|
|
|
|
+ a detail-sception, so to speak. And add the text of explanation into it. -->
|
|
|
|
+
|
|
|
|
+ """
|
|
|
|
+ page = page + "<details>\n"
|
|
|
|
+ page = page + " <summary> "+matchtext+i+"</summary>\n"
|
|
|
|
+ page = page + " <span>\n <p>\n"
|
|
|
|
+ page = page + " " + datapage.read()+"\n"
|
|
|
|
+ page = page + " </p>\n </span>\n </details>"
|
|
else:
|
|
else:
|
|
- page = page + " "+matchtext+i+"<br>"
|
|
|
|
- page = page + "<span><br></span></details>"
|
|
|
|
|
|
+ page = page + "\n <span> "+matchtext+i+"</span>\n <br>\n"
|
|
|
|
+ page = page + """
|
|
|
|
+
|
|
|
|
+ <!-- Just a tiny space after all the spans. So no to feel
|
|
|
|
+ too crowded, so to speak -->
|
|
|
|
+ <span><br></span>
|
|
|
|
+
|
|
|
|
+ </details>
|
|
|
|
+
|
|
|
|
+ """
|
|
|
|
|
|
|
|
|
|
return page
|
|
return page
|
|
@@ -150,7 +210,17 @@ def suggestions(page, json):
|
|
|
|
|
|
# This function will render suggestions
|
|
# This function will render suggestions
|
|
|
|
|
|
- page = page + "<h1>Free Competitors:</h1>"
|
|
|
|
|
|
+ page = page + """
|
|
|
|
+
|
|
|
|
+ <!-- ===========================================================
|
|
|
|
+
|
|
|
|
+ This is where ther actual competitors are starting to show!!!
|
|
|
|
+
|
|
|
|
+ ============================================================ -->
|
|
|
|
+
|
|
|
|
+ <h1>Free Competitors:</h1>
|
|
|
|
+
|
|
|
|
+ """
|
|
|
|
|
|
found = search.suggest(json)
|
|
found = search.suggest(json)
|
|
|
|
|
|
@@ -170,11 +240,28 @@ def suggestions(page, json):
|
|
frac = 0
|
|
frac = 0
|
|
|
|
|
|
if frac < 20 and not more: # Below 40% features match
|
|
if frac < 20 and not more: # Below 40% features match
|
|
- page = page + """<hr><details>
|
|
|
|
- <summary><h1 title="Click to show more / less.">Problematic Competitors:</h1></summary>"""
|
|
|
|
|
|
+ page = page + """
|
|
|
|
+
|
|
|
|
+ <!-- Sometimes the suggestion is not very good. Below 40%
|
|
|
|
+ of suggestion score. But it still kind of valid. So we
|
|
|
|
+ want to put it into the page. Only when the user clicks
|
|
|
|
+ something. Why not using the same old details? -->
|
|
|
|
+
|
|
|
|
+ <hr>
|
|
|
|
+ <details>
|
|
|
|
+ <summary><h1 title="Click to show more / less.">Problematic Competitors:</h1></summary>
|
|
|
|
+
|
|
|
|
+ """
|
|
more = True
|
|
more = True
|
|
|
|
+
|
|
|
|
+ page = page +"""
|
|
|
|
|
|
- page = page + "<hr><br>Suggestion score: " + str(frac) + "%"
|
|
|
|
|
|
+ <hr>
|
|
|
|
+<!-- ================================================================== -->
|
|
|
|
+
|
|
|
|
+ """
|
|
|
|
+
|
|
|
|
+ page = page + "<br>Suggestion score: " + str(frac) + "%"
|
|
page = html(page, i[-1])
|
|
page = html(page, i[-1])
|
|
|
|
|
|
if more:
|
|
if more:
|
|
@@ -186,12 +273,21 @@ def search_widget(page, address):
|
|
# Adds a search bar to the page
|
|
# Adds a search bar to the page
|
|
|
|
|
|
page = page + """
|
|
page = page + """
|
|
|
|
+ <!-- Search widget! This widget makes it possible to implement
|
|
|
|
+ a search feature without using a single line of JavaScript code.
|
|
|
|
+ In HTML, there is an input field that we can use. If we pare it
|
|
|
|
+ with a button into a <form>, we can get a button that activates
|
|
|
|
+ the search. -->
|
|
|
|
+
|
|
<form action="""
|
|
<form action="""
|
|
page = page + address
|
|
page = page + address
|
|
page = page + """search method="GET">
|
|
page = page + """search method="GET">
|
|
<input type="text" name="item" class="search" placeholder="Name of Software">
|
|
<input type="text" name="item" class="search" placeholder="Name of Software">
|
|
<button type="submit">Search</button>
|
|
<button type="submit">Search</button>
|
|
</form>
|
|
</form>
|
|
|
|
+
|
|
|
|
+ <!-- And that's it for the search widget -->
|
|
|
|
+
|
|
"""
|
|
"""
|
|
#page = page.format(ADDRESS)
|
|
#page = page.format(ADDRESS)
|
|
|
|
|
|
@@ -201,15 +297,31 @@ def source_code_link(page):
|
|
|
|
|
|
# Adds a source code link
|
|
# Adds a source code link
|
|
|
|
|
|
- page = page + "<br><br><hr><p>This website is under the GNU AGPL license.</p>"
|
|
|
|
page = page + """
|
|
page = page + """
|
|
|
|
+
|
|
|
|
+ <!-- This the the footer of every page -->
|
|
|
|
+
|
|
|
|
+ <br>
|
|
|
|
+ <br>
|
|
|
|
+
|
|
|
|
+ <hr>
|
|
|
|
+
|
|
|
|
+ <p>This website is under the GNU AGPL license.</p>
|
|
|
|
+
|
|
|
|
+ <!-- As always I want to add a bit of CSS to make tables
|
|
|
|
+ invisible -->
|
|
|
|
+
|
|
<style>
|
|
<style>
|
|
- table, th, td {
|
|
|
|
- border-right:none;
|
|
|
|
- border-left:none;
|
|
|
|
- border-bottom:none;
|
|
|
|
- border-top:none
|
|
|
|
- }</style>
|
|
|
|
|
|
+ table, th, td {
|
|
|
|
+ border-right:none;
|
|
|
|
+ border-left:none;
|
|
|
|
+ border-bottom:none;
|
|
|
|
+ border-top:none
|
|
|
|
+ }
|
|
|
|
+ </style>
|
|
|
|
+
|
|
|
|
+ <!-- This is self explanatory ( if you read most of the page ) -->
|
|
|
|
+
|
|
<table><tr>
|
|
<table><tr>
|
|
|
|
|
|
<th><form action=https://notabug.org/jyamihud/FreeCompetitors>
|
|
<th><form action=https://notabug.org/jyamihud/FreeCompetitors>
|
|
@@ -230,7 +342,16 @@ def source_code_link(page):
|
|
|
|
|
|
<th><form action=https://notabug.org/jyamihud/FreeCompetitors/issues/24>
|
|
<th><form action=https://notabug.org/jyamihud/FreeCompetitors/issues/24>
|
|
<button title="Report a mistake in data about software." type="submit">MISTAKE?</button>
|
|
<button title="Report a mistake in data about software." type="submit">MISTAKE?</button>
|
|
- </form></th></tr></table><br><br>
|
|
|
|
|
|
+ </form></th></tr>
|
|
|
|
+
|
|
|
|
+ </table>
|
|
|
|
+
|
|
|
|
+ <br>
|
|
|
|
+ <br>
|
|
|
|
+
|
|
|
|
+ <!-- And this was the page of Free Competitors. No Javascript.
|
|
|
|
+ No crap. No trackers. No nothing. And still works. Take that
|
|
|
|
+ Google!!! -->
|
|
|
|
|
|
|
|
|
|
"""
|
|
"""
|