List the featured projects on the anonymous index page

This improves discovery by not making the hub feels like it requires an
account just to browse

Ref: ~sircmpwn/hub.sr.ht#42
This commit is contained in:
наб 2020-08-11 23:36:48 +02:00 committed by Drew DeVault
parent 2b98206e43
commit 96c0147db1
2 changed files with 48 additions and 10 deletions

View File

@ -23,7 +23,14 @@ def index():
projects=projects, EventType=EventType, events=events,
notice=notice)
return render_template("new-user-dashboard.html", notice=notice)
return render_template("index.html")
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())
.limit(6)).all()
return render_template("index.html", features=features)
@public.route("/getting-started")
@loginrequired

View File

@ -6,20 +6,51 @@
<div class="row">
<div class="col-md-8">
<p>
Welcome to
Welcome to
<a href="{{cfg("sr.ht", "site-info")}}">
{{cfg("sr.ht", "site-name")}}</a>,
{{cfg("sr.ht", "site-blurb")}}!
</p>
<p>
<a
class="btn btn-primary"
href="{{get_origin("meta.sr.ht", external=True)}}/register"
>Register here {{icon('caret-right')}}</a>
or
<a href="{{oauth_url}}">
Log in {{icon('caret-right')}}
</a>
to get started.
</p>
<hr />
<h2>Featured projects</h2>
</div>
</div>
<div class="row event-list">
{% for feature in features %}
<div class="col-md-6">
<div class="event">
<h5>
<span class="text-muted"
>{{feature.project.owner.canonical_name}}/</span><a
href="{{url_for("projects.summary_GET",
owner=feature.project.owner.canonical_name,
project_name=feature.project.name)}}"
>{{feature.project.name}}</a>
</h5>
<blockquote>
{{feature.summary | md}}
</blockquote>
</div>
</div>
{% endfor %}
</div>
<div class="row">
<div class="col-md-4 offset-md-8">
<a
class="btn btn-primary"
href="{{get_origin("meta.sr.ht", external=True)}}/register"
>Register here {{icon('caret-right')}}</a>
or
<a href="{{oauth_url}}">
Log in {{icon('caret-right')}}
</a>
to get started.
href="{{url_for("public.project_index")}}"
class="btn btn-default btn-block"
>More projects {{icon('caret-right')}}</a>
</div>
</div>
{% endblock %}