diff --git a/bookmarks/migrations/0040_userprofile_items_per_page_and_more.py b/bookmarks/migrations/0040_userprofile_items_per_page_and_more.py new file mode 100644 index 0000000..0b11247 --- /dev/null +++ b/bookmarks/migrations/0040_userprofile_items_per_page_and_more.py @@ -0,0 +1,26 @@ +# Generated by Django 5.0.8 on 2024-09-18 20:11 + +import django.core.validators +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("bookmarks", "0039_globalsettings_enable_link_prefetch"), + ] + + operations = [ + migrations.AddField( + model_name="userprofile", + name="items_per_page", + field=models.IntegerField( + default=30, validators=[django.core.validators.MinValueValidator(10)] + ), + ), + migrations.AddField( + model_name="userprofile", + name="sticky_pagination", + field=models.BooleanField(default=False), + ), + ] diff --git a/bookmarks/models.py b/bookmarks/models.py index 6a4d112..7d8bc5a 100644 --- a/bookmarks/models.py +++ b/bookmarks/models.py @@ -1,12 +1,13 @@ +import binascii import logging import os from typing import List -import binascii from django import forms from django.conf import settings from django.contrib.auth import get_user_model from django.contrib.auth.models import User +from django.core.validators import MinValueValidator from django.db import models from django.db.models.signals import post_save, post_delete from django.dispatch import receiver @@ -422,6 +423,10 @@ class UserProfile(models.Model): search_preferences = models.JSONField(default=dict, null=False) enable_automatic_html_snapshots = models.BooleanField(default=True, null=False) default_mark_unread = models.BooleanField(default=False, null=False) + items_per_page = models.IntegerField( + null=False, default=30, validators=[MinValueValidator(10)] + ) + sticky_pagination = models.BooleanField(default=False, null=False) class UserProfileForm(forms.ModelForm): @@ -450,6 +455,8 @@ class UserProfileForm(forms.ModelForm): "default_mark_unread", "custom_css", "auto_tagging_rules", + "items_per_page", + "sticky_pagination", ] diff --git a/bookmarks/styles/bookmark-page.css b/bookmarks/styles/bookmark-page.css index 42a823a..8adc88d 100644 --- a/bookmarks/styles/bookmark-page.css +++ b/bookmarks/styles/bookmark-page.css @@ -300,6 +300,28 @@ li[ld-bookmark-item] { & .page-item:first-child a { padding-left: 0; } + + &.sticky { + position: sticky; + bottom: 0; + border-top: solid 1px var(--secondary-border-color); + background: var(--body-color); + padding-bottom: var(--unit-h); + + &:before { + content: ''; + position: absolute; + top: 0; + bottom: 0; + left: calc(-1 * calc(var(--bulk-edit-toggle-width) + var(--bulk-edit-toggle-offset))); + width: calc(var(--bulk-edit-toggle-width) + var(--bulk-edit-toggle-offset)); + background: var(--body-color); + } + } + + & .pagination { + overflow: hidden; + } } .tag-cloud { @@ -379,6 +401,7 @@ ul.bookmark-list { } /* Hide section border when bulk edit bar is opened, otherwise borders overlap in dark mode due to using contrast colors */ + &.active section:first-of-type .content-area-header { border-bottom-color: transparent; } @@ -389,6 +412,19 @@ ul.bookmark-list { overflow: visible; } + /* make sticky pagination expand to cover checkboxes to the left */ + + &.active .bookmark-pagination.sticky:before { + content: ''; + position: absolute; + top: -1px; + bottom: 0; + left: calc(-1 * calc(var(--bulk-edit-toggle-width) + var(--bulk-edit-toggle-offset))); + width: calc(var(--bulk-edit-toggle-width) + var(--bulk-edit-toggle-offset)); + background: var(--body-color); + border-top: solid 1px var(--secondary-border-color); + } + /* All checkbox */ & .form-checkbox.bulk-edit-checkbox.all { diff --git a/bookmarks/templates/bookmarks/bookmark_list.html b/bookmarks/templates/bookmarks/bookmark_list.html index def80ae..d68bdc1 100644 --- a/bookmarks/templates/bookmarks/bookmark_list.html +++ b/bookmarks/templates/bookmarks/bookmark_list.html @@ -149,7 +149,7 @@ {% endfor %} -
You have no bookmarks yet
', html ) + + def test_pagination_is_not_sticky_by_default(self): + self.setup_bookmark() + html = self.render_template() + + self.assertIn('