From c6483246d72b027005fcbc7c9ac5c1f62870c6d1 Mon Sep 17 00:00:00 2001 From: Max Goodman Date: Fri, 8 Mar 2013 22:58:09 -0800 Subject: [PATCH] Add "bare" request param for reloading listing content in-page. --- r2/r2/controllers/listingcontroller.py | 20 +++++++++-------- r2/r2/public/static/js/ui.js | 13 +++++++++++ r2/r2/templates/listing.html | 30 +++++++++++++------------- 3 files changed, 39 insertions(+), 24 deletions(-) diff --git a/r2/r2/controllers/listingcontroller.py b/r2/r2/controllers/listingcontroller.py index feda8f51d..68a8f1feb 100755 --- a/r2/r2/controllers/listingcontroller.py +++ b/r2/r2/controllers/listingcontroller.py @@ -88,6 +88,7 @@ class ListingController(RedditController, OAuth2ResourceController): def pre(self): self.check_for_bearer_token() RedditController.pre(self) + self.bare = request.get.pop('bare', False) @property def menus(self): @@ -109,15 +110,16 @@ class ListingController(RedditController, OAuth2ResourceController): self.listing_obj = self.listing() content = self.content() - res = self.render_cls(content = content, - page_classes = self.extra_page_classes, - show_sidebar = self.show_sidebar, - nav_menus = self.menus, - title = self.title(), - robots = getattr(self, "robots", None), - **self.render_params).render() - return res - + if self.bare: + return responsive(content.render()) + else: + return self.render_cls(content=content, + page_classes=self.extra_page_classes, + show_sidebar=self.show_sidebar, + nav_menus=self.menus, + title=self.title(), + robots=getattr(self, "robots", None), + **self.render_params).render() def content(self): """Renderable object which will end up as content of the render_cls""" diff --git a/r2/r2/public/static/js/ui.js b/r2/r2/public/static/js/ui.js index d9ec78a62..dbb781b50 100644 --- a/r2/r2/public/static/js/ui.js +++ b/r2/r2/public/static/js/ui.js @@ -31,6 +31,19 @@ r.ui.init = function() { r.ui.PermissionEditor.init() } +r.ui.refreshListing = function() { + var url = $.url(), + params = url.param() + params['bare'] = 'y' + $.ajax({ + type: 'GET', + url: url.attr('base') + url.attr('path'), + data: params + }).done(function(resp) { + $('#siteTable').replaceWith(resp) + }) +} + r.ui.Form = function(el) { r.ui.Base.call(this, el) this.$el.submit($.proxy(function(e) { diff --git a/r2/r2/templates/listing.html b/r2/r2/templates/listing.html index 0b135a1da..95b6a6a1d 100644 --- a/r2/r2/templates/listing.html +++ b/r2/r2/templates/listing.html @@ -33,21 +33,21 @@ %for a in thing.things: ${a} %endfor - -%if thing.nextprev and (thing.prev or thing.next): -

${_("view more:")} - %if thing.prev: - ${plain_link(unsafe("‹ " + _("prev")), thing.prev, _sr_path = (c.site != Sub), rel="nofollow prev")} + %if thing.nextprev and (thing.prev or thing.next): +

${_("view more:")} + %if thing.prev: + ${plain_link(unsafe("‹ " + _("prev")), thing.prev, _sr_path = (c.site != Sub), rel="nofollow prev")} + %endif + %if thing.prev and thing.next: + + %endif + %if thing.next: + ${plain_link(unsafe(_("next") + " ›"), thing.next, _sr_path = (c.site != Sub), rel="nofollow next")} + %endif +

%endif - %if thing.prev and thing.next: - + %if not thing.things: +

${_("there doesn't seem to be anything here")}

%endif - %if thing.next: - ${plain_link(unsafe(_("next") + " ›"), thing.next, _sr_path = (c.site != Sub), rel="nofollow next")} - %endif -

-%endif -%if not thing.things: -

${_("there doesn't seem to be anything here")}

-%endif +