def login(request): if request.method == 'GET': header = get_headers() body = template('login.html') return header + '\r\n' + body elif request.method == 'POST': data = request.form() user = User.validate(data['username'], data['password']) if user: # 产生一个32位0-9字符串 session_id = ''.join(str(randint(0, 9)) for _ in range(32)) # 保存session值 sessions[session_id] = user.id kwargs = { 'Location': '/', 'Set-Cookie': 'session_id:{}'.format(session_id), } # 设置返回头部信息,制造重定向 header = get_headers(code=302, **kwargs) return header + '\r\n' else: header = get_headers() body = template('login.html', message='登录失败') return header + '\r\n' + body else: return error(request)
def route_login(request): """ 登录的请求函数, 处理登录请求的响应 headers 的格式如下 # 'Set-Cookie': 'height=169; gua=1; pwd=2; Path=/', """ headers = { 'Content-Type': 'text/html', } log('login, cookies', request.cookies, current_user(request)) username, result = '【游客】', '' if request.method == 'POST': form = request.form() u = User(form) username = '******' if u.validate_login(): username = u.username user = User.find_by(username=u.username) # 可以通过设置一个令牌(随机字符串)进行使用 session_id = random_str() log('session_id', session_id) session[session_id] = user.id log('LOGIN', session, user.id) headers['Set-Cookie'] = 'user={}'.format(session_id) result = '登录成功' body = template('login.html', username=username, result=result) return http_response(body, headers) # return redirect('/', headers) else: result = '用户名或密码错误' else: result = '' body = template('login.html', username=username, result=result) return http_response(body, headers)
def make_iso_image(): setfile('${ISO_DESTDIR}/boot/loader.conf', template('${BUILD_CONFIG}/templates/cdrom/loader.conf')) setfile('${ISO_DESTDIR}/boot/grub/grub.cfg', template('${BUILD_CONFIG}/templates/cdrom/grub.cfg')) setfile('${ISO_DESTDIR}/.mount.conf', template('${BUILD_CONFIG}/templates/cdrom/mount.conf')) sh('cp ${WORLD_DESTDIR}/boot/device.hints ${ISO_DESTDIR}/boot/device.hints') sh('grub-mkrescue -o ${output} ${ISO_DESTDIR} -- -volid ${CDROM_LABEL}') sha256(output)
def linux_readme(data): master_tmpl = template('linux_readme_master.tmpl') row_tmpl = template('linux_driver_row.tmpl', True) link_tmpl = template('markdown_link.tmpl', True) md_true = template('markdown_true.tmpl', True).substitute() md_false = template('markdown_false.tmpl', True).substitute() drivers = sorted(data['drivers'], key=linux_driver_key) def row_gen(): for drv in drivers: driver_url = drv.get('driver_url') if driver_url: driver_link = link_tmpl.substitute(text="Driver link", url=driver_url) else: driver_link = '' nvenc_patch = md_true if drv['nvenc_patch'] else md_false nvfbc_patch = md_true if drv['nvfbc_patch'] else md_false yield row_tmpl.substitute(version=drv['version'], nvenc_patch=nvenc_patch, nvfbc_patch=nvfbc_patch, driver_link=driver_link) version_list = "\n".join(row_gen()) latest_version = drivers[-1]['version'] example_driver = find_driver(drivers, linux_driver_key(data['example']), linux_driver_key) example_driver_url = example_driver['driver_url'] return master_tmpl.substitute( version_list=version_list, latest_version=latest_version, example_driver_url=example_driver_url, example_driver_version=example_driver['version'], example_driver_file=os.path.basename(example_driver_url))
def windows_driver_rows(drivers): driver_row_tmpl = template('windows_driver_row.tmpl', True) markdown_link_tmpl = template('markdown_link.tmpl', True) def row_gen(): for d in drivers: product = PRODUCT_LABELS[Product[d['product']]] variant = d.get('variant') version_variant = d['version'] version_variant += (" " + variant) if variant else '' patch64_url = d.get('patch64_url') patch32_url = d.get('patch32_url') driver_url = d.get('driver_url') patch64_link = markdown_link_tmpl.substitute( text="x64 library patch", url=patch64_url) if patch64_url else '' patch32_link = markdown_link_tmpl.substitute( text="x86 library patch", url=patch32_url) if patch32_url else '' driver_link = markdown_link_tmpl.substitute( text="Driver link", url=driver_url) if driver_url else '' yield driver_row_tmpl.substitute(product=product, version_variant=version_variant, patch64_link=patch64_link, patch32_link=patch32_link, driver_link=driver_link) return "\n".join(row_gen())
def make_iso_image(): setfile('${ISO_DESTDIR}/boot/loader.conf', template('${BUILD_CONFIG}/templates/cdrom/loader.conf')) setfile('${ISO_DESTDIR}/.mount.conf', template('${BUILD_CONFIG}/templates/cdrom/mount.conf')) sh('cp ${WORLD_DESTDIR}/boot/loader ${ISO_DESTDIR}/boot/loader') sh('cp ${WORLD_DESTDIR}/boot/device.hints ${ISO_DESTDIR}/boot/device.hints' ) sh('cp ${WORLD_DESTDIR}/boot/*.4th ${ISO_DESTDIR}/boot') sh('cp ${WORLD_DESTDIR}/boot/loader.rc ${ISO_DESTDIR}/boot/loader.rc') sh('cp ${WORLD_DESTDIR}/boot/loader.rc.local ${ISO_DESTDIR}/boot/loader.rc.local' ) sh('cp ${WORLD_DESTDIR}/boot/menu.rc ${ISO_DESTDIR}/boot/menu.rc') sh('cp -R ${WORLD_DESTDIR}/boot/defaults ${ISO_DESTDIR}/boot/defaults') # New-style isoboot image output_nogrub = output.replace('.iso', '-NOGRUB.iso') sh('${BUILD_ROOT}/build/tools/make_iso_image.sh ${CDROM_LABEL} ${output_nogrub} ${WORLD_DESTDIR} ${ISO_DESTDIR}' ) sha256(output_nogrub) # Old-style GRUB image sh('mkdir -p ${ISO_DESTDIR}/boot/grub') setfile('${ISO_DESTDIR}/boot/grub/grub.cfg', template('${BUILD_CONFIG}/templates/cdrom/grub.cfg')) sh('grub-mkrescue --xorriso=${BUILD_ROOT}/build/tools/xorriso.sh -o ${output} ${ISO_DESTDIR} -- -volid ${CDROM_LABEL}' ) sha256(output)
def login_route(request): if request.Method == 'GET': header = 'HTTP/1.1 200 OK\r\nContent-Type: text/html\r\nConnection:Close\r\n' verify_session = request.cookies().get('username', '') username = session.get(verify_session, '') user = User.find_by(username) if user is not None: return redirect('/') else: body = template('login.html') r = header + '\r\n' + body return r if request.Method == 'POST': re_username = request.form().get('username', '') re_password = request.form().get('password', '') user = User.login_verify(re_username, re_password) if user: """如果登录成功,获取一个随机16位的字符串,和username一起放入session字典中""" user_session = create_session() session[user_session] = user.username return redirect('/', user_session) else: print '登录失败' my_word = '登录失败' header = 'HTTP/1.1 200 OK\r\nContent-Type: text/html\r\nConnection:Close\r\n' body = template( 'login_success.html', my_word=my_word, ) r = header + '\r\n' + body return r
def main(args): # pylint: disable=redefined-outer-name year = args.year if year == 0: year = NOW.year if not (modfile := pathlib.Path(f'{year}/d{args.day}.py')).exists(): logging.error('Module %s not found. Creating template', modfile) utils.template(modfile) return -1
def route_index(request): """ 主页的处理函数, 返回主页的响应 """ body = template('index.html', username='******') # 增加用户识别功能,并在主页显示名字 user = current_user(request) log('routes_index ----> check current_user 返回值的type: ', user) if user is not None: body = template('index.html', username=user.username) return http_response(body)
def run(words_list=create_word_list(args.d), source_stream=io.open(args.i, "r")): mapping_dict = create_mapping_dict(args.m) phone_number_encoder = PhoneNumberEncoder(mapping_dict=mapping_dict, words_list=words_list) for phone_number in source_stream: safe_phone_number = "".join(re.findall(r"\d+", phone_number)) if phone_number == "": break elif len(safe_phone_number) < 2: continue else: result = phone_number_encoder.get_encodings(str(safe_phone_number)) for r in result: print template(phone_number, r)
def register(request): if request.method == 'GET': header = get_headers() body = template('register.html') return header + '\r\n' + body elif request.method == 'POST': data = request.form() global next_id User.create_obj(**data) body = template('register.html', messgae='注册成功') header = get_headers() return header + '\r\n' + body else: return error(request)
def make_iso_image(): setfile('${ISO_DESTDIR}/boot/loader.conf', template('${BUILD_CONFIG}/templates/cdrom/loader.conf')) setfile('${ISO_DESTDIR}/.mount.conf', template('${BUILD_CONFIG}/templates/cdrom/mount.conf')) sh('cp ${WORLD_DESTDIR}/boot/loader ${ISO_DESTDIR}/boot/loader') sh('cp ${WORLD_DESTDIR}/boot/device.hints ${ISO_DESTDIR}/boot/device.hints' ) sh('cp -r ${WORLD_DESTDIR}/boot/lua ${ISO_DESTDIR}/boot/') sh('cp -R ${WORLD_DESTDIR}/boot/defaults ${ISO_DESTDIR}/boot/defaults') # New-style isoboot image sh('${BUILD_ROOT}/build/tools/make_iso_image.sh ${CDROM_LABEL} ${output} ${WORLD_DESTDIR} ${ISO_DESTDIR}' ) sha256(output)
def edit(request): header = 'HTTP/1.1 200 OK\r\nContent-Type: text/html\r\n' todo_id = int(request.query.get('id')) t = Todo.find(todo_id) body = template('simple_todo_edit.html', todo=t) r = header + '\r\n' + body return r.encode(encoding='utf-8')
def comment_edit(request): comment_id = int(request.query.get('id', -1)) c = Comment.find(comment_id) user = current_user(request) # 生成一个 edit 页面 body = template('comment_edit.html', comment=c, user=user) return http_response(body)
def edit_password(request): user_id = int(request.query.get('id', -1)) log('edit_password', user_id) u = User.find(user_id) # 替换模板文件中的标记字符串 body = template('admin_password_edit.html', user=u) return http_response(body)
def route_login(request): """ 登录页面的路由函数 """ headers = { 'Content-Type': 'text/html', } # username = current_user(request) if request.method == 'POST': form = request.form() u = User(form) if u.validate_login(): user = User.find_by(username=u.username) # server 端 设置 'Set-Cookie' 字段 并发送给 client # client 根据 response 中的该字段设置自己 request headers 的 'Cookie' 字段 # headers['Set-Cookie'] = 'user={}'.format(u.username) # 设置一个随机字符串来当令牌使用 session_id = random_str() # session[session_id] = user.id session[session_id] = user.username headers['Set-Cookie'] = 'user={}'.format(session_id) # log('headers response:', headers) print('登录成功:', user) return redirect('/', headers=headers) else: print('用户名或密码错误') return redirect('/login') body = template('login.html') return http_response(body, headers=headers)
def route_login(request): """ 登录页面的路由函数 """ headers = { 'Content-Type': 'text/html', # 'Set-Cookie': 'height=169; gua=1; pwd=2; Path=/', } if request.method == 'POST': form = request.form() u = User.new(form) if u.validate_login(): user = User.find_by(username=u.username) # 设置 session # 设置一个随机字符串来当令牌使用 session_id = random_str() session[session_id] = user.id headers['Set-Cookie'] = f'user={session_id}' # 下面是把用户名存入 cookie 中 # headers['Set-Cookie'] = 'user={}'.format(u.username) # log('headers response', headers) # 登录后重定向到 / return redirect('/', headers) # 显示登录页面 body = template('login.html') return http_response(body, headers=headers)
def index(request): """ 主页的处理函数, 返回主页的响应 """ todo_list = Todo.all() body = template('simple_todo_index.html', todos=todo_list) return http_response(body)
def edit_todo(request): if request.Method == 'GET': todo_id = request.query.get('id', '') if not todo_id: return handle_404() todo_id = int(todo_id) #根据前台get请求中的todo_id查找todo的条目 t = Todo.find_by_id(todo_id) if not t: return handle_404() header = 'HTTP/1.1 200 OK\r\nContent-Type: text/html\r\nConnection:Close\r\n' body = template( 'todo_update.html', todo_id=t.id, todo_content=t.content.encode('utf8'), ) r = header + '\r\n' + body return r if request.Method == 'POST': todo_id = int(request.form().get('id', '')) todo_content = request.form().get('content', '') t = Todo.find_by_id(todo_id) t.content = todo_content t.save() return redirect('/todo')
def route_index(request): """ 主页的处理函数,返回主页的响应 """ username = current_user(request) body = template('index.html', username=username) return http_response(body)
def page_post(num): if num < 1: abort(404) posts = Post.select().paginate(num, 5) post_count = posts.count() pages = (post_count - 1) / 5 + 1 return template('index.html', posts=posts, page=num, pages=pages)
def get(self, company): cache_key = "PromotionHandler.get.{}".format(company) cached_results = memcachePlus.get(cache_key) if cached_results: template_values = json.loads(cached_results) else: company_promo = Promotion.get(company_keyname=company) if not company_promo: self.error(404) return if not company_promo[0].promo_running_status: self.error(404) return template_values = Promotion.get_json_object(company_promo[0]) if company_promo[0].promo_title: template_values[ "title"] = "{promo_title} - {company_name} Promo Code".format( promo_title=company_promo[0].promo_title, company_name=company_promo[0].company_name, ) else: template_values[ "title"] = "Promo Code for {company_name}".format( company_name=company_promo[0].company_name) memcachePlus.set(cache_key, json.dumps(template_values)) page = utils.template("promo.html", "Promotion/html") self.response.out.write(template.render(page, template_values))
def home(self): template_values = { "emergency_status": "true" if Emergency().is_emergency() else "false", } page = utils.template("index.html", "ATTCaseHacks/html") self.response.out.write(template.render(page, template_values))
def route_message(request): """ 主页的处理函数, 返回主页的响应 """ log('from route_message -->本次请求的 method', request.method) if request.method == 'POST': form = request.form() msg = Message.new(form) # 增加一个存储功能 from kiwi # msg 和 message_list是2个不同的东西 # msg是Message类的一个实例,msg.save()会将数据存入txt中 # message_list是临时定义的空列表,其中元素是msg实例,每次启动会清零 # log('msg: type ', type(msg)) # log('msg: str ', str(msg)) # log('msg: ', msg) log('post', form) # 应该在这里保存 message_list # 列表推倒 # 注意str(m) msgs = '<br>'.join([str(m) for m in Message.all()]) # 上面的列表推倒相当于下面的功能 # messages = [] # for m in message_list: # messages.append(str(m)) # msgs = '<br>'.join(messages) body = template('html_basic.html', messages=msgs) return http_response(body)
def messages_add(request): log('本次请求的 method', request.method) data = request.form() if len(data) > 0: Message.new(data) body = template('message.html', messages=Message.all()) return http_response(body)
def route_login(request): headers = { 'Content-Type': 'text/html', } log('from route_login --> cookies: ', request.cookies) # 由cookie得到的用户实例,可能为None u = current_user(request) # 若有手动输入账号密码且用POST # 2个 if 解决 有没有 和 对不对 的问题。 if request.method == 'POST': form = request.form() # 创建一个新的用户实例 if User.validate_login(form): # 设置session_id session_id = random_str() log("from route_login --> session_id: ", session_id) u = User.find_by(username=form.get('username')) session[session_id] = u.id headers['Set-Cookie'] = 'sid={}'.format(session_id) result = '登录成功' else: result = '用户名或者密码错误' else: result = '请POST登录' body = template('login.html', result=result, username='******') # 第一次输入用户名密码并提交{{username}}并不会改变,第一次提交cookie中还没有user字段而current_user需要根据这个判断 # 但是可以替换,如下代码所示 if u is not None: body = body.replace('游客', u.username) header = response_with_headers(headers) r = header + '\r\n' + body return r.encode(encoding='utf-8')
def index(request): """ 主页的处理函数, 返回主页的响应 """ u = current_user(request) body = template('weibo_index.html') return http_response(body)
def route_login(request): """ 登录页面的路由函数 """ headers = { 'Content-Type': 'text/html', } log('login, cookies', request.cookies) if request.method == 'POST': form = request.form() u = User(form) if u.validate_login(): user = User.find_by(username=u.username) # 设置 session session_id = random_str() session[session_id] = user.id headers['Set-Cookie'] = 'user={}'.format(session_id) log('headers response', headers) # 登录后定向到 / return redirect('/', headers) # 显示登录页面 body = template('login.html') header = response_with_headers(headers) r = header + '\r\n' + body return r.encode(encoding='utf-8')
def index(request): headers = { 'Content-Type': 'text/html', } header = response_with_headers(headers) user_id = request.query.get('user_id', -1) user_id = int(user_id) user = User.find(user_id) if user is None: return redirect('/login') # 找到 user 发布的所有 weibo weibos = Tweet.find_all(user_id=user_id) log('weibos', weibos) def weibo_tag(weibo): return '<p>{} from {}@{} <a href="/tweet/delete?id={}">删除</a> <a href="/tweet/edit?id={}">修改</a></p>'.format( weibo.content, user.username, weibo.created_time, weibo.id, weibo.id, ) weibos = '\n'.join([weibo_tag(w) for w in weibos]) body = template('weibo_index.html', weibos=weibos) r = header + '\r\n' + body print(1) return r.encode(encoding='utf-8')
def get_update_post(id): category = Category.select() try: post = Post.get(id=id) except Post.DoesNotExist: abort(404) return template("admin/update.html", post=post, category=category)
def route_login(request): """ 登录页面的路由函数 """ log('login, cookies', request.cookies) if request.method == 'POST': form = request.form() u = User(form) if u.validate_login(): session_id = random_str() u = User.find_by(username=u.username) s = Session.new(dict( session_id=session_id, user_id=u.id, )) s.save() log('session', s) headers = { 'Set-Cookie': 'sid={}'.format(session_id) } # 登录后定向到 / return redirect('/', headers) # 显示登录页面 body = template('login.html') return http_response(body)
def index(request): """ _todo 首页的路由函数 """ todo_list = Todo.all() body = template('simple_todo_index.html', todos=todo_list) return http_response(body)
def install_files(): info('Copying installer files') setfile('${INSTUFS_DESTDIR}/etc/avatar.conf', template('${BUILD_CONFIG}/templates/avatar.conf')) if e("${UNATTENDED_CONFIG}"): sh('cp ${UNATTENDED_CONFIG} ${INSTUFS_DESTDIR}/etc/install.conf') sh('cp ${BUILD_CONFIG}/templates/cdrom/rc.conf ${INSTUFS_DESTDIR}/etc/')
def single_picky(slug='test'): try: f = open(PICKY_DIR + slug + '.md') except IOError: abort(404) picky = f.read() f.close() meta_regex = re.compile( r"^\s*(?:-|=){3,}\s*\n((?:.|\n)+?)\n\s*(?:-|=){3,}\s*\n*", re.MULTILINE ) match = re.match(meta_regex, picky) if not match: abort(404) metas = match.group(1) title = None date = None meta = metas.split("\n") try: title = meta[0].split("=>")[1] except IndexError: title = meta[0].split("=>")[0] try: date = meta[1].split("=>")[1] except IndexError: date = meta[1].split("=>")[0] cont = to_unicode(picky[match.end():]) content = to_markdown(cont) return template('picky.html', content=content, title=to_unicode(title), date=to_unicode(date), slug=slug)
def get(self): email = utils.AuthenticateUser(self, self.request.url) if not email: return template_values = {'email': email} page = utils.template("register.html") self.response.out.write(template.render(page, template_values))
def category_archive(category): category = category.decode('utf-8') try: category = Category.get(slug=category) except Category.DoesNotExist: abort(404) posts = category.posts count = posts.count() return template('archive.html', posts=posts, name=category.name, type="category", count=count)
def test_correct_encoding_on_sample_data(self): expected_results = [s.strip() for s in correct_output] for phone_number in sample_phones: encodings = self.phone_number_encoder.get_encodings(phone_number, separator=" ") for encoding in encodings: expected_output = template(phone_number, encoding) assert expected_output in expected_results expected_results.remove(expected_output) logging.info('here expected_results should be empty %s' % expected_results) assert len(expected_results) == 0
def tag_archive(tag): tag = tag.decode('utf-8').strip() try: tags = Tag.select().where(name=tag) except Tag.DoesNotExist: abort(404) postids = [_tag.post_id for _tag in tags] posts = Post.select().where(id__in=postids) count = posts.count() return template('archive.html', posts=posts, name=tag, type="tag", count=count)
def blog_feed(): def _format_date(dt): return "%s, %02d %s %04d %02d:%02d:%02d GMT" % ( ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"][dt.weekday()], dt.day, ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"][dt.month - 1], dt.year, dt.hour, dt.minute, dt.second) posts = Post.select().paginate(1, 10) response.content_type = 'application/rss+xml; charset=UTF-8' return template('feed.xml', posts=posts, format=_format_date)
def create_poudriere_config(): sh('mkdir -p ${DISTFILES_CACHE}') setfile('${POUDRIERE_ROOT}/etc/poudriere.conf', template('${BUILD_CONFIG}/templates/poudriere.conf', { 'ports_repo': config['repos'].where(name='ports')['path'], 'ports_branch': config['repos'].where(name='ports')['branch'], })) tree = e('${POUDRIERE_ROOT}/etc/poudriere.d/ports/p') sh('mkdir -p', tree) setfile(pathjoin(tree, 'mnt'), e('${PORTS_OVERLAY}')) setfile(pathjoin(tree, 'method'), 'git')
def admin_index(): post_count = Post.select().count() comm_count = Comment.select().count() tag_count = Tag.select().count() cate_count = Category.select().count() author = Author.get(id=1) posts = Post.select().paginate(1, 5) comments = Comment.select().order_by(('published', 'desc')).paginate(1, 5) return template('admin/index.html', posts=posts, comments=comments, post_count=post_count, comm_count=comm_count, tag_count=tag_count, cate_count=cate_count, author=author)
def create_aux_files(dsl, dest): for aux in dsl.aux_files: if not os.path.exists(aux.source): continue if aux.get('template'): f = template(aux.source) else: f = readfile(aux.source) name = aux.name setfile('${dest}/${name}', f)
def get(self, error=False, template_vars={}): if not template_vars: template_vars = {'show_graph':'false', 'categories':[], 'temp_list': [], 'rh_list': [], 'wind_speed_list': [], 'battery_voltage_list': [], 'wind_direction_list': [], 'rain_list': [], } user = utils.AuthenticateUser(self, self.request.url) if not user: return page = utils.template("main-weather_visualize.html") self.response.out.write(template.render(page,template_vars)) if error: self.response.out.write("Sorry, Invalid Excel File!")
def single_post(slug='test-post'): try: post = Post.get(slug=slug) except Post.DoesNotExist: abort(404) return template('post.html', post=post)
def admin_post(): posts = Post.select().paginate(1, 50) return template('admin/posts.html', posts=posts)
def install_files(): info('Copying installer files') setfile('${INSTUFS_DESTDIR}/etc/avatar.conf', template('${BUILD_CONFIG}/templates/avatar.conf'))
def blog_achive(): posts = Post.select() from utils import archives_list count = posts.count() return template('archives.html', posts=posts, count=count, archives_list=archives_list)
def error404(error): return template('e404.html')
def get_new_post(): category = Category.select() return template("admin/newpost.html", category=category)
def admin_comment(): comments = Comment.select().order_by(('published', 'desc')).paginate(1, 50) return template('admin/comments.html', comments=comments)
def get(self): user = utils.AuthenticateUser(self, self.request.url) if not user: return page = utils.template("main-dashboard_main.html") self.response.out.write(template.render(page, {}))
def main(): setfile('${WORLD_DESTDIR}/etc/avatar.conf', template('${BUILD_CONFIG}/templates/avatar.conf'))
def get_admin_login(): if get_auth_user(): redirect('/admin') return template("admin/login.html")
def __init__(self, args, options, config, gendoc=False, genmeta=False, export=False): self.roles_path = args[0] self.options = options self.config = config self.gendoc = gendoc self.genmeta = genmeta self.export = export # set the readme output format self.readme_format = c.ALLOWED_GENDOC_FORMATS[self.options.docformat] self.roles = utils.roles_dict(self.roles_path, "") if self.options.limit: self.limit_roles() utils.exit_if_no_roles(len(self.roles.keys()), self.roles_path) self.regex_facts = re.compile(r"set_fact:\w+") self.paths = {} # default values for the role report self.defaults = "" self.dependencies = [] self.all_files = [] self.yaml_files = [] # only load and validate the readme when generating docs if self.gendoc: # only change the format if it is different than the default if not self.options.format == self.readme_format: self.readme_format = self.options.format extend_path = self.config["options_readme_template"] if self.readme_format == "rst": readme_source = c.README_RST_TEMPLATE_PATH else: readme_source = c.README_MD_TEMPLATE_PATH self.readme_template = utils.template(readme_source, extend_path, self.readme_format) self.report = { "totals": { "roles": 0, "dependencies": 0, "defaults": 0, "facts": 0, "files": 0, "lines": 0, }, "state": { "ok_role": 0, "skipped_role": 0, "changed_role": 0, "missing_readme_role": 0, "missing_meta_role": 0, }, "roles": {}, "stats": { "longest_role_name_length": len(max(self.roles, key=len)), } } self.scan_roles() if self.export: self.export_roles()
def blog_search(): return template('search.html')
def index(): posts = Post.select().paginate(1, 5) return template('index.html', posts=posts, page=1)
def admin_settings(): author = Author.get(id=1) return template('admin/settings.html', author=author)