mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2025-01-20 22:18:07 +00:00
Merge branch 'main' into production
This commit is contained in:
commit
8dc8ea2f59
5 changed files with 30 additions and 9 deletions
|
@ -4,7 +4,6 @@
|
||||||
{% load humanize %}
|
{% load humanize %}
|
||||||
{% load utilities %}
|
{% load utilities %}
|
||||||
{% load static %}
|
{% load static %}
|
||||||
{% load layout %}
|
|
||||||
|
|
||||||
{% block title %}{{ book|book_title }}{% endblock %}
|
{% block title %}{{ book|book_title }}{% endblock %}
|
||||||
|
|
||||||
|
@ -43,7 +42,7 @@
|
||||||
</p>
|
</p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if book.authors %}
|
{% if book.authors.exists %}
|
||||||
<div class="subtitle">
|
<div class="subtitle">
|
||||||
{% trans "by" %} {% include 'snippets/authors.html' with book=book %}
|
{% trans "by" %} {% include 'snippets/authors.html' with book=book %}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
{% load utilities %}
|
{% load utilities %}
|
||||||
{% spaceless %}
|
{% spaceless %}
|
||||||
|
|
||||||
{% if book.authors %}
|
{% if book.authors.exists %}
|
||||||
{% blocktrans trimmed with path=book.local_path title=book|book_title %}
|
{% blocktrans trimmed with path=book.local_path title=book|book_title %}
|
||||||
<a href="{{ path }}">{{ title }}</a> by
|
<a href="{{ path }}">{{ title }}</a> by
|
||||||
{% endblocktrans %}
|
{% endblocktrans %}
|
||||||
|
|
|
@ -55,7 +55,8 @@ def truncatepath(value, arg):
|
||||||
|
|
||||||
@register.simple_tag(takes_context=False)
|
@register.simple_tag(takes_context=False)
|
||||||
def get_book_cover_thumbnail(book, size="medium", ext="jpg"):
|
def get_book_cover_thumbnail(book, size="medium", ext="jpg"):
|
||||||
"""Returns a book thumbnail at the specified size and extension, with fallback if needed"""
|
"""Returns a book thumbnail at the specified size and extension,
|
||||||
|
with fallback if needed"""
|
||||||
if size == "":
|
if size == "":
|
||||||
size = "medium"
|
size = "medium"
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -281,7 +281,7 @@ class StatusViews(TestCase):
|
||||||
("@nutria@%s" % DOMAIN, user),
|
("@nutria@%s" % DOMAIN, user),
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_format_links(self, *_):
|
def test_format_links_simple_url(self, *_):
|
||||||
"""find and format urls into a tags"""
|
"""find and format urls into a tags"""
|
||||||
url = "http://www.fish.com/"
|
url = "http://www.fish.com/"
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
|
@ -291,6 +291,27 @@ class StatusViews(TestCase):
|
||||||
views.status.format_links("(%s)" % url),
|
views.status.format_links("(%s)" % url),
|
||||||
'(<a href="%s">www.fish.com/</a>)' % url,
|
'(<a href="%s">www.fish.com/</a>)' % url,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def test_format_links_paragraph_break(self, *_):
|
||||||
|
"""find and format urls into a tags"""
|
||||||
|
url = """okay
|
||||||
|
|
||||||
|
http://www.fish.com/"""
|
||||||
|
self.assertEqual(
|
||||||
|
views.status.format_links(url),
|
||||||
|
'okay\n\n<a href="http://www.fish.com/">www.fish.com/</a>',
|
||||||
|
)
|
||||||
|
|
||||||
|
def test_format_links_parens(self, *_):
|
||||||
|
"""find and format urls into a tags"""
|
||||||
|
url = "http://www.fish.com/"
|
||||||
|
self.assertEqual(
|
||||||
|
views.status.format_links("(%s)" % url),
|
||||||
|
'(<a href="%s">www.fish.com/</a>)' % url,
|
||||||
|
)
|
||||||
|
|
||||||
|
def test_format_links_special_chars(self, *_):
|
||||||
|
"""find and format urls into a tags"""
|
||||||
url = "https://archive.org/details/dli.granth.72113/page/n25/mode/2up"
|
url = "https://archive.org/details/dli.granth.72113/page/n25/mode/2up"
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
views.status.format_links(url),
|
views.status.format_links(url),
|
||||||
|
|
|
@ -155,9 +155,11 @@ def format_links(content):
|
||||||
"""detect and format links"""
|
"""detect and format links"""
|
||||||
validator = URLValidator()
|
validator = URLValidator()
|
||||||
formatted_content = ""
|
formatted_content = ""
|
||||||
split_content = content.split()
|
split_content = re.split(r"(\s+)", content)
|
||||||
|
|
||||||
for index, potential_link in enumerate(split_content):
|
for potential_link in split_content:
|
||||||
|
if not potential_link:
|
||||||
|
continue
|
||||||
wrapped = _wrapped(potential_link)
|
wrapped = _wrapped(potential_link)
|
||||||
if wrapped:
|
if wrapped:
|
||||||
wrapper_close = potential_link[-1]
|
wrapper_close = potential_link[-1]
|
||||||
|
@ -182,8 +184,6 @@ def format_links(content):
|
||||||
|
|
||||||
if wrapped:
|
if wrapped:
|
||||||
formatted_content += wrapper_close
|
formatted_content += wrapper_close
|
||||||
if index < len(split_content) - 1:
|
|
||||||
formatted_content += " "
|
|
||||||
|
|
||||||
return formatted_content
|
return formatted_content
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue