def compute_main(): pages = session. \ query(Page). \ join(BlogPage). \ order_by(BlogPage.publish_date.desc()). \ all() return render_template('archive', pages=pages, number_to_us=number_to_us)
def compute_handle_page_get(request, map): map = session.query(UrlMap).filter_by(url_map_id=map['url_map_id']).first() template_data = default_page_template_data(request, map) text_ads = map.page.text_ads.filter( or_(TextAds.expires==None, TextAds.expires<=datetime.utcnow()) ).all() adsense = True if map.page_id in no_adsense_ids: adsense = False stackvm = False if map.page_id in stackvm_ids: stackvm=True referer = request.headers.get('Referer', 'None') mobile = False if mobile_rx.search(referer): mobile = True return render_template("page", text_ads=text_ads, stackvm=stackvm, adsense=adsense, mobile=mobile, **template_data)
def compute_all(): downloads = session. \ query(Download). \ order_by(Download.timestamp.desc()). \ all() return render_template('downloads', downloads=downloads, number_to_us=number_to_us)
def compute_main(request, seo_name): # TODO: perhaps this query is not necessary tag = session.query(Tag).filter_by(seo_name=seo_name).first() if not tag: raise NotFound() pages = tag.blog_pages.order_by(BlogPage.publish_date.desc()).all() return render_template('tag', tag=tag, pages=pages, number_to_us=number_to_us)
def compute_main(request, seo_name): category = session.query(Category).filter_by(seo_name=seo_name).first() if not category: raise NotFound() pages = category.blog_pages.order_by(BlogPage.publish_date.desc()).all() return render_template('category', category=category, pages=pages, number_to_us=number_to_us)
def compute_page_list(): posts = session. \ query(Page). \ join(BlogPage). \ order_by(BlogPage.publish_date.desc()). \ filter(BlogPage.visible==True). \ all() return render_template( 'page_list', posts=posts, pagination=Pagination(1, total_blogpages(), config.posts_per_page))
def main(request): exc_type, exc_value, tb = sys.exc_info() str_tb = str_traceback(exc_type, exc_value, tb) highlighted_str_tb = highlight(str_tb, PythonTracebackLexer(), HtmlFormatter()) template = render_template('exception', exception_type=exc_type.__name__, exception_message=str(exc_value), traceback=highlighted_str_tb) return Response(template, mimetype='text/html', status=500)
def compute_year(year): pages = session. \ query(Page). \ join(BlogPage). \ filter('year(blog_pages.publish_date) = %d' % year). \ order_by(BlogPage.publish_date.desc()). \ all() return render_template('archive_year', pages=pages, year=year, number_to_us=number_to_us)
def compute_main(sorted_by): if sorted_by == 'views': sort_f = Page.views.desc elif sorted_by == 'date': sort_f = BlogPage.publish_date.desc pages = session. \ query(Page). \ join(BlogPage). \ order_by(sort_f()). \ all() return render_template('archive', pages=pages, sorted_by=sorted_by, number_to_us=number_to_us)
def compute_handle_page(page_nr=1): mixergy = get_mixergy(page_nr) page_array = [] for page, urlmap in mixergy: page_array.append(mako_page(page, urlmap.request_path)) template_data = { "page_array": page_array, "pagination": Pagination(page_nr, total_blogpages(), config.posts_per_page), } if page_nr == 1: template_data["front_page"] = True return render_template("index", **template_data)
def compute_year_month(year, month): filter_str = 'year(blog_pages.publish_date) = %d and ' \ 'month(blog_pages.publish_date) = %d' % (year, month) pages = session. \ query(Page). \ join(BlogPage). \ filter(filter_str). \ order_by(BlogPage.publish_date.desc()). \ all() return render_template('archive_year_month', pages=pages, year=year, nmonth=month, month=MONTH[month], number_to_us=number_to_us)
def compute_handle_page(page_nr=1): mixergy = get_mixergy(page_nr) page_array = [] for page, urlmap in mixergy: page_array.append( mako_page(page, urlmap.request_path) ) template_data = { 'page_array': page_array, 'pagination': Pagination(page_nr, total_blogpages(), config.posts_per_page), 'page_nr' : page_nr } if page_nr == 1: template_data['front_page'] = True template_data['adsense'] = True else: template_data['front_page'] = False return render_template("index", **template_data)
def main(request): template = render_template('404', path=request.path) return Response(template, mimetype='text/html', status=404)
def compute_main(): news = session.query(News).order_by(News.timestamp.desc()).all() return render_template('news', news=news)
def compute_list(request): tags = session.query(Tag).order_by(Tag.name).all() return render_template('tag_list', tags=tags)
def compute_single(seo_name): series = session.query(ArticleSeries).filter_by(seo_name=seo_name).first() if not series: # TODO: better not-found message raise NotFound return render_template('series', series=series, number_to_us=number_to_us)
def compute_sitemap(): series = session.query(ArticleSeries).order_by(ArticleSeries.name).all() return render_template('sitemap', pages=PAGES, series=series)
def compute_list(request): return render_template('category_list')
def compute_list(): series = session. \ query(ArticleSeries). \ order_by(ArticleSeries.name.asc()). \ all() return render_template('series_list', series=series)