# HG changeset patch # User jbe # Date 1634138504 -7200 # Node ID 5b19007574deac334d2853fdfdcdd0e87f69a85d # Parent c43f251262d87427447e900e2fd6ad16884ff559 New argument active_link_attr for env.ui.paginate{...} diff -r c43f251262d8 -r 5b19007574de Makefile.options --- a/Makefile.options Wed Oct 13 16:48:34 2021 +0200 +++ b/Makefile.options Wed Oct 13 17:21:44 2021 +0200 @@ -11,7 +11,7 @@ # C compiler flags # TODO: check alternatives to -D_GNU_SOURCE -fPIC # using libtool? -CFLAGS = -O2 -D_GNU_SOURCE -fPIC -Wall -I /usr/include -I /usr/local/include -I /usr/include/lua5.3 -I /usr/local/include/lua53 +CFLAGS = -O2 -D_GNU_SOURCE -fPIC -Wall -I /usr/include -I /usr/local/include -I /usr/include/lua5.4 -I /usr/local/include/lua54 # additional C compiler flags for parts which depend on PostgreSQL CFLAGS_PGSQL = -I `pg_config --includedir` -I `pg_config --pkgincludedir` -I `pg_config --includedir-server` diff -r c43f251262d8 -r 5b19007574de framework/env/ui/paginate.lua --- a/framework/env/ui/paginate.lua Wed Oct 13 16:48:34 2021 +0200 +++ b/framework/env/ui/paginate.lua Wed Oct 13 17:21:44 2021 +0200 @@ -1,14 +1,15 @@ --[[-- ui.paginate{ - selector = selector, -- a selector for items from the database (will be modified) - anchor = anchor, -- optional name of anchor in document to jump to - per_page = per_page, -- items per page, defaults to 10 - container_attr = container_attr, -- html attr for the container element - link_attr = link_attr, -- html attr for each page link - name = name, -- name of the CGI get variable, defaults to "page" - position = position, -- position of page links relative to content: "before", "after", or "both" (default) - content = function() - ... -- code block which should be encapsulated with page selection links + selector = selector, -- a selector for items from the database (will be modified) + anchor = anchor, -- optional name of anchor in document to jump to + per_page = per_page, -- items per page, defaults to 10 + container_attr = container_attr, -- html attr for the container element + link_attr = link_attr, -- html attr for each page link + active_link_attr = active_link_attr, -- alternative html attr for the active page link + name = name, -- name of the CGI get variable, defaults to "page" + position = position, -- position of page links relative to content: "before", "after", or "both" (default) + content = function() + ... -- code block which should be encapsulated with page selection links end } @@ -17,14 +18,15 @@ --]]-- function ui.paginate(args) - local selector = args.selector - local anchor = args.anchor - local per_page = args.per_page or 10 - local container_attr = args.container_attr or { class = 'ui_paginate' } - local link_attr = args.link_attr or {} - local name = args.name or 'page' - local position = args.position or 'both' - local content = args.content + local selector = args.selector + local anchor = args.anchor + local per_page = args.per_page or 10 + local container_attr = args.container_attr or { class = 'ui_paginate' } + local link_attr = args.link_attr or {} + local active_link_attr = args.active_link_attr or link_attr + local name = args.name or 'page' + local position = args.position or 'both' + local content = args.content local count_selector = selector:get_db_conn():new_selector() count_selector:add_field('count(1)') count_selector:add_from(selector) @@ -49,13 +51,16 @@ slot.put(" ") end params[name] = page - local attr = table.new(link_attr) + local attr if current_page == page then + attr = table.new(active_link_attr) if attr.class then attr.class = attr.class .. " active" else attr.class = "active" end + else + attr = table.new(link_attr) end ui.link{ attr = attr,