Пример #1
0
 def __init__(self, title, content, **kwargs):
     Reddit.__init__(self,
         title=title,
         show_sidebar=False,
         content=content,
         **kwargs
     )
Пример #2
0
 def __init__(self, title, content, **kwargs):
     Reddit.__init__(self,
                     title=title,
                     show_sidebar=False,
                     show_newsletterbar=False,
                     content=content,
                     **kwargs)
Пример #3
0
 def GET_edit_promo(self, link):
     if not link or link.promoted is None:
         return self.abort404()
     rendered = wrap_links(link, skip=False)
     form = PromoteLinkForm(link, rendered)
     page = Reddit(title=_("edit sponsored link"), content=form,
                   show_sidebar=False, extension_handling=False)
     return page.render()
Пример #4
0
 def GET_edit_promo(self, link):
     if not link or link.promoted is None:
         return self.abort404()
     rendered = wrap_links(link, skip=False)
     form = PromoteLinkForm(link, rendered)
     page = Reddit(title=_("edit sponsored link"), content=form,
                   show_sidebar=False, extension_handling=False)
     return page.render()
Пример #5
0
    def __init__(self, content, websocket_url=None):
        extra_js_config = {
            "liveupdate_event": c.liveupdate_event._id,
        }

        if websocket_url:
            extra_js_config["liveupdate_websocket"] = websocket_url

        Reddit.__init__(self,
            title=c.liveupdate_event.title,
            show_sidebar=False,
            content=content,
            extra_js_config=extra_js_config,
        )
Пример #6
0
 def GET_index(self):
     res = Reddit(
         content=AdminErrorLog(),
         title='error log',
         show_sidebar=False,
     ).render()
     return res
Пример #7
0
    def __init__(self, content, websocket_url=None):
        extra_js_config = {
            "liveupdate_event": c.liveupdate_event._id,
            "liveupdate_pixel_domain": g.liveupdate_pixel_domain,
        }

        if websocket_url:
            extra_js_config["liveupdate_websocket"] = websocket_url

        title = c.liveupdate_event.title
        if c.liveupdate_event.state == "live":
            title = _("[live]") + " " + title

        Reddit.__init__(self,
            title=title,
            show_sidebar=False,
            content=content,
            extra_js_config=extra_js_config,
        )
Пример #8
0
    def GET_listing(self, num, after, before):
        if before:
            after = before
            reverse = True
        else:
            reverse = False

        q = GameLog.query(reverse=reverse, num=num)

        def after_fn(item):
            if isinstance(item, basestring):
                name, id = item.split('_')
                q.column_start = UUID(id)
            elif isinstance(item, GameLogEntry):
                q.column_start = item._id

        q._after = after_fn

        if after:
            q._after(after)

        def keep_fn(item):
            if isinstance(item.target, GameLogTarget):
                return item.target.subreddit.can_view(c.user)
            return True

        builder = QueryBuilder(q,
                               skip=True,
                               keep_fn=keep_fn,
                               num=num,
                               reverse=reverse)

        def wrap_items_fn(items):
            wrapped = []
            for item in items:
                w = Wrapped(item)
                wrapped.append(w)
            GameLogEntry.add_props(c.user, wrapped)
            return wrapped

        builder.wrap_items = wrap_items_fn

        listing = TableListing(builder)
        content = GameLogPage(listing.listing())
        return Reddit(content=content,
                      page_classes=["gamelog"],
                      show_sidebar=False,
                      extension_handling=False).render()
