Пример #1
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)
Пример #2
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)
Пример #3
0
import rfc822
import string
import sys
import time
import types

sys.path = ['${LIBDIR}'] + sys.path

import xhtml
import wgo
import wgo_news
import wgo_queue

print "Content-type: text/html"

wgo_news.header()

form = cgi.FieldStorage()

queue = ""
action = ""

if wgo.config.debug:
  xhtml.print_form(form)
  pass

if form.has_key("queue"):
  if form["queue"].value in ["pending", wgo_news.config.pending_queue]:
    queue = wgo_news.config.pending_queue
  elif form["queue"].value in ["current", wgo_news.config.current_queue]:
    queue = wgo_news.config.current_queue
Пример #4
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)