mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-12-14 12:16:31 +00:00
Merge branch 'main' into production
This commit is contained in:
commit
7db77c690e
5 changed files with 14 additions and 7 deletions
|
@ -172,13 +172,13 @@ class User(OrderedCollectionPageMixin, AbstractUser):
|
||||||
''' populate fields for new local users '''
|
''' populate fields for new local users '''
|
||||||
# this user already exists, no need to populate fields
|
# this user already exists, no need to populate fields
|
||||||
if self.id:
|
if self.id:
|
||||||
return
|
return super().save(*args, **kwargs)
|
||||||
|
|
||||||
if not self.local:
|
if not self.local:
|
||||||
# generate a username that uses the domain (webfinger format)
|
# generate a username that uses the domain (webfinger format)
|
||||||
actor_parts = urlparse(self.remote_id)
|
actor_parts = urlparse(self.remote_id)
|
||||||
self.username = '%s@%s' % (self.username, actor_parts.netloc)
|
self.username = '%s@%s' % (self.username, actor_parts.netloc)
|
||||||
return
|
return super().save(*args, **kwargs)
|
||||||
|
|
||||||
# populate fields for local users
|
# populate fields for local users
|
||||||
self.remote_id = 'https://%s/user/%s' % (DOMAIN, self.username)
|
self.remote_id = 'https://%s/user/%s' % (DOMAIN, self.username)
|
||||||
|
@ -191,7 +191,7 @@ class User(OrderedCollectionPageMixin, AbstractUser):
|
||||||
if not self.private_key:
|
if not self.private_key:
|
||||||
self.private_key, self.public_key = create_key_pair()
|
self.private_key, self.public_key = create_key_pair()
|
||||||
|
|
||||||
super().save(*args, **kwargs)
|
return super().save(*args, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
@receiver(models.signals.post_save, sender=User)
|
@receiver(models.signals.post_save, sender=User)
|
||||||
|
|
|
@ -37,10 +37,15 @@ def outbox(request, username):
|
||||||
|
|
||||||
|
|
||||||
def handle_remote_webfinger(query):
|
def handle_remote_webfinger(query):
|
||||||
''' webfingerin' other servers, username query should be user@domain '''
|
''' webfingerin' other servers '''
|
||||||
user = None
|
user = None
|
||||||
|
|
||||||
|
# usernames could be @user@domain or user@domain
|
||||||
|
if query[0] == '@':
|
||||||
|
query = query[1:]
|
||||||
|
|
||||||
try:
|
try:
|
||||||
domain = query.split('@')[2]
|
domain = query.split('@')[1]
|
||||||
except IndexError:
|
except IndexError:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
</a>
|
</a>
|
||||||
<form class="navbar-item" action="/search/">
|
<form class="navbar-item" action="/search/">
|
||||||
<div class="field is-grouped">
|
<div class="field is-grouped">
|
||||||
<input class="input" type="text" name="q" placeholder="Search for a book or user">
|
<input class="input" type="text" name="q" placeholder="Search for a book or user" value="{{ query }}">
|
||||||
<button class="button" type="submit">
|
<button class="button" type="submit">
|
||||||
<span class="icon icon-search">
|
<span class="icon icon-search">
|
||||||
<span class="is-sr-only">search</span>
|
<span class="is-sr-only">search</span>
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
{% load fr_display %}
|
{% load fr_display %}
|
||||||
{% with book|book_description as full %}
|
{% with book|book_description as full %}
|
||||||
|
{% if full %}
|
||||||
{% with full|text_overflow as trimmed %}
|
{% with full|text_overflow as trimmed %}
|
||||||
{% if trimmed != full %}
|
{% if trimmed != full %}
|
||||||
<div>
|
<div>
|
||||||
|
@ -17,4 +18,5 @@
|
||||||
</blockquote>
|
</blockquote>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endwith %}
|
{% endwith %}
|
||||||
|
{% endif %}
|
||||||
{% endwith %}
|
{% endwith %}
|
||||||
|
|
|
@ -116,7 +116,7 @@ def get_book_description(book):
|
||||||
def text_overflow(text):
|
def text_overflow(text):
|
||||||
''' dont' let book descriptions run for ages '''
|
''' dont' let book descriptions run for ages '''
|
||||||
if not text:
|
if not text:
|
||||||
return
|
return ''
|
||||||
char_max = 500
|
char_max = 500
|
||||||
if text and len(text) < char_max:
|
if text and len(text) < char_max:
|
||||||
return text
|
return text
|
||||||
|
|
Loading…
Reference in a new issue