Add page listing all featured projects

This commit is contained in:
Drew DeVault 2020-08-01 12:34:32 -04:00
parent b72c7c7feb
commit 981622c92f
3 changed files with 48 additions and 0 deletions

View File

@ -61,3 +61,14 @@ def project_index():
return render_template("project-index.html", projects=projects,
search=search, features=features, sort=sort, **pagination)
@public.route("/projects/featured")
def featured_projects():
features = (Feature.query
.join(Project, Feature.project_id == Project.id)
.join(User, Project.owner_id == User.id)
.filter(Project.visibility == Visibility.public)
.order_by(Feature.created.desc()))
features, pagination = paginate_query(features)
return render_template("featured-projects.html",
features=features, **pagination)

View File

@ -0,0 +1,33 @@
{% extends "layout-full.html" %}
{% block title %}
<title>Featured projects on {{cfg("sr.ht", "site-name")}}</title>
{% endblock %}
{% block body %}
<div class="container-fluid">
<div class="row">
<div class="col-lg-8">
<h3>Featured projects</h3>
<div class="event-list">
{% for feature in features %}
{% set project = feature.project %}
<div class="event">
<h4>
<a href="{{url_for("users.summary_GET",
username=project.owner.username)}}"
>{{project.owner.canonical_name}}</a>/<a
href="{{url_for("projects.summary_GET",
owner=project.owner.canonical_name,
project_name=project.name)}}"
>{{project.name}}</a>
</h4>
<blockquote style="margin-top: 0.5rem">
{{feature.summary | md}}
</blockquote>
</div>
{% endfor %}
{{pagination()}}
</div>
</div>
</div>
</div>
{% endblock %}

View File

@ -89,6 +89,10 @@
{{feature.summary | md}}
</blockquote>
{% endfor %}
<a
href="{{url_for("public.featured_projects")}}"
class="btn btn-default btn-block"
>More featured projects {{icon('caret-right')}}</a>
</div>
</div>
</div>