瀏覽代碼

Made carousel dynamic

joel
Simon Bowie 3 年之前
父節點
當前提交
f87dea6726
共有 2 個檔案被更改,包括 8 行新增16 行删除
  1. +3
    -1
      web/app/main.py
  2. +5
    -15
      web/app/templates/index.html

+ 3
- 1
web/app/main.py 查看文件

@@ -10,13 +10,15 @@
from flask import Blueprint, render_template
from flask_login import login_required, current_user
from . import db
from .models import Tool

main = Blueprint('main', __name__)

# route for index page
@main.route('/')
def index():
return render_template('index.html')
tools = Tool.query.limit(3)
return render_template('index.html', tools=tools)

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

+ 5
- 15
web/app/templates/index.html 查看文件

@@ -23,24 +23,14 @@

<!-- The slideshow/carousel -->
<div class="carousel-inner">
<div class="carousel-item active text-center">
<h2>Tool 1</h2>
{% for tool in tools %}
<div class="carousel-item {% if loop.index == 1 %} active {% endif %} text-center">
<h2>{{ tool['name'] }}</h2>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus varius, justo a iaculis porta, ipsum nibh suscipit orci, at lobortis quam orci ac orci. In non consectetur ipsum. Suspendisse sodales tempor ullamcorper.
</p>
</div>
<div class="carousel-item text-center">
<h2>Tool 2</h2>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus varius, justo a iaculis porta, ipsum nibh suscipit orci, at lobortis quam orci ac orci. In non consectetur ipsum. Suspendisse sodales tempor ullamcorper.
</p>
</div>
<div class="carousel-item text-center">
<h2>Tool 3</h2>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus varius, justo a iaculis porta, ipsum nibh suscipit orci, at lobortis quam orci ac orci. In non consectetur ipsum. Suspendisse sodales tempor ullamcorper.
{{tool['description']|truncate(200) }}
</p>
</div>
{% endfor %}
</div>

<!-- Left and right controls/icons -->

Loading…
取消
儲存