diff options
| author | Jonas Kohl | 2024-10-17 10:56:01 +0200 | 
|---|---|---|
| committer | Jonas Kohl | 2024-10-17 10:56:01 +0200 | 
| commit | fe0f414dc0211a4014581dc03fcfd514ed7ed02d (patch) | |
| tree | cd86fc00cd9b7a97eabb9668e0a39e2b4b3e5357 /src/application/templates/bootstrap-3/components | |
| parent | e0e89b9fdbf301e0ead944636023947a67aca57d (diff) | |
Transition templating to Twig
Diffstat (limited to 'src/application/templates/bootstrap-3/components')
5 files changed, 254 insertions, 0 deletions
| diff --git a/src/application/templates/bootstrap-3/components/alert_error.twig b/src/application/templates/bootstrap-3/components/alert_error.twig new file mode 100644 index 0000000..f3f759b --- /dev/null +++ b/src/application/templates/bootstrap-3/components/alert_error.twig @@ -0,0 +1,8 @@ +<div class="alert alert-danger" role="alert"> +    <span class="fa fa-exclamation-circle" aria-hidden="true"></span> +    {% if message starts with "?!HTML::" %} +        {{ message|slice(8)|raw }} +    {% else %} +        {{ message }} +    {% endif %} +</div> diff --git a/src/application/templates/bootstrap-3/components/alert_info.twig b/src/application/templates/bootstrap-3/components/alert_info.twig new file mode 100644 index 0000000..099d091 --- /dev/null +++ b/src/application/templates/bootstrap-3/components/alert_info.twig @@ -0,0 +1,8 @@ +<div class="alert alert-info" role="alert"> +    <span class="fa fa-info-circle" aria-hidden="true"></span> +    {% if message starts with "?!HTML::" %} +        {{ message|slice(8)|raw }} +    {% else %} +        {{ message }} +    {% endif %} +</div> diff --git a/src/application/templates/bootstrap-3/components/alert_success.twig b/src/application/templates/bootstrap-3/components/alert_success.twig new file mode 100644 index 0000000..1c8f403 --- /dev/null +++ b/src/application/templates/bootstrap-3/components/alert_success.twig @@ -0,0 +1,8 @@ +<div class="alert alert-success" role="alert"> +    <span class="fa fa-check-circle" aria-hidden="true"></span> +    {% if message starts with "?!HTML::" %} +        {{ message|slice(8)|raw }} +    {% else %} +        {{ message }} +    {% endif %} +</div> diff --git a/src/application/templates/bootstrap-3/components/post.twig b/src/application/templates/bootstrap-3/components/post.twig new file mode 100644 index 0000000..ac969c0 --- /dev/null +++ b/src/application/templates/bootstrap-3/components/post.twig @@ -0,0 +1,168 @@ +{%- set fileAttachments = attachments|filter(a => not (a.mimeType starts with "image/" or a.mimeType starts with "video/")) -%} +{%- set imageAttachments = attachments|filter(a => a.mimeType starts with "image/" or a.mimeType starts with "video/") -%} + +{%- set canReply = +    not post.deleted +    and not topic.isLocked +    and currentUser is not null +    and currentUser.hasPermission(permission("CREATE_OWN_POST")) +-%} + +{%- set canEdit = +    not post.deleted +    and not topic.isLocked +    and currentUser is not null +    and ( +        ( +            postAuthor is not null +            and postAuthor.hasPermission(permission("EDIT_OWN_POST")) +        ) +        or currentUser.hasPermission(permission("EDIT_OTHER_POST")) +    ) -%} + +{%- set canDelete = +    not post.deleted +    and currentUser is not null +    and ( +        ( +            postAuthor is not null +            and postAuthor.id == currentUser.id +            and postAuthor.hasPermission(permission("DELETE_OWN_POST")) +        ) +        or currentUser.hasPermission(permission("DELETE_OTHER_POST")) +    ) -%} + +{%- set canViewAttachments = currentUser is not null -%} + +{%- set your_are_the_author = +    currentUser is not null +    and postAuthor is not null +    and currentUser.id == postAuthor.id +-%} + +{%- set is_op = +    topicAuthor is not null +    and postAuthor is not null +    and postAuthor.id == topicAuthor.id +-%} + +{% if post.deleted %} +    <div class="media" id="post-{{ post.id }}"> +        <div class="media-left hidden-sm hidden-xs"> +            <div class="media-object" style="width:64px"></div> +        </div> +        <div class="media-body"> +            <div class="well icon-well text-warning"> +                <span class="fa fa-exclamation-triangle text-warning" aria-hidden="true"></span> +                <em>{{ __("This post has been deleted") }}</em> +            </div> +        </div> +    </div> +{% else %} +    <div class="media" id="post-{{ post.id }}" data-text="{{ post.content }}" style="overflow: visible;"> +        {% if not hide_pfp %} +            <div class="media-left hidden-sm hidden-xs"> +                {% if postAuthor %} +                    {% if hide_actions %} +                        <img class="media-object" alt="{{ __("Profile picture") }}" src="?_action=profilepicture&user={{ postAuthor.id|url_encode }}" width="64" height="64"> +                    {% else %} +                        <a href="?_action=viewuser&user={{ postAuthor.id|url_encode }}"> +                            <img class="media-object" alt="{{ __("Profile picture") }}" src="?_action=profilepicture&user={{ postAuthor.id|url_encode }}" width="64" height="64"> +                        </a> +                    {% endif %} +                {% else %} +                    <div class="media-object" style="width:64px;height:64px"></div> +                {% endif %} +            </div> +        {% endif %} +        <div class="media-body" style="overflow: visible;"> +            <div class="panel panel-default"> +                <div class="panel-heading"> +                    <div class="panel-title h3"> +                        {% if not hide_actions %} +                            <div class="pull-right"> +                                <a href="#post-{{ post.id }}" class="btn btn-default"><span class="fa fa-link" aria-hidden="true"></span><span class="sr-only">{{ __("Permalink") }}</span></a> +                                {% if canReply %} +                                    <button data-post-id="{{ post.id }}" class="btn btn-default js-only _reply-post"><span class="fa fa-comment" aria-hidden="true"></span><span class="sr-only">{{ __("Reply to post") }}</span></button> +                                {% endif %} +                                {% if canEdit %} +                                    <button data-post-id="{{ post.id }}" class="btn btn-default js-only _edit-post"><span class="fa fa-pencil" aria-hidden="true"></span><span class="sr-only">{{ __("Edit post") }}</span></button> +                                {% endif %} +                                {% if canDelete %} +                                    <form action="?_action=deletepost" method="post" class="seamless-inline"> +                                        <input type="hidden" name="post" value="{{ post.id }}"> +                                        <button type="submit" class="btn btn-danger"><span class="fa fa-trash" aria-hidden="true"></span><span class="sr-only">{{ __("Delete post") }}</span></button> +                                    </form> +                                {% endif %} +                            </div> +                        {% endif %} +                        {% if postAuthor %} +                            {% if hide_actions %} +                                {{ postAuthor.displayName }} +                            {% else %} +                                <a href="?_action=viewuser&user={{ postAuthor.id|url_encode }}">{{ postAuthor.displayName }}</a> +                                {% if is_op %} +                                    <span title="{{ __("Created this topic") }}" class="text-info fa fa-user-circle"></span> +                                {% endif %} +                            {% endif %} +                            {% if your_are_the_author %} +                                <span class="text-normal label label-primary">{{ __("You") }}</span> +                            {% endif %} +                        {% else %} +                            <em class="text-muted">{{ __("(deleted)") }}</em> +                        {% endif %} +                    </div> +                    <span class="_time">{{ post.postDate.format("c") }}</span> +                    {% if post.edited %} +                        <em class="text-muted">{{ __("(edited)") }}</em> +                    {% endif %} +                </div> +                <div class="panel-body"> +                    <div class="post-content">{{ renderPost(post.content) }}</div> +                    {% if imageAttachments|length > 0 %} +                        <div class="post-images clearfix"> +                            {% for attachment in imageAttachments %} +                                {% if hide_actions %} +                                    <span class="image-attachment" title="{{ attachment.name }}"> +                                        <img class="image-attachment-image" src="?_action=thumb&attachment={{ attachment.id|url_encode }}" alt="" width="100"> +                                    </span> +                                {% else %} +                                    <a class=" +                                        image-attachment +                                        attachment +                                        {{ attachment.mimeType starts with "video/" ? "video-attachment" }} +                                    " href="?_action=attachment&attachment={{ attachment.id|url_encode }}" title="{{ attachment.name }}" data-attachment-id="{{ attachment.id }}"> +                                        <img class="image-attachment-image" src="?_action=thumb&attachment={{ attachment.id|url_encode }}" alt="" width="100"> +                                        {% if not canViewAttachments %} +                                            <span class="attachment-lock fa fa-ban" aria-hidden="true"></span> +                                        {% elseif attachment.mimeType starts with "video/" %} +                                            <span class="video-player-icon fa fa-play-circle" aria-hidden="true"></span> +                                        {% endif %} +                                    </a> +                                {% endif %} +                            {% endfor %} +                        </div> +                    {% endif %} +                </div> +                {% if fileAttachments|length > 0 %} +                    <div class="panel-footer"> +                        <div class="btn-group"> +                            {% for attachment in fileAttachments %} +                                {% if hide_actions %} +                                    <button class="btn btn-default">{{ attachment.name }}</button> +                                {% else %} +                                    <a class="btn btn-default attachment" href="?_action=attachment&attachment={{ attachment.id|url_encode }}"> +                                        {% if not canViewAttachments %} +                                            <span class="fa fa-ban" aria-hidden="true"></span> +                                        {% endif %} +                                        {{ attachment.name }} +                                    </a> +                                {% endif %} +                            {% endfor %} +                        </div> +                    </div> +                {% endif %} +            </div> +        </div> +    </div> +{% endif %} diff --git a/src/application/templates/bootstrap-3/components/topic_log.twig b/src/application/templates/bootstrap-3/components/topic_log.twig new file mode 100644 index 0000000..9364cd1 --- /dev/null +++ b/src/application/templates/bootstrap-3/components/topic_log.twig @@ -0,0 +1,62 @@ +{%- set user = "" -%} +{%- if postAuthor is null -%} +    {%- set user = __("deleted")|e("html") -%} +{%- else -%} +    {%- set user = +        '<a href="?_action=viewuser&user=' +        ~ postAuthor.id|url_encode|e("html") +        ~ '">' +        ~ postAuthor.displayName|e("html") +        ~ '</a>' +    -%} +{%- endif -%} + +<div class="media" id="post-{{ logMessage.id }}"> +    <div class="media-left hidden-sm hidden-xs"> +        {% if postAuthor %} +            {% if hideActions %} +                <img class="media-object" alt="{{ __("Profile picture") }}" src="?_action=profilepicture&user={{ postAuthor.id|url_encode }}" width="64" height="64"> +            {% else %} +                <a href="?_action=viewuser&user={{ postAuthor.id|url_encode }}"> +                    <img class="media-object" alt="{{ __("Profile picture") }}" src="?_action=profilepicture&user={{ postAuthor.id|url_encode }}" width="64" height="64"> +                </a> +            {% endif %} +        {% else %} +            <div class="media-object" style="width:64px;height:64px"></div> +        {% endif %} +    </div> +    <div class="media-body"> +        {% if logMessage.type == constant("mystic\\forum\\orm\\TopicLogMessage::LOCKED") %} +            <div class="well icon-well text-info"> +                <span class="fa fa-lock text-info" aria-hidden="true"></span> +                <em>{{ __("%user% locked this topic", { +                    "user": user, +                }) }}</em> +                <br> +                <small class="_time">{{ logMessage.postDate.format("c") }}</small> +            </div> +        {% elseif logMessage.type == constant("mystic\\forum\\orm\\TopicLogMessage::UNLOCKED") %} +            <div class="well icon-well text-success"> +                <span class="fa fa-unlock text-success" aria-hidden="true"></span> +                <em>{{ __("%user% unlocked this topic", { +                    "user": user, +                }) }}</em> +                <br> +                <small class="_time">{{ logMessage.postDate.format("c") }}</small> +            </div> +        {% elseif logMessage.type == constant("mystic\\forum\\orm\\TopicLogMessage::TITLE_CHANGED") %} +            <div class="well icon-well text-info"> +                <span class="fa fa-pencil text-info" aria-hidden="true"></span> +                <em>{{ __("%user% changed the title of this topic from %old_title% to %new_title%", { +                    "user": user, +                    "old_title": '<strong>' ~ logMessage.params.old_value|default(__("unknown"))|e("html") ~ '</strong>', +                    "new_title": '<strong>' ~ logMessage.params.new_value|default(__("unknown"))|e("html") ~ '</strong>', +                }) }}</em> +                <br> +                <small class="_time">{{ logMessage.postDate.format("c") }}</small> +            </div> +        {% else %} +            {{ __("unknown") }} +        {% endif %} +    </div> +</div> |