Licenses Support Inside Articles Metadata

This commit is contained in:
BlenderDumbass 2024-11-27 00:33:53 +02:00
parent 1a9d3d0b39
commit a4759785cb
10 changed files with 86 additions and 26 deletions

BIN
icons/agpl3.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5 KiB

BIN
icons/cc-by-sa.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.7 KiB

BIN
icons/cc-by.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

BIN
icons/cc0.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

BIN
icons/gpl3-or-later.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

BIN
icons/gpl3.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

BIN
icons/lgpl3.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

View file

@ -130,3 +130,38 @@ def IDcolor(ID):
c = IDColors[ID] c = IDColors[ID]
return c return c
# Licenses for stuff
Licenses = {
"cc0":{
"name":"CC0 Public Domain",
"link":"https://creativecommons.org/publicdomain/zero/1.0/"
},
"cc-by":{
"name":"Creative Commons Attribution",
"link":"https://creativecommons.org/licenses/by/4.0/"
},
"cc-by-sa":{
"name":"Creative Commons Attribution Share-Alike",
"link":"https://creativecommons.org/licenses/by-sa/4.0/"
},
"gpl3":{
"name":"GNU General Public License Version 3",
"link":"https://www.gnu.org/licenses/gpl.html"
},
"lgpl3":{
"name":"GNU Lesser General Public License Version 3",
"link":"https://www.gnu.org/licenses/lgpl.html"
},
"agpl":{
"name":"GNU Affero General Public License Version 3",
"link":"https://www.gnu.org/licenses/agpl.html"
},
"gpl3-or-later":{
"name":"GNU General Public License Version 3 or any later version",
"link":"https://www.gnu.org/licenses/"
}
}

View file

@ -469,6 +469,14 @@ def ArticlePage(server, url):
""" """
html = html + '</div>' html = html + '</div>'
License = Articles.get(article, {}).get("license", "")
if License:
html = html + '<div class="dark_box"> <center>'
html = html + 'License:<br><img style="vertical-align: middle" src="/icon/'+License+'"> '
html = html + '<a href="'+Licenses.get(License, {}).get("link")+'">'
html = html + Licenses.get(License, {}).get("name")+'</a>'
html = html + '</center></div>'
# Audio recording of the article # Audio recording of the article
recording = Articles.get(article, {}).get("recording", "") recording = Articles.get(article, {}).get("recording", "")
@ -1120,26 +1128,27 @@ def Graph(server, url):
except: except:
article = {} article = {}
dates = article.get("views", {}).get("dates", {})
largest = max(dates.values())
dateformat = "%Y-%m-%d" dateformat = "%Y-%m-%d"
startdate = datetime.strptime(sorted(list(dates.keys()), reverse=True)[0], dateformat) dates = article.get("views", {}).get("dates", {})
enddate = datetime.strptime(sorted(list(dates.keys()), reverse=True)[-1], dateformat) if dates:
largest = max(dates.values())
alldays = int((startdate - enddate).days)
for n, date in enumerate(sorted(dates, reverse=True)):
amount = dates[date] startdate = datetime.strptime(sorted(list(dates.keys()), reverse=True)[0], dateformat)
width = 100 / (alldays+1) enddate = datetime.strptime(sorted(list(dates.keys()), reverse=True)[-1], dateformat)
height = 60 * (amount / largest)
alldays = int((startdate - enddate).days)
for n, date in enumerate(sorted(dates, reverse=True)):
amount = dates[date]
width = 100 / (alldays+1)
height = 60 * (amount / largest)
cd = datetime.strptime(date, dateformat)
nd = int((startdate - cd).days)
html = html + '<div style="top:'+str(60-height)+'%;right:'+str((nd)*(width))+'%; width:'+str(max(width-0.5,0.5))+'%; height:'+str(height)+'%" title="'+str(date)+' - '+str(amount)+' views" class="graph_line"></div>\n'
cd = datetime.strptime(date, dateformat)
nd = int((startdate - cd).days)
html = html + '<div style="top:'+str(60-height)+'%;right:'+str((nd)*(width))+'%; width:'+str(max(width-0.5,0.5))+'%; height:'+str(height)+'%" title="'+str(date)+' - '+str(amount)+' views" class="graph_line"></div>\n'
# Saving the view # Saving the view
cookies = [server.cookie] cookies = [server.cookie]
@ -1155,11 +1164,15 @@ def Graph(server, url):
cookies.append(cookie) cookies.append(cookie)
for cookie in cookies: for cookie in cookies:
if cookie not in article.get("views", {}).get("viewers", []): if cookie and cookie not in article.get("views", {}).get("viewers", []):
article["views"]["amount"] += 1 article["views"]["amount"] += 1
article["views"]["viewers"].append(cookie) article["views"]["viewers"].append(cookie)
dates = article["views"]["dates"]
date = datetime.now().strftime(dateformat)
dates[date] = dates.get(date, 0) + 1
server.newview = True server.newview = True
with open(Set.Folder()+"/tabs"+url+"/metadata.json", "w") as save: with open(Set.Folder()+"/tabs"+url+"/metadata.json", "w") as save:

View file

@ -28,16 +28,28 @@ class handler(BaseHTTPRequestHandler):
q = clr["tbbl"] q = clr["tbbl"]
b = clr["tbbl"] b = clr["tbbl"]
if self.newview: #print(dir(self))
b = clr["bold"]+clr["tbrd"]
for i in self.parsed: try:
if i != "password": if self.newview:
q = q + "[ "+i+" : "+self.parsed[i][0]+" ] " b = clr["bold"]+clr["tbrd"]
else:
q = q + "[ "+i+" : ******* ] " for i in self.parsed:
if i != "password":
q = q + "[ "+i+" : "+self.parsed[i][0]+" ] "
else:
q = q + "[ "+i+" : ******* ] "
toprint = consoleForm(self.cookie)+" "+b+"[ "+str(datetime.datetime.now())+" ] "+self.path+" "+q cookie = self.cookie
toprint = consoleForm(cookie)+" "+b+"[ "+str(datetime.datetime.now())+" ] "+self.path+" "+q
except:
cookie = None
toprint = consoleForm(cookie)+" "+b+"[ "+str(datetime.datetime.now())+" ] "+self.requestline
print(toprint) print(toprint)
folder = Set.Folder() folder = Set.Folder()