Esempio n. 1
0
    def add(self, msg_num, msgobj, email):
        # Ok, time to index the actual message
        rm = email_message.RenderMessage(mimemsg=msgobj)

        self._write("Path-Name: %s" % (os.path.join(self._path, str(msg_num))))

        extra = []
        if 1:
          for hdr in ["subject"]:
              val = rm.decode_header(msgobj, hdr, "", as_utf8=1)
              if val: 
                extra.append('<meta name="%s" content="%s">' % (hdr, neo_cgi.htmlEscape(val)))
          extra.append('<meta name="author" content="%s">' % neo_cgi.htmlEscape(string.lower(email)))
        extra = string.join(extra, "\n")

        data = rm.as_text()
        data = neo_cgi.htmlEscape(data)

        data = data + extra

        self._write("Document-Type: HTML*")
        self._write("Content-Length: %s" % str(len(data)))
        self._writeln()
        
        self._rtv.stdin.write(data)

        self._rtv_count = self._rtv_count + 1
Esempio n. 2
0
  def export_message (self, prefix, hdf, m = None, as_text = 0, attach_str = ""):
    self._charset = None
    if m is None: m = self.message
    hdf.setValue ("%s.charset" % prefix, neo_cgi.htmlEscape(self.charset(m)))
    h_date = self.decode_header(m, 'date', as_utf8 = 0)
    if h_date:
      tup = date.parsedate_tz(h_date)
      if tup:
        try:
          t = date.mktime_tz(tup)
          hdf.setValue("%s.date_t" % prefix, str(t))
          neo_cgi.exportDate(hdf, "%s.h_date" % prefix, self._tz, t)
        except ValueError:
          log("Bad Date: %s" % repr(tup))
          pass
        except OverflowError:
          log("Bad Date: %s" % repr(tup))
          pass
      hdf.setValue ("%s.h_date" % prefix, neo_cgi.htmlEscape(self.decode_header(m, 'date', as_utf8 = 1)))
    hdf.setValue ("%s.h_from" % prefix, htmlhelp.emailEscape(maskAddr(self.decode_header(m, 'from', as_utf8 = 1))))
    hdf.setValue ("%s.h_to" % prefix, htmlhelp.emailEscape(maskAddr(self.decode_header(m, 'to', as_utf8 = 1))))
    hdf.setValue ("%s.h_cc" % prefix, htmlhelp.emailEscape(maskAddr(self.decode_header(m, 'cc', as_utf8 = 1))))
    hdf.setValue ("%s.h_subject" % prefix, neo_cgi.htmlEscape(self.decode_header(m, 'subject', as_utf8 = 1)))
    self.export_address_header("%s.addr.from" % prefix, hdf, m, 'from')
    self.export_address_header("%s.addr.to" % prefix, hdf, m, 'to')
    self.export_address_header("%s.addr.cc" % prefix, hdf, m, 'cc')
    self._urls = {}
    if attach_str: self.embedded_parts(m, attach_str, self._urls)
    if as_text:
      body = self.part_as_text (m)
      body = re.sub("\s([^\s@]+)@([^\s@]+\.[^\s@]+)","\\1@...",body)

      hdf.setValue("%s.textbody" % prefix,neo_cgi.htmlEscape(body))
    else:
      self.export_part (m, prefix, hdf)
Esempio n. 3
0
    def redirectUri(self,redirectTo):
        ncgi = self.ncgi
        if ncgi.hdf.getIntValue("Cookie.debug",0) == 1:
            ncgi.hdf.setValue("CGI.REDIRECT_TO",redirectTo)
            ncgi.display("dbg/redirect.cs")
            print "<PRE>"
            print neo_cgi.htmlEscape(ncgi.hdf.dump())
            print "</PRE>"
            raise DisplayDone

        self.ncgi.redirectUri(redirectTo)
        raise Redirected, "redirected To: %s" % redirectTo
Esempio n. 4
0
File: CSPage.py Progetto: jeske/csla
    def redirectUri(self,redirectTo):
        ncgi = self.ncgi
        if ncgi.hdf.getIntValue("Cookie.debug",0) == 1:
            ncgi.hdf.setValue("CGI.REDIRECT_TO",redirectTo)
            ncgi.display("dbg/redirect.cs")
            print "<PRE>"
            print neo_cgi.htmlEscape(ncgi.hdf.dump())
            print "</PRE>"
            raise DisplayDone

        self.ncgi.redirectUri(redirectTo)
        raise Redirected, "redirected To: %s" % redirectTo
