def edit_image(form): wgo.http_preamble(["Content-type: text/html"]) wgo_admin.header('www.gimp.org - Administration - Splash Image', [ {"rel" : "stylesheet", "href" : wgo_contest.config.contest_dir + "/wgo-contest.css", "type" : "text/css", "media" : "screen"} ]) print xhtml.h1("www.gimp.org - Administrate Contest - Edit Entry", {"class" : "heading"}) name = form["name"].value image = wgo_contest.gallery_image(name) cell = xhtml.table.cell row = xhtml.table.row fields = (xhtml.table.init({"cellspacing" : 6}) + row(cell("Name:", {"style" : "font-weight: bold"}) + cell(name)) + row(cell("Title:", {"style" : "font-weight: bold"}) + cell(xhtml.input.text({"name" : "title", "value" : image["title"]}))) + row(cell("Artist's Name:", {"style" : "font-weight: bold"}) + cell(xhtml.input.text({"name" : "author", "value" : image["author"]}))) + row(cell("Artists Email:", {"style" : "font-weight: bold"}) + cell(xhtml.input.text({"name" : "email", "value" : image["email"]}))) + row(cell(xhtml.input.hidden({"name" : "name", "value" : name})) + cell(xhtml.input.submit({"name" : "mode", "value" : "SAVE"}) + xhtml.input.submit({"name" : "mode", "value" : "DELETE"}))) + xhtml.table.fini()) print xhtml.para(xhtml.form(xhtml.div(fields), {"enctype" : "multipart/form-data", "method" : "post", "action" : "gallery-edit.cgi"})) if image.exists(): print xhtml.div(image.ashtml("image"), {"class": "splash-image"}) else: print xhtml.div(xhtml.para("That image is not available in the gallery.")) pass wgo_admin.footer() return (0)
def header(): wgo.http_preamble(["Content-type: text/html"]) # wgo_admin.header("www.gimp.org - Administration", # [ {"rel" : "stylesheet", "href" : config.news_dir + "/news-admin.css", "type" : "text/css", "media" : "screen"} ]) wgo_admin.header("www.gimp.org - Administration") return
def delete_image(form): wgo.http_preamble(["Content-type: text/html"]) wgo_admin.header('www.gimp.org - Administration - Splash Image', [ {"rel" : "stylesheet", "href" : wgo_contest.config.contest_dir + "/wgo-contest.css", "type" : "text/css", "media" : "screen"} ]) name = form["name"].value entry = wgo_contest.gallery_image(name) entry.delete() wgo_admin.footer() return (0)
def display_image(form): wgo.http_preamble(["Content-type: text/html"]) wgo_admin.header('www.gimp.org - Administration - Splash Image', [ {"rel" : "stylesheet", "href" : wgo_contest.config.contest_dir + "/wgo-contest.css", "type" : "text/css", "media" : "screen"} ]) name = os.path.basename(form.getvalue("name", "")) entry = wgo_contest.gallery_image(name) if entry.exists(): print xhtml.div(entry.ashtml("image"), {"class": "splash-image"}) else: print wgo.error("That image is not available in the gallery.") pass wgo_admin.footer() return
def save_image(form): wgo.http_preamble(["Content-type: text/html"]) wgo_admin.header('www.gimp.org - Administration - Splash Image', [ {"rel" : "stylesheet", "href" : wgo_contest.config.contest_dir + "/wgo-contest.css", "type" : "text/css", "media" : "screen"} ]) name = form["name"].value entry = wgo_contest.gallery_image(name) entry["title"] = form.getvalue("title", "") entry["author"] = form.getvalue("author", "") entry["email"] = form.getvalue("email", "") print entry["author"], "<br/>" entry.save() wgo_admin.footer() return (0)
def display_gallery(form): wgo.http_preamble(["Content-type: text/html"]) wgo_admin.header('www.gimp.org - Administration - Splash Image', [ {"rel" : "stylesheet", "href" : wgo_contest.config.contest_dir + "/wgo-contest.css", "type" : "text/css", "media" : "screen"} ]) names = get_gallery_names() if len(names) == 0: # If there's nothing to do, return wgo_admin.footer() return this_page_index = int(form.getfirst("index", "0")) images_per_page = 12 next_page_index = this_page_index + images_per_page prev_page_index = this_page_index - images_per_page next = ">" if this_page_index < len(names) and len(names) >= next_page_index: next = xhtml.hyperlink({"href" : "gallery-edit.cgi?mode=GALLERY&index=%d" % (next_page_index)}, next) pass prev = "<" if this_page_index >= images_per_page: prev = xhtml.hyperlink({"href" : "gallery-edit.cgi?mode=GALLERY&index=%d" % (prev_page_index)}, prev) pass print xhtml.table.init({"class" : "contest-progress-bar"}) print xhtml.table.row.init() print xhtml.table.cell({"id" : "prev"}, prev) position = this_page_index * 100 / len(names) for i in range(0, 100): index = len(names) * i / 100 link = " " if i == position: print xhtml.table.cell({"id" : "current-position", "title" : "image %d (%d%%)" % (this_page_index, i)}, link) else: print xhtml.table.cell(link) pass pass print xhtml.table.cell({"id" : "next" }, next) print xhtml.table.row.fini() print xhtml.table.fini() print xhtml.table.init({"class" : "contest-image-gallery"}) row_start = this_page_index row = names[row_start : row_start + 4] print xhtml.table.row("".join(map(lambda k: str(xhtml.table.cell(format(k))), row))) row_start = this_page_index + 4 row = names[row_start : row_start + 4] print xhtml.table.row("".join(map(lambda k: str(xhtml.table.cell(format(k))), row))) row_start = this_page_index + 8 row = names[row_start : row_start + 4] print xhtml.table.row("".join(map(lambda k: str(xhtml.table.cell(format(k))), row))) print xhtml.table.fini() wgo_admin.footer() return