コード例 #1
0
ファイル: movie.py プロジェクト: nikillpop/hatena-server
	def getChild(self, name, request):
		CreatorID = request.path.split("/")[-2]
		filename = ".".join(name.split(".")[:-1])

		if Database.FlipnoteExists(CreatorID, filename):#html, ppm and info
			return self.CreatorIDFile
		elif name == "":
			return self
		else:
			return NotFound
コード例 #2
0
ファイル: movie.py プロジェクト: nikillpop/hatena-server
	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().Read(Database.GetFlipnoteTMB(CreatorID, filename))
		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 = 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
		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"

		#doto: add original author info too

		#add the entries to page:
		return DetailsPageTemplate.replace("%%CreatorID%%", CreatorID).replace("%%Filename%%", filename).replace("%%CommentCount%%", Comments).replace("%%Spinoff%%", Spinnoff).replace("%%PageEntries%%", PageEntrySeparator.join(Entries))