diff --git a/app/domain/routes.py b/app/domain/routes.py index ea038919..54a74a38 100644 --- a/app/domain/routes.py +++ b/app/domain/routes.py @@ -74,9 +74,13 @@ def domains(): return render_template('domain/domains.html', title='All known domains', domains=domains, next_url=next_url, prev_url=prev_url, search=search, ban_visibility_permission=ban_visibility_permission) + @bp.route('/domains/banned', methods=['GET']) @login_required def blocked_domains(): + if not current_user.trustworthy(): + abort(404) + page = request.args.get('page', 1, type=int) search = request.args.get('search', '') @@ -86,15 +90,11 @@ def blocked_domains(): domains = domains.order_by(Domain.name) domains = domains.paginate(page=page, per_page=100, error_out=False) - ban_visibility_permission = False - if not current_user.created_recently() and current_user.reputation > 100 or current_user.is_admin(): - ban_visibility_permission = True - next_url = url_for('domain.domains', page=domains.next_num) if domains.has_next else None prev_url = url_for('domain.domains', page=domains.prev_num) if domains.has_prev and page != 1 else None - return render_template('domain/domains_banned.html', title='Domains banned on this instance', domains=domains, - next_url=next_url, prev_url=prev_url, search=search, ban_visibility_permission=ban_visibility_permission) + return render_template('domain/domains_blocked.html', title='Domains blocked on this instance', domains=domains, + next_url=next_url, prev_url=prev_url, search=search) @bp.route('/d//block') diff --git a/app/models.py b/app/models.py index 8d4cc870..c42f8a59 100644 --- a/app/models.py +++ b/app/models.py @@ -591,6 +591,13 @@ class User(UserMixin, db.Model): return True return False + def trustworthy(self): + if self.is_admin(): + return True + if self.created_recently() or self.reputation < 100: + return False + return True + def link(self) -> str: if self.is_local(): return self.user_name @@ -1075,7 +1082,8 @@ class Filter(db.Model): def keywords_string(self): if self.keywords is None or self.keywords == '': return '' - return ', '.join(self.keywords.split('\n')) + split_keywords = [kw.strip() for kw in self.keywords.split('\n')] + return ', '.join(split_keywords) class Role(db.Model): diff --git a/app/templates/base.html b/app/templates/base.html index c2b5c857..f54a21bf 100644 --- a/app/templates/base.html +++ b/app/templates/base.html @@ -167,10 +167,8 @@ diff --git a/app/templates/domain/domains.html b/app/templates/domain/domains.html index 0f814a57..e6fcd163 100644 --- a/app/templates/domain/domains.html +++ b/app/templates/domain/domains.html @@ -6,35 +6,32 @@ {% from 'bootstrap/form.html' import render_form %} {% block app_content %} -
-
- - -
-
-

{{ _('Domains') }}

+
+
{% if search == '' %} -

All domains this instance knows about

+

{{ _('Domains') }}

{% else %} -

Domains containing "{{ _('%(search)s', search=search) }}"

+

{{ _('Domains containing "%(search)s"', search=search) }}

+ {% endif %} + {% if not current_user.is_anonymous and current_user.trustworthy() %} + {% endif %} -
-
+
@@ -48,7 +45,7 @@ {% if not current_user.is_anonymous %} {% if user_access('ban users', current_user.id) or user_access('manage users', current_user.id) %} {% endif %} {% endif %} @@ -68,8 +65,10 @@ {% endif %} - + + + {% endblock %} diff --git a/app/templates/domain/domains_banned.html b/app/templates/domain/domains_banned.html deleted file mode 100644 index 661fa9b4..00000000 --- a/app/templates/domain/domains_banned.html +++ /dev/null @@ -1,77 +0,0 @@ -{% if theme() and file_exists('app/templates/themes/' + theme() + '/base.html') %} - {% extends 'themes/' + theme() + '/base.html' %} -{% else %} - {% extends "base.html" %} -{% endif %} %} -{% from 'bootstrap/form.html' import render_form %} - -{% block app_content %} -
-
- - -
-
-

