diff --git a/handlers/account.py b/handlers/account.py index cbc1c9b..d61e7cc 100644 --- a/handlers/account.py +++ b/handlers/account.py @@ -81,6 +81,12 @@ def get(self, user_name=None, page=None): if not images and page != 1: raise tornado.web.HTTPError(404) + + # Annotate each file with page position to facilitate navigation. + for i, file in enumerate(images): + file.first_on_page = (i == 0) + file.last_on_page = (i == len(images) - 1) + return self.render("account/index.html", images=images, user=user, current_user_obj=current_user, count=count, page=page, url_format=url_format, can_follow=can_follow, @@ -149,7 +155,15 @@ def get(self, user_name=None, before_or_after=None, favorite_id=None): followers = shake.subscribers(page=1) follower_count = shake.subscriber_count() - return self.render("account/likes.html", sharedfiles=sharedfiles[0:10], + # Trim to presentation length + sharedfiles = sharedfiles[0:10] + + # Annotate each file with page position to facilitate navigation. + for i, file in enumerate(sharedfiles): + file.first_on_page = (i == 0) + file.last_on_page = (i == len(sharedfiles) - 1) + + return self.render("account/likes.html", sharedfiles=sharedfiles, current_user_obj=current_user_obj, following_shakes=following_shakes[:10], following_shakes_count=following_shakes_count, diff --git a/handlers/incoming.py b/handlers/incoming.py index 7269faf..a96f5c5 100644 --- a/handlers/incoming.py +++ b/handlers/incoming.py @@ -54,7 +54,15 @@ def get(self, before_or_after=None, base36_id=None): if len(sharedfiles) > 10: older_link = "/incoming/before/%s" % sharedfiles[9].share_key - return self.render("incoming/index.html", sharedfiles=sharedfiles[0:10], + # Trim to presentation length + sharedfiles = sharedfiles[0:10] + + # Annotate each file with page position to facilitate navigation. + for i, file in enumerate(sharedfiles): + file.first_on_page = (i == 0) + file.last_on_page = (i == len(sharedfiles) - 1) + + return self.render("incoming/index.html", sharedfiles=sharedfiles, current_user_obj=current_user_obj, older_link=older_link, newer_link=newer_link, notifications_count=notifications_count) diff --git a/handlers/popular.py b/handlers/popular.py index 7ca08b6..049b4e7 100644 --- a/handlers/popular.py +++ b/handlers/popular.py @@ -35,6 +35,12 @@ def get(self): best_of_user = user.User.get("name=%s", options.best_of_user_name) best_of_shake = best_of_user.shake() + + # Annotate each file with page position to facilitate navigation. + for i, file in enumerate(sharedfiles): + file.first_on_page = (i == 0) + file.last_on_page = (i == len(sharedfiles) - 1) + return self.render("popular/index.html", sharedfiles=sharedfiles, notifications_count=notifications_count, diff --git a/handlers/search.py b/handlers/search.py index 00412db..e973614 100644 --- a/handlers/search.py +++ b/handlers/search.py @@ -136,6 +136,11 @@ def get(self, base36_id=None): older_link = "/search?q=%s&offset=%d" % (escape.url_escape(q), offset + MAX_PER_PAGE) sharedfiles = sharedfiles[0:MAX_PER_PAGE] + # Annotate each file with page position to facilitate navigation. + for i, file in enumerate(sharedfiles): + file.first_on_page = (i == 0) + file.last_on_page = (i == len(sharedfiles) - 1) + return self.render("search/search.html", current_user_obj=current_user_obj, sharedfiles=sharedfiles, q=q, diff --git a/static/js/paging_keys.js b/static/js/paging_keys.js index 9db5c46..b9c432f 100755 --- a/static/js/paging_keys.js +++ b/static/js/paging_keys.js @@ -83,9 +83,9 @@ HotKey.prototype.remove = function (key) { var pagingKeys = (function () { // settings var config = { - nodeSelector: ".image-title", // used to select each item on the page and place in the map (must be a link) - prevPageSelector: ".newer a", // link on this element should always jump to prev page a.prev_page (must be a link) - nextPageSelector: ".older a", // link on this element should always jump to next page a.next_page (must be a link) + nodeSelector: "article.shared-file", // used to select each item on the page and place in the map (must be a link) + prevPageSelector: "a.newer", // link on this element should always jump to prev page a.prev_page (must be a link) + nextPageSelector: "a.older", // link on this element should always jump to next page a.next_page (must be a link) pagingNavId: "paging-nav", // dom id of the floating page navigation element keyNext: "j", // hot keys used keyPrev: "k", diff --git a/templates/incoming/index.html b/templates/incoming/index.html index 0f23e7d..44b1320 100644 --- a/templates/incoming/index.html +++ b/templates/incoming/index.html @@ -55,18 +55,21 @@
This may not be safe for viewing at work.
- -