mirror of https://gitlab.com/tildes/tildes.git
Browse Source
Hide tags in listings by default + layout updates
Hide tags in listings by default + layout updates
Topic tags are no longer shown in listing pages by default (except "important" ones such as "nsfw" and "spoiler"), and the layout and emphasis on them has been adjusted in multiple other ways as well. A preference to continue showing them in listings has been added, and this preference is enabled by default for all users with the "topic.tag" permission (ability to tag any users' topics). Other changes: * The tagging field is collapsed by default when posting a new topic. If a user expands it and enters tags, it will be shown expanded in the future. It will also be expanded by default after the user adds/changes tags on a topic, and will also be set automatically for users that have shown an interest in tagging recently (by submitting a topic with tags or changing tags). * "Content metadata" such as word count and duration is now shown next to the group name (where tags were previously), instead of after the title. * Topic icons (favicons) are now shown next to the domain name, instead of before the title. Blank icons no longer have a dashed border and are now just an empty space. * When on a topic's comments page, tags are now shown in the main content area, below the "byline" information about who posted the topic and when, instead of in the sidebar. * Other minor layout changes to adjust for tags, as well as prepare for some other upcoming changes like adding "actions" to topics in listings.merge-requests/85/head
Deimos
5 years ago
16 changed files with 229 additions and 65 deletions
-
72tildes/alembic/versions/d56e71257a86_add_tag_related_user_settings.py
-
1tildes/scripts/generate_site_icons_css.py
-
36tildes/scss/modules/_topic.scss
-
12tildes/scss/themes/_theme_base.scss
-
16tildes/tildes/models/topic/topic.py
-
6tildes/tildes/models/user/user.py
-
8tildes/tildes/templates/includes/new_topic_form.jinja2
-
11tildes/tildes/templates/includes/topic_tags.jinja2
-
3tildes/tildes/templates/intercooler/topic_tags_edit.jinja2
-
2tildes/tildes/templates/macros/forms.jinja2
-
36tildes/tildes/templates/macros/topics.jinja2
-
21tildes/tildes/templates/settings.jinja2
-
6tildes/tildes/templates/topic.jinja2
-
5tildes/tildes/views/api/web/topic.py
-
16tildes/tildes/views/api/web/user.py
-
5tildes/tildes/views/topic.py
@ -0,0 +1,72 @@ |
|||
"""Add tag-related user settings |
|||
|
|||
Revision ID: d56e71257a86 |
|||
Revises: a195ddbb4be6 |
|||
Create Date: 2019-09-27 23:53:34.287619 |
|||
|
|||
""" |
|||
from alembic import op |
|||
import sqlalchemy as sa |
|||
|
|||
|
|||
# revision identifiers, used by Alembic. |
|||
revision = "d56e71257a86" |
|||
down_revision = "a195ddbb4be6" |
|||
branch_labels = None |
|||
depends_on = None |
|||
|
|||
|
|||
def upgrade(): |
|||
op.add_column( |
|||
"users", |
|||
sa.Column( |
|||
"show_tags_in_listings", |
|||
sa.Boolean(), |
|||
server_default="false", |
|||
nullable=False, |
|||
), |
|||
) |
|||
op.add_column( |
|||
"users", |
|||
sa.Column( |
|||
"show_tags_on_new_topic", |
|||
sa.Boolean(), |
|||
server_default="false", |
|||
nullable=False, |
|||
), |
|||
) |
|||
|
|||
# enable the new settings for any users that have the "topic.tag" permission |
|||
op.execute( |
|||
""" |
|||
UPDATE users |
|||
SET show_tags_in_listings = true, show_tags_on_new_topic = true |
|||
WHERE permissions ? 'topic.tag' |
|||
""" |
|||
) |
|||
|
|||
# show tagging on new topics for any users that have changed tags recently or posted |
|||
# a topic that has tags and wasn't re-tagged by another user |
|||
op.execute( |
|||
""" |
|||
UPDATE users |
|||
SET show_tags_on_new_topic = true |
|||
WHERE user_id IN ( |
|||
SELECT DISTINCT(user_id) FROM log_topics WHERE event_type = 'TOPIC_TAG' |
|||
) OR user_id IN ( |
|||
SELECT DISTINCT(user_id) FROM topics |
|||
WHERE tags != '{}' AND created_time > NOW() - INTERVAL '30 days' |
|||
AND NOT EXISTS ( |
|||
SELECT * FROM log_topics |
|||
WHERE topic_id = topics.topic_id |
|||
AND event_type = 'TOPIC_TAG' |
|||
AND user_id != topics.user_id |
|||
) |
|||
) |
|||
""" |
|||
) |
|||
|
|||
|
|||
def downgrade(): |
|||
op.drop_column("users", "show_tags_on_new_topic") |
|||
op.drop_column("users", "show_tags_in_listings") |
@ -1,12 +1,9 @@ |
|||
{# Copyright (c) 2018 Tildes contributors <code@tildes.net> #} |
|||
{# SPDX-License-Identifier: AGPL-3.0-or-later #} |
|||
|
|||
{% from 'macros/topics.jinja2' import topic_tag %} |
|||
|
|||
<ul class="topic-tags"> |
|||
<div class="topic-full-tags">{% if topic.tags %}Tags:{% endif %} |
|||
{% for tag in topic.tags %} |
|||
{{ topic_tag(tag, "/~"~topic.group.path~"?tag="~tag.replace(' ', '_')) }} |
|||
{% else %} |
|||
<li class="label label-topic-tag">No tags</li> |
|||
<a href="/~{{ topic.group.path }}?tag={{ tag.replace(" ", "_") }}">{{ tag }}</a> |
|||
{%- if not loop.last %},{% endif %} |
|||
{% endfor %} |
|||
</ul> |
|||
</div> |
Write
Preview
Loading…
Cancel
Save
Reference in new issue