diff --git a/r2/r2/lib/pages/pages.py b/r2/r2/lib/pages/pages.py index 7dc995509..10c5acd5d 100644 --- a/r2/r2/lib/pages/pages.py +++ b/r2/r2/lib/pages/pages.py @@ -2704,12 +2704,18 @@ class SubredditStylesheet(Templated): """form for editing or creating subreddit stylesheets""" def __init__(self, site = None, stylesheet_contents = ''): + allow_image_upload = site and not site.quarantine raw_images = ImagesByWikiPage.get_images(c.site, "config/stylesheet") images = {name: make_url_protocol_relative(url) for name, url in raw_images.iteritems()} - Templated.__init__(self, site = site, images=images, - stylesheet_contents = stylesheet_contents) + Templated.__init__( + self, + site=site, + images=images, + stylesheet_contents=stylesheet_contents, + allow_image_upload=allow_image_upload, + ) @staticmethod def find_preview_comments(sr): diff --git a/r2/r2/templates/subredditstylesheet.html b/r2/r2/templates/subredditstylesheet.html index beb33e486..780d98e46 100644 --- a/r2/r2/templates/subredditstylesheet.html +++ b/r2/r2/templates/subredditstylesheet.html @@ -112,115 +112,116 @@ -
-

${_("images")}

+ %if thing.allow_image_upload: +
+

${_("images")}

- <%call expr="image_upload('/api/upload_sr_img', '', - onchange='return file_changed(this)', - label = _('image file'), ask_type=True)"> - -
- - - ${error_field("BAD_CSS_NAME", "name")} -
- - ${_("(image names should consist of alphanumeric characters and '-' only)")} - - -

- ${_("Note: any changes to images here will be reflected immediately on reload and cannot be undone.")} -

- - - - - -
+
+ + ${name} + +
+ link: +
url(%%${name}%%)
+
+ + ${_("paste into stylesheet")} + +
+ ${ynbutton(_("delete this image"), _("deleted"), + "delete_sr_img", callback = "delete_img", + hidden_data = dict(img_name = name))} +
+ + + ${make_li(prototype=True)} + %for name, url in thing.images.iteritems(): + ${make_li(name=name, img=url)} + %endfor + + + +
+ %endif