{{ _('Domains') }}

- {% if not ban_visibility_permission %} -

Your account is either too new or too low reputation to be able to see banned domains on this instance.

- {% else %} - {% if search == '' %} -

All domains this instance banned

- {% else %} -

Banned domains containing "{{ _('%(search)s', search=search) }}"

- {% endif %} -
- -
-
Domain - {{ _('Ban') }} + {{ _('Ban') }}
- - - {% if user_access('ban users', current_user.id) or user_access('manage users', current_user.id) %}{%endif%} - - {% for domain in domains %} - - - - - {% endfor %} -
DomainActions
{{ domain.name }} - {% if user_access('ban users', current_user.id) or user_access('manage users', current_user.id) %} - {% if domain.banned %} - {{ _('Unban') }} - {% else %} - {{ _('Ban') }} - {% endif %} - {% endif %} -
-
- -
- {% endif %} -
-
-{% endblock %} - diff --git a/app/templates/domain/domains_blocked.html b/app/templates/domain/domains_blocked.html new file mode 100644 index 00000000..9bb9f1ca --- /dev/null +++ b/app/templates/domain/domains_blocked.html @@ -0,0 +1,71 @@ +{% if theme() and file_exists('app/templates/themes/' + theme() + '/base.html') %} + {% extends 'themes/' + theme() + '/base.html' %} +{% else %} + {% extends "base.html" %} +{% endif %} %} +{% from 'bootstrap/form.html' import render_form %} + +{% block app_content %} +
+
+ {% if search == '' %} +

{{ _('Blocked domains') }}

+ {% else %} +

{{ _('Blocked domains containing "%(search)s"', search=search) }}

+ {% endif %} + {% if not current_user.is_anonymous and current_user.trustworthy() %} + + {% endif %} + +
+ + + + {% if user_access('ban users', current_user.id) or user_access('manage users', current_user.id) %}{%endif%} + + {% for domain in domains %} + + + + + {% endfor %} +
DomainActions
{{ domain.name }} + {% if user_access('ban users', current_user.id) or user_access('manage users', current_user.id) %} + {% if domain.banned %} + {{ _('Unban') }} + {% else %} + {{ _('Ban') }} + {% endif %} + {% endif %} +
+
+ +
+
+{% endblock %} + diff --git a/app/templates/user/_user_nav.html b/app/templates/user/_user_nav.html new file mode 100644 index 00000000..f8bb8122 --- /dev/null +++ b/app/templates/user/_user_nav.html @@ -0,0 +1,15 @@ + \ No newline at end of file diff --git a/app/templates/user/edit_filters.html b/app/templates/user/edit_filters.html index 1618ec65..af3449c3 100644 --- a/app/templates/user/edit_filters.html +++ b/app/templates/user/edit_filters.html @@ -7,41 +7,40 @@ {% set active_child = 'filters' %} {% block app_content %} -
-
- +
+
+
+ + + {% if content_filter %} +

{{ _('Filter %(name)s', name=content_filter.title) }}

+ {% else %} +

{{ _('Add filter') }}

+ {% endif %} + {% include "user/_user_nav.html" %} +
+ {{ form.csrf_token() }} + {{ render_field(form.title) }} +

{{ _('Filter in these places') }}

+ {{ render_field(form.filter_home) }} + {{ render_field(form.filter_posts) }} + {{ render_field(form.filter_replies) }} + {{ render_field(form.hide_type) }} + {{ render_field(form.keywords) }} + {{ _('One per line. Case does not matter.') }} + {{ render_field(form.expire_after) }} + {{ _('Stop applying this filter after this date. Optional.') }} + {{ render_field(form.submit) }} +
+
{% endblock %} \ No newline at end of file diff --git a/app/templates/user/edit_profile.html b/app/templates/user/edit_profile.html index 40d73f9c..c3731876 100644 --- a/app/templates/user/edit_profile.html +++ b/app/templates/user/edit_profile.html @@ -7,53 +7,56 @@ {% from 'bootstrap/form.html' import render_field %} {% block app_content %} -
-
- -

