Exemple #1
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 #2
0
def submit_manually(args):
  try:
    opts, args = getopt.getopt(sys.argv[1:], "ha:t:e:", ["help", "author=", "title=", "email="])
  except getopt.GetoptError:
    usage()
    sys.exit(2)
    pass
  
  title = ""
  email = ""
  author = ""
  
  for o, a in opts:
    if o in ("-h", "--help"):
      print "-a, --author: author name"
      print "-e, --email: email name"
      print "-t, --title: title name"
      sys.exit()
      pass
    if o in ("-a", "--author"): author = a
    if o in ("-e", "--email"): email = a
    if o in ("-t", "--title"): title = a
    pass

  for arg in args:
    name = tempfile("")
    entry = wgo_contest.gallery_image(name)

    try:
      image_path = wgo_contest.gallery_path(name, ".png")
      thumb_path = wgo_contest.gallery_path(name, "-t.png")
      thumb_path = wgo_contest.gallery_path(name, "-t.jpg")

      os.system("/usr/bin/convert '%s' 'png:%s'" % (arg, image_path))
      
      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))
  
      #os.system("/usr/bin/convert '%s' 'png:%s'" % (arg, wgo.config.DocumentRoot_path + entry["image"]))
      #os.system("/usr/bin/convert -geometry 150 '%s' 'png:%s'\n" % (wgo.config.DocumentRoot_path + entry["image"],
      #                                                                    wgo.config.DocumentRoot_path + entry["thumb"]))
      #os.system("/usr/bin/convert -geometry 150 '%s' 'jpg:%s'\n" % (wgo.config.DocumentRoot_path + entry["image"],
      #                                                                    wgo.config.DocumentRoot_path + entry["thumb"]))

      #os.chown(wgo.config.DocumentRoot_path + entry["image"], wgo.config.user_uid, wgo.config.user_gid)
      #os.chown(wgo.config.DocumentRoot_path + entry["thumb"], wgo.config.user_uid, wgo.config.user_gid)
    except Exception, e:
      print arg, name, e
      return (False)

    entry["title"] = title
    entry["author"] = author
    entry["email"] = email
    entry.save()

    if not entry.exists():
      print "Eeek! Gallery became insane. Failed to add entry: ", name
      return (-1)
  
    print name, "success"
    pass