Exemple #1
0
def add_article():
    url = request.vars.url
    board = cacher.get('board',long(request.vars.board))
    article = logic.get_article_by_url(url)

    if article is None:
        r = Readability()
        json = r.content(url)
        article = db.article.insert(
            url=json['url'],
            readability_url=json['short_url'],
            title=json['title'],
            #content=json['content'],
            domain=json['domain'],
            author=json['author'],
            excerpt=json['excerpt'],
            word_count=json['word_count'],
            total_pages=json['total_pages'],
            date_published=json['date_published'],
            next_page_id=json['next_page_id'],
            rendered_pages=json['rendered_pages'],            
        )
    
    pin = logic.add_pin(article, board)
    if request.vars.linkedin and request.env.http_host != '127.0.0.1:8080':
        logic.share_on_linkedin(session.linkedin, pin)

    return 'Success'
Exemple #2
0
def get_article(id):
    article = cacher.get('article', id)
    if not article.has_key('content'):
        #fetch content from readability in real time
        r = Readability()
        json = r.content(article['url'])
        article['content'] = json['content'].encode('UTF8', 'replace')
        cacher.set(article)

    return article