Add "bare" request param for reloading listing content in-page.

This commit is contained in:
Max Goodman
2013-03-08 22:58:09 -08:00
parent 38802df7ff
commit c6483246d7
3 changed files with 39 additions and 24 deletions

View File

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

View File

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

View File

@@ -33,21 +33,21 @@
%for a in thing.things:
${a}
%endfor
</div>
%if thing.nextprev and (thing.prev or thing.next):
<p class="nextprev"> ${_("view more:")}&#32;
%if thing.prev:
${plain_link(unsafe("&lsaquo; " + _("prev")), thing.prev, _sr_path = (c.site != Sub), rel="nofollow prev")}
%if thing.nextprev and (thing.prev or thing.next):
<p class="nextprev"> ${_("view more:")}&#32;
%if thing.prev:
${plain_link(unsafe("&lsaquo; " + _("prev")), thing.prev, _sr_path = (c.site != Sub), rel="nofollow prev")}
%endif
%if thing.prev and thing.next:
<span class="separator"></span>
%endif
%if thing.next:
${plain_link(unsafe(_("next") + " &rsaquo;"), thing.next, _sr_path = (c.site != Sub), rel="nofollow next")}
%endif
</p>
%endif
%if thing.prev and thing.next:
<span class="separator"></span>
%if not thing.things:
<p id="noresults" class="error">${_("there doesn't seem to be anything here")}</p>
%endif
%if thing.next:
${plain_link(unsafe(_("next") + " &rsaquo;"), thing.next, _sr_path = (c.site != Sub), rel="nofollow next")}
%endif
</p>
%endif
%if not thing.things:
<p id="noresults" class="error">${_("there doesn't seem to be anything here")}</p>
%endif
</div>