mirror of
http://git.carcosa.net/jmcbray/brutaldon.git
synced 2024-11-23 15:23:52 -05:00
Add options to filter replies and boosts out of timelines
This commit is contained in:
parent
72912c1e58
commit
66861e7abd
@ -25,6 +25,16 @@ class SettingsForm(forms.Form):
|
||||
help_text=
|
||||
"""FULLBRUTALISM mode strips away most of the niceties of modern web design when
|
||||
brutaldon is viewed in a graphical browser. It has no effect in text-only browsers.""")
|
||||
filter_replies = forms.BooleanField(label="Filter replies from home timeline?",
|
||||
required=False,
|
||||
help_text=
|
||||
"""Should replies be filtered out of your home timeline, giving you only pure,
|
||||
top-level posts?""")
|
||||
filter_boosts = forms.BooleanField(label="Filter boosts from home timeline?",
|
||||
required=False,
|
||||
help_text=
|
||||
"""Should replies be filtered out of your home timeline, giving you only pure,
|
||||
Original Content?""")
|
||||
|
||||
|
||||
class PostForm(forms.Form):
|
||||
|
@ -11,6 +11,18 @@
|
||||
{{ form.fullbrutalism.label }}
|
||||
</label>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label class="label checkbox">
|
||||
{% render_field form.filter_replies %}
|
||||
{{ form.filter_replies.label }}
|
||||
</label>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label class="label checkbox">
|
||||
{% render_field form.filter_boosts %}
|
||||
{{ form.filter_boosts.label }}
|
||||
</label>
|
||||
</div>
|
||||
<div class="field">
|
||||
<input type="submit" name="submit"
|
||||
value="Save" class="button is-primary" >
|
||||
|
@ -87,6 +87,12 @@ def timeline(request, timeline='home', timeline_name='Home', max_id=None, since_
|
||||
next = data[-1]._pagination_next
|
||||
except (IndexError, AttributeError):
|
||||
next = None
|
||||
|
||||
# This filtering has to be done *after* getting next/prev links
|
||||
if request.session.get('filter_replies', False):
|
||||
data = [x for x in data if not x.in_reply_to_id]
|
||||
if request.session.get('filter_boosts', False):
|
||||
data = [x for x in data if not x.reblog]
|
||||
return render(request, 'main/%s_timeline.html' % timeline,
|
||||
{'toots': data, 'form': form, 'timeline': timeline,
|
||||
'timeline_name': timeline_name,
|
||||
@ -313,6 +319,8 @@ def settings(request):
|
||||
form = SettingsForm(request.POST)
|
||||
if form.is_valid():
|
||||
request.session['fullbrutalism'] = form.cleaned_data['fullbrutalism']
|
||||
request.session['filter_replies'] = form.cleaned_data['filter_replies']
|
||||
request.session['filter_boosts'] = form.cleaned_data['filter_boosts']
|
||||
return redirect(home)
|
||||
else:
|
||||
return render(request, 'setup/settings.html',
|
||||
|
Loading…
Reference in New Issue
Block a user