{{ _('Edit profile of %(name)s', name=user.user_name) }}

-
- {{ form.csrf_token() }} - {{ render_field(form.title) }} - {{ render_field(form.email) }} - {{ render_field(form.password_field) }} -
- {{ render_field(form.about) }} - {% if not low_bandwidth %} - {% if markdown_editor %} - - {% else %} - - {% endif %} + setupAutoResize('about'); + }); + + {% else %} + {% endif %} - {{ render_field(form.matrixuserid) }} - e.g. @something:matrix.org. Include leading @ and use : before server - {{ render_field(form.profile_file) }} - Provide a square image that looks good when small. - {{ render_field(form.banner_file) }} - Provide a wide image - letterbox orientation. -
- {{ render_field(form.bot) }} - {{ render_field(form.submit) }} -
-

- {{ _('Delete account') }} -

-
+ {% endif %} + {{ render_field(form.bot) }} + {{ render_field(form.matrixuserid) }} + e.g. @something:matrix.org. Include leading @ and use : before server +
Profile Images
+ {{ render_field(form.profile_file) }} + Provide a square image that looks good when small. + {{ render_field(form.banner_file) }} + Provide a wide image - letterbox orientation. + {{ render_field(form.submit) }} + +

+ {{ _('Delete account') }} +

+
{% endblock %} \ No newline at end of file diff --git a/app/templates/user/edit_profile2.html b/app/templates/user/edit_profile2.html deleted file mode 100644 index d4327813..00000000 --- a/app/templates/user/edit_profile2.html +++ /dev/null @@ -1,77 +0,0 @@ -{% if theme() and file_exists('app/templates/themes/' + theme() + '/base.html') %} - {% extends 'themes/' + theme() + '/base.html' %} -{% else %} - {% extends "base.html" %} -{% endif %} %} -{% set active_child = 'edit_profile' %} -{% from 'bootstrap/form.html' import render_field %} - -{% block app_content %} -
-
- - -
-
-

{{ _('Edit profile of %(name)s', name=user.user_name) }}

-

-
- {{ form.csrf_token() }} - - {{ render_field(form.email) }} - {{ render_field(form.password_field) }} -
Profile Data
- {{ render_field(form.title) }} - {{ render_field(form.about) }} - {% if not low_bandwidth %} - {% if markdown_editor %} - - {% else %} - - {% endif %} - {% endif %} - {{ render_field(form.bot) }} - {{ render_field(form.matrixuserid) }} - e.g. @something:matrix.org. Include leading @ and use : before server -
Profile Images
- {{ render_field(form.profile_file) }} - Provide a square image that looks good when small. - {{ render_field(form.banner_file) }} - Provide a wide image - letterbox orientation. - {{ render_field(form.submit) }} -
-

- {{ _('Delete account') }} -

-
-
-{% endblock %} \ No newline at end of file diff --git a/app/templates/user/edit_settings.html b/app/templates/user/edit_settings.html index d5301c52..feb8a9d4 100644 --- a/app/templates/user/edit_settings.html +++ b/app/templates/user/edit_settings.html @@ -7,32 +7,37 @@ {% set active_child = 'settings' %} {% block app_content %} -
-
- -

{{ _('Change settings') }}

