Add Colour Star Support
User has 9001 of each colour star.
This commit is contained in:
1 parent
1ef8436e50
commit
b6b2016a6d
1 file changed
+14
-3
@@ -82,6 +82,10 @@ class CreatorIDFileResource(resource.Resource):
|
|||||||
return self.GenerateDetailsPage(creator, ".".join(file.split(".")[:-1])).encode("UTF-8")
|
return self.GenerateDetailsPage(creator, ".".join(file.split(".")[:-1])).encode("UTF-8")
|
||||||
elif filetype == "star":
|
elif filetype == "star":
|
||||||
path = "/".join(request.path.split("/")[3:])
|
path = "/".join(request.path.split("/")[3:])
|
||||||
|
try:
|
||||||
|
color = request.args.get('starcolor')[0] #colour of the star. can be green, red, blue, or purple.
|
||||||
|
except:
|
||||||
|
color = "yellow" #if starcolor arg doesn't exist, then its yellow. there's probably a better way to handle this, but I'm not fluent with python ;-;
|
||||||
headers = request.getAllHeaders()
|
headers = request.getAllHeaders()
|
||||||
|
|
||||||
#bad formatting
|
#bad formatting
|
||||||
@@ -97,14 +101,14 @@ class CreatorIDFileResource(resource.Resource):
|
|||||||
request.setResponseCode(403)
|
request.setResponseCode(403)
|
||||||
return "403 - Denied access\nRequest has an invalid X-Hatena-Star-Count http header"
|
return "403 - Denied access\nRequest has an invalid X-Hatena-Star-Count http header"
|
||||||
|
|
||||||
if not Database.AddStar(creator, file[:-5], amount):
|
if not Database.AddStar(creator, file[:-5], amount, color):
|
||||||
#error
|
#error
|
||||||
ServerLog.write("%s got 500 when requesting %s" % (request.getClientIP(), path), Silent)
|
ServerLog.write("%s got 500 when requesting %s" % (request.getClientIP(), path), Silent)
|
||||||
request.setResponseCode(500)
|
request.setResponseCode(500)
|
||||||
return "500 - Internal server error\nAdding the stars seem to have failed."
|
return "500 - Internal server error\nAdding the stars seem to have failed."
|
||||||
|
|
||||||
#report success
|
#report success
|
||||||
ServerLog.write("%s added %i stars to %s/%s.ppm" % (request.getClientIP(), amount, creator, file[:-5]), Silent)
|
ServerLog.write("%s added %i %s stars to %s/%s.ppm" % (request.getClientIP(), amount, color, creator, file[:-5]), Silent)
|
||||||
return "Success"
|
return "Success"
|
||||||
elif filetype == "dl":
|
elif filetype == "dl":
|
||||||
path = "/".join(request.path.split("/")[3:])
|
path = "/".join(request.path.split("/")[3:])
|
||||||
@@ -149,7 +153,10 @@ class CreatorIDFileResource(resource.Resource):
|
|||||||
#Stars:
|
#Stars:
|
||||||
name = "Stars"
|
name = "Stars"
|
||||||
content = u'<a href="http://flipnote.hatena.com/ds/v2-xx/movie/%s/%s.htm?mode=stardetail"><span class="star0c">\u2605</span> <span class="star0">%s</span></a>' % (CreatorID, filename, flipnote[2])#yellow stars
|
content = u'<a href="http://flipnote.hatena.com/ds/v2-xx/movie/%s/%s.htm?mode=stardetail"><span class="star0c">\u2605</span> <span class="star0">%s</span></a>' % (CreatorID, filename, flipnote[2])#yellow stars
|
||||||
#todo: add other stars
|
content += u'<br/><a href="http://flipnote.hatena.com/ds/v2-xx/movie/%s/%s.htm?mode=stardetail"><span class="star1c">\u2605</span> <span class="star1">%s</span></a>' % (CreatorID, filename, flipnote[3])#green stars
|
||||||
|
content += u'<br/><a href="http://flipnote.hatena.com/ds/v2-xx/movie/%s/%s.htm?mode=stardetail"><span class="star2c">\u2605</span> <span class="star2">%s</span></a>' % (CreatorID, filename, flipnote[4])#red stars
|
||||||
|
content += u'<br/><a href="http://flipnote.hatena.com/ds/v2-xx/movie/%s/%s.htm?mode=stardetail"><span class="star3c">\u2605</span> <span class="star3">%s</span></a>' % (CreatorID, filename, flipnote[5])#blue stars
|
||||||
|
content += u'<br/><a href="http://flipnote.hatena.com/ds/v2-xx/movie/%s/%s.htm?mode=stardetail"><span class="star4c">\u2605</span> <span class="star4">%s</span></a>' % (CreatorID, filename, flipnote[6])#purple stars
|
||||||
Entries.append(PageEntryTemplate.replace("%%Name%%", name).replace("%%Content%%", content))
|
Entries.append(PageEntryTemplate.replace("%%Name%%", name).replace("%%Content%%", content))
|
||||||
|
|
||||||
#Views:
|
#Views:
|
||||||
@@ -182,6 +189,10 @@ DetailsPageTemplate = """<html>
|
|||||||
<title>Flipnote by %%Username%%</title>
|
<title>Flipnote by %%Username%%</title>
|
||||||
<meta name="upperlink" content="http://flipnote.hatena.com/ds/v2-xx/movie/%%CreatorID%%/%%Filename%%.ppm">
|
<meta name="upperlink" content="http://flipnote.hatena.com/ds/v2-xx/movie/%%CreatorID%%/%%Filename%%.ppm">
|
||||||
<meta name="starbutton" content="http://flipnote.hatena.com/ds/v2-xx/movie/%%CreatorID%%/%%Filename%%.star">
|
<meta name="starbutton" content="http://flipnote.hatena.com/ds/v2-xx/movie/%%CreatorID%%/%%Filename%%.star">
|
||||||
|
<meta name="starbutton1" content="http://flipnote.hatena.com/ds/v2-xx/movie/%%CreatorID%%/%%Filename%%.star?starcolor=green,9001">
|
||||||
|
<meta name="starbutton2" content="http://flipnote.hatena.com/ds/v2-xx/movie/%%CreatorID%%/%%Filename%%.star?starcolor=red,9001">
|
||||||
|
<meta name="starbutton3" content="http://flipnote.hatena.com/ds/v2-xx/movie/%%CreatorID%%/%%Filename%%.star?starcolor=blue,9001">
|
||||||
|
<meta name="starbutton4" content="http://flipnote.hatena.com/ds/v2-xx/movie/%%CreatorID%%/%%Filename%%.star?starcolor=purple,9001">
|
||||||
<meta name="savebutton" content="http://flipnote.hatena.com/ds/v2-xx/movie/%%CreatorID%%/%%Filename%%.ppm">
|
<meta name="savebutton" content="http://flipnote.hatena.com/ds/v2-xx/movie/%%CreatorID%%/%%Filename%%.ppm">
|
||||||
<meta name="playcontrolbutton" content="">
|
<meta name="playcontrolbutton" content="">
|
||||||
<link rel="stylesheet" href="http://flipnote.hatena.com/css/ds/basic.css">
|
<link rel="stylesheet" href="http://flipnote.hatena.com/css/ds/basic.css">
|
||||||
|
|||||||
Reference in new issue
Block a user
