Exemple #1
0
def display_image(form):
  wgo_contest.folio_init("GIMP Splash Image Contender")

  name = os.path.basename(form.getvalue("name", "")) # XXX
  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_contest.folio_fini()

  return
Exemple #2
0
def submit(form):
  wgo_contest.folio_init("GIMP 10th Anniversary Contest Submission")
  
  image = 'images/gimp-splash.png'
  author = "Wilber Gimp"
  email = "*****@*****.**"

  print xhtml.h1("GIMP 10th Anniversary Contest", {"class" : "heading"})
  #xhtml.div(thumb, {"class": "splash-thumb", "style" : "float: right; margin-left: 1em;"})
  print xhtml.para("""Welcome to the www.gimp.org 10th Anniversary Splash Contest.
  From here you may submit images to be considered as candidates
  for a splash image.""")

  print xhtml.h2("Submit Your Image", {"class" : "subtitle"})

  cell = xhtml.table.cell
  row = xhtml.table.row

  thumb = wgo_contest.image_generate("Your Image Here", image, "Wilber", "*****@*****.**")

  fields = (xhtml.table.init({"cellspacing" : 0})
            + row(cell("Image File name:",     {"style" : "font-weight: bold"}) + cell(xhtml.input.file({"name" : "image"})))
            + row(cell("Title:",         {"style" : "font-weight: bold"}) + cell(xhtml.input.text({"name" : "title"})))
            + row(cell("Artist's Name:", {"style" : "font-weight: bold"}) + cell(xhtml.input.text({"name" : "author"})))
            + row(cell("Artist's Email:", {"style" : "font-weight: bold"}) + cell(xhtml.input.text({"name" : "email"})))
            + row(cell("Tutorial File name:",     {"style" : "font-weight: bold"}) + cell(xhtml.input.file({"name" : "tutorial"})))
            + row(cell(xhtml.input.hidden({"name" : "mode","value" : "preview"})) + cell(xhtml.input.submit({"name" : "preview", "value" : "PREVIEW"})))
            + xhtml.table.fini())
  
  form = xhtml.form(fields, {"enctype" : "multipart/form-data",
                             "method" : "post",
                             "action" : "contest.cgi",
                             "style" : "margin: 1.33em 0px; margin-left: 40px; margin-right: 40px;" })

  guidelines = (xhtml.para("Fill in the fields below, and click the "
                             + xhtml.input.submit({"value" : "PREVIEW", "disabled" : "disabled"})
                             + " button below."))

  print guidelines
  print form

  wgo_contest.folio_fini()
  return
Exemple #3
0
def approved(form):
  wgo_contest.folio_init("GIMP 10th Anniversary Contest Submission Approved")

  print xhtml.h1("GIMP 10th Anniversary Contest", {"class" : "heading"})
  print xhtml.para("""Welcome to the www.gimp.org splash image contest. """
                   """From here you may submit images to be considered as candidates for a "splash" image.""")
  print xhtml.h2("Thank You!", {"class" : "subtitle"})
  print xhtml.para("Again, we offer No Promises on what may become of your image here.")
  
  name = os.path.basename(form.getvalue("name", ""))
  entry = wgo_contest.gallery_image(name)
  entry["title"] = xhtml.quote(form.getvalue("title", ""))
  entry["author"] = xhtml.quote(form.getvalue("author", ""))
  entry["email"] = xhtml.quote(form.getvalue("email", ""))

  tutorial_path = wgo_contest.spool_path(name, ".tut")

  image_path = wgo_contest.spool_path(name, ".png")
  thumb_path = wgo_contest.spool_path(name, "-t.png")
  thumb_path = wgo_contest.spool_path(name, "-t.jpg")
  
  image_file = wgo_contest.gallery_file(name, ".png")
  thumb_file = wgo_contest.gallery_file(name, "-t.png")
  thumb_file = wgo_contest.gallery_file(name, "-t.jpg")
  image_html = wgo_contest.gallery_path(name, ".html")
  thumb_html = wgo_contest.gallery_path(name, "-t.html")
  
  #print "/bin/cp -f '%s' '%s' '%s'<br />" % (image_path, thumb_path, wgo_contest.config.gallery_path)
  os.system("/bin/cp -f '%s' '%s' '%s' '%s'" % (tutorial_path, image_path, thumb_path, wgo_contest.config.gallery_path))

  entry.save()

  #print xhtml.div(entry.ashtml("image"), {"class" : "splash-image"})
  print entry.ashtml("image")

  print xhtml.para("You can " + xhtml.hyperlink("submit another image", {"href" : "/contest/contest.cgi"})
                  + " or "  + xhtml.hyperlink("view the gallery.", {"href" : "/contest/gallery.cgi?display=gallery"}))

  wgo_contest.folio_fini()
  return
