瀏覽代碼

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…
取消
儲存