mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-10-31 22:19:00 +00:00
Merge branch 'main' into production
This commit is contained in:
commit
aafc9654c1
4 changed files with 94 additions and 46 deletions
|
@ -13,57 +13,81 @@
|
|||
|
||||
<div class="block">
|
||||
{% for notification in notifications %}
|
||||
{% related_status notification as related_status %}
|
||||
<div class="notification {% if notification.id in unread %} is-primary{% endif %}">
|
||||
<div class="block">
|
||||
<p>
|
||||
{# DESCRIPTION #}
|
||||
{% if notification.related_user %}
|
||||
{% include 'snippets/avatar.html' with user=notification.related_user %}
|
||||
{% include 'snippets/username.html' with user=notification.related_user %}
|
||||
{% if notification.notification_type == 'FAVORITE' %}
|
||||
favorited your
|
||||
<a href="{{ notification.related_status.local_path }}">status</a>
|
||||
|
||||
{% elif notification.notification_type == 'MENTION' %}
|
||||
mentioned you in a
|
||||
<a href="{{ notification.related_status.local_path }}">status</a>
|
||||
|
||||
<div class="columns is-mobile">
|
||||
<div class="column is-narrow is-size-3 {% if notification.id in unread%}has-text-white{% else %}has-text-grey{% endif %}">
|
||||
{% if notification.notification_type == 'MENTION' %}
|
||||
<span class="icon icon-comment"></span>
|
||||
{% elif notification.notification_type == 'REPLY' %}
|
||||
<a href="{{ notification.related_status.local_path }}">replied</a>
|
||||
to your
|
||||
<a href="{{ notification.related_status.reply_parent.local_path }}">status</a>
|
||||
{% elif notification.notification_type == 'FOLLOW' %}
|
||||
followed you
|
||||
{% elif notification.notification_type == 'FOLLOW_REQUEST' %}
|
||||
sent you a follow request
|
||||
<div class="row shrink">
|
||||
{% include 'snippets/follow_request_buttons.html' with user=notification.related_user %}
|
||||
</div>
|
||||
|
||||
<span class="icon icon-comments"></span>
|
||||
{% elif notification.notification_type == 'FOLLOW' or notification.notification_type == 'FOLLOW_REQUEST' %}
|
||||
<span class="icon icon-local"></span>
|
||||
{% elif notification.notification_type == 'BOOST' %}
|
||||
boosted your <a href="{{ notification.related_status.local_path }}">status</a>
|
||||
<span class="icon icon-boost"></span>
|
||||
{% elif notification.notification_type == 'FAVORITE' %}
|
||||
<span class="icon icon-heart"></span>
|
||||
{% endif %}
|
||||
{% else %}
|
||||
your <a href="/import-status/{{ notification.related_import.id }}">import</a> completed.
|
||||
{% endif %}
|
||||
</p>
|
||||
</div>
|
||||
{% if notification.related_status %}
|
||||
<div class="block">
|
||||
{# PREVIEW #}
|
||||
<div class="notification py-2 {% if notification.id in unread %}is-primary is-light{% else %}has-background-white{% if notification.notification_type == 'REPLY' or notification.notification_type == 'MENTION' %} has-text-black{% else %}-bis has-text-grey-dark{% endif %}{% endif %}">
|
||||
<div class="columns">
|
||||
<div class="column">
|
||||
<a href="{{ notification.related_status.local_path }}">{{ notification.related_status.content | safe | truncatewords_html:10 }}</a>
|
||||
</div>
|
||||
<div class="column is-narrow {% if notification.notification_type == 'REPLY' or notification.notification_type == 'MENTION' %}has-text-black{% else %}has-text-grey-dark{% endif %}">
|
||||
{{ notification.related_status.published_date | post_date }}
|
||||
{% include 'snippets/privacy-icons.html' with item=notification.related_status %}
|
||||
</div>
|
||||
<div class="column">
|
||||
<div class="block">
|
||||
<p>
|
||||
{# DESCRIPTION #}
|
||||
{% if notification.related_user %}
|
||||
{% include 'snippets/avatar.html' with user=notification.related_user %}
|
||||
{% include 'snippets/username.html' with user=notification.related_user %}
|
||||
{% if notification.notification_type == 'FAVORITE' %}
|
||||
favorited your
|
||||
<a href="{{ related_status.local_path }}">{{ related_status | status_preview_name|safe }}</a>
|
||||
|
||||
{% elif notification.notification_type == 'MENTION' %}
|
||||
mentioned you in a
|
||||
<a href="{{ related_status.local_path }}">{{ related_status | status_preview_name|safe }}</a>
|
||||
|
||||
{% elif notification.notification_type == 'REPLY' %}
|
||||
<a href="{{ related_status.local_path }}">replied</a>
|
||||
to your
|
||||
<a href="{{ related_status.reply_parent.local_path }}">{{ related_status | status_preview_name|safe }}</a>
|
||||
{% elif notification.notification_type == 'FOLLOW' %}
|
||||
followed you
|
||||
{% elif notification.notification_type == 'FOLLOW_REQUEST' %}
|
||||
sent you a follow request
|
||||
<div class="row shrink">
|
||||
{% include 'snippets/follow_request_buttons.html' with user=notification.related_user %}
|
||||
</div>
|
||||
|
||||
{% elif notification.notification_type == 'BOOST' %}
|
||||
boosted your <a href="{{ related_status.local_path }}">{{ related_status | status_preview_name|safe }}</a>
|
||||
{% endif %}
|
||||
{% else %}
|
||||
your <a href="/import-status/{{ notification.related_import.id }}">import</a> completed.
|
||||
{% endif %}
|
||||
</p>
|
||||
</div>
|
||||
{% if related_status %}
|
||||
<div class="block">
|
||||
{# PREVIEW #}
|
||||
<div class="notification py-2 {% if notification.id in unread %}is-primary is-light{% else %}has-background-white{% if notification.notification_type == 'REPLY' or notification.notification_type == 'MENTION' %} has-text-black{% else %}-bis has-text-grey-dark{% endif %}{% endif %}">
|
||||
<div class="columns">
|
||||
<div class="column">
|
||||
{% if related_status.content %}
|
||||
<a href="{{ related_status.local_path }}">{{ related_status.content | safe | truncatewords_html:10 }}</a>
|
||||
{% elif related_status.quote %}
|
||||
<a href="{{ related_status.local_path }}">{{ related_status.quote | safe | truncatewords_html:10 }}</a>
|
||||
{% elif related_status.rating %}
|
||||
{% include 'snippets/stars.html' with rating=related_status.rating %}
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="column is-narrow {% if notification.notification_type == 'REPLY' or notification.notification_type == 'MENTION' %}has-text-black{% else %}has-text-grey-dark{% endif %}">
|
||||
{{ related_status.published_date | post_date }}
|
||||
{% include 'snippets/privacy-icons.html' with item=related_status %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endfor %}
|
||||
|
||||
|
|
|
@ -147,6 +147,30 @@ def get_mentions(status, user):
|
|||
return ' '.join(
|
||||
'@' + get_user_identifier(m) for m in mentions if not m == user)
|
||||
|
||||
@register.filter(name='status_preview_name')
|
||||
def get_status_preview_name(obj):
|
||||
name = obj.__class__.__name__.lower()
|
||||
if name == 'review':
|
||||
return '%s of <em>%s</em>' % (name, obj.book.title)
|
||||
if name == 'comment':
|
||||
return '%s on <em>%s</em>' % (name, obj.book.title)
|
||||
if name == 'quotation':
|
||||
return '%s from <em>%s</em>' % (name, obj.book.title)
|
||||
return name
|
||||
|
||||
@register.simple_tag(takes_context=False)
|
||||
def related_status(notification):
|
||||
''' for notifications '''
|
||||
if not notification.related_status:
|
||||
return None
|
||||
if hasattr(notification.related_status, 'quotation'):
|
||||
return notification.related_status.quotation
|
||||
if hasattr(notification.related_status, 'review'):
|
||||
return notification.related_status.review
|
||||
if hasattr(notification.related_status, 'comment'):
|
||||
return notification.related_status.comment
|
||||
return notification.related_status
|
||||
|
||||
@register.simple_tag(takes_context=True)
|
||||
def active_shelf(context, book):
|
||||
''' check what shelf a user has a book on, if any '''
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
''' defining regexes for regularly used concepts '''
|
||||
|
||||
domain = r'[\w_\-\.]+\.[a-z]{2,}'
|
||||
localname = r'@?[a-zA-Z_\-\.0-9]+\b'
|
||||
localname = r'@?[a-zA-Z_\-\.0-9]+'
|
||||
strict_localname = r'@[a-zA-Z_\-\.0-9]+'
|
||||
username = r'%s(@%s)?' % (localname, domain)
|
||||
strict_username = r'\B%s(@%s)?\b' % (strict_localname, domain)
|
||||
full_username = r'\B%s@%s\b' % (localname, domain)
|
||||
full_username = r'%s@%s\b' % (localname, domain)
|
||||
# should match (BookWyrm/1.0.0; or (BookWyrm/99.1.2;
|
||||
bookwyrm_user_agent = r'\(BookWyrm/[0-9]+\.[0-9]+\.[0-9]+;'
|
||||
|
|
|
@ -265,7 +265,7 @@ def search(request):
|
|||
return JsonResponse([r.json() for r in book_results], safe=False)
|
||||
|
||||
# use webfinger for mastodon style account@domain.com username
|
||||
if re.match(regex.full_username, query):
|
||||
if re.match(r'\B%s' % regex.full_username, query):
|
||||
outgoing.handle_remote_webfinger(query)
|
||||
|
||||
# do a local user search
|
||||
|
|
Loading…
Reference in a new issue