Пример #9
0
    def GET_listing(self, num, after, before, count, is_embed, style_sr):
        """Get a list of updates posted in this thread.

        See also: [/api/live/*thread*/update](#POST_api_live_{thread}_update).

        """

        # preemptively record activity for clients that don't send pixel pings.
        # this won't capture their continued visit, but will at least show a
        # correct activity count for short lived connections.
        record_activity(c.liveupdate_event._id)

        reverse = False
        if before:
            reverse = True
            after = before

        query = LiveUpdateStream.query([c.liveupdate_event._id],
                                       count=num, reverse=reverse)
        if after:
            query.column_start = after
        builder = LiveUpdateBuilder(query=query, skip=True,
                                    reverse=reverse, num=num,
                                    count=count)
        listing = pages.LiveUpdateListing(builder)
        wrapped_listing = listing.listing()

        if c.user_is_loggedin:
            report_type = LiveUpdateReportsByAccount.get_report(
                c.user, c.liveupdate_event)
        else:
            report_type = None

        content = pages.LiveUpdateEventApp(
            event=c.liveupdate_event,
            listing=wrapped_listing,
            show_sidebar=not is_embed,
            report_type=report_type,
        )

        c.js_preload.set_wrapped(
            "/live/" + c.liveupdate_event._id + "/about.json",
            Wrapped(c.liveupdate_event),
        )

        c.js_preload.set_wrapped(
            "/live/" + c.liveupdate_event._id + ".json",
            wrapped_listing,
        )

        if not is_embed:
            return pages.LiveUpdateEventAppPage(
                content=content,
                page_classes=['liveupdate-app'],
            ).render()
        else:
            # ensure we're off the cookie domain before allowing embedding
            if request.host != g.media_domain:
                abort(404)
            c.allow_framing = True

            # interstitial redirects and nsfw settings are funky on the media
            # domain. just disable nsfw embeds.
            if c.liveupdate_event.nsfw:
                embed_page = pages.LiveUpdateEventEmbed(
                    content=pages.LiveUpdateNSFWEmbed(),
                )
                request.environ["usable_error_content"] = embed_page.render()
                abort(403)

            embed_page = pages.LiveUpdateEventEmbed(
                content=content,
                page_classes=['liveupdate-app'],
            )

            if style_sr and getattr(style_sr, "type", "private") != "private":
                c.can_apply_styles = True
                c.allow_styles = True
                embed_page.subreddit_stylesheet_url = \
                    Reddit.get_subreddit_stylesheet_url(style_sr)

            return embed_page.render()
    def GET_listing(self, num, after, before, count, is_embed, style_sr):
        """Get a list of updates posted in this thread.

        See also: [/api/live/*thread*/update](#POST_api_live_{thread}_update).

        """
        reverse = False
        if before:
            reverse = True
            after = before

        query = LiveUpdateStream.query([c.liveupdate_event._id],
                                       count=num, reverse=reverse)
        if after:
            query.column_start = after
        builder = LiveUpdateBuilder(query=query, skip=True,
                                    reverse=reverse, num=num,
                                    count=count)
        listing = pages.LiveUpdateListing(builder)
        wrapped_listing = listing.listing()

        if c.user_is_loggedin:
            report_type = LiveUpdateReportsByAccount.get_report(
                c.user, c.liveupdate_event)
        else:
            report_type = None

        content = pages.LiveUpdateEventApp(
            event=c.liveupdate_event,
            listing=wrapped_listing,
            show_sidebar=not is_embed,
            report_type=report_type,
        )

        c.js_preload.set_wrapped(
            "/live/" + c.liveupdate_event._id + "/about.json",
            Wrapped(c.liveupdate_event),
        )

        c.js_preload.set_wrapped(
            "/live/" + c.liveupdate_event._id + ".json",
            wrapped_listing,
        )

        if not is_embed:
            return pages.LiveUpdateEventAppPage(
                content=content,
                page_classes=['liveupdate-app'],
            ).render()
        else:
            # ensure we're off the cookie domain before allowing embedding
            if request.host != g.media_domain:
                abort(404)
            c.allow_framing = True

            # interstitial redirects and nsfw settings are funky on the media
            # domain. just disable nsfw embeds.
            if c.liveupdate_event.nsfw:
                embed_page = pages.LiveUpdateEventEmbed(
                    content=pages.LiveUpdateNSFWEmbed(),
                )
                request.environ["usable_error_content"] = embed_page.render()
                abort(403)

            embed_page = pages.LiveUpdateEventEmbed(
                content=content,
                page_classes=['liveupdate-app'],
            )

            if style_sr and getattr(style_sr, "type", "private") != "private":
                c.can_apply_styles = True
                c.allow_styles = True
                embed_page.subreddit_stylesheet_url = \
                    Reddit.get_subreddit_stylesheet_url(style_sr)

            return embed_page.render()
Пример #11
0
 def __init__(self, nav_menus = None, *a, **kw):
     Reddit.__init__(self, nav_menus = nav_menus, *a, **kw)
Пример #12
0
 def __init__(self, content):
     Reddit.__init__(
         self,
         show_sidebar=False,
         content=content,
     )
Пример #13
0
 def __init__(self, content):
     websocket_url = websockets.make_url("/thebutton", max_age=24 * 60 * 60)
     extra_js_config = {"thebutton_websocket": websocket_url}
     Reddit.__init__(self, content=content, extra_js_config=extra_js_config)
Пример #14
0
 def __init__(self, content):
     websocket_url = websockets.make_url("/thebutton", max_age=24 * 60 * 60)
     extra_js_config = {"thebutton_websocket": websocket_url}
     Reddit.__init__(self, content=content, extra_js_config=extra_js_config)
Пример #15
0
    def GET_refund(self, link, campaign):
        if link._id != campaign.link_id:
            return self.abort404()

        content = RefundPage(link, campaign)
        return Reddit("refund", content=content, show_sidebar=False).render()
Пример #16
0
 def __init__(self, nav_menus=None, *a, **kw):
     Reddit.__init__(self, nav_menus=nav_menus, *a, **kw)
Пример #17
0
 def __init__(self, content):
     Reddit.__init__(
         self,
         show_sidebar=False,
         content=content,
     )