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 folio_init(title=""): wgo.http_preamble(["Content-Type: text/html"]) wgo.header("page", title, [{"rel" : "stylesheet", "href" : config.contest_dir + "wgo-contest.css", "type" : "text/css"}]) return
def display_slideshow(form): names = get_gallery_names() if len(names) == 0: wgo_contest.folio_init() wgo_contest.folio_fini() return name = os.path.basename(form.getvalue("image", names[0])) refresh = int(form.getvalue("refresh", "5")) fullscreen = form.getvalue("fullscreen", "") style = form.getvalue("style", "") if refresh < 2: refresh = 2 entry = wgo_contest.gallery_image(name) image_file = wgo_contest.gallery_file(entry["name"], ".png") next_name = name[0] for i in range(0, len(names)): if names[i] == name: next_name = names[(i + 1) % len(names)] break pass url = "gallery.cgi?display=slideshow&image=%s" % (next_name) if (fullscreen == "true"): fullscreen_attr = "&fullscreen=true" refresh_attr = "&refresh=%d" % (refresh) if style != "": style_attr = "&style=" + style else: style_attr = "" wgo.http_preamble(["Content-Type: text/html", "Refresh: " + str(refresh) + ";url=" + url + refresh_attr + fullscreen_attr + style_attr]) print xhtml.html.init() print xhtml.head() print xhtml.body.init({"style" : "background: black; color: white;"}) if style == "": fill_window = xhtml.hyperlink({"style" : "color: gray;", "href" : url + refresh_attr + fullscreen_attr + "&style=width:100%;"}, "[fill window]") else: fill_window = xhtml.hyperlink({"style" : "color: gray;", "href" : url + refresh_attr + fullscreen_attr}, "[normal size]") print xhtml.span({"style" : "font-size: small; margin-top: 10ex; margin-bottom: 5ex;"}, xhtml.hyperlink({"style" : "color: gray;", "href" : url + fullscreen_attr + style_attr + "&refresh=%s" % (5)}, "5s") + " " + xhtml.hyperlink({"style" : "color: gray;", "href" : url + fullscreen_attr + style_attr + "&refresh=%s" % (10)}, "10s") + " " + xhtml.hyperlink({"style" : "color: gray;", "href" : url + fullscreen_attr + style_attr + "&refresh=%s" % (15)}, "15s") + " " + xhtml.hyperlink({"style" : "color: gray;", "href" : url + fullscreen_attr + style_attr + "&refresh=%s" % (20)}, "20s") + " " + fill_window ) print xhtml.table.init({"style" : "text-align: center; vertical-align: middle; width: 100%;"}) print xhtml.table.row( xhtml.table.cell(xhtml.image({"style" : "%s" % (style), "src" : image_file})) + xhtml.table.cell({"style" : "font-size: xx-large; text-align: right; padding-right: 5%;" }, "<i>" + entry["title"] + "</i><br /> " + entry["author"]) ) print xhtml.table.fini() print xhtml.body.fini() print xhtml.html.fini() pass else: url = "gallery.cgi?display=slideshow&image=%s&refresh=%d" % (next_name, refresh) wgo.http_preamble(["Content-Type: text/html", "Refresh: %s;url=%s" % (refresh, url)]) wgo.header("page", "GIMP Splash Image Slideshow", [{"rel" : "stylesheet", "href" : wgo_contest.config.contest_dir + "wgo-contest.css", "type" : "text/css"}]) print xhtml.span({"style" : "font-size: small; margin-bottom: 5ex;"}, xhtml.hyperlink({"href" : "gallery.cgi?display=slideshow&image=%s&refresh=%s" % (next_name, 5)}, "[5s]") + " " + xhtml.hyperlink({"href" : "gallery.cgi?display=slideshow&image=%s&refresh=%s" % (next_name, 10)}, "[10s]") + " " + xhtml.hyperlink({"href" : "gallery.cgi?display=slideshow&image=%s&refresh=%s" % (next_name, 15)}, "[15s]") + " " + xhtml.hyperlink({"href" : "gallery.cgi?display=slideshow&image=%s&refresh=%s" % (next_name, 20)}, "[20s]") + " " + xhtml.hyperlink({"href" : "gallery.cgi?display=slideshow&image=%s&refresh=%s&fullscreen=true" % (next_name, refresh)}, "[full window]") ) print xhtml.table.init({"class" : "splash-slideshow"}) print xhtml.table.row( xhtml.table.cell(xhtml.image({"src" : image_file})) + xhtml.table.cell("<i>" + entry["title"] + "</i><br /> " + entry["author"]) ) print xhtml.table.fini() wgo_contest.folio_fini() pass return
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