-
- {{ form.csrf_token() }} - {{ render_field(form.newsletter) }} - {{ render_field(form.email_unread) }} - {{ render_field(form.ignore_bots) }} - {{ render_field(form.nsfw) }} - {{ render_field(form.nsfl) }} - {{ render_field(form.markdown_editor) }} - {{ render_field(form.searchable) }} - {{ render_field(form.indexable) }} - {{ render_field(form.default_sort) }} - {{ render_field(form.import_file) }} - {{ render_field(form.theme) }} - {{ render_field(form.submit) }} -   {{ _('Manage content filters') }} -
-
-
+ +
+
+ +

{{ _('Change settings') }}

+ {% include "user/_user_nav.html" %} +
+ {{ form.csrf_token() }} +
Mail Settings
+ {{ render_field(form.newsletter) }} + {{ render_field(form.email_unread) }} +
Visibility
+ {{ render_field(form.ignore_bots) }} + {{ render_field(form.nsfw) }} + {{ render_field(form.nsfl) }} + {{ render_field(form.searchable) }} + {{ render_field(form.indexable) }} +
Preferences
+ {{ render_field(form.markdown_editor) }} + {{ render_field(form.default_sort) }} + {{ render_field(form.theme) }} +
Import
+ {{ render_field(form.import_file) }} + {{ render_field(form.submit) }} +
+
+
{% endblock %} \ No newline at end of file diff --git a/app/templates/user/edit_settings2.html b/app/templates/user/edit_settings2.html deleted file mode 100644 index be4a207c..00000000 --- a/app/templates/user/edit_settings2.html +++ /dev/null @@ -1,59 +0,0 @@ -{% if theme() and file_exists('app/templates/themes/' + theme() + '/base.html') %} - {% extends 'themes/' + theme() + '/base.html' %} -{% else %} - {% extends "base.html" %} -{% endif %} %} -{% from 'bootstrap/form.html' import render_field %} -{% set active_child = 'settings' %} - -{% block app_content %} - -
-
- - -
-
-

{{ _('Change settings') }}

-

Change your basic settings and preferences

-
- {{ form.csrf_token() }} -
Mail Settings
- {{ render_field(form.newsletter) }} - {{ render_field(form.email_unread) }} -
Visibility
- {{ render_field(form.ignore_bots) }} - {{ render_field(form.nsfw) }} - {{ render_field(form.nsfl) }} - {{ render_field(form.searchable) }} - {{ render_field(form.indexable) }} -
Preferences
- {{ render_field(form.markdown_editor) }} - {{ render_field(form.default_sort) }} - {{ render_field(form.theme) }} -
Import
- {{ render_field(form.import_file) }} - {{ render_field(form.submit) }} -
-
-
-{% endblock %} \ No newline at end of file diff --git a/app/templates/user/filters.html b/app/templates/user/filters.html index 26163ee6..b7e34f85 100644 --- a/app/templates/user/filters.html +++ b/app/templates/user/filters.html @@ -7,46 +7,53 @@ {% set active_child = 'filters' %} {% block app_content %} -
-
- - -

{{ _('Filters') }}

-

{{ _('Filters can hide posts that contain keywords you specify, either by making them less noticeable or invisible.') }}

- {% if filters %} - - - - - - - - - {% for filter in filters %} - - - - - - - - {% endfor %} -
{{ _('Name') }}{{ _('Keywords') }}{{ _('Action') }}{{ _('Expires') }}
{{ filter.title }}{{ filter.keywords_string()|shorten(30) }}{{ _('Invisible') if filter.hide_type == 1 else _('Semi-transparent') }}{{ filter.expire_after if filter.expire_after }} - Edit | - Delete -
- {% else %} -

{{ _('No filters defined yet.') }}

- {% endif %} +
+
+ +

{{ _('Filters') }}

+ {% include "user/_user_nav.html" %} + + +

{{ _('Filters can hide posts that contain keywords you specify, either by making them less noticeable or invisible.') }}

