Always link to the slug even if it's empty string.

modified:   remarkbox/models/node.py
	modified:   remarkbox/templates/home.j2
This commit is contained in:
Russell Ballestrini 2024-02-05 19:23:45 -05:00
parent da39486af2
commit e4429951db
2 changed files with 6 additions and 5 deletions

View file

@ -284,14 +284,15 @@ class Node(RBase, Base):
@property
def slug(self):
"""return slug from title or None"""
"""return slug from title or empty string"""
if self.title:
return slugify(self.title)
return ""
@property
def path(self):
"""return a node's path part of uri"""
if self.slug is not None:
if self.slug:
return "/{}/{}".format(self.id, self.slug)
else:
return "/{}".format(self.id)

View file

@ -28,7 +28,7 @@
{% if node.user %}
{{ snippets.user_link(node.user) }}
{% else %}
<a href="{{ request.link_prefix }}/{{ node.id }}">thread</a>
<a href="{{ request.link_prefix }}/{{ node.id }}/{{ node.slug }}">thread</a>
{% endif %}
<span id="{{ node.id }}" class="date" title="{{ node.created_date }}">
{{ node.human_changed_timestamp }}
@ -38,10 +38,10 @@
{% if node.has_uri -%}
<a href="{{ node.uri.data }}" target="_blank" rel="nofollow">{{ node.uri.data }}</a>
{% else -%}
<a href="{{ node.path }}">{{ node.title }}</a>
<a href="{{ request.link_prefix }}/{{ node.id }}/{{ node.slug }}">{{ node.title }}</a>
{% endif -%}
<br>
<a href="{{ request.link_prefix }}/{{ node.id }}">
<a href="{{ request.link_prefix }}/{{ node.id }}/{{ node.slug }}">
<span class="remark-count">{{ node.stats["root"]["visible_count"] }} remarks</span>
</a>
</div>