예제 #1
0
def do_file(filename):

    fp = open(filename, "r")
    print "<!-- This file automatically generated by mirrorfmt.py $Revision$ -->"
    print "<!-- DO NOT EDIT THIS FILE - edit the master file MIRRORS instead -->"
    print xhtml.dl.init({"class" : "download-mirror"})

    for l in fp:
        l = l.rstrip()
        if len(l) > 1:
            if l[0] == "#":
                pass
            elif l[0] not in [' ', '\t', '\n']:
                print xhtml.dt(l)
            else:
                l = l.lstrip()
                idx = 0
                while idx < len(l) and l[idx] not in string.whitespace:
                    idx = idx + 1
                if idx < len(l):
                    # split the link (before whitespace) from the comment
                    print xhtml.dd(xhtml.hyperlink(l[0:idx], {"href" : l[0:idx]})
                                   + l[idx:len(l)])
                else:
                    print xhtml.dd(xhtml.hyperlink(l, {"href" : l}))
                pass
            pass
        pass

    print xhtml.dl.fini()
    fp.close()
    
    return
예제 #2
0
def html_index_page(queue, news):
  if news == None or not news.valid:
    return (1)

  message_id = news["message-id"]

  filename = wgo_queue.message_path(queue, message_id)
  
  edit_target = "news-edit.cgi?message-id=" + xhtml.quote(message_id) + "&amp;queue=" + xhtml.quote(queue)

  checkbox_attrs = { "class" : "news-index", "name" : xhtml.quote(news["message-id"]) }
  title = ""
  if len(news["body"]) < 2:
    title = "this article has no body"
    checkbox_attrs.update({"disabled" : "disabled", "title" : title})
    pass
           
  attrs = { "class" : "news-index" }

  print xhtml.table.row(
    xhtml.table.cell(xhtml.quote(news["date"]), {'title' : title})
    + xhtml.table.cell(xhtml.mailto(news["from"]), {'title' : title})
    + xhtml.table.cell(xhtml.hyperlink(news["subject"], {"href" : edit_target, "class" : "news-index", "title" : 'edit this article'}), {'title' : title })
    + xhtml.table.cell(xhtml.input.checkbox(checkbox_attrs), {'title' : title}))
    
  return (1)
예제 #3
0
def format(name):
  edit_button = {"name" : "action", "value" : "edit"}
  delete_button = {"name" : "action", "value" : "delete"}
  edit = "gallery-edit.cgi?mode=EDIT&amp;name=" + name
  delete = "gallery-edit.cgi?mode=DELETE&amp;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"}))
예제 #4
0
def format(name):
  view_button = {"name" : "action", "value" : "view"}
  view = "gallery.cgi?display=image&amp;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"}))
예제 #5
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
예제 #6
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)
예제 #7
0
        pass
      pass
    elif action == "reject":
      status = "Reject unimplemented"
      pass
    else:
      status = "Bad action: " + form["action"].value
      pass
            
    if status == 0:
      print xhtml.table.cell("Successful", {"id" : "success"})
    else:
      print xhtml.table.cell(status, {"id" : "failure"})
      pass
        
    print xhtml.table.row.fini()
    pass
  pass

print xhtml.table.fini()

wgo_queue.generate_blotter(wgo_news.config.archive_queue)
wgo_queue.generate_blotter(wgo_news.config.current_queue)
wgo_queue.generate_blotter(wgo_news.config.pending_queue)

print xhtml.para(xhtml.hyperlink("Continue", { "href" : "news-index.cgi?%s" % (queue)}))

wgo_news.footer()
            
sys.exit(1)
예제 #8
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)
예제 #9
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
예제 #10
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
예제 #11
0
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 = "&gt;"
  if this_page_index < len(names) and len(names) >= next_page_index:
    next = xhtml.hyperlink({"href" : "gallery-edit.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-edit.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()

  wgo_admin.footer()
  return