Graph cookie fix ( better counting of views )
This commit is contained in:
parent
a87eb14ebc
commit
1467421c13
2 changed files with 22 additions and 2 deletions
|
@ -523,6 +523,10 @@ def ArticlePage(server, url):
|
||||||
if author:
|
if author:
|
||||||
html = html + '<center>'+User( author )+'</center>'
|
html = html + '<center>'+User( author )+'</center>'
|
||||||
|
|
||||||
|
timestamp = Articles.get(article, {}).get("timestamp", "")
|
||||||
|
arttime = str(datetime.fromtimestamp(timestamp).strftime("%B %d, %Y"))
|
||||||
|
html = html + "<br><small><center>"+str(arttime)+"</center></small>"
|
||||||
|
|
||||||
# Page views
|
# Page views
|
||||||
# Views are calculated using an iframe which only loads when the page is
|
# Views are calculated using an iframe which only loads when the page is
|
||||||
# rendered in a browser. It is also looking at whether the same cookie renders
|
# rendered in a browser. It is also looking at whether the same cookie renders
|
||||||
|
@ -1357,6 +1361,16 @@ def User(username, stretch=False):
|
||||||
|
|
||||||
def Graph(server, url):
|
def Graph(server, url):
|
||||||
|
|
||||||
|
# Since /graph/ is used to count views
|
||||||
|
# we need the cookie to be generated and
|
||||||
|
# used by the user's browser before we load
|
||||||
|
# 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:
|
||||||
|
Redirect(server, server.path, time=2)
|
||||||
|
|
||||||
user = validate(server.cookie)
|
user = validate(server.cookie)
|
||||||
|
|
||||||
html = """
|
html = """
|
||||||
|
@ -1654,9 +1668,9 @@ def AccessDenied(server):
|
||||||
|
|
||||||
###
|
###
|
||||||
|
|
||||||
def Redirect(server, url):
|
def Redirect(server, url, time=0):
|
||||||
|
|
||||||
html = """<meta http-equiv="Refresh" content="0; url='"""+url+"""'" />"""
|
html = """<meta http-equiv="Refresh" content=\""""+str(time)+"""; url='"""+url+"""'" />"""
|
||||||
send(server, html, 200)
|
send(server, html, 200)
|
||||||
|
|
||||||
def Login(server):
|
def Login(server):
|
||||||
|
|
|
@ -117,6 +117,12 @@ class handler(BaseHTTPRequestHandler):
|
||||||
self.cookie = self.headers.get("Cookie")
|
self.cookie = self.headers.get("Cookie")
|
||||||
if self.cookie: self.cookie = self.cookie[-50:]
|
if self.cookie: self.cookie = self.cookie[-50:]
|
||||||
|
|
||||||
|
# ignore = ["/rss"]
|
||||||
|
|
||||||
|
# if not self.cookie and not self.path.startswith(tuple(ignore)):
|
||||||
|
# Render.Redirect(self, self.path)
|
||||||
|
# return
|
||||||
|
|
||||||
self.newview = False
|
self.newview = False
|
||||||
|
|
||||||
categories = list(Render.tabs().keys())
|
categories = list(Render.tabs().keys())
|
||||||
|
|
Loading…
Add table
Reference in a new issue