def MakePage(self, flipnotes, page, next, count):
        ugo = UGO()
        ugo.Loaded = True
        ugo.Items = []

        #meta
        ugo.Items.append(("layout", (2, 1)))
        ugo.Items.append(("topscreen text", [
            "Popular Flipnotes", "Flipnotes",
            str(count), "", "The most popular new Flipnotes."
        ], 0))

        #categories
        ugo.Items.append(
            ("category",
             "http://flipnote.hatena.com/ds/v2-xx/frontpage/hotmovies.uls",
             "Most Popular", True))
        ugo.Items.append(
            ("category",
             "http://flipnote.hatena.com/ds/v2-xx/frontpage/likedmovies.uls",
             "Most Liked", False))
        #ugo.Items.append(("category", "http://flipnote.hatena.com/ds/v2-xx/frontpage/recommended.uls", "Recommended", False))
        ugo.Items.append(
            ("category",
             "http://flipnote.hatena.com/ds/v2-xx/frontpage/newmovies.uls",
             "New Flipnotes", False))
        #ugo.Items.append(("category", "http://flipnote.hatena.com/ds/v2-xx/frontpage/following.uls", "New Favourites", False))

        #the "post flipnote" button
        ugo.Items.append(
            ("unknown",
             ("3", "http://flipnote.hatena.com/ds/v2-xx/help/post_howto.htm",
              "UABvAHMAdAAgAEYAbABpAHAAbgBvAHQAZQA=")))

        #previous page
        if page > 1:
            ugo.Items.append((
                "button", 115, "Previous",
                "http://flipnote.hatena.com/ds/v2-xx/frontpage/hotmovies.uls?page=%i"
                % (page - 1), ("", ""), None))

        #Flipnotes
        for creatorid, filename in flipnotes:
            stars = str(Database.GetFlipnote(creatorid, filename)[2])
            ugo.Items.append(
                ("button", 3, "",
                 "http://flipnote.hatena.com/ds/v2-xx/movie/%s/%s.ppm" %
                 (creatorid, filename), (stars, "765", "573", "0"),
                 (filename + ".ppm",
                  Database.GetFlipnoteTMB(creatorid, filename))))

        #next page
        if next:
            ugo.Items.append((
                "button", 115, "Next",
                "http://flipnote.hatena.com/ds/v2-xx/frontpage/hotmovies.uls?page=%i"
                % (page + 1), ("", ""), None))

        return ugo.Pack()
Exemple #2
0
	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))