def show_paste(self, identifier, raw=False): """Show an existing paste.""" linenos = local.request.args.get('linenos') != 'no' paste = Paste.get(identifier) if paste is None: raise NotFound() if raw: return Response(paste.code, mimetype='text/plain; charset=utf-8') style, css = get_style(local.request) return render_to_response('show_paste.html', paste=paste, style=style, css=css, styles=STYLES, linenos=linenos, )
def show_paste(self, identifier, raw=False): """Show an existing paste.""" linenos = local.request.args.get('linenos') != 'no' paste = Paste.get(identifier) if paste is None: raise NotFound() if raw: return Response(paste.code, mimetype='text/plain; charset=utf-8') style, css = get_style(local.request) return render_to_response( 'show_paste.html', paste=paste, style=style, css=css, styles=STYLES, linenos=linenos, )
def show_all(self, page=1): """Paginated list of pages.""" def link(page): if page == 1: return '/all/' return '/all/%d' % page form_args = local.request.args query = Paste.find_all() pastes = query.limit(10).offset(10 * (page - 1)).all() if not pastes and page != 1: raise NotFound() return render_to_response('show_all.html', pastes=pastes, pagination=generate_pagination( page, 10, query.count(), link), css=get_style(local.request)[1], show_personal='show_personal' in form_args)
def show_all(self, page=1): """Paginated list of pages.""" def link(page): if page == 1: return '/all/' return '/all/%d' % page form_args = local.request.args query = Paste.find_all() pastes = query.limit(10).offset(10 * (page - 1)).all() if not pastes and page != 1: raise NotFound() return render_to_response('show_all.html', pastes=pastes, pagination=generate_pagination(page, 10, query.count(), link), css=get_style(local.request)[1], show_personal='show_personal' in form_args )
def styles_get_stylesheet(name): """Return the stylesheet for a given style.""" return get_style(name)