rss mime type

main
Bob Mottram 2020-02-27 20:33:49 +00:00
parent 44d027e84f
commit 867be4d249
1 changed files with 52 additions and 50 deletions

102
daemon.py
View File

@ -1025,7 +1025,7 @@ class PubServer(BaseHTTPRequestHandler):
maxPostsInRSSFeed,1) maxPostsInRSSFeed,1)
if msg!=None: if msg!=None:
msg=msg.encode() msg=msg.encode()
self._set_headers('application/rss+xml',len(msg),cookie) self._set_headers('text/xml',len(msg),cookie)
self._write(msg) self._write(msg)
return return
self._404() self._404()
@ -1036,61 +1036,63 @@ class PubServer(BaseHTTPRequestHandler):
self.path=='/blog/' or \ self.path=='/blog/' or \
self.path=='/blogs' or \ self.path=='/blogs' or \
self.path=='/blogs/'): self.path=='/blogs/'):
if not self.server.session: if '/rss.xml' not in self.path:
self.server.session= \ if not self.server.session:
createSession(self.server.useTor) self.server.session= \
msg=htmlBlogView(authorized, \ createSession(self.server.useTor)
self.server.session, \ msg=htmlBlogView(authorized, \
self.server.baseDir, \ self.server.session, \
self.server.httpPrefix, \ self.server.baseDir, \
self.server.translate, \ self.server.httpPrefix, \
self.server.domain,self.server.port, \ self.server.translate, \
maxPostsInBlogsFeed) self.server.domain,self.server.port, \
if msg!=None: maxPostsInBlogsFeed)
msg=msg.encode() if msg!=None:
self._set_headers('text/html',len(msg),cookie) msg=msg.encode()
self._write(msg) self._set_headers('text/html',len(msg),cookie)
self._write(msg)
return
self._404()
return return
self._404()
return
# show a particular page of blog entries # show a particular page of blog entries
# for a particular account # for a particular account
if htmlGET and self.path.startswith('/blog/'): if htmlGET and self.path.startswith('/blog/'):
pageNumber=1 if '/rss.xml' not in self.path:
nickname=self.path.split('/blog/')[1] pageNumber=1
if '/' in nickname: nickname=self.path.split('/blog/')[1]
nickname=nickname.split('/')[0] if '/' in nickname:
if '?' in nickname: nickname=nickname.split('/')[0]
nickname=nickname.split('?')[0] if '?' in nickname:
if '?page=' in self.path: nickname=nickname.split('?')[0]
pageNumberStr=self.path.split('?page=')[1] if '?page=' in self.path:
if '?' in pageNumberStr: pageNumberStr=self.path.split('?page=')[1]
pageNumberStr=pageNumberStr.split('?')[0] if '?' in pageNumberStr:
if pageNumberStr.isdigit(): pageNumberStr=pageNumberStr.split('?')[0]
pageNumber=int(pageNumberStr) if pageNumberStr.isdigit():
if pageNumber<1: pageNumber=int(pageNumberStr)
pageNumber=1 if pageNumber<1:
elif pageNumber>10: pageNumber=1
pageNumber=10 elif pageNumber>10:
if not self.server.session: pageNumber=10
self.server.session= \ if not self.server.session:
createSession(self.server.useTor) self.server.session= \
msg=htmlBlogPage(authorized, \ createSession(self.server.useTor)
self.server.session, \ msg=htmlBlogPage(authorized, \
self.server.baseDir, \ self.server.session, \
self.server.httpPrefix, \ self.server.baseDir, \
self.server.translate, \ self.server.httpPrefix, \
nickname, \ self.server.translate, \
self.server.domain,self.server.port, \ nickname, \
maxPostsInBlogsFeed,pageNumber) self.server.domain,self.server.port, \
if msg!=None: maxPostsInBlogsFeed,pageNumber)
msg=msg.encode() if msg!=None:
self._set_headers('text/html',len(msg),cookie) msg=msg.encode()
self._write(msg) self._set_headers('text/html',len(msg),cookie)
self._write(msg)
return
self._404()
return return
self._404()
return
if htmlGET and '/users/' in self.path: if htmlGET and '/users/' in self.path:
# show the person options screen with view/follow/block/report # show the person options screen with view/follow/block/report