diff --git a/brutaldon/forms.py b/brutaldon/forms.py index 9a85766..3951c5d 100644 --- a/brutaldon/forms.py +++ b/brutaldon/forms.py @@ -25,7 +25,7 @@ class PreferencesForm(forms.ModelForm): class Meta: model = Preference fields = ['theme', 'filter_replies', 'filter_boosts', 'timezone', - 'no_javascript', 'notifications', 'click_to_load'] + 'no_javascript', 'notifications', 'click_to_load', 'lightbox'] class PostForm(forms.Form): """def status_post(self, status, in_reply_to_id=None, media_ids=None, diff --git a/brutaldon/migrations/0016_auto_20181009_1805.py b/brutaldon/migrations/0016_auto_20181009_1805.py new file mode 100644 index 0000000..c3fba21 --- /dev/null +++ b/brutaldon/migrations/0016_auto_20181009_1805.py @@ -0,0 +1,33 @@ +# Generated by Django 2.1.2 on 2018-10-09 22:05 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('brutaldon', '0015_auto_20181001_1812'), + ] + + operations = [ + migrations.AddField( + model_name='preference', + name='lightbox', + field=models.BooleanField(default=False, help_text='Use a JavaScript lightbox to display media.'), + ), + migrations.AlterField( + model_name='preference', + name='click_to_load', + field=models.BooleanField(default=False, help_text='Click to load more toots in the same page, rather than using pagination.'), + ), + migrations.AlterField( + model_name='preference', + name='no_javascript', + field=models.BooleanField(default=False, help_text='Disable all JavaScript. Overrides all other JavaScript options.'), + ), + migrations.AlterField( + model_name='preference', + name='notifications', + field=models.BooleanField(default=True, help_text='Display live notifications in header.'), + ), + ] diff --git a/brutaldon/models.py b/brutaldon/models.py index e540e98..bdce33f 100644 --- a/brutaldon/models.py +++ b/brutaldon/models.py @@ -36,6 +36,8 @@ class Preference(models.Model): help_text="""Display live notifications in header.""") click_to_load = models.BooleanField(default=False, help_text="""Click to load more toots in the same page, rather than using pagination.""") + lightbox = models.BooleanField(default=False, + help_text="""Use a JavaScript lightbox to display media.""") class Account(models.Model): username = models.EmailField(unique=True) diff --git a/brutaldon/templates/base.html b/brutaldon/templates/base.html index 6b2c4e3..dabde7f 100644 --- a/brutaldon/templates/base.html +++ b/brutaldon/templates/base.html @@ -173,10 +173,13 @@ $(document).ready(function () { menuPrepare(); }); + + {% if preferences.lightbox %} Intercooler.ready(function () { $(".attachments").photobox('a', { history: false }); }); + {% endif %} {% block page_scripts_inline %} {% endblock %} diff --git a/brutaldon/templates/setup/settings.html b/brutaldon/templates/setup/settings.html index 21d8fb7..c803abd 100644 --- a/brutaldon/templates/setup/settings.html +++ b/brutaldon/templates/setup/settings.html @@ -75,6 +75,16 @@

+
+ +

+ {{ form.lightbox.help_text }} +

+
+
diff --git a/brutaldon/views.py b/brutaldon/views.py index af4c513..19a1379 100644 --- a/brutaldon/views.py +++ b/brutaldon/views.py @@ -400,6 +400,7 @@ def settings(request): account.preferences.no_javascript = form.cleaned_data['no_javascript'] account.preferences.notifications = form.cleaned_data['notifications'] account.preferences.click_to_load = form.cleaned_data['click_to_load'] + account.preferences.lightbox = form.cleaned_data['lightbox'] request.session['timezone'] = account.preferences.timezone account.preferences.save() account.save()