Skip to content

Commit

Permalink
Refactor subreddit about.json to enable separate api_docs.
Browse files Browse the repository at this point in the history
  • Loading branch information
chromakode committed Mar 26, 2012
1 parent ffca452 commit e62dcd3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
1 change: 1 addition & 0 deletions r2/r2/config/routing.py
Expand Up @@ -51,6 +51,7 @@ def make_map(global_conf={}, app_conf={}):

mc('/about/message/:where', controller='message', action='listing')
mc('/about/log', controller='front', action='moderationlog')
mc('/about', controller='front', action='about')
mc('/about/:location', controller='front',
action='editreddit', location = 'about')

Expand Down
11 changes: 9 additions & 2 deletions r2/r2/controllers/front.py
Expand Up @@ -571,8 +571,8 @@ def _edit_normal_reddit(self, location, num, after, reverse, count, created,
pane = FlairPane(num, after, reverse, name, user)
elif c.user_is_sponsor and location == 'ads':
pane = RedditAds()
elif (not location or location == "about") and is_api():
return Reddit(content = Wrapped(c.site)).render()
elif (location == "about") and is_api():
return self.redirect(add_sr('about.json'), code=301)
else:
return self.abort404()

Expand Down Expand Up @@ -606,6 +606,13 @@ def GET_editreddit(self, location, num, after, reverse, count, created,
return self._edit_normal_reddit(location, num, after, reverse,
count, created, name, user)

def GET_about(self):
"""Return information about the subreddit.
Data includes the subscriber count, description, and header image."""
if not is_api() or isinstance(c.site, FakeSubreddit):
return self.abort404()
return Reddit(content = Wrapped(c.site)).render()

def GET_awards(self):
"""The awards page."""
Expand Down

0 comments on commit e62dcd3

Please sign in to comment.