1a107601fa490ca69215facceebe3d0dc5e7f1f8 | 6bcef0037bdb2d139a15065c3f31e872bae79df3 | ||
---|---|---|---|
32 | from r2.lib.filters import spaceCompress, _force_unicode | 32 | from r2.lib.filters import spaceCompress, _force_unicode |
33 | from r2.lib.menus import NavButton, NamedButton, NavMenu, PageNameNav, JsButton, menu | 33 | from r2.lib.menus import NavButton, NamedButton, NavMenu, PageNameNav, JsButton, menu |
34 | from r2.lib.strings import plurals, rand_strings, strings | 34 | from r2.lib.strings import plurals, rand_strings, strings |
35 | from r2.lib.utils import title_to_url | 35 | from r2.lib.utils import title_to_url, query_string |
36 | from r2.lib.template_helpers import add_sr | ||
36 | import sys | 37 | import sys |
37 | 38 | ||
38 | def get_captcha(): | 39 | def get_captcha(): |
... | ... | ||
119 | 120 | ||
120 | if self.submit_box: | 121 | if self.submit_box: |
121 | ps.append(SideBox(_('Submit a link'), | 122 | ps.append(SideBox(_('Submit a link'), |
122 | c.site.path + 'submit', 'submit', | 123 | '/submit', 'submit', |
123 | subtitles = [_('to anything interesting: news article, blog entry, video, picture...')], | 124 | subtitles = [_('to anything interesting: news article, blog entry, video, picture...')], |
124 | show_cover = True)) | 125 | show_cover = True)) |
125 | 126 | ||
126 | if self.create_reddit_box: | 127 | if self.create_reddit_box: |
127 | ps.append(SideBox(_('Create your own reddit'), | 128 | ps.append(SideBox(_('Create your own reddit'), |
128 | '/reddits/create', 'create', | 129 | '/reddits/create', 'create', |
129 | subtitles = rand_strings.get("create_reddit", 2), | 130 | subtitles = rand_strings.get("create_reddit", 2), |
130 | show_cover = True)) | 131 | show_cover = True, nocname=True)) |
131 | return ps | 132 | return ps |
132 | 133 | ||
133 | def render(self, *a, **kw): | 134 | def render(self, *a, **kw): |
... | ... | ||
160 | if c.user_is_loggedin: | 161 | if c.user_is_loggedin: |
161 | if c.user.name in g.admins: | 162 | if c.user.name in g.admins: |
162 | if c.user_is_admin: | 163 | if c.user_is_admin: |
163 | buttons += [NamedButton("adminoff", False)] | 164 | buttons += [NamedButton("adminoff", False, nocname=True, |
165 | target = "_self")] | ||
164 | else: | 166 | else: |
165 | buttons += [NamedButton("adminon", False)] | 167 | buttons += [NamedButton("adminon", False, nocname=True, |
168 | target = "_self")] | ||
166 | buttons += [NamedButton("prefs", False, | 169 | buttons += [NamedButton("prefs", False, |
167 | css_class = "pref-lang")] | 170 | css_class = "pref-lang")] |
168 | else: | 171 | else: |
... | ... | ||
170 | buttons += [JsButton(g.lang_name.get(lang, lang), | 173 | buttons += [JsButton(g.lang_name.get(lang, lang), |
171 | onclick = "return showlang();", | 174 | onclick = "return showlang();", |
172 | css_class = "pref-lang")] | 175 | css_class = "pref-lang")] |
173 | buttons += [NamedButton("stats", False)] | 176 | buttons += [NamedButton("stats", False, nocname=True)] |
174 | buttons += [NamedButton("help", False), | 177 | buttons += [NamedButton("help", False, nocname=True), |
175 | NamedButton("blog", False)] | 178 | NamedButton("blog", False, nocname=True)] |
176 | 179 | ||
177 | if c.user_is_loggedin: | 180 | if c.user_is_loggedin: |
178 | buttons += [NamedButton("logout", False)] | 181 | buttons += [NamedButton("logout", False, nocname=True, |
182 | target = "_self")] | ||
179 | 183 | ||
180 | return NavMenu(buttons, base_path = "/", type = "flatlist") | 184 | return NavMenu(buttons, base_path = "/", type = "flatlist") |
181 | 185 | ||
... | ... | ||
185 | NamedButton("bookmarklets", False), | 189 | NamedButton("bookmarklets", False), |
186 | NamedButton("buttons", False), | 190 | NamedButton("buttons", False), |
187 | NamedButton("widget", False), | 191 | NamedButton("widget", False), |
188 | NamedButton("code", False), | 192 | NamedButton("code", False, nocname=True), |
189 | NamedButton("mobile", False), | 193 | NamedButton("mobile", False, nocname=True), |
190 | NamedButton("store", False), | 194 | NamedButton("store", False, nocname=True), |
191 | NamedButton("ad_inq", False), | 195 | NamedButton("ad_inq", False, nocname=True), |
192 | ] | 196 | ] |
193 | 197 | ||
194 | return NavMenu(buttons, base_path = "/", type = "flatlist") | 198 | return NavMenu(buttons, base_path = "/", type = "flatlist") |
... | ... | ||
217 | toolbar = [NavMenu(main_buttons, type='tabmenu')] | 221 | toolbar = [NavMenu(main_buttons, type='tabmenu')] |
218 | if more_buttons: | 222 | if more_buttons: |
219 | toolbar.append(NavMenu(more_buttons, title=menu.more, type='tabdrop')) | 223 | toolbar.append(NavMenu(more_buttons, title=menu.more, type='tabdrop')) |
220 | if c.site != Default: | 224 | if c.site != Default and not c.cname: |
221 | toolbar.insert(0, PageNameNav('subreddit')) | 225 | toolbar.insert(0, PageNameNav('subreddit')) |
222 | 226 | ||
223 | return toolbar | 227 | return toolbar |
... | ... | ||
259 | class SideBox(Wrapped): | 263 | class SideBox(Wrapped): |
260 | """Generic sidebox used to generate the 'submit' and 'create a reddit' boxes.""" | 264 | """Generic sidebox used to generate the 'submit' and 'create a reddit' boxes.""" |
261 | def __init__(self, title, link, css_class='', subtitles = [], | 265 | def __init__(self, title, link, css_class='', subtitles = [], |
262 | show_cover = False): | 266 | show_cover = False, nocname=False): |
263 | Wrapped.__init__(self, link = link, | 267 | Wrapped.__init__(self, link = link, target = '_top', |
264 | title = title, css_class = css_class, | 268 | title = title, css_class = css_class, |
265 | subtitles = subtitles, show_cover = show_cover) | 269 | subtitles = subtitles, show_cover = show_cover, nocname=nocname) |
266 | 270 | ||
267 | 271 | ||
268 | class PrefsPage(Reddit): | 272 | class PrefsPage(Reddit): |
... | ... | ||
429 | 433 | ||
430 | toolbar = [NavMenu(buttons, base_path = "", type="tabmenu")] | 434 | toolbar = [NavMenu(buttons, base_path = "", type="tabmenu")] |
431 | 435 | ||
432 | if c.site != Default: | 436 | if c.site != Default and not c.cname: |
433 | toolbar.insert(0, PageNameNav('subreddit')) | 437 | toolbar.insert(0, PageNameNav('subreddit')) |
434 | 438 | ||
435 | return toolbar | 439 | return toolbar |
... | ... | ||
463 | Reddit.__init__(self, title = title, *a, **kw) | 467 | Reddit.__init__(self, title = title, *a, **kw) |
464 | 468 | ||
465 | def build_toolbars(self): | 469 | def build_toolbars(self): |
466 | return [PageNameNav('subreddit')] | 470 | if not c.cname: |
471 | return [PageNameNav('subreddit')] | ||
472 | else: | ||
473 | return [] | ||
467 | 474 | ||
468 | 475 | ||
469 | 476 | ||
... | ... | ||
659 | def __init__(self, site = None, name = ''): | 666 | def __init__(self, site = None, name = ''): |
660 | Wrapped.__init__(self, site = site, name = name) | 667 | Wrapped.__init__(self, site = site, name = name) |
661 | 668 | ||
669 | class SubredditStylesheet(Wrapped): | ||
670 | """form for editing or creating subreddit stylesheets""" | ||
671 | def __init__(self, site = None, | ||
672 | stylesheet_contents = ''): | ||
673 | Wrapped.__init__(self, site = site, | ||
674 | stylesheet_contents = stylesheet_contents) | ||
675 | |||
676 | class CssError(Wrapped): | ||
677 | """Rendered error returned to the stylesheet editing page via ajax""" | ||
678 | def __init__(self, error): | ||
679 | # error is an instance of cssutils.py:ValidationError | ||
680 | Wrapped.__init__(self, error = error) | ||
681 | |||
682 | class UploadedImage(Wrapped): | ||
683 | "The page rendered in the iframe during an upload of a header image" | ||
684 | def __init__(self,status,img_src,op): | ||
685 | Wrapped.__init__(self, | ||
686 | status=status, img_src=img_src, op=op) | ||
662 | 687 | ||
663 | class Password(Wrapped): | 688 | class Password(Wrapped): |
664 | """Form encountered when 'recover password' is clicked in the LoginFormWide.""" | 689 | """Form encountered when 'recover password' is clicked in the LoginFormWide.""" |
... | ... | ||
1042 | from admin_pages import Details | 1067 | from admin_pages import Details |
1043 | return self.content_stack(self.link_listing, Details(link = self.link)) | 1068 | return self.content_stack(self.link_listing, Details(link = self.link)) |
1044 | 1069 | ||
1070 | class Cnameframe(Wrapped): | ||
1071 | """The frame page.""" | ||
1072 | def __init__(self, original_path, sr_name, sr_title, sub_domain): | ||
1073 | Wrapped.__init__(self, original_path=original_path) | ||
1074 | self.title = "%s - %s" % (sr_title, sub_domain) | ||
1075 | port = request.environ.get('request_port') | ||
1076 | request.get['cnameframe'] = 1 | ||
1077 | path = original_path + query_string(request.get) | ||
1078 | if port > 0: | ||
1079 | self.frame_target = "http://%s:%d/r/%s%s" % (c.domain, port, sr_name, path) | ||
1080 | else: | ||
1081 | self.frame_target = "http://%s/r/%s%s" % (c.domain, sr_name, path) |