Esempio n. 5
0
    def redirectUri(self, redirectTo):
        ncgi = self.ncgi
        if ncgi.hdf.getIntValue("Cookie.debug", 0) == 1:
            ncgi.hdf.setValue("CGI.REDIRECT_TO", redirectTo)
            #            ncgi.display("dbg/redirect.cs")

            cs = neo_cs.CS(ncgi.hdf)
            self['Content-Type'] = "text/html"
            template = """
Redirect
<br><br>
<a href="<?cs var:CGI.REDIRECT_TO ?>"><?cs var:CGI.REDIRECT_TO ?></a>
"""
            cs.parseStr(template)
            page = cs.render()

            self.push(page)

            self.push("<PRE>\n")
            self.push(neo_cgi.htmlEscape(ncgi.hdf.dump()) + "\n")
            self.push("</PRE>\n")
            raise DisplayDone()

        self.context.setStatus(self, 302)
        self.ncgi.redirectUri(redirectTo)
        raise Redirected("redirected To: %s" % redirectTo)
Esempio n. 6
0
def eval_cs(hdf,a_cs_string):
    cs = neo_cs.CS(hdf)
    try:
      cs.parseStr(a_cs_string)
      return cs.render()
    except:
      return "Error in CS tags: %s" % neo_cgi.htmlEscape(repr(a_cs_string))
Esempio n. 7
0
    def redirectUri(self,redirectTo):
        ncgi = self.ncgi
        if ncgi.hdf.getIntValue("Cookie.debug",0) == 1:
            ncgi.hdf.setValue("CGI.REDIRECT_TO",redirectTo)
#            ncgi.display("dbg/redirect.cs")

            cs = neo_cs.CS(ncgi.hdf)
            self['Content-Type'] = "text/html"
            template = """
Redirect
<br><br>
<a href="<?cs var:CGI.REDIRECT_TO ?>"><?cs var:CGI.REDIRECT_TO ?></a>
"""
            cs.parseStr(template)
            page = cs.render()

            self.push(page)

            self.push("<PRE>\n")
            self.push(neo_cgi.htmlEscape(ncgi.hdf.dump()) + "\n")
            self.push("</PRE>\n")
            raise DisplayDone()

        self.context.setStatus(self, 302)
        self.ncgi.redirectUri(redirectTo)
        raise Redirected("redirected To: %s" % redirectTo)
Esempio n. 8
0
def eval_cs(hdf,a_cs_string):
    cs = neo_cs.CS(hdf)
    try:
      cs.parseStr(a_cs_string)
      return cs.render()
    except:
      return "Error in CS tags: %s" % neo_cgi.htmlEscape(repr(a_cs_string))
Esempio n. 9
0
    def hdfExport(self, prefix, hdf_dataset, *extra, **extranamed):
        skip_fields = extranamed.get("skip_fields", None)
        no_escape = extranamed.get("no_escape", None)
        translate_dict = extranamed.get("translate_dict", None)
        tz = extranamed.get("tz", "US/Pacific")

        for col_name, value in self.items():
            if skip_fields and (col_name in skip_fields):
                continue
            try:
                name, col_type, col_options = self._table.getColumnDef(
                    col_name)
            except:
                col_type = odb.kVarString
                col_options = {}

            if (value is not None):
                if col_options.get("no_export", 0): continue
                if type(value) in [type(0), type(0L)]:
                    hdf_dataset.setValue(prefix + "." + col_name, "%d" % value)
                elif type(value) == type(1.0):
                    if int(value) == value:
                        hdf_dataset.setValue(prefix + "." + col_name,
                                             "%d" % value)
                    else:
                        hdf_dataset.setValue(prefix + "." + col_name,
                                             "%0.2f" % value)
                else:
                    if col_type == odb.kReal:
                        log("why are we here with this value: %s" % value)
                    if translate_dict:
                        for k, v in translate_dict.items():
                            value = string.replace(value, k, v)
                    if no_escape and col_name in no_escape:
                        hdf_dataset.setValue(prefix + "." + col_name,
                                             str(value))
                    else:
                        hdf_dataset.setValue(prefix + "." + col_name,
                                             neo_cgi.htmlEscape(str(value)))
                if col_options.get("int_date", 0):
                    hdf_dataset.setValue(prefix + "." + col_name + ".string",
                                         renderDate(value))
                    hdf_dataset.setValue(
                        prefix + "." + col_name + ".day_string",
                        renderDate(value, day=1))
                    hdf_dataset.setValue(
                        prefix + "." + col_name + ".date_string",
                        renderDate(value, date=1))
                    if value:
                        try:
                            neo_cgi.exportDate(hdf_dataset,
                                               "%s.%s" % (prefix, col_name),
                                               tz, value)
                        except TypeError:
                            pass

                if col_options.has_key("enum_values"):
                    enum = col_options["enum_values"]
                    hdf_dataset.setValue(prefix + "." + col_name + ".enum",
                                         str(enum.get(value, '')))
