コード例 #1
0
ファイル: gallery-edit.py プロジェクト: pquentin/gimp-web
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)
コード例 #2
0
ファイル: gallery.py プロジェクト: pquentin/gimp-web
def format(name):
  view_button = {"name" : "action", "value" : "view"}
  view = "gallery.cgi?display=image&name=" + name

  entry = wgo_contest.gallery_image(name)
  if not entry.exists():
    link = "Eeek!  This entry is not available in the gallery. ", name
  else:
    link = entry.ashtml("thumb") + xhtml.hyperlink("view", {"href" : view, "class" : "faux-button"})
    pass

  return (xhtml.div(link, {"class" : "splash-thumb"}))
コード例 #3
0
ファイル: gallery-edit.py プロジェクト: pquentin/gimp-web
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)
コード例 #4
0
ファイル: gallery.py プロジェクト: pquentin/gimp-web
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
コード例 #5
0
ファイル: gallery-edit.py プロジェクト: pquentin/gimp-web
def format(name):
  edit_button = {"name" : "action", "value" : "edit"}
  delete_button = {"name" : "action", "value" : "delete"}
  edit = "gallery-edit.cgi?mode=EDIT&name=" + name
  delete = "gallery-edit.cgi?mode=DELETE&name=" + name
  
  entry = wgo_contest.gallery_image(name)
  if not entry.exists():
    link = "Eeek!  This entry is not available in the gallery. ", name
  else:
    link =  xhtml.div(entry.ashtml("thumb")
                      + (xhtml.span(xhtml.hyperlink("edit", {"href" : edit, "class" : "faux-button"})
                                    + xhtml.hyperlink("delete", {"href" : delete, "class" : "faux-button"}), {"style" : "text-align: left;"})),
                           {"style" : "text-align: left;"})
    pass

  return (xhtml.div(link, {"class" : "splash-thumb"}))
コード例 #6
0
ファイル: gallery-edit.py プロジェクト: pquentin/gimp-web
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
コード例 #7
0
ファイル: gallery-edit.py プロジェクト: pquentin/gimp-web
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)
コード例 #8
0
ファイル: contest.py プロジェクト: pquentin/gimp-web
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
コード例 #9
0
ファイル: gallery.py プロジェクト: pquentin/gimp-web
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
コード例 #10
0
ファイル: contest.py プロジェクト: pquentin/gimp-web
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