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 @@

Did You Know?

{% for sharedfile in sharedfiles %} {{modules.Image(sharedfile, current_user=current_user_obj, list_view=True, show_attribution_in_title=True)}} {% end %} - -
-
+ +
-
{% if newer_link %} - Newer » + Newer » + {% else %} + {# Simplify container layout #} +
{% end %} -
+
diff --git a/templates/uimodules/image.html b/templates/uimodules/image.html index ad0226c..2f0002d 100644 --- a/templates/uimodules/image.html +++ b/templates/uimodules/image.html @@ -1,233 +1,236 @@ -
- {% if can_edit and not site_is_readonly %} - {% if list_view %} - {% if sharedfile.get_title() == "" %} -

click here to edit title

- {% else %} -

{{escape(sharedfile.get_title())}}

- {% end %} - {% else %} - {% if sharedfile.get_title() == "" %} -

click here to edit title

+
+
+ {% if can_edit and not site_is_readonly %} + {% if list_view %} + {% if sharedfile.get_title() == "" %} +

click here to edit title

+ {% else %} +

{{escape(sharedfile.get_title())}}

+ {% end %} {% else %} -

{{escape(sharedfile.get_title())}}

- {% end %} - {% end %} -
- {{ xsrf_form_html() }} - -
- - or - Cancel -
-
- {% else %} - {% if show_attribution_in_title %} -
- - {{escape(attribution['name'])}} - -
- {% end %} - {% if list_view %} - {% if sharedfile.get_title() == "" and show_attribution_in_title %} -

 

- {% elif sharedfile.get_title() != "" %} -

{{escape(sharedfile.get_title())}}

- {% end %} - {% else %} - {% if sharedfile.get_title() == "" and show_attribution_in_title %} -

 

- {% elif sharedfile.get_title() != "" %} -

{{escape(sharedfile.get_title())}}

+ {% if sharedfile.get_title() == "" %} +

click here to edit title

+ {% else %} +

{{escape(sharedfile.get_title())}}

+ {% end %} {% end %} - {% end %} -
- {% end %} - {% if list_view and can_remove_from_shake and not site_is_readonly %} -
-
- + {{ xsrf_form_html() }} - + +
+ + or + Cancel +
-
- {% end %} -
-
-
- {% if is_nsfw and hide_nsfw %} -
-

This may not be safe for viewing at work.

-

Click here to view

-
{% else %} - {% if sharedfile.type() == 'link' %} -
- {{sharedfile.render_data(user=current_user)}} + {% if show_attribution_in_title %} + - {% else %} - {% if sourcefile.mp4_flag or sourcefile.webm_flag %} - - {% if sourcefile.webm_flag %}{% end %} - {% if sourcefile.mp4_flag %}{% end %} - - {% else %} - {% if list_view %} - {{escape(sharedfile.get_alt_text(raw=True) or 'No alt provided')}} - {% else %} - {{escape(sharedfile.get_alt_text(raw=True) or 'No alt provided')}} - {% end %} - {% end %} {% end %} - {% end %} -
-