+ {% if filters %} + + + + + + + + + {% for filter in filters %} + + + + + + + + {% endfor %} +
{{ _('Name') }}{{ _('Keywords') }}{{ _('Action') }}{{ _('Expires') }}
{{ filter.title }}{{ filter.keywords_string()|shorten(30) }}{{ _('Invisible') if filter.hide_type == 1 else _('Semi-transparent') }}{{ filter.expire_after if filter.expire_after }} + Edit | + Delete +
+ {% else %} +

{{ _('No filters defined yet.') }}

+ {% endif %} +
Blocks
+

Manage what users, communities, domains or instances you want to block. Blocking them means you will no longer see any posts associated with them.

+ Manage User Blocks + Manage Communities Blocks + Manage Domain Blocks + Manage Instance Blocks
+
{% endblock %} \ No newline at end of file diff --git a/app/templates/user/filters2.html b/app/templates/user/filters2.html deleted file mode 100644 index 005e166d..00000000 --- a/app/templates/user/filters2.html +++ /dev/null @@ -1,76 +0,0 @@ -{% if theme() and file_exists('app/templates/themes/' + theme() + '/base.html') %} - {% extends 'themes/' + theme() + '/base.html' %} -{% else %} - {% extends "base.html" %} -{% endif %} %} -{% from 'bootstrap/form.html' import render_field %} -{% set active_child = 'filters' %} - -{% block app_content %} -
-
- - -
-
- -

{{ _('Filters') }}

-

{{ _('Filters can hide posts that contain keywords you specify, either by making them less noticeable or invisible.') }}

- {% if filters %} - - - - - - - - - {% for filter in filters %} - - - - - - - - {% endfor %} -
{{ _('Name') }}{{ _('Keywords') }}{{ _('Action') }}{{ _('Expires') }}
{{ filter.title }}{{ filter.keywords_string()|shorten(30) }}{{ _('Invisible') if filter.hide_type == 1 else _('Semi-transparent') }}{{ filter.expire_after if filter.expire_after }} - Edit | - Delete -
- {% else %} -

{{ _('No filters defined yet.') }}

- {% endif %} -

Blocks

-

Manage what users, communities, domains or instances you want to block. Blocking them means you will no longer see any posts associated with them.

- Manage User Blocks - Manage Communities Blocks - Manage Domain Blocks - Manage Instance Blocks -
-
-
-
-{% endblock %} \ No newline at end of file diff --git a/app/user/routes.py b/app/user/routes.py index 3f5d4a88..04c9af0b 100644 --- a/app/user/routes.py +++ b/app/user/routes.py @@ -142,7 +142,7 @@ def edit_profile(actor): form.matrixuserid.data = current_user.matrix_user_id form.password_field.data = '' - return render_template('user/edit_profile2.html', title=_('Edit profile'), form=form, user=current_user, + return render_template('user/edit_profile.html', title=_('Edit profile'), form=form, user=current_user, markdown_editor=current_user.markdown_editor, moderating_communities=moderating_communities(current_user.get_id()), joined_communities=joined_communities(current_user.get_id()) @@ -202,7 +202,7 @@ def change_settings(): form.theme.data = current_user.theme form.markdown_editor.data = current_user.markdown_editor - return render_template('user/edit_settings2.html', title=_('Edit profile'), form=form, user=current_user, + return render_template('user/edit_settings.html', title=_('Edit profile'), form=form, user=current_user, moderating_communities=moderating_communities(current_user.get_id()), joined_communities=joined_communities(current_user.get_id()) ) @@ -614,11 +614,12 @@ def import_settings_task(user_id, filename): @login_required def user_settings_filters(): filters = Filter.query.filter_by(user_id=current_user.id).order_by(Filter.title).all() - return render_template('user/filters2.html', filters=filters, user=current_user, + return render_template('user/filters.html', filters=filters, user=current_user, moderating_communities=moderating_communities(current_user.get_id()), joined_communities=joined_communities(current_user.get_id()) ) + @bp.route('/user/settings/filters/add', methods=['GET', 'POST']) @login_required def user_settings_filters_add():