Esempio n. 1
0
def source(request, source=''):
    s = db.get_source(source)
    if s is None:
        return _404_response()
    start, end, limit = _parse_params(request)
    articles = db.list_articles_by_source(source, start=start, end=end, limit=limit)
    s['articles'] = articles
    return json_response(s)
Esempio n. 2
0
def source(request):
    s = _get(request, 's')
    if not s:
        return HttpResponseRedirect('/')
    articles = db.list_articles_by_source(s)
    if not articles:
        return HttpResponseRedirect('/')
    for article in articles:
        article['url'] = urllib.unquote(article['url'])
    source = db.get_source(s)
    return render_to_response('source.html', dict(articles=articles,
                                                  source=source))
Esempio n. 3
0
def article_by_url(request):
    url = views._get(request, 'url')
    if not url:
        return _404_response()
    article = db.get_article_by_url(url)
    if not article:
        return _404_response()
    article['source'] = db.get_source(article['source'])
    #article['topics'] = db.get_topics_by_article(aid)
    article['url'] = urllib.unquote(article['url'])
    article['source']['url'] = urllib.unquote(article['source']['url'])
    #if article['cached'] and len(article['cached']) > 100:
    #    article['cached'] = article['cached'][:100] + '...'
    return json_response(article)
Esempio n. 4
0
def article(request, aid=''):
    if not aid:
        return _404_response()
    aid = int(aid)
    article = db.get_article(aid)
    if not article:
        return _404_response()
    article['source'] = db.get_source(article['source'])
    article['topics'] = db.get_topics_by_article(aid)
    article['url'] = urllib.unquote(article['url'])
    article['source']['url'] = urllib.unquote(article['source']['url'])
    #if article['cached'] and len(article['cached']) > 100:
    #    article['cached'] = article['cached'][:100] + '...'
    return json_response(article)
Esempio n. 5
0
def article(request):
    aid = _get(request, 'id')
    if not aid:
        return HttpResponseRedirect('/')
    aid = int(aid)
    article = db.get_article(aid)
    if not article:
        return HttpResponseRedirect('/')
    article['source'] = db.get_source(article['source'])
    article['topics'] = db.get_topics_by_article(aid)
    article['url'] = urllib.unquote(article['url'])
    article['source']['url'] = urllib.unquote(article['source']['url'])
    if article['cached'] and len(article['cached']) > 100:
        article['cached'] = article['cached'][:100] + '...'
    return render_to_response('article.html', article)