RSS wasn't properly generated. Fixed!
This commit is contained in:
parent
161eb85e29
commit
6b5d67f429
2 changed files with 90 additions and 11 deletions
|
@ -4,6 +4,7 @@
|
|||
import os
|
||||
import json
|
||||
import time
|
||||
import email
|
||||
import random
|
||||
import hashlib
|
||||
import urllib.parse
|
||||
|
@ -14,9 +15,12 @@ from modules import Set
|
|||
from modules import markdown
|
||||
from modules.Common import *
|
||||
|
||||
|
||||
|
||||
KnownCookies = []
|
||||
RecentArticles = {}
|
||||
RefferedArticles = {}
|
||||
ProblematicRefreshes = []
|
||||
|
||||
def guess_type(path):
|
||||
|
||||
|
@ -1267,7 +1271,58 @@ def EditorPage(server):
|
|||
|
||||
<img style="vertical-align: middle" src="/icon/mus">
|
||||
<input class="button" style="width:90%" name="recording" placeholder="Link To Sound Recording ( Optional )" value='"""+article.get("recording", "").replace("'", "'")+"""'>
|
||||
|
||||
"""
|
||||
|
||||
|
||||
# Optional release options
|
||||
|
||||
if rank(user.get("username","")) == 0:
|
||||
html = html + """
|
||||
|
||||
<details>
|
||||
<summary class="button">
|
||||
<img alt="[icon unlock]" style="vertical-align: middle" src="/icon/unlock">
|
||||
Unlock
|
||||
</summary>
|
||||
|
||||
<div class="dark_box">
|
||||
<br>
|
||||
<br>
|
||||
<center><small>
|
||||
For unlockable files that will be published after a certain statistics is reached.
|
||||
</small></center>
|
||||
<br><br>
|
||||
|
||||
<img alt="[icon file]" style="vertical-align: middle" src="/icon/file">
|
||||
<input class="button" style="width:90%" name="unlock_file" placeholder="Unlocked File ( on the server )">
|
||||
<br>
|
||||
|
||||
<img alt="[icon link]" style="vertical-align: middle" src="/icon/link">
|
||||
<input class="button" style="width:90%" name="unlock_file" placeholder="API to check">
|
||||
<br>
|
||||
|
||||
<img alt="[icon checlist]" style="vertical-align: middle" src="/icon/checklist">
|
||||
<input class="button" style="width:90%" name="unlock_file" placeholder="Key To Look For ( split with / for nested deep data )">
|
||||
<br>
|
||||
|
||||
<img alt="[icon ok]" style="vertical-align: middle" src="/icon/ok">
|
||||
<input class="button" style="width:90%" name="unlock_file" placeholder="Goal ( should be a number )">
|
||||
<br>
|
||||
|
||||
<img alt="[icon scene]" style="vertical-align: middle" src="/icon/scene">
|
||||
<input class="button" style="width:90%" name="unlock_file" placeholder="Statistic's Name">
|
||||
<br>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
</details>
|
||||
"""
|
||||
|
||||
|
||||
html = html + """
|
||||
|
||||
<br>
|
||||
<center>
|
||||
|
@ -1276,6 +1331,7 @@ def EditorPage(server):
|
|||
<textarea class="toot" rows="5" style="width:95%" name="description" placeholder="Description ( Optional )">"""+article.get("description", "")+"""</textarea>
|
||||
</center>
|
||||
|
||||
|
||||
<button class="button" type="submit">
|
||||
<img style="vertical-align: middle" src="/icon/scene_new">
|
||||
Publish
|
||||
|
@ -1288,6 +1344,7 @@ def EditorPage(server):
|
|||
html = html + LoginButton(server)
|
||||
|
||||
send(server, html, 200)
|
||||
|
||||
|
||||
###
|
||||
|
||||
|
@ -1325,7 +1382,7 @@ def ArticlePreview(article, Tabs, cookie=""):
|
|||
html = html + '<img alt="[icon '+tab+']" src="/icon/'+Tabs.get(tab, {}).get("icon", "folder")+'" style="vertical-align: middle">'
|
||||
html = html + article.get("title", "")+"</h1></a>"+sup+"\n"
|
||||
|
||||
if "thumbnail" in article:
|
||||
if article.get("thumbnail"):
|
||||
html = html + '<center><a href="'+url+'"><img alt="[thumbnail]" src="'+article["thumbnail"]+'"></a></center>'
|
||||
|
||||
author = article.get("author", "")
|
||||
|
@ -1401,11 +1458,17 @@ def Graph(server, url):
|
|||
# it, since a lot of people might just click
|
||||
# the link once. In which case the entire page
|
||||
# including graph loads before the cookie.
|
||||
|
||||
|
||||
if not server.cookie:
|
||||
|
||||
if not server.cookie and server.headers.get("user-agent", "") not in ProblematicRefreshes:
|
||||
Redirect(server, server.path)
|
||||
ProblematicRefreshes.append(server.headers.get("user-agent", ""))
|
||||
return
|
||||
|
||||
if server.headers.get("user-agent", "") in ProblematicRefreshes:
|
||||
ProblematicRefreshes.remove(server.headers.get("user-agent", ""))
|
||||
|
||||
# Sometimes scrapers try to load graph without
|
||||
# loading the article first. We don't want to count
|
||||
# it as a view.
|
||||
|
@ -1413,6 +1476,7 @@ def Graph(server, url):
|
|||
print(consoleForm(server.cookie), "Article wasn't loaded, scrapers!")
|
||||
AccessDenied(server)
|
||||
return
|
||||
|
||||
|
||||
|
||||
user = validate(server.cookie)
|
||||
|
@ -2390,9 +2454,7 @@ def RSS(server):
|
|||
|
||||
title = account.get("title", author)+" at: "+title
|
||||
|
||||
rss = """
|
||||
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
rss = """<?xml version="1.0" encoding="UTF-8"?>
|
||||
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
|
||||
<channel>
|
||||
|
||||
|
@ -2419,14 +2481,15 @@ def RSS(server):
|
|||
|
||||
pubDate = Articles[article].get("timestamp", 0)
|
||||
pubDate = datetime.fromtimestamp(pubDate)
|
||||
pubDate = pubDate.strftime('%a, %d %b %H:%M:%S')+" -0000"
|
||||
pubDate = email.utils.format_datetime(pubDate)
|
||||
|
||||
rss = rss + """
|
||||
<item>
|
||||
|
||||
<title>"""+Articles[article].get("title", article)+"""</title>
|
||||
<title>"""+Articles[article].get("title", article).replace("&", "&")+"""</title>
|
||||
<link>https://"""+config.get("domain", "example.com")+Articles[article].get("url", "")+"""</link>
|
||||
<description><![CDATA["""+markdown.convert(Articles[article].get("description", article), False)+"""]]></description>
|
||||
<guid>https://"""+config.get("domain", "example.com")+Articles[article].get("url", "")+"""</guid>
|
||||
<description><![CDATA["""+markdown.convert(Articles[article].get("description", article), False, fullpath=True)+"""]]></description>
|
||||
<pubDate>"""+pubDate+"""</pubDate>
|
||||
|
||||
</item>
|
||||
|
|
|
@ -399,8 +399,13 @@ def search_convert(s):
|
|||
r = r + i
|
||||
return r
|
||||
|
||||
def convert(filename, isfile=True):
|
||||
def convert(filename, isfile=True, fullpath=True):
|
||||
|
||||
|
||||
if fullpath:
|
||||
from modules import Set
|
||||
config = Set.Load()
|
||||
domain = config.get("domain", "")
|
||||
|
||||
textReturn = ""
|
||||
if isfile:
|
||||
|
@ -458,11 +463,17 @@ def convert(filename, isfile=True):
|
|||
textReturn = textReturn + '\n<br></div><br><div class="dark_box"><br><a href="#'+search_convert(i[-1].replace("#", "").replace("\n", "")[1:])+'"><h'+str(i[0])+' id="'+search_convert(i[-1].replace("#", "").replace("\n", "")[1:])+'">' + i[-1].replace("#", "") +"</h"+str(i[0])+"></a><br><br>"
|
||||
|
||||
elif i[0] == "image_link":
|
||||
|
||||
if fullpath and i[-1].startswith("/"):
|
||||
i[-1] = "https://"+domain+i[-1]
|
||||
|
||||
textReturn = textReturn + '\n<center><a href="'+i[-1]+'">'+'<img src="'+i[1]+'">'+"</a></center>"
|
||||
|
||||
elif i[0] == "image":
|
||||
|
||||
|
||||
|
||||
if fullpath and i[-1].startswith("/"):
|
||||
i[-1] = "https://"+domain+i[-1]
|
||||
|
||||
if i[1] == "audio":
|
||||
try:
|
||||
|
@ -486,9 +497,14 @@ def convert(filename, isfile=True):
|
|||
|
||||
elif i[0] == "link":
|
||||
|
||||
|
||||
if not i[-1]:
|
||||
i[-1] = "/search?text="+urllib.parse.quote_plus(i[1])
|
||||
|
||||
|
||||
if fullpath and i[-1].startswith("/"):
|
||||
i[-1] = "https://"+domain+i[-1]
|
||||
|
||||
|
||||
textReturn = textReturn + '<a href="'+i[-1]+'">'+i[1]+"</a>"
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue