Mercurial > libervia-web
comparison libervia/server/pages.py @ 1410:80683be8d341
pages: keep `search` query when using pagination
author | Goffi <goffi@goffi.org> |
---|---|
date | Thu, 22 Apr 2021 18:23:47 +0200 |
parents | 3dff555fe691 |
children | 2c3bdba880bb |
comparison
equal
deleted
inserted
replaced
1409:83b477d36725 | 1410:80683be8d341 |
---|---|
968 "before" and "after" URL parameters | 968 "before" and "after" URL parameters |
969 @param request(server.Request): current HTTP request | 969 @param request(server.Request): current HTTP request |
970 @param pubsub_data(dict): pubsub metadata | 970 @param pubsub_data(dict): pubsub metadata |
971 """ | 971 """ |
972 template_data = request.template_data | 972 template_data = request.template_data |
973 extra = {} | |
973 try: | 974 try: |
974 rsm = pubsub_data["rsm"] | 975 rsm = pubsub_data["rsm"] |
975 last_id = rsm["last"] | 976 last_id = rsm["last"] |
976 except KeyError: | 977 except KeyError: |
977 # no pagination available | 978 # no pagination available |
978 return | 979 return |
979 | 980 |
981 # if we have a search query, we must keep it | |
982 search = self.getPostedData(request, 'search', raise_on_missing=False) | |
983 if search is not None: | |
984 extra['search'] = search.strip() | |
985 | |
980 if rsm.get("index", 1) > 0: | 986 if rsm.get("index", 1) > 0: |
981 # We only show previous button if it's not the first page already. | 987 # We only show previous button if it's not the first page already. |
982 # If we have no index, we default to display the button anyway | 988 # If we have no index, we default to display the button anyway |
983 # as we can't know if we are on the first page or not. | 989 # as we can't know if we are on the first page or not. |
984 first_id = rsm["first"] | 990 first_id = rsm["first"] |
985 template_data['previous_page_url'] = self.getParamURL(request, | 991 template_data['previous_page_url'] = self.getParamURL( |
986 before=first_id) | 992 request, before=first_id, **extra) |
987 if not pubsub_data["complete"]: | 993 if not pubsub_data["complete"]: |
988 # we also show the page next button if complete is None because we | 994 # we also show the page next button if complete is None because we |
989 # can't know where we are in the feed in this case. | 995 # can't know where we are in the feed in this case. |
990 template_data['next_page_url'] = self.getParamURL(request, after=last_id) | 996 template_data['next_page_url'] = self.getParamURL( |
997 request, after=last_id, **extra) | |
991 | 998 |
992 | 999 |
993 ## Cache handling ## | 1000 ## Cache handling ## |
994 | 1001 |
995 def _setCacheHeaders(self, request, cache): | 1002 def _setCacheHeaders(self, request, cache): |