Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: reddit/reddit
base: cae49daf4c6236081bcd638ec22c645ab0574fd0
...
head fork: reddit/reddit
compare: c408f832b8c8186782b8cfeb34153d7ab2871321
  • 2 commits
  • 2 files changed
  • 0 commit comments
  • 1 contributor
Showing with 47 additions and 0 deletions.
  1. +3 −0  r2/r2/config/templates.py
  2. +44 −0 r2/r2/lib/jsontemplates.py
View
3  r2/r2/config/templates.py
@@ -57,4 +57,7 @@ def api(type, cls):
api('flairlist', FlairListJsonTemplate)
api('flaircsv', FlairCsvJsonTemplate)
+api('subredditstylesheet', StylesheetTemplate)
+api('createsubreddit', SubredditSettingsTemplate)
+
tpm.add_handler('usertableitem', 'api-html', UserItemHTMLJsonTemplate())
View
44 r2/r2/lib/jsontemplates.py
@@ -560,3 +560,47 @@ def row_to_json(row):
class FlairCsvJsonTemplate(JsonTemplate):
def render(self, thing, *a, **kw):
return ObjectTemplate([l.__dict__ for l in thing.results_by_line])
+
+class StylesheetTemplate(ThingJsonTemplate):
+ _data_attrs_ = dict(subreddit_id = '_fullname',
+ stylesheet = 'stylesheet_contents',
+ images = '_images')
+
+ def kind(self, wrapped):
+ return 'stylesheet'
+
+ def images(self):
+ images = []
+ for name, url in c.site.get_images():
+ images.append({'name': name,
+ 'link': 'url(%%%%%s%%%%)' % name,
+ 'url': url})
+ return images
+
+ def thing_attr(self, thing, attr):
+ if attr == '_images':
+ return self.images()
+ elif attr == '_fullname':
+ return c.site._fullname
+
+class SubredditSettingsTemplate(ThingJsonTemplate):
+ _data_attrs_ = dict(subreddit_id = 'site._fullname',
+ title = 'site.title',
+ description = 'site.description',
+ language = 'site.lang',
+ subreddit_type = 'site.type',
+ content_options = 'site.link_type',
+ over_18 = 'site.over_18',
+ default_set = 'site.allow_top',
+ show_media = 'site.show_media',
+ domain = 'site.domain',
+ domain_css = 'site.css_on_cname',
+ domain_sidebar = 'site.show_cname_sidebar')
+
+ def kind(self, wrapped):
+ return 'subreddit_settings'
+
+ def thing_attr(self, thing, attr):
+ if attr.startswith('site.'):
+ return getattr(thing.site, attr[5:])
+ return ThingJsonTemplate.thing_attr(self, thing, attr)

No commit comments for this range

Something went wrong with that request. Please try again.