frens
This commit is contained in:
parent
dd547903dc
commit
6106a96b3a
4 changed files with 64 additions and 2 deletions
|
@ -86,6 +86,8 @@ class User(Base):
|
||||||
bio_html = Column(String)
|
bio_html = Column(String)
|
||||||
sig = Column(String)
|
sig = Column(String)
|
||||||
sig_html = Column(String)
|
sig_html = Column(String)
|
||||||
|
friends = Column(String)
|
||||||
|
friends_html = Column(String)
|
||||||
is_banned = Column(Integer, default=0)
|
is_banned = Column(Integer, default=0)
|
||||||
unban_utc = Column(Integer, default=0)
|
unban_utc = Column(Integer, default=0)
|
||||||
ban_reason = Column(String)
|
ban_reason = Column(String)
|
||||||
|
|
|
@ -178,6 +178,36 @@ def settings_profile_post(v):
|
||||||
msg="Your sig has been updated.")
|
msg="Your sig has been updated.")
|
||||||
|
|
||||||
|
|
||||||
|
if request.values.get("friends"):
|
||||||
|
friends = request.values.get("friends")[:500]
|
||||||
|
|
||||||
|
for i in re.finditer('^(https:\/\/.*\.(png|jpg|jpeg|gif|webp|PNG|JPG|JPEG|GIF|WEBP|9999))', friends, re.MULTILINE):
|
||||||
|
if "wikipedia" not in i.group(1): friends = friends.replace(i.group(1), f'})')
|
||||||
|
|
||||||
|
friends_html = CustomRenderer().render(mistletoe.Document(friends))
|
||||||
|
friends_html = sanitize(friends_html)
|
||||||
|
bans = filter_comment_html(friends_html)
|
||||||
|
|
||||||
|
if bans:
|
||||||
|
ban = bans[0]
|
||||||
|
reason = f"Remove the {ban.domain} link from your top 8 friends list and try again."
|
||||||
|
if ban.reason: reason += f" {ban.reason}"
|
||||||
|
return {"error": reason}, 401
|
||||||
|
|
||||||
|
if len(friends_html) > 1000:
|
||||||
|
return render_template("settings_profile.html",
|
||||||
|
v=v,
|
||||||
|
error="Your top 8 friends list is too long")
|
||||||
|
|
||||||
|
v.friends = friends[:500]
|
||||||
|
v.friends_html=friends_html
|
||||||
|
g.db.add(v)
|
||||||
|
g.db.commit()
|
||||||
|
return render_template("settings_profile.html",
|
||||||
|
v=v,
|
||||||
|
msg="Your top 8 friends have been updated.")
|
||||||
|
|
||||||
|
|
||||||
if request.values.get("bio") or request.files.get('file') and request.headers.get("cf-ipcountry") != "T1":
|
if request.values.get("bio") or request.files.get('file') and request.headers.get("cf-ipcountry") != "T1":
|
||||||
bio = request.values.get("bio")[:1500]
|
bio = request.values.get("bio")[:1500]
|
||||||
|
|
||||||
|
|
|
@ -587,6 +587,28 @@
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="body d-lg-flex border-bottom">
|
||||||
|
|
||||||
|
<label class="text-black w-lg-25">Top 8 friends</label>
|
||||||
|
|
||||||
|
<div class="w-lg-100">
|
||||||
|
<form id="profile-friends" action="/settings/profile" method="post" enctype="multipart/form-data">
|
||||||
|
<input type="hidden" name="formkey" value="{{v.formkey}}">
|
||||||
|
<div class="input-group mb-2">
|
||||||
|
<textarea id="friends-text" class="form-control rounded" aria-label="With textarea" placeholder="Enter your top 8 friends on the site..." rows="3" name="friends" form="profile-friends" maxlength="1500">{% if v.friends %}{{v.friends}}{% endif %}</textarea>
|
||||||
|
</div>
|
||||||
|
<pre></pre>
|
||||||
|
<div class="d-flex">
|
||||||
|
<small>Limit of 500 characters</small>
|
||||||
|
<input class="btn btn-primary ml-auto" id="friendsSave" type="submit" value="Save Changes">
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
{% if v.patron or v.id == 1904 %}
|
{% if v.patron or v.id == 1904 %}
|
||||||
<div class="body d-lg-flex border-bottom">
|
<div class="body d-lg-flex border-bottom">
|
||||||
<label class="text-black w-lg-25">Signature</label>
|
<label class="text-black w-lg-25">Signature</label>
|
||||||
|
|
|
@ -175,7 +175,10 @@
|
||||||
{% else %}
|
{% else %}
|
||||||
<p class="text-muted">No bio...</p>
|
<p class="text-muted">No bio...</p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if u.bio_html and v %}
|
|
||||||
|
{% if u.friends_html %}
|
||||||
|
<p class="text-muted font-weight-bold">Top 8 friends:</p>
|
||||||
|
{{u.friends_html | safe}}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if u.received_awards %}
|
{% if u.received_awards %}
|
||||||
|
@ -441,7 +444,12 @@
|
||||||
<br>joined <span data-bs-toggle="tooltip" data-bs-placement="bottom" title="" data-bs-original-title="{{u.created_datetime}}" class="font-weight-bold">{{u.created_date}}</span>
|
<br>joined <span data-bs-toggle="tooltip" data-bs-placement="bottom" title="" data-bs-original-title="{{u.created_datetime}}" class="font-weight-bold">{{u.created_date}}</span>
|
||||||
</div>
|
</div>
|
||||||
{% if u.bio_html %}
|
{% if u.bio_html %}
|
||||||
<p class="text-muted text-break">{{u.bio_html | safe}}</p>
|
<p class="text-muted text-break">{{u.bio_html | safe}}</p>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% if u.friends_html %}
|
||||||
|
<p class="text-muted font-weight-bold mt-3">Top 8 friends:</p>
|
||||||
|
{{u.friends_html | safe}}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if u.received_awards %}
|
{% if u.received_awards %}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue