Added the flipnote details page and the ability to add stars

This commit is contained in:
pbsds committed 2014-01-26 16:36:39 +01:00
1 parent d683aae26f
commit 0deaa0ab54
5 files changed
+1243 -98

No files matched your search

+7 -2
View File
@@ -1,10 +1,15 @@
#patterns #ignore patterns
*_bak *_bak
*.pyc *.pyc
*.pyd *.pyd
*.pyo *.pyo
*.lnk *.lnk
#spesifics #Don't need all these on github
logs
#not yet ready
documentation documentation
#temp
flipnote details.htm flipnote details.htm
+3 -3
View File
@@ -228,7 +228,7 @@ class Database:
def FlipnoteExists(self, CreatorID, filename): def FlipnoteExists(self, CreatorID, filename):
return os.path.exists("database/Creators/%s/%s.ppm" % (CreatorID, filename)) return os.path.exists("database/Creators/%s/%s.ppm" % (CreatorID, filename))
#interface: #interface:
def GetCreator(self, CreatorID, Load=False):#Load holds it in memory, use this when making changes or reading him often def GetCreator(self, CreatorID, Store=False):#"Store" holds it in memory, use this when making changes or reading it often
if CreatorID in self.Creator: if CreatorID in self.Creator:
return self.Creator[CreatorID] return self.Creator[CreatorID]
else: else:
@@ -239,7 +239,7 @@ class Database:
ret = [i.split("\t") for i in f.read().split("\n")] ret = [i.split("\t") for i in f.read().split("\n")]
f.close() f.close()
if Load: if Store:
self.Creator[CreatorID] = ret self.Creator[CreatorID] = ret
return ret return ret
@@ -285,7 +285,7 @@ class Database:
self.Views += 1 self.Views += 1
return True return True
return False return False
def AddStar(self, Creator, filename, amount=1): def AddStar(self, CreatorID, filename, amount=1):
for i, flipnote in enumerate(self.GetCreator(CreatorID, True) or []): for i, flipnote in enumerate(self.GetCreator(CreatorID, True) or []):
if flipnote[0] == filename: if flipnote[0] == filename:
self.Creator[CreatorID][i][2] = int(flipnote[2]) + amount self.Creator[CreatorID][i][2] = int(flipnote[2]) + amount
+863
View File
@@ -0,0 +1,863 @@
@charset "UTF-8";
div.head {
margin: 10px 0 0 0;
}
a {
color:#e63333;
}
table.profbox {
background-color: #353535;
color: #ffffff;
}
div.prof_out {
margin: 0 11px 0 11px;
background-color: #353535;
border-style: solid;
border-width: 0 1px 0 1px;
border-color: #6c8ff2;
}
span.more-f{
color: #e63333;
}
div.notice2 {
margin:0 11px 5px 11px;
padding:5px;
border-style:solid;
border-width:1px;
border-color:#139a2f;
background-color:#ffffff;
}
td.border{
background-color: #000000;
}
div.border {
border-style: solid;
border-width: 0 0 5px 0;
border-color: #000000;
}
div.border-c {
border-style: solid;
border-width: 0 0 2px 0;
border-color: #000000;
}
td.space {
background-color: #000000;
}
td.tabon {
color: #ed5151;
}
td.taboff {
background-color: #000000;
color: #ed5151;
}
td.tabpager {
background-color: #000000;
color: #ed5151;
}
span.url{
text-decoration:underline;
}
span.comptxt {
color:#ff8a00;
}
span.star0 {
color:#fdc556;
}
span.star1 {
color:#138200;
}
span.star2 {
color:#ff455c;
}
span.star3 {
color:#00b0f9;
}
span.star4 {
color:#a411b9;
}
span.star0c {
color:#fdc556;
}
span.star1c {
color:#138200;
}
span.star2c {
color:#ff455c;
}
span.star3c {
color:#00b0f9;
}
span.star4c {
color:#a411b9;
}
span.orange{
color: #ff8d45;
}
span.green {
color: #82c300;
}
span.gray{
color: #666666;
}
span.white {
color:#FFFFFF;
}
html {
margin:0;
padding:0;
}
body {
color:#333333;
margin:0;
padding:0;
}
div.title {
margin:0 7px 0 7px;
padding:7px 5px 7px 5px;
border-style:solid;
border-width:0 0 1px 0;
border-color:#CCCCCC;
}
div.description {
margin:0 7px 0 7px;
padding:7px 5px 7px 5px;
border-style:solid;
border-width:0 0 1px 0;
border-color:#CCCCCC;
}
div.hr {
border-style:solid;
border-width:0 0 1px 0;
border-color:#CCCCCC;
}
div.hr-tab {
border-style:solid;
border-width:0 0 1px 0;
border-color:#82c300;
}
span.timestamp {
color:#999999;
}
a.timestamp {
color:#999999;
}
a.violation {
color:#333333;
}
div.box {
padding:7px;
border-style:solid;
border-width:1px;
border-color:#CCCCCC;
background-color:#FFFFFF;
}
div.more {
margin:7px 0 0 0;
}
div.pager {
padding:5px;
}
div.num {
margin:5px;
padding:5px;
border-style:solid;
border-width:1px;
border-color:#CCCCCC;
background-color:#FFFFFF;
}
span.new {
color: #cc0000;
}
span.price {
color: #92cb22;
}
span.date {
color: #cccccc;
}
table.detail{
margin:0 7px 0 7px;
}
table.fullsize {
margin:0;
}
div.item-term {
padding:3px 0 3px 5px;
}
div.item-value {
padding:3px 5px 3px 0;
}
div.item-text {
padding:3px 5px 3px 15px;
}
div.item-tcom {
padding: 3px 5px 0 5px;
}
div.item-com {
padding: 0 5px 0 5px;
}
div.td-body {
padding:3px 5px 3px 5px;
}
div.comlist {
background-color:#FFFFFF;
}
div.comment-text {
padding:3px 5px 5px 15px;
}
div.comment-memo {
padding:0 0 0 15px;
}
div.staff {
color:#FFFFFF;
background-color:#1a1a1a;
}
a.staffnam {
color:#FFFFFF;
}
div.notice {
width:226px;
margin:7px 7px 3px 7px;
padding:5px;
border-style:solid;
border-width:1px;
border-color:#BCCDED;
background-color:#E5EEFE;
}
div.colorstar {
margin:7px 0 7px 0;
}
div.code-box{
width:226px;
margin:7px 0 0 0;
padding:5px;
border-style:solid;
border-width:1px;
border-color:#BCCDED;
background-color:#E5EEFE;
}
div.code-data{
margin:7px 0 7px 0;
}
div.mail-reply {
width:226px;
margin:7px 7px 2px 7px;
padding:5px;
border-style:solid;
border-width:1px;
border-color:#BCCDED;
background-color:#E5EEFE;
}
div.lett_txt {
margin: 0 11px 0 11px;
border-style:solid;
border-width:0 2px 0 2px;
border-color:#92d300;
background-color:#ffffff;
}
div.lett_to {
margin: 0 11px 0 11px;
background-color:#92d300;
color:#ffffff;
padding: 1px 0 6px 5px;
}
div.pad0{
padding: 0 0 0 0;
}
div.pad5t{
padding: 5px 0 0 0;
}
div.pad5b{
padding: 0 0 5px 0;
}
div.pad1b{
padding: 0 0 1px 0;
}
div.pad2b{
padding: 0 0 2px 0;
}
div.pad2{
padding: 2px 2px 2px 2px;
}
div.pad5{
padding: 5px 5px 5px 5px;
}
div.pad0-5{
padding: 0 5px 0 5px;
}
td.pad2{
padding: 2px 2px 2px 2px;
}
div.pad3-5{
padding: 3px 5px 3px 5px;
}
div.lett_from{
padding: 3px 11px 3px 0;
}
div.pad11{
padding: 11px 11px 11px 11px;
}
div.pad5-11{
padding: 5px 11px 5px 11px;
}
div.pad10b{
padding: 0 0 10px 0;
}
div.pad20b{
padding: 0 0 20px 0;
}
div.mar0-7{
margin: 0px 7px 0px 7px;
}
div.mar0-11{
margin: 0px 11px 0px 11px;
}
div.mar0{
margin: 0px 0px 0px 0px;
}
div.mar5 {
margin: 5px 5px 5px 5px;
}
div.yaritori{
margin: 0 11px 0 11px;
background-color:#ffffff;
border-style:solid;
border-width:0 2px 0 2px;
border-color:#92d300;
}
div.gr-tit{
margin: 0 11px 0 11px;
background-color:#92d300;
color:#ffffff;
}
div.kadomaru{
margin: 0 11px 0 11px;
}
div.lett-note{
margin: 5px 11px 5px 11px;
padding:5px;
border-style:solid;
border-width:1px;
border-color:#92d300;
background-color:#ffffff;
}
div.pk{
background-color:#ff3ab7;
}
div.blue{
background-color:#3acfff;
}
div.gray{
background-color:#cccccc;
}
div.gray_box{
padding:5px;
border-style:solid;
border-width:1px;
border-color:#cccccc;
background-color:#ffffff;
}
div.vio-intro {
width:240px;
padding:7px 0 7px 7px;
}
div.vio-memo {
padding:0 0 10px 15px;
}
div.vio-text {
padding:0 0 10px 15px;
}
div.vio-note {
color:#999999;
padding:0 0 10px 15px;
}
div.vio-submit {
padding:10px 0 10px 0;
}
div.info-head {
padding:5px 7px 5px 7px;
border-style:solid;
border-width:0 0 1px 0;
border-color:#CCCCCC;
background-color:#eeeeee;
}
div.noborder{
border-style:solid;
border-color:#CCCCCC;
border-width:0 0 0 0;
}
div.info-body {
padding:7px;
}
div.info-msg {
margin:0 0 7px 0;
}
div.news-head {
padding:5px 7px 5px 7px;
border-style:solid;
border-width:0 0 1px 0;
border-color:#CCCCCC;
background-color:#eeeeee;
}
div.news-body {
padding:7px;
}
div.news-h1 {
margin:7px 7px 0 7px;
padding:7px;
border-style:solid;
border-width:3px;
border-color:#91C900;
}
div.news-h2 {
padding:0 0 3px 7px;
border-style:solid;
border-width:0 0 1px 4px;
border-color:#91C900;
}
img.news-memo {
margin:0 10px 5px 0;
border-style:solid;
border-width:1px;
border-color:#CCCCCC;
}
div.info-h2 {
padding:0 0 3px 7px;
border-style:solid;
border-width:0 0 1px 4px;
border-color:#91C900;
}
div.num-box{
background-color:#cccccc;
margin:0 30px;
}
td.tit-star{
background-color:#e9f8c3;
}
img.help{
border-style:solid;
border-width:2px;
border-color:#ffffff;
}
div.list{
padding:0 0 5px 0;
}
div.star-det{
padding:5px 0 5px 0;
}
img.sc{
border-style:solid;
border-width:1px;
border-color:#cccccc;
}
td.border {
background-color: #82c300;
}
div.border {
border-style: solid;
border-width: 0 0 5px 0;
border-color: #82c300;
}
div.border-c {
border-style: solid;
border-width: 0 0 2px 0;
border-color: #82c300;
}
td.space {
background-color: #82c300;
color: #82c300;
}
td.tabon {
color: #82c300;
}
td.taboff {
background-color: #82c300;
color: #ffffff;
}
td.tabpager {
background-color: #82c300;
color: #ffffff;
}
div.on {
padding: 1px 6px 3px 6px;
}
span.border {
color: #b2db59;
}
span.border-gray {
color: #cccccc;
}
a.taboff {
color: #ffffff;
}
div.comme {
padding: 3px 3px 3px 12px;
color: #b2db59;
}
span.text {
color: #333333;
}
td.gray {
background-color: #f2f2f2;
}
div.message {
width:226px;
margin:7px 7px 2px 7px;
padding:5px;
border-style:solid;
border-width:1px;
border-color:#BCCDED;
background-color:#E5EEFE;
}
div.error-message {
width:226px;
margin:7px 7px 2px 7px;
padding:5px;
border-style:solid;
border-width:1px;
border-color:#F5C8A7;
background-color:#FFEED8;
color:#9B2E2E;
}
div.ok-message {
width:226px;
margin:7px 7px 2px 7px;
padding:5px;
border-style:solid;
border-width:1px;
border-color:#C5DABA;
background-color:#E3F9DB;
color:#517B29;
}
div.guide-h2 {
padding:0 0 3px 7px;
border-style:solid;
border-width:0 0 1px 4px;
border-color:#66ccff;
}
div.guide-h3 {
padding:3px 3px 3px 3px;
background-color:#66ccff;
color: #ffffff;
}
div.select-t {
color: #66ccff;
padding: 0 0 3px 0;
}
div.select-b {
padding:5px 3px 5px 3px;
border-style: solid;
border-width: 1px 1px 1px 1px;
border-color: #99ccff;
background-color: #ffffff;
}
span.border-s {
color: #99ccff;
}
span.color {
color: #ffffff;
}
div.credit {
padding:5px 7px 5px 7px;
background-color:#eeeeee;
}
div.rule-tit {
background-color: #82c300;
color: #ffffff;
padding: 3px 3px 3px 3px;
}
div.rule-ind {
margin: 0 0 0 10px;
}
div.hr-prof {
border-style:solid;
border-width:0 0 3px 0;
border-color:transparent;
}
table.send {
margin: 5px 0 0 0 ;
}
div.icon {
border-style: solid;
border-width: 1px 1px 1px 1px;
border-color: #cccccc;
}
td.username {
height:20px;
}
td.mystatus {
}
div.prev {
padding: 1px 0 5px 0;
}
div.next {
padding: 5px 0 1px 0;
}
div.prof-det{
padding: 0 5px 0 5px;
}
div.catch {
margin: 5px 5px 5px 5px;
padding: 5px 5px 5px 5px;
border-style: solid;
border-width: 2px 2px 2px 2px;
border-color: #ffffff;
}
a.still {
color: #ffffff;
}
div.head {
margin: 0px 0 0 0;
}
div.send {
margin: 0px 10px 3px 11px;
}
div.link {
margin: 0px 10px 0 11px;
}
img.button {
margin: 5px 0 0 0;
}
td.theme {
margin: 0 0 0 3px;
}
div.trial-h1 {
margin: 5px 0 5px 0;
padding:3px;
border-style:solid;
border-width:3px;
border-color:#91C900;
}
div.mar-b10{
margin:0 0 10px 0;
}
div.cam1{
margin:7px 7px 0 7px;
padding:7px;
background-color: #ff2828;
color: #ffffff;
}
div.cam2{
margin:0 7px 0 7px;
padding:7px;
border-style:solid;
border-width: 2px 2px 2px 2px;
border-color: #ff2828;
}
table.xmas2009{
margin: 0 10px 0 11px;
background-color: #c70606;
color: #ffffff;
}
div.yellow {
margin: 0 11px 0 11px;
background-color:#ffe800;
}
div.sttr_mes {
width:226px;
margin:7px 7px 0px 7px;
padding:5px;
border-style:solid;
border-width:1px;
border-color:#92cb22;
background-color:#ffffff;
}
div.sttr_gacha {
width:226px;
margin:7px 7px 0px 7px;
padding:5px;
border-style:solid;
border-width:1px;
border-color:#ea475c;
background-color:#ffffff;
}
div.compsp {
width:226px;
margin:7px 7px 0px 7px;
padding:5px;
border-style:solid;
border-width:1px;
border-color:#ffe800;
background-color:#fff9b7;
}
div.sttr_war {
width:226px;
margin:7px 7px 0px 7px;
padding:5px;
border-style:solid;
border-width:1px;
border-color:#F5C8A7;
background-color:#FFEED8;
color:#9B2E2E;
}
div.sttr_price {
background-color:#FF9933;
color: #ffffff;
}
div.sttr_item {
width:226px;
margin:0px 7px 0px 7px;
padding:5px;
border-style:solid;
border-width:1px;
border-color:#92cb22;
background-color:#ffffff;
}
div.sttr_theme {
width:226px;
margin:0px 7px 3px 7px;
padding:5px;
border-style:solid;
border-width:0px 1px 1px 1px;
border-color:#92cb22;
background-color:#ffffff;
}
div.sttr_back {
width:226px;
margin:0px 7px 0px 7px;
}
div.gift_l {
margin: 0 11px 0 11px;
border-style:solid;
border-width:0 2px 0px 2px;
border-color:#ff5252;
}
div.gift_h {
margin: 0 11px 0 11px;
border-style:solid;
border-width:0 2px 0px 2px;
border-color:#ffd616;
}
img.shop_icon {
margin:0 1px 1px 0;
}
div.help_guide {
border-style:solid;
border-width:0 1px 1px 1px;
border-color:#ffac3e;
}
div.guide-head {
color: #ffffff;
background-color: #5abcea;
}
div.guide-title {
color: #ffffff;
background-color: #5abcea;
}
div.guide-main {
border-style:solid;
border-width:0 1px 1px 1px;
border-color:#5abcea;
}
div.green-title {
color: #ffffff;
background-color: #91C900;
}
div.green-main {
border-style:solid;
border-width:0 1px 1px 1px;
border-color:#91C900;
}
table.method{
border-style:solid;
border-width:1px;
border-color:#cccccc;
}
div.search {
background-color: #eeeeee;
border-style: solid;
border-width: 1px;
border-color:#cccccc;
}
td.keyboard {
background-color: #eeeeee;
}
table.key-tab{
margin: 0 6px 0 6px;
}
div.keyout {
margin: 0 7px 0 7px;
border-style: solid;
border-width: 0 1px 1px 1px;
border-color:#cccccc;
}
div.on-ja {
border-style: solid;
border-width: 1px 1px 0 1px;
border-color:#cccccc;
}
div.off-en {
border-style: solid;
border-width: 1px 1px 0 0;
border-color:#cccccc;
}
div.off-aa {
border-style: solid;
border-width: 1px 1px 0 0;
border-color:#cccccc;
}
table.camp-detail {
border-style: solid;
border-width: 1px;
border-color:#cccccc;
}
table.center {
margin: 0 15px 0 16px;
}
div.codeborder {
border-style: solid;
border-width:0 1px 1px 1px;
border-color:#82c300;
}
div.codeprev {
border-style: solid;
border-width:1px;
border-color:#82c300;
}
td.code {
background-color:#ffffff;
}
table.codetab {
border-style: solid;
border-width: 1px 1px 0 1px;
border-color:#82c300;
}
div.codetab {
border-style: solid;
border-width: 0 1px 1px 1px;
border-color:#82c300;
background-color:#ffffff;
}
div.c_tab2 {
border-style: solid;
border-width: 1px 1px 1px 1px;
border-color:#82c300;
background-color:#ffffff;
}
div.topic {
border-style:solid;
border-width:1px;
border-color:#fff273;
background-color:#fff8b2;
}
div.icon-green {
border-style: solid;
border-width: 1px 1px 1px 1px;
border-color: #82c300;
}
div.p-block {
border-style:solid;
border-width:1px;
border-color:#000000;
color:#000000;
background-color:#ffffff;
}
div.clstar-help{
background-color:#ffffff;
color:#82c300;
}
div.ugo4th{
border-style:solid;
border-width:1px;
border-color:#c4260f;
background-color:#d52515;
}
+223 -93
View File
@@ -1,93 +1,223 @@
from twisted.web import resource from twisted.web import resource
import os import os
from hatena import Database, Log, ServerLog, Silent, NotFound from hatena import Database, Log, ServerLog, Silent, NotFound
from Hatenatools import TMB
detailsHMTL = """uguu"""
#The movie folder:
class PyResource(resource.Resource):
#The movie folder: isLeaf = False
class PyResource(resource.Resource): def __init__(self):
isLeaf = False resource.Resource.__init__(self)
def __init__(self):
resource.Resource.__init__(self) self.CreatorID = CreatorID()
def getChild(self, name, request):
self.CreatorID = CreatorID() if Database.CreatorExists(name):
def getChild(self, name, request): return self.CreatorID
if Database.CreatorExists(name): elif name == "":
return self.CreatorID return self
elif name == "": else:
return self return NotFound
else: def render(self, request):
return NotFound request.setResponseCode(403)
def render(self, request): return "403 - Denied access"
request.setResponseCode(403)
return "403 - Denied access" #The creator ID folder:
class CreatorID(resource.Resource):
#The creator ID folder: isLeaf = False
class CreatorID(resource.Resource): def __init__(self):
isLeaf = False resource.Resource.__init__(self)
def __init__(self):
resource.Resource.__init__(self) self.CreatorIDFile = CreatorIDFile()
def getChild(self, name, request):
self.CreatorIDFile = CreatorIDFile() CreatorID = request.path.split("/")[-2]
def getChild(self, name, request): filename = ".".join(name.split(".")[:-1])
CreatorID = request.path.split("/")[-2]
filename = ".".join(name.split(".")[:-1]) if Database.FlipnoteExists(CreatorID, filename):#html, ppm and info
return self.CreatorIDFile
if Database.FlipnoteExists(CreatorID, filename):#html, ppm and info elif name == "":
return self.CreatorIDFile return self
elif name == "": else:
return self return NotFound
else: def render(self, request):
return NotFound request.setResponseCode(403)
def render(self, request): return "403 - Denied access"
request.setResponseCode(403)
return "403 - Denied access" #Any public file inside creator ID folder:
class CreatorIDFile(resource.Resource):
#Any public file inside creator ID folder: isLeaf = True
class CreatorIDFile(resource.Resource): def __init__(self):
isLeaf = True resource.Resource.__init__(self)
def __init__(self): def render(self, request):
resource.Resource.__init__(self) creator, file = request.path.split("/")[-2:]
def render(self, request): filetype = file.split(".")[-1].lower()
creator, file = request.path.split("/")[-2:]
filetype = file.split(".")[-1].lower() if filetype == "ppm":
#log it:
if filetype == "ppm": path = "/".join(request.path.split("/")[3:])
#log it: Log(request, path)
path = "/".join(request.path.split("/")[3:])
Log(request, path) #add a view:
Database.AddView(creator, file[:-4])
#add a view:
Database.AddView(creator, file[:-4]) #read ppm file:
f = open(Database.FlipnotePath(creator, file), "rb")
#read ppm file: data = f.read()
f = open(Database.FlipnotePath(creator, file), "rb") f.close()
data = f.read()
f.close() #send file to client:
request.responseHeaders.setRawHeaders('content-type', ['text/plain'])
#send file to client: return data
request.responseHeaders.setRawHeaders('content-type', ['text/plain']) elif filetype == "info":
return data path = "/".join(request.path.split("/")[3:])
elif filetype == "info": Log(request, path)
path = "/".join(request.path.split("/")[3:]) request.responseHeaders.setRawHeaders('content-type', ['text/plain'])
Log(request, path) return "0\n0\n"#undocumented what it means
request.responseHeaders.setRawHeaders('content-type', ['text/plain']) elif filetype == "htm":
return "0\n0\n"#undocumented what it means #maybe cache the details page of Database.Newest
elif filetype == "htm":#not yet implemented if "mode" in request.args:
if request.args["mode"][0] == "commentshalfsize":
pass
#ret = detailsHMTL[:]
#ret.replace("%%CreatorID%%", creator) return self.GenerateDetailsPage(creator, ".".join(file.split(".")[:-1])).encode("UTF-8")
#ret.replace("%%Filename%%", file[:-4])#without the ext elif filetype == "star":
#ret.replace("%%%%", ) path = "/".join(request.path.split("/")[3:])
#ret.replace("%%%%", ) headers = request.getAllHeaders()
return "Not yet implemented" #bad formatting
else: if "x-hatena-star-count" not in headers:
path = "/".join(request.path.split("/")[3:]) ServerLog.write("%s got 403 when requesting %s without a X-Hatena-Star-Count header" % (request.getClientIP(), path), Silent)
ServerLog.write("%s got 403 when requesting " % (request.getClientIP(), path), Silent) request.setResponseCode(400)
return "400 - Denied access\nRequest lacks a X-Hatena-Star-Count http header"
request.setResponseCode(403)
return "403 - Denied access" #add the stars:
amount = int(headers["x-hatena-star-count"])
if not Database.AddStar(creator, file[:-5], amount):
#error
ServerLog.write("%s got 500 when requesting %s" % (request.getClientIP(), path), Silent)
request.setResponseCode(500)
return "500 - Internal server error\nAdding the stars seem to have failed."
#report success
ServerLog.write("%s added %i stars to %s/%s.ppm" % (request.getClientIP(), amount, creator, file[:-5]), Silent)
return "Success"
else:
path = "/".join(request.path.split("/")[3:])
ServerLog.write("%s got 403 when requesting %s" % (request.getClientIP(), path), Silent)
request.setResponseCode(403)
return "403 - Denied access"
#details page
def GenerateDetailsPage(self, CreatorID, filename):#filename without ext
flipnote = Database.GetFlipnote(CreatorID, filename)#flipnote = [filename, views, stars, green stars, red stars, blue stars, purple stars, Channel], all probably strings
if not flipnote:
return "This flipnote doesn't exist!"
tmb = TMB().ReadFile(Database.FlipnotePath(CreatorID, filename+".ppm"))
if not tmb:
return "This flipnote is corrupt!"
#Is it a spinoff?
Spinnoff = ""
if tmb.OriginalAuthorID <> tmb.EditorAuthorID or tmb.OriginalFilename <> tmb.CurrentFilename:
if Database.FlipnoteExists(tmb.OriginalAuthorID, tmb.OriginalFilename[:-4]):
Spinnoff = SpinoffTemplate1.replace("%%CreatorID%%", tmb.OriginalAuthorID).replace("%%Filename%%", tmb.OriginalFilename[:-4])
elif tmb.OriginalAuthorID <> tmb.EditorAuthorID:
Spinnoff = SpinoffTemplate2
#make each entry:
Entries = []
#Creator username:
name = "Creator"
#content = "<a href=\"http://flipnote.hatena.com/ds/ds/v2-xx/%s/profile.htm?t=260&pm=80\">%s</a>" % (CreatorID, tmb.EditorAuthorName)
content = '<a href="http://flipnote.hatena.com/ds/v2-xx/%s/profile.htm?t=260&pm=80\">%s</a>' % (CreatorID, tmb.Username)
Entries.append(PageEntryTemplate.replace("%%Name%%", name).replace("%%Content%%", content))
#Stars:
name = "Stars"
content = '<a href="http://flipnote.hatena.com/ds/v2-xx/movie/%s/%s.htm?mode=stardetail"><span class="star0c">?</span> <span class="star0">%s</span></a>' % (CreatorID, filename, flipnote[2])#yellow stars
#todo: add other stars
Entries.append(PageEntryTemplate.replace("%%Name%%", name).replace("%%Content%%", content))
#Views:
name = "Views"
content = str(flipnote[1])
Entries.append(PageEntryTemplate.replace("%%Name%%", name).replace("%%Content%%", content))
#Channel:
if flipnote[7]:#todo: make channels work at all
name = "Channel"
content = 'a href="http://flipnote.hatena.com/ds/v2-xx/ch/%s.uls">%s</a>' % (flipnote[7], flipnote[7])
Entries.append(PageEntryTemplate.replace("%%Name%%", name).replace("%%Content%%", content))
#Comments:
Comments = "0"
#add the entries to page:
return DetailsPageTemplate.replace("%%CreatorID%%", CreatorID).replace("%%Filename%%", filename).replace("%%CommentCount%%", Comments).replace("%%Spinoff%%", Spinnoff).replace("%%PageEntries%%", PageEntrySeparator.join(Entries))
#templates:
DetailsPageTemplate = """<html>
<head>
<title>Flipnote by %%Username%%</title>
<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="savebutton" content="http://flipnote.hatena.com/ds/v2-xx/movie/%%CreatorID%%/%%Filename%%.ppm">
<meta name="playcontrolbutton" content="">
<link rel="stylesheet" href="http://flipnote.hatena.com/css/ds/camp100618.css">
</head>
<body>
<table width="240" border="0" cellspacing="0" cellpadding="0" class="tab">
<tr>
<td class="border" width="5" align="center">
<div class="border"></div>
</td>
<td class="border" width="70" align="center">
<div class="border"></div>
</td>
<td class="border" width="95" align="center">
<div class="border"></div>
</td>
</tr>
<tr>
<td class="space"> </td>
<td class="tabon" align="center">
<div class="on" align="center">Description</div>
</td>
<td class="taboff" align="center">
<a class="taboff" href="http://flipnote.hatena.com/ds/v2-eu/movie/%%CreatorID%%/%%Filename%%.htm?mode=commentshalfsize">Comments(%%CommentCount%%)</a>
</td>
</tr>
</table>
<div class="pad5b"></div>%%Spinoff%%
<table width="226" border="0" cellspacing="0" cellpadding="0" class="detail">%%PageEntries%%
</table>
</body>
</html>"""#remember to remove camp100618.css
SpinoffTemplate1 = """
<div class="notice2" align="center">
This Flipnote is a spin-off.<br>
<a href="http://flipnote.hatena.com/ds/v2-eu/movie/%%CreatorID%%/%%Filename%%.htm">Original Flipnote</a>
</div>"""
SpinoffTemplate2 = """
<div class="notice2" align="center">
This Flipnote is a spin-off.
</div>"""
PageEntryTemplate = """
<tr>
<th width="90">
<div class="item-term" align="left">%%Name%%</div>
</th>
<td width="136">
<div class="item-value" align="right">
%%Content%%
</div>
</td>
</tr>"""
PageEntrySeparator="""
<tr> </tr>
<tr>
<td colspan="2">
<div class="hr"></div>
</td>
</tr>"""
+147
View File
@@ -1,3 +1,150 @@
[05:04:23] Server startup... [05:04:23] Server startup...
[05:04:25] Server shutdown [05:04:25] Server shutdown
[14:39:12] Server startup...
[14:39:40] 192.168.0.2 requested en/eula.txt
[14:39:41] 192.168.0.2 requested en/confirm/upload.txt
[14:39:41] 192.168.0.2 requested en/confirm/download.txt
[14:39:42] 192.168.0.2 requested en/confirm/delete.txt
[14:39:42] 192.168.0.2 requested index.ugo
[14:39:54] 192.168.0.2 requested frontpage/hotmovies.ugo page 1
[14:40:03] 192.168.0.2 requested movie/930EDBE0CC6FF483/6FF483_0948E7A5F44D5_000.info
[14:40:03] 192.168.0.2 requested movie/930EDBE0CC6FF483/6FF483_0948E7A5F44D5_000.ppm
[14:40:41] Server shutdown
[14:40:41] Server startup...
[14:40:44] 192.168.0.2 requested movie/930EDBE0CC6FF483/6FF483_0948E7A5F44D5_000.info
[14:40:44] 192.168.0.2 requested movie/930EDBE0CC6FF483/6FF483_0948E7A5F44D5_000.ppm
[14:41:06] Server shutdown
[14:41:06] Server startup...
[14:41:09] 192.168.0.2 requested movie/930EDBE0CC6FF483/6FF483_0948E7A5F44D5_000.info
[14:41:10] 192.168.0.2 requested movie/930EDBE0CC6FF483/6FF483_0948E7A5F44D5_000.ppm
[14:41:32] Server shutdown
[14:41:33] Server startup...
[14:41:35] 192.168.0.2 requested movie/930EDBE0CC6FF483/6FF483_0948E7A5F44D5_000.info
[14:41:36] 192.168.0.2 requested movie/930EDBE0CC6FF483/6FF483_0948E7A5F44D5_000.ppm
[14:42:12] 127.0.0.1 got 404 when requesting "/ds/v2-xx/ds/movie/930EDBE0CC6FF483/6FF483_0948E7A5F44D5_000.htm"
[14:42:13] 127.0.0.1 requested root
[14:42:44] 127.0.0.1 requested root
[14:43:29] Server shutdown
[14:43:29] Server startup...
[14:43:33] 192.168.0.2 requested movie/930EDBE0CC6FF483/6FF483_0948E7A5F44D5_000.info
[14:43:34] 192.168.0.2 requested movie/930EDBE0CC6FF483/6FF483_0948E7A5F44D5_000.ppm
[14:43:41] 127.0.0.1 requested root
[14:44:26] Server shutdown
[14:44:26] Server startup...
[14:44:28] 192.168.0.2 requested movie/930EDBE0CC6FF483/6FF483_0948E7A5F44D5_000.info
[14:44:29] 192.168.0.2 requested movie/930EDBE0CC6FF483/6FF483_0948E7A5F44D5_000.ppm
[14:45:34] Server shutdown
[14:45:34] Server startup...
[14:45:37] 192.168.0.2 requested movie/930EDBE0CC6FF483/6FF483_0948E7A5F44D5_000.info
[14:45:37] 192.168.0.2 requested movie/930EDBE0CC6FF483/6FF483_0948E7A5F44D5_000.ppm
[14:47:16] Server shutdown
[14:47:16] Server startup...
[14:47:18] 192.168.0.2 requested movie/930EDBE0CC6FF483/6FF483_0948E7A5F44D5_000.info
[14:47:19] 192.168.0.2 requested movie/930EDBE0CC6FF483/6FF483_0948E7A5F44D5_000.ppm
[14:48:13] Server shutdown
[14:48:13] Server startup...
[14:48:16] 192.168.0.2 requested frontpage/hotmovies.ugo page 1
[14:48:17] 192.168.0.2 requested movie/930EDBE0CC6FF483/6FF483_0948E7A5F44D5_000.info
[14:48:18] 192.168.0.2 requested movie/930EDBE0CC6FF483/6FF483_0948E7A5F44D5_000.ppm
[14:49:23] 192.168.0.2 requested frontpage/hotmovies.ugo page 1
[14:49:42] 192.168.0.2 requested movie/9E96B750A0976F76/976F76_0A5B18A4D8171_000.info
[14:49:43] 192.168.0.2 requested movie/9E96B750A0976F76/976F76_0A5B18A4D8171_000.ppm
[14:50:01] 192.168.0.2 requested movie/9F346F10CC728EA2/728EA2_096EEE4226FB1_004.info
[14:50:01] 192.168.0.2 requested movie/9F346F10CC728EA2/728EA2_096EEE4226FB1_004.ppm
[14:51:40] Server shutdown
[14:51:41] Server startup...
[14:52:01] 192.168.0.2 requested movie/9F346F10CC728EA2/728EA2_096EEE4226FB1_004.info
[14:52:01] 192.168.0.2 requested movie/9F346F10CC728EA2/728EA2_096EEE4226FB1_004.ppm
[14:52:15] 192.168.0.2 requested frontpage/hotmovies.ugo page 2
[14:52:30] 192.168.0.2 requested frontpage/hotmovies.ugo page 3
[14:52:45] 192.168.0.2 requested frontpage/hotmovies.ugo page 4
[14:53:25] 192.168.0.2 requested frontpage/hotmovies.ugo page 5
[14:54:59] Server shutdown
[14:54:59] Server startup...
[14:55:04] 192.168.0.2 requested frontpage/hotmovies.ugo page 1
[14:55:05] 192.168.0.2 requested movie/930EDBE0CC6FF483/6FF483_0948E7A5F44D5_000.info
[14:55:06] 192.168.0.2 requested movie/930EDBE0CC6FF483/6FF483_0948E7A5F44D5_000.ppm
[14:56:24] Server shutdown
[14:56:25] Server startup...
[14:59:09] 127.0.0.1 requested root
[15:00:14] Server shutdown
[15:00:15] Server startup...
[15:00:17] 127.0.0.1 requested root
[15:00:42] 192.168.0.2 requested movie/930EDBE0CC6FF483/6FF483_0948E7A5F44D5_000.info
[15:00:43] 192.168.0.2 requested movie/930EDBE0CC6FF483/6FF483_0948E7A5F44D5_000.ppm
[15:02:43] 192.168.0.2 requested frontpage/hotmovies.ugo page 1
[15:04:40] Server shutdown
[15:04:41] Server startup...
[15:04:49] 192.168.0.2 requested frontpage/hotmovies.ugo page 1
[15:04:55] 192.168.0.2 requested movie/930EDBE0CC6FF483/6FF483_0948E7A5F44D5_000.info
[15:04:56] 192.168.0.2 requested movie/930EDBE0CC6FF483/6FF483_0948E7A5F44D5_000.ppm
[15:05:29] 192.168.0.2 requested frontpage/hotmovies.ugo page 1
[15:10:09] 192.168.0.2 requested movie/930EDBE0CC6FF483/6FF483_0948E7A5F44D5_000.info
[15:10:10] 192.168.0.2 requested movie/930EDBE0CC6FF483/6FF483_0948E7A5F44D5_000.ppm
[15:14:48] 192.168.0.2 requested frontpage/hotmovies.ugo page 1
[15:17:56] Server shutdown
[15:17:57] Server startup...
[15:18:03] 192.168.0.2 requested movie/930EDBE0CC6FF483/6FF483_0948E7A5F44D5_000.info
[15:18:03] 192.168.0.2 requested movie/930EDBE0CC6FF483/6FF483_0948E7A5F44D5_000.ppm
[15:18:45] 192.168.0.2 requested frontpage/hotmovies.ugo page 1
[15:23:04] Server shutdown
[15:23:04] Server startup...
[15:23:12] 192.168.0.2 requested movie/930EDBE0CC6FF483/6FF483_0948E7A5F44D5_000.info
[15:23:12] 192.168.0.2 requested movie/930EDBE0CC6FF483/6FF483_0948E7A5F44D5_000.ppm
[15:23:18] 192.168.0.2 got 403 when requesting movie/930EDBE0CC6FF483/6FF483_0948E7A5F44D5_000.star
[15:23:22] 192.168.0.2 requested frontpage/hotmovies.ugo page 1
[16:19:22] Server shutdown
[16:19:23] Server startup...
[16:19:32] 192.168.0.2 requested movie/930EDBE0CC6FF483/6FF483_0948E7A5F44D5_000.info
[16:19:33] 192.168.0.2 requested movie/930EDBE0CC6FF483/6FF483_0948E7A5F44D5_000.ppm
[16:19:44] 192.168.0.2 got 403 when requesting movie/930EDBE0CC6FF483/6FF483_0948E7A5F44D5_000.star without a X-Hatena-Star-Count header
[16:21:53] 192.168.0.2 requested frontpage/hotmovies.ugo page 1
[16:29:56] Server shutdown
[16:29:57] Server startup...
[16:30:05] 192.168.0.2 requested movie/930EDBE0CC6FF483/6FF483_0948E7A5F44D5_000.info
[16:30:06] 192.168.0.2 requested movie/930EDBE0CC6FF483/6FF483_0948E7A5F44D5_000.ppm
[16:30:20] Server shutdown
[16:30:21] Server startup...
[16:31:00] Server shutdown
[16:31:01] Server startup...
[16:31:03] 192.168.0.2 requested frontpage/hotmovies.ugo page 1
[16:31:05] 192.168.0.2 requested movie/930EDBE0CC6FF483/6FF483_0948E7A5F44D5_000.info
[16:31:05] 192.168.0.2 requested movie/930EDBE0CC6FF483/6FF483_0948E7A5F44D5_000.ppm
[16:31:13] Server shutdown
[16:31:13] Server startup...
[16:31:26] Server shutdown
[16:31:26] Server startup...
[16:31:29] 192.168.0.2 added 3 stars to 930EDBE0CC6FF483/6FF483_0948E7A5F44D5_000.ppm
[16:31:30] 192.168.0.2 requested frontpage/hotmovies.ugo page 1
[16:31:56] Server shutdown
[16:31:56] Server startup...
[16:31:59] 192.168.0.2 requested frontpage/hotmovies.ugo page 1
[16:32:07] 192.168.0.2 requested movie/9EEDCBF0AA42BE29/42BE29_0A52A7C3273AE_000.info
[16:32:08] 192.168.0.2 requested movie/9EEDCBF0AA42BE29/42BE29_0A52A7C3273AE_000.ppm
[16:32:20] 192.168.0.2 added 30 stars to 9EEDCBF0AA42BE29/42BE29_0A52A7C3273AE_000.ppm
[16:32:26] 192.168.0.2 requested frontpage/hotmovies.ugo page 1
[16:32:33] Server shutdown