~sircmpwn/sr.ht-dev

This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch
1

[PATCH man.sr.ht v2] add user index view for man.sr.ht

Details
Message ID
<20200828162502.2898-1-gildarts@orbital.rocks>
DKIM signature
fail
Download raw message
Patch: +116 -0 DKIM signature: fail
Fixed the import issue and style problems.

---
 mansrht/app.py               |  2 +
 mansrht/blueprints/public.py | 33 +++++++++++++++
 mansrht/templates/user.html  | 81 ++++++++++++++++++++++++++++++++++++
 3 files changed, 116 insertions(+)
 create mode 100644 mansrht/blueprints/public.py
 create mode 100644 mansrht/templates/user.html

diff --git a/mansrht/app.py b/mansrht/app.py
index 8e0521f..9ba91e2 100644
--- a/mansrht/app.py
+++ b/mansrht/app.py
@@ -31,11 +31,13 @@ class ManApp(SrhtFlask):
        from mansrht.blueprints.create import create
        from mansrht.blueprints.manage import manage
        from mansrht.blueprints.notify import webhooks_notify
        from mansrht.blueprints.public import public

        self.register_blueprint(html)
        self.register_blueprint(create)
        self.register_blueprint(manage)
        self.register_blueprint(webhooks_notify)
        self.register_blueprint(public)

        self.url_map.strict_slashes = False

diff --git a/mansrht/blueprints/public.py b/mansrht/blueprints/public.py
new file mode 100644
index 0000000..f13491b
--- /dev/null
+++ b/mansrht/blueprints/public.py
@@ -0,0 +1,33 @@
from flask import Blueprint, render_template, abort, request
from srht.flask import paginate_query
from srht.search import search_by
from srht.oauth import current_user
from mansrht.types import User, Wiki, WikiVisibility

public = Blueprint('public', __name__)


@public.route("/~<username>")
@public.route("/~<username>/")
def user_index(username):
    user = User.query.filter(User.username == username).first()
    if not user:
        abort(404)
    terms = request.args.get("search")
    wikis = Wiki.query.filter(Wiki.owner_id == user.id)
    if current_user and current_user.id != user.id:
        wikis = wikis.filter(Wiki.visibility == WikiVisibility.public)
    elif not current_user:
        wikis = wikis.filter(Wiki.visibility == WikiVisibility.public)

    search_error = None
    try:
        wikis = search_by(wikis, terms, [Wiki.name])
    except ValueError as ex:
        search_error = str(ex)

    wikis = wikis.order_by(Wiki.updated.desc())
    wikis, pagination = paginate_query(wikis)

    return render_template("user.html", user=user, wikis=wikis,
        search=terms, search_error=search_error, **pagination)
diff --git a/mansrht/templates/user.html b/mansrht/templates/user.html
new file mode 100644
index 0000000..e0d2b8e
--- /dev/null
+++ b/mansrht/templates/user.html
@@ -0,0 +1,81 @@
{% extends "man.html" %}

{% block content %}
<div class="container">
  <div class="row">
    <section class="col-md-4">
      <h2>
        ~{{ user.username }}
      </h2>
      {% if user.location %}
      <p>{{user.location}}</p>
      {% endif %}
      {% if user.url %}
      <p>
        <a
          href="{{user.url}}"
          target="_blank"
          rel="me noopener noreferrer nofollow"
        >{{user.url}}</a>
      </p>
      {% endif %}
      {% if user.bio %}
      {{user.bio | md}}
      {% endif %}
      {% if notice %}
      <div class="alert alert-success">
        {{ notice }}
      </div>
      {% endif %}
    </section>
    <section class="col-md-8">
      {% if len(wikis) == 0 %}
      {% if search %}
      <form>
        <input
          name="search"
          type="text"
          placeholder="Search"
          class="form-control"
          value="{{ search if search else "" }}" />
      </form>
      <p>Nothing found.</p>
      {% else %}
      <p>This user has no wikis.</p>
      {% endif %}
      {% else %}
      <form>
        <input
          name="search"
          type="text"
          placeholder="Search"
          class="form-control{% if search_error %} is-invalid{% endif %}"
          value="{{ search if search else "" }}" />
        {% if search_error %}
          <div class="invalid-feedback">{{ search_error }}</div>
        {% endif %}
      </form>
      <div class="event-list">
        {% for wiki in wikis %}
        <div class="event">
          <h4>
            <a href="/~{{user.username}}/{{wiki.name}}">
              ~{{user.username}}/{{wiki.name}}
            </a>
            {% if wiki.visibility.value != 'public' %}
            <small class="pull-right">
              {{ wiki.visibility.value }}
            </small>
            {% endif %}
          </h4>
          <p>
          </p>
        </div>
        {% endfor %}
      </div>
      {% endif %}
      {{ pagination() }}
    </section>
  </div>
</div>
{% endblock %}
-- 
2.25.1

[man.sr.ht/patches] build failed

builds.sr.ht
Details
Message ID
<C58RRZTPLFOP.1AB4RUGOMT9I3@cirno2>
In-Reply-To
<20200828162502.2898-1-gildarts@orbital.rocks> (view parent)
DKIM signature
missing
Download raw message
man.sr.ht/patches: FAILED in 2m29s

[add user index view for man.sr.ht][0] v2 from [gildarts][1]

[0]: https://lists.sr.ht/~sircmpwn/sr.ht-dev/patches/12166
[1]: mailto:gildarts@orbital.rocks

✓ #289522 SUCCESS man.sr.ht/patches/archlinux.yml https://builds.sr.ht/~sircmpwn/job/289522
✗ #289523 FAILED  man.sr.ht/patches/debian.yml    https://builds.sr.ht/~sircmpwn/job/289523
✓ #289521 SUCCESS man.sr.ht/patches/alpine.yml    https://builds.sr.ht/~sircmpwn/job/289521
Reply to thread Export thread (mbox)