[dw-free] Set the number of icons to show per page in /icons
[commit: http://hg.dwscoalition.org/dw-free/rev/0d421138560e]
http://bugs.dwscoalition.org/show_bug.cgi?id=3419
Add sitewide default pagination, and create a setting in S2.
Patch by
exor674.
Files modified:
http://bugs.dwscoalition.org/show_bug.cgi?id=3419
Add sitewide default pagination, and create a setting in S2.
Patch by
![[personal profile]](https://www.dreamwidth.org/img/silk/identity/user.png)
Files modified:
- bin/upgrading/s2layers/core2.s2
- bin/upgrading/s2layers/siteviews/layout.s2
- cgi-bin/LJ/Global/Defaults.pm
- cgi-bin/LJ/S2/IconsPage.pm
-------------------------------------------------------------------------------- diff -r 1c2762171cbd -r 0d421138560e bin/upgrading/s2layers/core2.s2 --- a/bin/upgrading/s2layers/core2.s2 Sat Feb 04 19:49:53 2012 +0800 +++ b/bin/upgrading/s2layers/core2.s2 Sat Feb 04 19:53:57 2012 +0800 @@ -1164,8 +1164,9 @@ set num_items_reading = 20; property int num_items_icons { - des = "Number of icons to show on the icons page, or 0 for no pagination"; + des = "Number of icons to show on the icons page, or 0 for site default"; doc_flags = "[construct]"; + max = 50; } set num_items_icons = 0; diff -r 1c2762171cbd -r 0d421138560e bin/upgrading/s2layers/siteviews/layout.s2 --- a/bin/upgrading/s2layers/siteviews/layout.s2 Sat Feb 04 19:49:53 2012 +0800 +++ b/bin/upgrading/s2layers/siteviews/layout.s2 Sat Feb 04 19:53:57 2012 +0800 @@ -43,6 +43,40 @@ function Page::print_theme_stylesheet() {} +# ItemRange + +function ItemRange::print(string{} opts) { + if ($.all_subitems_displayed) { return; } + + var string anchor = $opts{"anchor"} ? "#$opts{"anchor"}" : ""; + var string class = $opts{"class"} ? $opts{"class"} : "action-box"; + + """<div class="$class">"""; + print """<p style="font-weight: bolder; margin: 0 0 .5em 0;">""" + lang_page_of_pages($.current, $.total) + "</p>"; + var string url_prev = $this->url_of($.current - 1); + if ($.current != 1) { + print " <b><a href='$url_prev$anchor'>$*comment_page_prev</a></b> "; + } else { + print " <b>$*comment_page_prev</b> "; + } + """<span style="text-align: center">"""; + foreach var int i (1..$.total) { + if ($i == $.current) { "<b>[$i]</b> "; } + else { + var string url_of = $this->url_of($i); + "<a href='$url_of$anchor'><b>[$i]</b></a> "; + } + } + """</span>"""; + var string url_next = $this->url_of($.current + 1); + if ($.current != $.total) { + print " <b><a href='$url_next$anchor'>$*comment_page_next</a></b> "; + } else { + print " <b>$*comment_page_next</b> "; + } + "</div>"; +} + # IconsPage set text_icons_keyword_sep = ", "; diff -r 1c2762171cbd -r 0d421138560e cgi-bin/LJ/Global/Defaults.pm --- a/cgi-bin/LJ/Global/Defaults.pm Sat Feb 04 19:49:53 2012 +0800 +++ b/cgi-bin/LJ/Global/Defaults.pm Sat Feb 04 19:53:57 2012 +0800 @@ -87,6 +87,7 @@ $MAX_SCROLLBACK_LASTN ||= 100; $MAX_SCROLLBACK_FRIENDS ||= 1000; $MAX_USERPIC_KEYWORDS ||= 10; + $MAX_ICONS_PER_PAGE = 50 unless defined $MAX_ICONS_PER_PAGE; # We want to be able to configure this to unlimited ( 0 ) $LJ::AUTOSAVE_DRAFT_INTERVAL ||= 3; diff -r 1c2762171cbd -r 0d421138560e cgi-bin/LJ/S2/IconsPage.pm --- a/cgi-bin/LJ/S2/IconsPage.pm Sat Feb 04 19:49:53 2012 +0800 +++ b/cgi-bin/LJ/S2/IconsPage.pm Sat Feb 04 19:53:57 2012 +0800 @@ -62,7 +62,11 @@ my $pagingbar; my $start_index = 0; - my $page_size = S2::get_property_value($opts->{'ctx'}, "num_items_icons")+0; + my $page_size = S2::get_property_value($opts->{'ctx'}, "num_items_icons")+0 || $LJ::MAX_ICONS_PER_PAGE || 0; + + $page_size = $LJ::MAX_ICONS_PER_PAGE if ( $LJ::MAX_ICONS_PER_PAGE && $page_size > $LJ::MAX_ICONS_PER_PAGE ); + $page_size = 0 if $get->{view} eq 'all'; + $p->{pages} = ItemRange_fromopts({ items => \@pics, pagesize => $page_size || scalar @pics, @@ -72,7 +76,7 @@ args => { page => $_[0], }, - keep_args => [ 'sortorder' ], + keep_args => [ 'sortorder', 'view', 'inactive' ], viewing_style => 1, cur_args => $get, ); --------------------------------------------------------------------------------