Beispiel #1
0
    def _format_message_from_db_row(self, entry):
        date_formater.init_date()
        message = {}
        message["imapid"] = entry[0]
        message["fulltext"] = entry[1]
        message["encoding"] = entry[2]
        message["subject"] = entry[3]
        addr = email_utils.parseaddr(entry[4])
        message["sender"] = addr
        message["seen"] = entry[5]
        message["date"] = date_formater.format_date(entry[6], True)
        message["mailbox"] = entry[7]

        encoding = "utf-8" # is this encoding stuff *really* necessary?
        if message["fulltext"] is not None: # yay, we even have the content!!
            if message["encoding"] is not None:
                encoding = message["encoding"]
        else:
            m = self.mailbox
            if message["mailbox"] != m:
                self.load_mailbox(message["mailbox"])
                message["fulltext"] = self._load_message_body(message["imapid"])
                self.load_mailbox(m)
            else:
                message["fulltext"] = self._load_message_body(message["imapid"])
        email_message = email.message_from_string(message["fulltext"].encode(encoding))
        content = self.get_content_from_message(email_message)[0]
        message["body"] = unicode(content)
        return message
Beispiel #2
0
 def load_threads_searched(self, start, end, token):
     date_formater.init_date()
     cur = self.db.execute('select imapid, subject, seen, sender, date from threads'
                          + self._get_where() + (" and subject like '%s' " % ("%" + token + "%"))
                          + self._get_order_by()
                          + ' limit %s,%s' % (start, end))
     entries = [dict(imapid=row[0], subject=row[1],
                     seen=row[2], sender=self.parse_emails(row[3]),
                     date=date_formater.format_date(row[4]) ) for row in cur.fetchall()]
     return entries
Beispiel #3
0
def before_request():
    g.db = sqlite3.connect(app.config['DATABASE'])
    import rss_db
    g.al = rss_db.FeedsDatabase()
    date_formater.init_date()
Beispiel #4
0
def ajax_full_view(article):
    save_view_mode(1)
    date_formater.init_date()
    cur = g.al.get_articles_for_feed(article)
    feeds = [dict(sender=(art.name, feed.url, art.url), imapid=art.id, seen=art.seen, body=art.content + "<div class=\"clearer\"></div>", date=date_formater.format_date(art.pubDate), feedid=art.feed) for art, feed in cur]
    return jsonify(content=render_template("rss/rss-ajax-thread.html", thread=feeds))
Beispiel #5
0
def ajax_full_view_unread():
    save_view_mode(1)
    date_formater.init_date()
    cur = g.db.execute("select feeds.url, articles.name, articles.id, articles.content, articles.seen, feeds.name, articles.pubDate, articles.url, articles.feed from articles, feeds where feeds.id = articles.feed and seen = 0 order by articles.pubDate desc")
    feeds = [dict(sender=(row[1], row[5], row[7]), imapid=row[2], seen=row[4], body=row[3] + "<div class=\"clearer\"></div>", date=date_formater.format_date(row[6]), feedid=row[8]) for row in cur.fetchall()]
    return jsonify(content=render_template("rss/rss-ajax-thread.html", thread=feeds))