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
aafc9654c1
4 changed files with 94 additions and 46 deletions
|
@ -13,7 +13,23 @@
|
|||
|
||||
<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="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' %}
|
||||
<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' %}
|
||||
<span class="icon icon-boost"></span>
|
||||
{% elif notification.notification_type == 'FAVORITE' %}
|
||||
<span class="icon icon-heart"></span>
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="column">
|
||||
<div class="block">
|
||||
<p>
|
||||
{# DESCRIPTION #}
|
||||
|
@ -22,16 +38,16 @@
|
|||
{% 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>
|
||||
<a href="{{ related_status.local_path }}">{{ related_status | status_preview_name|safe }}</a>
|
||||
|
||||
{% elif notification.notification_type == 'MENTION' %}
|
||||
mentioned you in a
|
||||
<a href="{{ notification.related_status.local_path }}">status</a>
|
||||
<a href="{{ related_status.local_path }}">{{ related_status | status_preview_name|safe }}</a>
|
||||
|
||||
{% elif notification.notification_type == 'REPLY' %}
|
||||
<a href="{{ notification.related_status.local_path }}">replied</a>
|
||||
<a href="{{ related_status.local_path }}">replied</a>
|
||||
to your
|
||||
<a href="{{ notification.related_status.reply_parent.local_path }}">status</a>
|
||||
<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' %}
|
||||
|
@ -41,30 +57,38 @@
|
|||
</div>
|
||||
|
||||
{% elif notification.notification_type == 'BOOST' %}
|
||||
boosted your <a href="{{ notification.related_status.local_path }}">status</a>
|
||||
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 notification.related_status %}
|
||||
{% 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">
|
||||
<a href="{{ notification.related_status.local_path }}">{{ notification.related_status.content | safe | truncatewords_html:10 }}</a>
|
||||
{% 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 %}">
|
||||
{{ notification.related_status.published_date | post_date }}
|
||||
{% include 'snippets/privacy-icons.html' with item=notification.related_status %}
|
||||
{{ related_status.published_date | post_date }}
|
||||
{% include 'snippets/privacy-icons.html' with item=related_status %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
|
||||
{% if not notifications %}
|
||||
|
|
|
@ -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