Esempio n. 10
0
def hdfExport(prefix, hdf):
    global PROFILER_DATA
    n = 0
    for p in PROFILER_DATA:
        hdf.setValue("%s.%d.when" % (prefix, n), "%5.2f" % (p.when))
        hdf.setValue("%s.%d.time" % (prefix, n), "%5.2f" % (p.length))
        hdf.setValue("%s.%d.klass" % (prefix, n), p.klass)
        hdf.setValue("%s.%d.what" % (prefix, n), "&nbsp;" * p.depth + p.what)
        hdf.setValue("%s.%d.where" % (prefix, n), neo_cgi.htmlEscape(p.where))
Esempio n. 11
0
def hdfExport(prefix, hdf):
    global PROFILER_DATA
    n = 0
    for p in PROFILER_DATA:
        hdf.setValue("%s.%d.when" % (prefix, n), "%5.2f" % (p.when))
        hdf.setValue("%s.%d.time" % (prefix, n), "%5.2f" % (p.length))
        hdf.setValue("%s.%d.klass" % (prefix, n), p.klass)
        hdf.setValue("%s.%d.what" % (prefix, n), p.what)
        hdf.setValue("%s.%d.where" % (prefix, n), neo_cgi.htmlEscape(p.where))
Esempio n. 12
0
    def hdfExport(self, prefix, hdf, tz="US/Pacific", subj_prefix=None):
        hdf.setValue(prefix, "1")
        obj = hdf.getObj(prefix)
        obj.setValue("doc_id", str(self.doc_id))
        obj.setValue("thread_id", str(self.thread_id))
        obj.setValue("parent_id", str(self.parent_id))
        obj.setValue("next_id", str(self.next_id))
        obj.setValue("child_id", str(self.child_id))
        if self.date:
            neo_cgi.exportDate(obj, "date", tz, self.date)

        subject = self.subject
        if subj_prefix:
            subject = subject.replace(subj_prefix, '')
        obj.setValue("subject", neo_cgi.htmlEscape(subject))
        obj.setValue("subject_strip", neo_cgi.htmlEscape(strip_re(subject, subj_prefix=subj_prefix)))
        obj.setValue("subject_reduced", reduce_subject(subject, subj_prefix=subj_prefix))

        obj.setValue("author", neo_cgi.htmlEscape(self.author))
        obj.setValue("email", neo_cgi.htmlEscape(self.email))
        if self.summary is not None:
            obj.setValue("summary", neo_cgi.text2html(self.summary))
        if self.snippet is not None:
            obj.setValue("snippet", self.snippet)
Esempio n. 13
0
    def hdfExport(self, prefix, hdf_dataset, *extra, **extranamed):
        skip_fields = extranamed.get("skip_fields", None)
        no_escape = extranamed.get("no_escape", None)
        translate_dict = extranamed.get("translate_dict", None)
        tz = extranamed.get("tz", "US/Pacific")

        for col_name,value in self.items():
            if skip_fields and (col_name in skip_fields):
                continue
            try:
                name,col_type,col_options = self._table.getColumnDef(col_name)
            except:
                col_type = odb.kVarString
                col_options = {}
            
	    if (value is not None):
                if col_options.get("no_export",0): continue
		if type(value) in [ type(0), type(0L) ]:
		    hdf_dataset.setValue(prefix + "." + col_name,"%d" % value)
                elif type(value) == type(1.0):
                    if int(value) == value:
                        hdf_dataset.setValue(prefix + "." + col_name,"%d" % value)
                    else:
                        hdf_dataset.setValue(prefix + "." + col_name,"%0.2f" % value)
		else:
                    if col_type == odb.kReal:
                        log("why are we here with this value: %s" % value)
                    if translate_dict:
                        for k,v in translate_dict.items():
                            value = string.replace(value,k,v)
                    if no_escape and col_name in no_escape:
                      hdf_dataset.setValue(prefix + "." + col_name,str(value))
                    else:
                      hdf_dataset.setValue(prefix + "." + col_name,neo_cgi.htmlEscape(str(value)))
                if col_options.get("int_date",0):
                    hdf_dataset.setValue(prefix + "." + col_name + ".string",renderDate(value))
                    hdf_dataset.setValue(prefix + "." + col_name + ".day_string",renderDate(value,day=1))
                    hdf_dataset.setValue(prefix + "." + col_name + ".date_string",renderDate(value,date=1))
                    if value: 
                      try:
                        neo_cgi.exportDate(hdf_dataset, "%s.%s" % (prefix, col_name), tz, value)
                      except TypeError:
                        pass

		if col_options.has_key("enum_values"):
		    enum = col_options["enum_values"]
		    hdf_dataset.setValue(prefix + "." + col_name + ".enum",
					 str(enum.get(value,'')))
