diff --git a/modules/render.py b/modules/render.py
index 3a2cda3..ba16c7e 100644
--- a/modules/render.py
+++ b/modules/render.py
@@ -13,42 +13,36 @@ from modules import missing
def html(page, json):
-
# This function adds a rendering of the json into the page
free = search.is_free(json)
- name = json.get("names",["Unknown"])[0]
+ name = json.get("names", ["Unknown"])[0]
page = page + """
-
-
-
"""
- page = page + "\n "
- page = page + "\n "
+ page = page + "\n "
+ page = page + "\n "
try:
- page = page + '\n \n'
+ page = page + '\n '
except:
pass
- page = page + " "+ name +" \n"
+ page = page + "" + name + "\n"
page = page + "
\n \n\n"
page = page + """
-
-
"""
-
+
# Few words about it
- comment = json.get("comment","")
+ comment = json.get("comment", "")
not_foss = ['open source', 'open-source']
if "open source" or "open-source" in comment.lower():
# Well... Here is a thing. Free Software, not open source.
@@ -56,74 +50,69 @@ def html(page, json):
# In case it has a slash in it.
if where == -1:
where = comment.lower().find("open-source")
- ops = comment[where:where+11]
+ ops = comment[where:where + 11]
if ops:
comment = comment.replace(ops,
- ""+ops+"")
- page = page + "\n
\n "+comment+"\n
\n\n"
+ "" + ops + "")
+ page = page + "\n
\n\n"
# I want to show nothing else from if it's proprietary
issues_files = list(os.listdir("data/issues"))
if "issues" in json and json["issues"]:
l = json.get("issues", [])
- page = page +"Anti-Features / Problems:
"
+ page = page + "Anti-Features / Problems:
"
+ page = page + ""
for i in l:
- if i+".html" not in issues_files:
- page = page + " "+i+"
"
+ if i + ".html" not in issues_files:
+ page = page + "- " + i + "
"
else:
- page = page + ''
- page = page + "  "+i+"
"
- issuefile = open("data/issues/"+i+".html")
- page = page + ""+issuefile.read()+"
"
- page = page + " "
+ page = page + ''
+ page = page + "" + i + "
"
+ issuefile = open("data/issues/" + i + ".html")
+ page = page + "" + issuefile.read() + "
"
+ page = page + " "
+
+ page = page + "
"
+
if not free:
return page
-
# Links
-
page = page + """
-
-
"""
-
- linksfilter = {"git":"source code","fsd":"Free Software Directory"}
+
+ linksfilter = {"git": "source code", "fsd": "Free Software Directory"}
links = json.get("links", {})
for website in links:
if website in ["icon"]:
continue
link = links[website]
page = page + """
-
- """+linksfilter.get(website,website).upper()+"""
-
- """
+ """ + linksfilter.get(website,
+ website).upper() + """
+ """
page = page + """
-
-
"""
-
- # 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",
- "interface":"Interface",
- "languages":"Programming Languages"}
+ # 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",
+ "interface": "Interface",
+ "languages": "Programming Languages"}
for c in categories:
-
l = json.get(c, [])
if not l:
continue
@@ -134,70 +123,64 @@ def html(page, json):
for folder in alldata:
if c.startswith(folder):
try:
- allfiles = list(os.listdir("data/"+folder))
+ allfiles = list(os.listdir("data/" + folder))
break
except:
pass
+
# Count matches
matches = 0
for i in l:
if i.startswith("*"):
matches += 1
+
if matches:
- matchtext = "( "+str(matches)+" )"
+ matchtext = "( " + str(matches) + " )"
else:
matchtext = ""
+
page = page + "\n\n "
- page = page +"\n "+categories[c]+": "+matchtext+"
"
+ page = page + "\n " + categories[c] + ": " + matchtext + "
"
for i in l:
matchtext = ""
if i.startswith("*"):
i = i[1:]
matchtext = " ( match ) "
- if i+".html" in allfiles:
- datapage = open("data/"+folder+"/"+i+".html")
+
+ if i + ".html" in allfiles:
+ datapage = open("data/" + folder + "/" + i + ".html")
page = page + """
-
-
-
- """
+
+ """
page = page + "\n"
- page = page + " "+matchtext+i+"
\n"
+ page = page + " " + matchtext + i + "
\n"
page = page + " \n \n"
- page = page + " " + datapage.read()+"\n"
+ page = page + " " + datapage.read() + "\n"
page = page + "
\n \n "
else:
- page = page + "\n "+matchtext+i+"\n
\n"
+ page = page + "\n " + matchtext + i + "\n
\n"
+
page = page + """
-
-
-
"""
-
-
+
return page
+
def suggestions(page, json):
-
# This function will render suggestions
-
page = page + """
-
-
- Free Competitors:
-
+
+
Free Competitors:
"""
found = search.suggest(json)
@@ -219,24 +202,19 @@ def suggestions(page, json):
if frac < 10 and not more: # Below 10% features match
page = page + """
-
-
- Problematic Competitors:
-
+ Problematic Competitors:
"""
more = True
page = page +"""
-
-
-
+
"""
page = progress(page, frac/100, "Suggestion score: " + str(frac) + "%")
@@ -244,80 +222,65 @@ def suggestions(page, json):
if more:
page = page + " "
+
+ page = page + "" # Close the suggestions-container
+
return page
+
def search_widget(page, address):
-
# Adds a search bar to the page
-
page = page + """
-
-
-
"""
- #page = page.format(ADDRESS)
-
+
return page
+
def source_code_link(page):
-
# Adds a source code link
-
page = page + """
-
-
-
-
- This website is under the GNU AGPL license.
-
-
-
-
-
- HOME
- SOURCE CODE
- FAQ
- BUG?
- MISSING?
- MISTAKE?
- STATS
-
-
+
+
-
-
- """
-
-
-
+ """
return page
+
def progress(page, frac, text=""):
-
# This will output a progress bar
-
page = page + """
-
-
@@ -326,27 +289,24 @@ def progress(page, frac, text=""):
"""
return page
+
def stats(page, mis=False, data=[]):
-
-
# Graph will require some math to work.
# We are going to use CSS and HTML5 to
# draw it / interact with it.
- spd = 60*60*24 # Seconds in each day
- span = max(data) - min(data) # Time of seconds between first and last entry
- days = span / spd # Time in days between first and last entry
+ spd = 60 * 60 * 24 # Seconds in each day
+ span = max(data) - min(data) # Time of seconds between first and last entry
+ days = span / spd # Time in days between first and last entry
# making sure there is at least something to show
if days < 20:
- data.append(min(data)-(spd*20))
- spd = 60*60*24
- span = max(data) - min(data)
- days = span / spd
+ data.append(min(data) - (spd * 20))
+ spd = 60 * 60 * 24
+ span = max(data) - min(data)
+ days = span / spd
-
-
- widthfrac = 100 / days # the % to use for the width of each div
+ widthfrac = 100 / days # the % to use for the width of each div
# Count how much hits happen per each day
biggest = 0
@@ -354,36 +314,38 @@ def stats(page, mis=False, data=[]):
for d in range(int(round(days))):
count = 0
for i in data:
- day = min(data) + (d*spd)
- if int(i) in range(int(day), int(day+spd)):
+ day = min(data) + (d * spd)
+ if int(i) in range(int(day), int(day + spd)):
count += 1
if count > biggest:
biggest = count
day_counts.append(count)
# Render them
- page = page +"
"
+ page = page + ""
for n, d in enumerate(day_counts):
if n == 0:
d -= 1
- dayis = min(data)+(n*spd)
- dayis = time.strftime("%Y/%m/%d", time.gmtime( dayis) )
-
- page = page + '\n'
- frac = 100-(d/biggest*99)
- page = page + '
\n\n'
-
+ dayis = min(data) + (n * spd)
+ dayis = time.strftime("%Y/%m/%d", time.gmtime(dayis))
+
+ page = page + '\n'
+ frac = 100 - (d / biggest * 99)
+ page = page + '
\n\n'
+
page = page + '\n\n\n'
# If to render missing software
# TODO: We had a list of missing software which are known of,
# but people abused this feature to add a bunch of hilarious spam.
# maybe there is a way to design this better.
-
- #if mis:
+
+ # if mis:
# page = page + missing.List_html()
-
page = source_code_link(page)
- return page
+ return page
\ No newline at end of file