Ejemplo n.º 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
Ejemplo n.º 2
0
def main():
  wgo_news.header()

  form = cgi.FieldStorage()

  if not (form.has_key("message-id") and form.has_key("queue")):
    wgo_news.footer(wgo.error("Malformed Request"))
    return (1)

  queue = form["queue"].value
  
  if queue in ["pending", wgo_news.config.pending_queue]:
    this_queue = wgo_news.config.pending_queue
    other_queue = wgo_news.config.current_queue
  elif queue in ["current", wgo_news.config.current_queue]:
    this_queue = wgo_news.config.current_queue
    other_queue = wgo_news.config.pending_queue
  elif queue in ["archive", wgo_news.config.archive_queue]:
    this_queue = wgo_news.config.archive_queue
    other_queue = wgo_news.config.archive_queue
  else:
    wgo_news.footer(wgo.error("Malformed request"))
    return (1)

  message_id = xhtml.unescape(form["message-id"].value)

  try:
    m = wgo_news.news(wgo_queue.message_path(this_queue, message_id))
  except:
    m = wgo_news.news()
    m["message-id"] = message_id
    m["date"] = rfc822.formatdate()
    pass

  if os.environ.has_key("REMOTE_USER"):
    editor = os.environ["REMOTE_USER"]
  else:
    editor = "*****@*****.**"
    pass
  
  html_news_edit(this_queue, other_queue, m, editor)
  
  wgo_news.footer()
  
  return (0)
Ejemplo n.º 3
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
Ejemplo n.º 4
0
def main(queue):
  wgo_news.header()

  if queue in [wgo_news.config.pending_queue, wgo_news.config.current_queue, wgo_news.config.archive_queue]:
    dirpath = wgo.config.spool_path + queue
    names = map(lambda t: dirpath + "/" + t, os.listdir(dirpath))
    names.sort(lambda a, b: cmp(os.stat(a).st_mtime, os.stat(b).st_mtime))

    news = map(lambda f: wgo_news.news(f, False), names)
    news = filter(lambda n: n.valid, news)

    print xhtml.include('%s%s_header.html' % (wgo_news.config.news_path, queue))

    # If this is the pending queue, then create one initialised news article for display.
    if queue == wgo_news.config.pending_queue:
      n = wgo_news.news()
      n["Subject"] = "NEW NEWS"
      html_index_page(queue, n)
      pass

    map(lambda n: html_index_page(queue, n), news)

    control_panel(queue)
                
    print xhtml.include('%s/%s_footer.html' % (wgo_news.config.news_path, queue))
    if 0:
      print xhtml.hyperlink("XML", { "class" : "faux-button",
                                     "style" : "background: #ff6600 none; color: white; font-weight: bold; padding: 0 .5em 0 .5em; font-size: medium;",
                                     "href"  : wgo_news.config.news_dir + queue + "/news.rdf"})
      pass

    print xhtml.include(wgo_queue.generate_blotter(queue))
  else:
    print wgo.error("Malformed Request")
    pass
  
  wgo_news.footer()
  
  return (0)
Ejemplo n.º 5
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)
Ejemplo n.º 6
0
def main():
  form = cgi.FieldStorage()

  #wgo.config.debug = True
  
  if wgo.config.debug: xhtml.print_form(form)

  if not (form.has_key("message-id") and form.has_key("action") and form.has_key("queue")) and not (form.has_key("subject") and form.has_key("body")):
    wgo_news.header()
    wgo_news.footer(wgo.error("Malformed http request."))
    return (-1)
  
  action = string.lower(xhtml.unescape(form["action"].value))

  queue = xhtml.unescape(form["queue"].value)
    
  if queue in ["pending", wgo_news.config.pending_queue]:
    queue = wgo_news.config.pending_queue
  elif queue in ["current", wgo_news.config.current_queue]:
    queue = wgo_news.config.current_queue
  elif queue in ["archive", wgo_news.config.archive_queue]:
    queue = wgo_news.config.archive_queue
  else:
    action = ""
    queue = ""
    pass

  try:
    news = wgo_news.news(form)
  except:
    wgo_news.header()
    wgo_news.footer(wgo.error("The news article is malformed.  Check the date, it should be <i>day month year hour:minute:seconds</i> GMT  Perhaps it is missing a subject line, or it has no body.  "))
    return (-1)
    

  if action == "save":
    news.to_queue(queue)
    link = xhtml.hyperlink("Continue", { "href" : "news-edit.cgi?message-id=%s&queue=%s" % (news["message-id"], queue)})
    status = "success"
    goto = ["Location: news-edit.cgi?message-id=%s&queue=%s" % (xhtml.escape(news["message-id"]), queue)]
  elif action == "approve":
    news.to_queue(wgo_news.config.current_queue)
    if os.path.exists(wgo_queue.message_path(queue, news["message-id"])):
      os.remove(wgo_queue.message_path(queue, news["message-id"]))
      pass
    
    link = xhtml.hyperlink("Continue", { "href" : "news-index.cgi?%s" % (queue)})
    status = "success"
    goto = ["Location: news-index.cgi?%s" % (queue)]
  elif action == "disapprove":
    news.to_queue(wgo_news.config.pending_queue)
    if os.path.exists(wgo_queue.message_path(queue, news["message-id"])):
      os.remove(wgo_queue.message_path(queue, news["message-id"]))
      pass
    
    link = xhtml.hyperlink("Continue", {"href" : "news-index.cgi?%s" % (queue)})
    status = "success"
    goto = ["Location: news-index.cgi?%s" % (queue)]
  elif action == "archive":
    news.to_queue(wgo_news.config.archive_queue)
    if os.path.exists(wgo_queue.message_path(queue, news["message-id"])):
      os.remove(wgo_queue.message_path(queue, news["message-id"]))
      pass
    
    link = xhtml.hyperlink("Continue", {"href" : "news-index.cgi?%s" % (queue)})
    status = "success"
    goto = ["Location: news-index.cgi?%s" % (queue)]
  elif action == "delete":
    if os.path.exists(wgo_queue.message_path(queue, news["message-id"])):
      os.remove(wgo_queue.message_path(queue, news["message-id"]))
      pass
    
    link = xhtml.hyperlink("Continue", {"href" : "news-index.cgi?%s" % (queue)})
    status = "success"
    goto = ["Location: news-index.cgi?%s" % (queue)]
  else:
    link = xhtml.hyperlink("Restart", {"href" : "index.html"})
    queue = ""
    status = "failed"
    pass

  if status == "success":
     print goto[0]
     print
  else:
    wgo_news.header()
    wgo_news.footer(wgo.error(string.capitalize(action) + " " + string.capitalize(status)))
    pass
    
  return (0)
Ejemplo n.º 7
0
    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)
    except: pass

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

  wgo_contest.folio_init("GIMP 10th Anniversary Contest Preview")

  print xhtml.h1("GIMP 10th Anniversary Contest", {"class" : "heading"})
  print xhtml.para("""Welcome to the www.gimp.org 10th Anniversary Splash Contest. """
                   """From here you may submit images with tutorials to be considered as candidates
                   for a "splash" image.  We appreciate your participation, but we
                   offer No Promises on what may become of your image here.""")

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

  form = xhtml.form(xhtml.input.submit({"name" : "approve", "value" : "APPROVE"})
                    + xhtml.input.hidden({"name" : "mode", "value" : "approve"})