Esempio n. 14
0
''')

            self.push("</head>")

            self.push("<H1> Error in Page </H1>\n")
            self.push(
                "A copy of this error report has been submitted to the developers. "
            )
            self.push("The details of the error report are below.")

            self.push(handle_error.exceptionString())

            # print debug info always on page error...
            self.push("<HR>\n")
            self.push("<PRE>")
            self.push(neo_cgi.htmlEscape(ncgi.hdf.dump()))
            self.push("</PRE>")

        etime = time.time() - self.page_start_time
        ncgi.hdf.setValue("CGI.debug.execute_time", "%f" % (etime))
        #warn("excute_time", etime)

        if SHOULD_DISPLAY and self.pagename:
            debug_output = ncgi.hdf.getIntValue(
                "page.debug", ncgi.hdf.getIntValue("Cookie.debug", 0))

            # hijack the built-in debug output method...
            if ncgi.hdf.getValue("Query.debug", "") == ncgi.hdf.getValue(
                    "Config.DebugPassword", "1"):
                ncgi.hdf.setValue(
                    "Config.DebugPassword", "CSPage.py DEBUG hijack (%s)" %
Esempio n. 15
0
    def display_index(self):
        self.pagename = "index"

        # There are a couple different modes here... for now, we're doing 
        # thread mode

        mode = "new"
        if len(self.path_info) > 2:
            mode = self.path_info[2]
            if mode == "thread":
                try:
                    thread_id = int(self.path_info[3])
                except (ValueError, IndexError):
                    thread_id = -1
            elif mode == "month":
                try:
                    month = self.path_info[3]
                except (ValueError, IndexError):
                    tup = time.localtime(time.time())
                    year = tup[0]
                    mon = tup[1]
                    month = '%s-%02d' % (year, mon)
                bym = self.mdb.openByMonth()
                (first_num, count) = bym.get(month)
            elif mode == "author":
                try:
                    email = self.path_info[3].lower()
                except IndexError:
                    email = ""
                try:
                    sub_mode = self.path_info[5]
                except IndexError:
                    sub_mode = None
                if sub_mode == "month":
                    try:
                        month = self.path_info[6]
                    except (ValueError, IndexError):
                        tup = time.localtime(time.time())
                        year = tup[0]
                        mon = tup[1]
                        month = '%s-%02d' % (year, mon)
            elif mode == "search":
                query = self.ncgi.hdf.getValue("Query.query", "")
                if not query:
                    uri_root = self.ncgi.hdf.getValue("CGI.URIRoot", "/")
                    self.redirectUri("%s%s/search" % (uri_root, self.listname))
            else:
                mode = "new"
                thread_id = -1
        else:
            thread_id = -1

        self.ncgi.hdf.setValue("CGI.IndexMode", mode)
        self.ncgi.hdf.setValue("CGI.DisplayMode", "thread")

        if mode == "new":
            for x in range(1,10):
                try:
                    msgs = self.mdb.thread(-1 * x)
                    self.export_thread_index(msgs, "CGI.Index.Threads")
                except message_db.eNoMessage:
                    pass
            self.export_pages()
        elif mode == "thread":
            msgs = self.mdb.thread(thread_id)
            self.export_thread_index(msgs, "CGI.Index.Threads")
            self.export_pages()

        elif mode == "month":
            bym = self.mdb.openByMonth()
            firstnum,count = bym.get(month)
            inv_key = "%s:%s" % (firstnum,count)

            threads = {}
            thread_date = {}
            num = first_num
            x = 0
            (year, mon) = month.split('-')
            year = int(year) 
            mon = int(mon)
#            if count > 250:
#                self.ncgi.hdf.setValue("CGI.Index.More", "1")
#                count = 250 
            if self.debugEnabled:
                p = profiler.Profiler("MDB", "Month Fetch: %d messages" % count)
            while x < count:
                msg = self.mdb.message(num)
                if not msg: break
                tup = time.localtime(msg.date)
                if tup[0] == year and tup[1] == mon:
                    try:
                        threads[msg.thread_id].append(msg)
                    except KeyError:
                        threads[msg.thread_id] = [msg]
                    try:
                        if thread_date[msg.thread_id] > msg.date:
                            thread_date[msg.thread_id] = msg.date
                    except KeyError:
                        thread_date[msg.thread_id] = msg.date
                    x += 1
                num += 1
            if self.debugEnabled: p.end()
            if self.debugEnabled:
                p = profiler.Profiler("EXPORT", "Exporting threads")
            order_threads = []
            for thread_id, t_date in thread_date.items():
                order_threads.append((t_date, thread_id))
            order_threads.sort()

            for t_date, thread_id in order_threads:
                self.export_thread_index(threads[thread_id], "CGI.Index.Threads")
            if self.debugEnabled: p.end()
            self.export_pages()


        elif mode == "author" or mode == "search":
            self.ncgi.hdf.setValue("CGI.DisplayMode", "author")
            msgs = []
            if mode == "author":
                # Here, we search for the author
                msgs = self.mdb.search_author(email)
                authors = self.mdb.openAuthorIndex('r')
                
                authorRow = authors.get(email)
                self.ncgi.hdf.setValue("CGI.Author.Name", neo_cgi.htmlEscape(authorRow.name))
                self.ncgi.hdf.setValue("CGI.Author.Email", neo_cgi.htmlEscape(email))
            elif mode == "search":
                total, msgs = self.mdb.search(query)
                
            n = 0
            for msg in msgs:
                msg.hdfExport("CGI.Index.Messages.%d" % (n), self.ncgi.hdf, tz=self.tz, subj_prefix=self.subj_prefix)
                self._add_msg_to_page(msg, "CGI.Index.Messages.%d" % (n))
                n += 1
            self.export_pages()

        self.add_whichread_info()
Esempio n. 16
0
            import handle_error
            handle_error.handleException("Display Failed!")
            ERROR_MESSAGE = handle_error.exceptionString()

        if DISPLAY_ERROR:
            print "Content-Type: text/html\n\n"

            # print the page

            print "<H1> Error in Page </H1>"
            print "A copy of this error report has been submitted to the developers. "
            print "The details of the error report are below."


            print "<PRE>"
            print neo_cgi.htmlEscape(ERROR_MESSAGE)
            print "</PRE>\n"
            # print debug info always on page error...
            print "<HR>\n"
            print "<PRE>"
            print neo_cgi.htmlEscape(ncgi.hdf.dump())
            print "</PRE>"


        etime = time.time() - self.page_start_time
        ncgi.hdf.setValue("CGI.debug.execute_time","%f" % (etime))

        if SHOULD_DISPLAY and self.pagename:
            debug_output = ncgi.hdf.getIntValue("page.debug",ncgi.hdf.getIntValue("Cookie.debug",0))

            # hijack the built-in debug output method...
Esempio n. 17
0
File: CSPage.py Progetto: jeske/csla
            from clearsilver import handle_error
            handle_error.handleException("Display Failed!")
            ERROR_MESSAGE = handle_error.exceptionString()

        if DISPLAY_ERROR:
            print "Content-Type: text/html\n\n"

            # print the page

            print "<H1> Error in Page </H1>"
            print "A copy of this error report has been submitted to the developers. "
            print "The details of the error report are below."


            print "<PRE>"
            print neo_cgi.htmlEscape(ERROR_MESSAGE)
            print "</PRE>\n"
            # print debug info always on page error...
            print "<HR>\n"
            print "<PRE>"
            print neo_cgi.htmlEscape(ncgi.hdf.dump())
            print "</PRE>"


        etime = time.time() - self.page_start_time
        ncgi.hdf.setValue("CGI.debug.execute_time","%f" % (etime))

        if SHOULD_DISPLAY and self.pagename:
            debug_output = self.debugEnabled or ncgi.hdf.getIntValue("page.debug",ncgi.hdf.getIntValue("Cookie.debug",0))

            if not debug_output:
Esempio n. 18
0
    def _renderPlainTextToHtml(self,raw_body, hide_quoted=1):
        # log("render: " + raw_body[:100])
        result = RenderResultInfo()

        raw_body = fixbody(string.strip(raw_body))

        lines = string.split(raw_body,"\n")
        result.num_lines = len(lines)

        def urlsub(match):
            url_text = match.group(1)
            if len(url_text) > 60:
                url_text = url_text[:60] + "..."
            return '<a class=newlink target=_blank href="%s">%s</a>' % (match.group(1), url_text)
        def news_urlsub(match):
            return '[<a class=newlink target=_blank href="http://groups.google.com/groups?as_umsgid=%s">msg</a>]' % neo_cgi.urlEscape(match.group(1))

        def chopword(match):
            outdata = []
            indata = match.group(0)
            while len(indata) > 80:
                outdata.append(indata[:80])
                indata = indata[80:]
            outdata.append(indata)
            return string.join(outdata," ")
            

        line_render = msgutil.RenderDataRE(default_renderer=neo_cgi.htmlEscape)
        line_render.addRenderer("([a-z]{3,10}://[[a-zA-Z0-9.]+[^ \t\n]*[^.,> ])",urlsub)
        # line_render.addRenderer("([-_*/])\\1{2,}","\\1")
        # line_render.addRenderer("[^\s]{80,}",chopword)

        line_render.addRenderer("([<\s][a-zA-Z0-9-_.+=]+)(@[a-zA-Z0-9-_.])[a-zA-Z0-9-_.]+([>\s])",
                              lambda m: neo_cgi.htmlEscape(m.group(1) + m.group(2) + "..." + m.group(3)))
        line_render.addRenderer("news:([^/][^ ]+@[0-9a-zA-Z-_.]+)",
                                news_urlsub)


        output = []
        quoted_text = []
        signature_text = []
        quoted_text_word_start = 0
        ws_lines = 0
        eat_rest = 0
        eat_rest_signature = 0
        in_paragraph = 0

        for a_line in lines:
            # this regex was hanging! - jeske
            # I think this was the input: "http://groups.yahoo.com/group/tuna/"
            # workaround terrible IE wrapping bug
            # if re.search("/(([^ ]+)){30,}",a_line):
            #     a_line = re.sub("/([^ ]+) ","    /    \\1 ",a_line)

            if re.match("[-]+ Yahoo! Groups Sponsor [-~>]+",a_line):
                break

            if re.match("Yahoo! Groups Links",a_line):
                eat_rest = 1
                break

            if re.match("mythtv-users mailing list",a_line):
                eat_rest = 1
                break

            # need to do our word counting here!
            word_line = re.sub("[^a-zA-Z0-9 ]"," ",a_line)
            insert_shift = 0
            word_arr = generateWordPosArr(word_line)

            # keep track of where quoted regions start
            if not quoted_text:
                quoted_text_word_start = self._cur_word_count

            # do mark insertion            
            for word_pos in word_arr:
                if self._word_marks.has_key(self._cur_word_count):
                    wref_list = self._word_marks[self._cur_word_count]
                    a_line = a_line[:word_pos+insert_shift] + REPLACE_MARKER + a_line[word_pos+insert_shift:]
                    insert_shift = insert_shift + len(REPLACE_MARKER)

                    # we're going to come back and put it in later
                    if self._debug:
                        self._mark_insert_list.append(string.join(map(lambda wref: '<span id="qref_%s" class=mark>%s</span>' % (wref,wref),wref_list),''))
                    else:
                        self._mark_insert_list.append(string.join(map(lambda wref: '<span id="qref_%s" class=mark></span>' % (wref),wref_list),''))
                
                self._cur_word_count = self._cur_word_count + 1

            # log("handle: " + a_line)
            # a_line = string.strip(a_line)
            if hide_quoted:
                if re.match("^-- $",a_line):
                    eat_rest_signature = 1
                    continue

                # hack for mythtv mailing list
                if re.match("_______________________________________________",a_line):
                    eat_rest_signature = 1
                    continue
                
                if eat_rest_signature:
                    signature_text.append(a_line)
                    continue

                if eat_rest or re.match("^([A-Z]{2})?[}>|]+( .*)?",a_line):
                    # quoted text
                    quoted_text.append(a_line)
                    result.num_quoted_lines += 1
                    continue

                if re.match(" *-+ ?Original Message ?(Follows )?-+ *",a_line):
                    output.append(a_line)
                    eat_rest = 1
                    continue

            if not string.strip(a_line):
                ws_lines = ws_lines + 1
                continue

            if len(quoted_text):
                hidden = 0
                # log("checking for range %s,%s -- %s" % (quoted_text_word_start,self._cur_word_count,repr(self._hide_quote_at)))
                for i in range(quoted_text_word_start,self._cur_word_count):
                    if self._hide_quote_at.has_key(i):
                        hidden = 1

                if len(quoted_text) > 15:
                    hidden = 1
                    
                output.append(self.renderQuoteBlock(quoted_text,hidden=hidden))
                in_paragraph = 0
                ws_lines = 0
                quoted_text = []

            if ws_lines:
                ws_lines = 0
                output.append("<p>")
                in_paragraph = 0

 
            # when we're rendering a quoted block, this outputs the lines
            if re.match("^([A-Z]{2})?[}>|]+( .*)?",a_line):
                output.append(line_render.renderString(a_line) + "<br>")
                in_paragraph = 0
                continue

            if re.search(" {5,}[^ ]+ {2,}",a_line):
                # whitespace formatted
                output.append(preformat(line_render.renderString(a_line)) +"<br>")
                in_paragraph = 0
                continue

            if re.match("^((\t+)|( {3,})).*",a_line):
                # indent
                output.append(preformat(line_render.renderString(a_line)) +"<br>")
                in_paragraph = 0
                continue

            if re.match(".*:\s*",a_line):
                # ends in a colon
                output.append(line_render.renderString(a_line) + "<br>")
                in_paragraph = 0
                continue


            if ( re.match("\s*[0-9a-z]+[).].*",a_line) or
                 re.match("\s*[-*=+]+ .*",a_line) ):
                # number/letter outlines, bullet lists
                if in_paragraph:
                    output.append("<br>")
                output.append(preformat(line_render.renderString(a_line)) +"<br>")
                in_paragraph = 0
                continue

            if re.match("[\t ]{3,}.*",a_line) or containsSymbols(a_line):
                output.append(preformat(line_render.renderString(a_line)) +"<br>")
                in_paragraph = 0
                continue

            if len(a_line) < 50:
                output.append(line_render.renderString(a_line) + "<br>")
                in_paragraph = 0
                continue

            # japansese non-wrap code from gaku...
            if 0:
                output.append(line_render.renderString(a_line) + "<br>")
                continue

            output.append(line_render.renderString(a_line))
            in_paragraph = 1

        if len(quoted_text):
            output.append(self.renderQuoteBlock(quoted_text))

        if len(signature_text):
            output.append(self.renderSignatureBlock(signature_text))
 
        result.s = string.join(output,"\n")
        return result
Esempio n. 19
0
def emailEscape(addr):
    return neo_cgi.htmlEscape(addr)
Esempio n. 20
0
.cgitb .buttons li {display: inline; margin: 0; padding: 0 0.25em;}
</style>
''')

            self.push("</head>")

            self.push("<H1> Error in Page </H1>\n")
            self.push("A copy of this error report has been submitted to the developers. ")
            self.push("The details of the error report are below.")

            self.push(handle_error.exceptionString())

            # print debug info always on page error...
            self.push("<HR>\n")
            self.push("<PRE>")
            self.push(neo_cgi.htmlEscape(ncgi.hdf.dump()))
            self.push("</PRE>")


        etime = time.time() - self.page_start_time
        ncgi.hdf.setValue("CGI.debug.execute_time","%f" % (etime))
        #warn("excute_time", etime)

        if SHOULD_DISPLAY and self.pagename:
            debug_output = ncgi.hdf.getIntValue("page.debug",ncgi.hdf.getIntValue("Cookie.debug",0))

            # hijack the built-in debug output method...
            if ncgi.hdf.getValue("Query.debug","") == ncgi.hdf.getValue("Config.DebugPassword","1"):
                ncgi.hdf.setValue("Config.DebugPassword","CSPage.py DEBUG hijack (%s)" %
                    ncgi.hdf.getValue("Config.DebugPassword",""))
                debug_output = 1