Ejemplo n.º 1
0
def works():
	num_per_page = 10

	work_type = request.args['type'] if 'type' in request.args else 'all'
	dynasty_abbr = request.args['dynasty'] if 'dynasty' in request.args else 'all'
	page = int(request.args['page'] if 'page' in request.args else 1)

	works = Work.get_works(work_type, dynasty_abbr, page, num_per_page)
	for work in works:
		work['Content'] = content_clean(work['Content'])

	works_num = Work.get_works_num(work_type, dynasty_abbr)

	# page paras
	total_page = int(math.ceil(works_num / num_per_page))
	pre_page = (page - 1) if page > 1 else 1
	if total_page == 0:
		next_page = 1
	elif page < total_page:
		next_page = page + 1
	else:
		next_page = total_page

	work_types = Work.get_types()

	dynasties = Dynasty.get_dynasties()

	return render_template('work/works.html', works=works, works_num=works_num, work_types=work_types, dynasties=dynasties, page=page, total_page=total_page, pre_page=pre_page, next_page=next_page, work_type=work_type, dynasty_abbr=dynasty_abbr)
Ejemplo n.º 2
0
def single_author(authorID):
	author = Author.get_author(authorID)
	collections = Collection.get_collections_by_author(authorID)
	works = Work.get_works_by_author(authorID)
	for work in works:
		work['Content'] = re.sub(r'<([^<]+)>', '', work['Content'])
		work['Content'] = work['Content'].replace('%', '').replace('/', '')
	worksNum = Work.get_works_num(works)
	return render_template('single_author.html', author=author, collections=collections, works=works, worksNum=worksNum)
Ejemplo n.º 3
0
def works():
    num_per_page = 10

    work_type = request.args['type'] if 'type' in request.args else 'all'
    dynasty_abbr = request.args[
        'dynasty'] if 'dynasty' in request.args else 'all'
    page = int(request.args['page'] if 'page' in request.args else 1)

    works = Work.get_works(work_type, dynasty_abbr, page, num_per_page)
    for work in works:
        work['Content'] = content_clean(work['Content'])

    works_num = Work.get_works_num(work_type, dynasty_abbr)

    # page paras
    total_page = int(math.ceil(works_num / num_per_page))
    pre_page = (page - 1) if page > 1 else 1
    if total_page == 0:
        next_page = 1
    elif page < total_page:
        next_page = page + 1
    else:
        next_page = total_page

    work_types = Work.get_types()

    dynasties = Dynasty.get_dynasties()

    return render_template('work/works.html',
                           works=works,
                           works_num=works_num,
                           work_types=work_types,
                           dynasties=dynasties,
                           page=page,
                           total_page=total_page,
                           pre_page=pre_page,
                           next_page=next_page,
                           work_type=work_type,
                           dynasty_abbr=dynasty_abbr)