소스 검색

curated homepage

joel
Simon Bowie 1 년 전
부모
커밋
5d02c551ff
2개의 변경된 파일11개의 추가작업 그리고 32개의 파일을 삭제
  1. +9
    -10
      web/app/main.py
  2. +2
    -22
      web/app/templates/index.html

+ 9
- 10
web/app/main.py 파일 보기

@@ -20,19 +20,18 @@ main = Blueprint('main', __name__)
@main.route('/')
def index():
view = request.args.get('view')
tools = Resource.query.filter_by(type='tool').order_by(func.random()).limit(6).all()
if view != 'list':
# append relationships to each tool
append_relationships_multiple(tools)
books = Resource.query.filter_by(type='book').order_by(func.random()).limit(6).all()
if view != 'list':
# append relationships to each book
append_relationships_multiple(books)
# curated list of resources to display on homepage
tool_ids = ['4','10', '34', '27']
practice_ids = ['53', '59', '65', '56']
book_ids = ['94', '72', '105', '67']
# concatenate lists of resources
resource_ids = tool_ids + practice_ids + book_ids
# get data for curated resources
curated = get_curated_resources(resource_ids)
with open('content/home.md', 'r') as f:
text = f.read()
text = markdown.markdown(text)
book_showcase = get_full_resource('69')
return render_template('index.html', text=text, tools=tools, books=books, book=book_showcase, view=view)
return render_template('index.html', text=text, resources=curated, view=view)

# route for profile page
@main.route('/profile')

+ 2
- 22
web/app/templates/index.html 파일 보기

@@ -27,29 +27,9 @@
{% if view == 'list' %}
THIS IS LIST VIEW
{% else %}
{% for tool in tools %}

{{ resource_with_related(tool, loop, false) }}

{% endfor %}

{% for book in books %}

{{ resource_with_related(book, loop, false) }}

{% endfor %}

{% for tool in tools2 %}

{{ resource_with_related(tool, loop, false) }}

{% endfor %}

{% for book in books2 %}

{{ resource_with_related(book, loop, false) }}

{% for resource in resources %}
{{ resource_with_related(resource, loop, false) }}
{% endfor %}

{% endif %}

Loading…
취소
저장