This commit is contained in:
Your Name 2023-01-31 10:24:57 -05:00 committed by Henri Dickson
parent d30c2d5ddf
commit 60378b0b6d
10 changed files with 44 additions and 39 deletions

View file

@ -36,6 +36,11 @@ function catalog_init(context) {
$(this).parent().siblings(".entity-desc__content").removeClass('entity-desc__content--folded');
$(this).parent(".entity-desc__unfold-button").remove();
});
// spoiler
$(".spoiler", context).on('click', function(){
$(this).toggleClass('revealed');
})
}
$(function() {

View file

@ -149,7 +149,7 @@
{% endif %}
{% if others_mark.text %}
<p class="entity-marks__mark-content">{{ others_mark.text }}</p>
<p class="entity-marks__mark-content">{{ others_mark.comment_html|safe }}</p>
{% endif %}
</li>
{% empty %}
@ -222,7 +222,7 @@
</div>
{% if mark.text %}
<p class="mark-panel__text">{{ mark.text }}</p>
<p class="mark-panel__text">{{ mark.comment_html|safe }}</p>
{% endif %}
<div class="tag-collection">

View file

@ -51,7 +51,7 @@
{% endif %}
{% if others_mark.mark.text %}
<p class="entity-marks__mark-content">{{ others_mark.mark.text }}</p>
<p class="entity-marks__mark-content">{{ others_mark.mark.comment_html|safe }}</p>
{% endif %}
</li>
{% empty %}

View file

@ -64,10 +64,12 @@
background: unset;
text-decoration: underline;
& .spoiler
filter: blur(8px);
cursor: pointer;
.spoiler
background: grey;
filter: blur(2px);
cursor: pointer;
& .spoiler .revealed
filter: unset;
color: inherit;
.spoiler.revealed
background: unset;
filter: unset;
color: inherit;

View file

@ -22,7 +22,7 @@ from django.utils.baseconv import base62
from django.db.models import Q
from catalog.models import *
from django.contrib.contenttypes.models import ContentType
from .renderers import render_md
from .renderers import render_md, render_text
from catalog.common import jsondata
from journal import renderers
@ -188,6 +188,10 @@ class Memo(Content):
class Comment(Content):
text = models.TextField(blank=False, null=False)
@property
def html(self):
return render_text(self.text)
@staticmethod
def comment_item_by_user(item, user, text, visibility=0):
comment = Comment.objects.filter(owner=user, item=item).first()
@ -949,6 +953,10 @@ class Mark:
def text(self):
return self.comment.text if self.comment else None
@property
def comment_html(self):
return self.comment.html if self.comment else None
@cached_property
def review(self):
return Review.objects.filter(owner=self.owner, item=self.item).first()

View file

@ -1,7 +1,7 @@
from typing import cast
import mistune
import re
from django.utils.html import escape
MARKDOWNX_MARKDOWNIFY_FUNCTION = "journal.renderers.render_md"
@ -30,5 +30,19 @@ def render_md(s) -> str:
return cast(str, _markdown(s))
def _spolier(s):
l = s.split(">!", 1)
if len(l) == 1:
return escape(s)
r = l[1].split("!<", 1)
return (
escape(l[0])
+ '<span class="spoiler">'
+ escape(r[0])
+ "</span>"
+ (_spolier(r[1]) if len(r) == 2 else "")
)
def render_text(s):
return mistune.html(s)
return _spolier(s)

View file

@ -96,7 +96,7 @@
</span>
<p class="entity-marks__mark-content">&nbsp;
{% if mark.text %}
{{ mark.text }}
{{ mark.comment_html|safe }}
{% endif %}
</p>
</li>

View file

@ -44,17 +44,5 @@
{% endfor %}
</div>
<p class="entity-list__entity-brief">
{% if activity.review %}
<a href="{{ activity.review.url }}">{{ activity.review.title }}</a>
{% endif %}
{% if activity.mark %}
{% if activity.mark.rating %}
<span class="entity-marks__rating-star rating-star" data-rating-score="{{ activity.mark.rating | floatformat:"0" }}" style=""></span>
{% endif %}
{% if activity.mark.text %}
<p class="entity-marks__mark-content">{{ activity.mark.text }}</p>
{% endif %}
{% endif %}
</p>
</div>
</div>

View file

@ -42,17 +42,5 @@
</a>
</div>
<p class="entity-list__entity-brief">
{% if activity.review %}
<a href="{{ activity.review.url }}">{{ activity.review.title }}</a>
{% endif %}
{% if activity.mark %}
{% if activity.mark.rating %}
<span class="entity-marks__rating-star rating-star" data-rating-score="{{ activity.mark.rating | floatformat:"0" }}" style=""></span>
{% endif %}
{% if activity.mark.text %}
<p class="entity-marks__mark-content">{{ activity.mark.text }}</p>
{% endif %}
{% endif %}
</p>
</div>

View file

@ -53,7 +53,7 @@
<span class="entity-marks__rating-star rating-star" data-rating-score="{{ activity.action_object.mark.rating }}" style=""></span>
{% endif %}
{% if activity.action_object.mark.text %}
<p class="entity-marks__mark-content">{{ activity.action_object.mark.text }}</p>
<p class="entity-marks__mark-content">{{ activity.action_object.mark.comment_html|safe }}</p>
{% endif %}
</p>
</div>