Beispiel #1
0
def new_list(page):
    search_form = SearchForm()
    q = News.query().order(-News.post_time)
    news, cursor, more =q.fetch_page(PAGESIZE,offset=PAGESIZE*(page-1))
    return render_template('new.html',search_form=search_form,news=news, page=more and page+1 or 0, host=HOST,counter=counter.load_and_get_count("view"),acc=ACC)    
Beispiel #2
0
def comment(post_id):
    news = ndb.Key("News",post_id).get()
    return render_template('comment.html',article=news,host=HOST,counter=counter.load_and_get_count("view"),acc=ACC)
Beispiel #3
0
def search_keyword():
    search_form = SearchForm()
    logging.info(request.args.get('keyword'))
    results = search.Index(name=_INDEX_NAME).search("\""+request.args.get('keyword')+"\"")
    return render_template('search.html',search_form=search_form,results=results, host=HOST,counter=counter.load_and_get_count("view"),acc=ACC)
Beispiel #4
0
def bookmarklet():
    return render_template('bookmarklet.html',counter=counter.load_and_get_count("view"),acc=ACC)
Beispiel #5
0
def news_post():
    form = NewsForm()
    if form.validate_on_submit():
        news = News(view = 0, title = form.title.data,url = form.url.data,hot = False)
        try:
            news.put()
            search.Index(name=_INDEX_NAME).add(create_doc(news.key.id(),news.title,news.url,news.post_time))
            flash(u'저장 성공', 'success')
            return redirect(url_for('new_list'))
        except CapabilityDisabledError:
            flash(u'App Engine Datastore is currently in read-only mode.', 'failure')
            return redirect(url_for('new_list'))
    return render_template('news_post.html', form=form,title= request.args.get('title'), url= request.args.get('url'),counter=counter.load_and_get_count("view"),acc=ACC)