Exemple #1
0
def main(argv):
    "threader main, start threadreader webapp"
    # open threadstore client
    ThreadStoreClient.open(**settings.THREADSTORE)
    # start threadreader webapp
    msg = 'Starting Threadreader on port %d...' % settings.APP.port
    log.info(msg)
    print(msg)
    application = tornado.web.Application(handlers, **settings.TORNADO)
    application.listen(settings.APP.port)
    tornado.ioloop.IOLoop.instance().start()
Exemple #2
0
 def post(self, item):
     "add tqgs to given item"
     tags = self.get_body_argument('tags').strip()
     if tags:
         tags = list(map(str.strip, tags.split(',')))
     ThreadStoreClient.instance().blocking_threadstore.update_tags(item, user='******', add_tags=tags)
     # pull & return updated tag directory
     feeds, threads = self._get_dirs()
     self.render('directory_tree.html',
                 thread_dir=threads,
                 feed_dir=feeds,
                 new_feed=None,
                 utils=utils)
Exemple #3
0
 def _create_feed(self, posts, title='', subtitle='', updated=None):
     # connect to threadstore
     ts = ThreadStoreClient.instance().blocking_threadstore  # TODO: make async
     title = ThreadStore.tag_escape(title)
     if not self.collection:
         # construct feed collection name
         self.collection = 'threadreader.feeds.%s.%s' % (self.user, title)
     # construct feed tag, for now just escaped title if not supplied
     if not self.feed_tag:
         self.feed_tag = 'feed:' + title
     self.tags.append(self.feed_tag)
     # build or update feed collection
     try:
         col_id = ts.get_collection(self.collection)['_id']
         # TODO: should ensure existing collection is from same feed_url, in case titles from two feeds are the same
     except ItemNotFound:
         col_id = ts.create_collection(self.collection, user=self.user)['_id']
     ts.update_collection(dict(_id=col_id,
                               title=title,
                               subtitle=subtitle,
                               feed_tag=self.feed_tag,
                               feed_url=self.feed_url,
                               seed_url=self.seed_url,
                               updated=dateutil.parser.parse(updated) if updated else None,
                               ))
     # TODO: get & cache favicon.ico
     # add feed entry posts
     for post in posts:
         ts.create_post(col_id, user='******', body=post, tags=self.tags)
Exemple #4
0
    def _get_dirs(self):
        "get up-to-date feed & tag dirs for threadreader feeds"
        # for now, a simple tag directory, with the feed: TL tree pulled out as the feed tree
        #   this hides feeds with no current posts, TODO: fix this to show all owned feed collections when users/perms system comes up
        # get the initial tag directory
        threads = ThreadStoreClient.instance().blocking_threadstore.posts_tag_directory(collection='threadreader.feeds',
                                                                                        counts=True,
                                                                                        filter={"$not":{"$regex": r'tagging|taggedBy'}})
        # extract feed: subtree
        feeds = threads.pop('feed:', dict())

        return feeds, threads
Exemple #5
0
 def _get_feeds_dir(self):
     "get an up-to-date structured of all threadreader feed collections"
     return ThreadStoreClient.instance().blocking_threadstore.collection_directory(collection='threadreader.feeds',
                                                                                   counts=True)
Exemple #6
0
 def _get_threads_dir(self):
     "get an up-to-date structured tag directory for all threadreader collections"
     return ThreadStoreClient.instance().blocking_threadstore.posts_tag_directory(collection='threadreader.feeds',
                                                                                  counts=True,
                                                                                  filter={"$not":{"$regex": r'tagging|taggedBy'}})
Exemple #7
0
 def get(self, item_id):
     item = ThreadStoreClient.instance().blocking_threadstore.get_post(item_id)
     if item:
         self.render('thread_select.html', item=item, thread_tag=None, utils=utils)
Exemple #8
0
 def get(self, tag):
     thread = ThreadStoreClient.instance().blocking_threadstore.thread(tag, 'threadreader', sort=[{"published": -1}])
     if thread:
         self.render('threadlist.html', thread=thread['items'], thread_tag=tag, utils=utils)
Exemple #9
0
def build_test_db(argv):
    "init reader threadstore collections & build test feeds"
    tsc = ThreadStoreClient.open(**settings.THREADSTORE)
    tsc.init_reader_threadstore()
    tsc.build_test_db()
    tsc.close()
Exemple #10
0
def init_reader_threadstore(argv):
    "init reader threadstore collections"
    tsc = ThreadStoreClient.open(**settings.THREADSTORE)
    tsc.init_reader_threadstore()
    tsc.close()