示例#1
0
文件: api.py 项目: udimilo/udi0312
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'
示例#2
0
文件: api.py 项目: udimilo/udi0312
def add_repin():
    pin = cacher.get('pin', long(request.vars.id))
    board = cacher.get('board', long(request.vars.repin_board))

    if pin and board:
        repin = db((db.pin.article==pin['article'])&(db.pin.board==board['id'])).select().first()
        if repin is None:
            article = cacher.get('article', pin['article'])
            repin = logic.add_pin(article, board)
            repin.original_pin = pin['id']
            repin.update_record()
            cacher.delete(repin.id)
            if request.vars.linkedin and request.env.http_host != '127.0.0.1:8080':
                logic.share_on_linkedin(session.linkedin, repin)

    return 'Success'