[ENTITY][Note] Added function getRenderedSplit, return an array of paragraphs/line breaks
[PLUGINS][Favourite] Foreign keys now properly defined on schema [CARDS][Note] Note text is now hidden by default if too many paragraphs/line breaks are present, BlogCollection plugin will certainly need this feature
This commit is contained in:
parent
fb76775716
commit
4dd976eb22
@ -55,7 +55,7 @@ class AttachmentCollection extends Entity
|
||||
public static function schemaDef()
|
||||
{
|
||||
return [
|
||||
'name' => 'collection',
|
||||
'name' => 'attachment_collection',
|
||||
'fields' => [
|
||||
'id' => ['type' => 'serial', 'not null' => true, 'description' => 'unique identifier'],
|
||||
'name' => ['type' => 'varchar', 'length' => 255, 'not null' => true, 'description' => 'collection\'s name'],
|
||||
|
@ -153,6 +153,10 @@ class NoteFavourite extends Entity
|
||||
'modified' => ['type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'],
|
||||
],
|
||||
'primary key' => ['note_id', 'actor_id'],
|
||||
'foreign keys' => [
|
||||
'note_id_to_id_fkey' => ['note', ['note_id' => 'id']],
|
||||
'actor_reply_to_id_fkey' => ['actor', ['actor_id' => 'id']],
|
||||
],
|
||||
'indexes' => [
|
||||
'fave_note_id_idx' => ['note_id'],
|
||||
'fave_actor_id_idx' => ['actor_id', 'modified'],
|
||||
|
@ -324,6 +324,29 @@ embed header {
|
||||
text-decoration: underline !important;
|
||||
}
|
||||
|
||||
.note-text p:not(:last-of-type) {
|
||||
display: block;
|
||||
margin-bottom: var(--s);
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.note-text-details-summary:after {
|
||||
content: "\2193";
|
||||
}
|
||||
|
||||
.note-text-details .note-text-details-summary small {
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.note-text-details[open] summary:after {
|
||||
content: "\2191";
|
||||
float: right;
|
||||
}
|
||||
|
||||
.note-text-details[open] .note-text-details-summary small {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.note-wrapper {
|
||||
height: inherit;
|
||||
width: 100%;
|
||||
|
@ -286,6 +286,11 @@ class Note extends Entity
|
||||
return !\is_null($this->getLanguageId()) ? Language::getById($this->getLanguageId())->getLocale() : null;
|
||||
}
|
||||
|
||||
public function getRenderedSplit(): array
|
||||
{
|
||||
return preg_split('/(<\s*p\s*\/?>)|(<\s*br\s*\/?>)|(\s\s+)|(<\s*\/p\s*\/?>)/', $this->getRendered(), -1, PREG_SPLIT_NO_EMPTY);
|
||||
}
|
||||
|
||||
public static function getAllNotesByActor(Actor $actor): array
|
||||
{
|
||||
// TODO: Enforce scoping on the notes before returning
|
||||
|
@ -64,7 +64,22 @@
|
||||
{% block note_text %}
|
||||
<div class="note-text" tabindex="0"
|
||||
title="{{ 'Note text content.' | trans }}">
|
||||
{{ note.getRendered() | raw }}
|
||||
{% set paragraph_array = note.getRenderedSplit() %}
|
||||
{% if 'conversation' not in app.request.get('_route') and paragraph_array | length > 3 %}
|
||||
<p>{{ paragraph_array[0] | raw }}</p>
|
||||
<details class="note-text-details">
|
||||
<summary class="note-text-details-summary">
|
||||
<small>{% trans %}Expand to see all content{% endtrans %}</small>
|
||||
</summary>
|
||||
{% for paragraph in paragraph_array | slice(1, paragraph_array | length) %}
|
||||
<p>{{ paragraph | raw }}</p>
|
||||
{% endfor %}
|
||||
</details>
|
||||
{% else %}
|
||||
{% for paragraph in paragraph_array %}
|
||||
<p>{{ paragraph | raw }}</p>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endblock note_text %}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user