Exemple #4
0
def preview(form):
  name = tempfile("")

  tutorial_path = wgo_contest.spool_path(name, ".tut")

  image_path = wgo_contest.spool_path(name, ".png")
  thumb_path = wgo_contest.spool_path(name, "-t.png")
  thumb_path = wgo_contest.spool_path(name, "-t.jpg")
  
  image_file = wgo_contest.spool_file(name, ".png")
  thumb_file = wgo_contest.spool_file(name, "-t.png")
  thumb_file = wgo_contest.spool_file(name, "-t.jpg")
  
  author = form.getvalue("author", "unknown")
  email = form.getvalue("email", "")
  title = form.getvalue("title", "")

  if len(form["tutorial"].value) == 0:
    wgo_contest.folio_init("GIMP 10th Anniversary Contest Preview Failed")
    print wgo.error("You didn't submit a tutorial.")
    wgo_contest.folio_fini()
    return (1)

  if len(form["image"].value) == 0:
    wgo_contest.folio_init("GIMP 10th Anniversary Contest Preview Failed")
    print wgo.error("You didn't submit an image.")
    wgo_contest.folio_fini()
    return (1)

  try:
    fp = open(tutorial_path, "w")
    fp.write(form["tutorial"].value)
    fp.close()
  except Exception, e:
    wgo_contest.folio_init("GIMP 10th Anniversary Contest Preview Failed")
    try: os.remove(tutorial_path)
    except: pass

    print wgo.error(str(e))
    wgo_contest.folio_fini()
    return (1)
Exemple #5
0
def display_gallery(form):
  wgo_contest.folio_init("GIMP Splash Image Gallery")

  names = get_gallery_names()

  if len(names) == 0:
    wgo_contest.folio_fini();
    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 = "&gt;"
  if this_page_index < len(names) and len(names) >= next_page_index:
    next = xhtml.hyperlink({"href" : "gallery.cgi?mode=GALLERY&amp;index=%d" % (next_page_index)}, next)
    pass

  prev = "&lt;"
  if this_page_index >= images_per_page:
    prev = xhtml.hyperlink({"href" : "gallery.cgi?mode=GALLERY&amp;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 = "&nbsp;"
    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()

  # Comment out submission when contest is closed.
  #print xhtml.div(xhtml.hyperlink("Submit an image", {"href" : "/contest/contest.cgi"}))

  wgo_contest.folio_fini()
  return
Exemple #6
0
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 />&nbsp;" + 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 />&nbsp;" + entry["author"])
      )
    print xhtml.table.fini()

    wgo_contest.folio_fini()
    pass
  return
Exemple #7
0
  try:
    fp = open(tutorial_path, "w")
    fp.write(form["tutorial"].value)
    fp.close()
  except Exception, e:
    wgo_contest.folio_init("GIMP 10th Anniversary Contest Preview Failed")
    try: os.remove(tutorial_path)
    except: pass

    print wgo.error(str(e))
    wgo_contest.folio_fini()
    return (1)

  if (not tarfile.is_tarfile(tutorial_path) and
      not zipfile.is_zipfile(tutorial_path)):
    wgo_contest.folio_init("GIMP 10th Anniversary Contest Preview Failed")
    print "Tutorial file is not a tarball or a zip file"
    wgo_contest.folio_fini()
    return (1)
    
  try:
    fp = os.popen("/usr/bin/convert - 'png:%s'" % (image_path), "w")
    fp.write(form["image"].value)
    fp.close()
    os.system("/usr/bin/convert -geometry 150 '%s' 'png:%s'\n" % (image_path, thumb_path))
    os.system("/usr/bin/convert -geometry 150 '%s' 'jpg:%s'\n" % (image_path, thumb_path))
  except Exception, e:
    wgo_contest.folio_init("GIMP 10th Anniversary Contest Preview Failed")
    try: os.remove(image_path)
    except: pass
    try: os.remove(thumb_path)