Beispiel #1
0
 def create_chimps_redirect_url(self):
     return create_redirect_url("/gae_bingo",
                               ["chimps_conversion_1",
                                "chimps_conversion_2"])
Beispiel #2
0
 def create_chimps_redirect_url(self):
     return create_redirect_url("http://www.google.com", ["chimps_conversion_1", "chimps_conversion_2"])
Beispiel #3
0
 def create_monkeys_redirect_url(self):
     return create_redirect_url("/gae_bingo", "monkeys")
Beispiel #4
0
 def create_monkeys_redirect_url(self):
     return create_redirect_url("http://www.google.com", "monkeys")
Beispiel #5
0
    def get(self):
        version_number = None

        if (user_models.UserData.current() and
            user_models.UserData.current().developer):
            version_number = self.request_string('version', default=None)

        thumbnail_link_sets = new_and_noteworthy_link_sets()

        # If all else fails, just show the TED talk on the homepage
        marquee_video = {
            "youtube_id": "gM95HHI4gLk",
            "href": "/video?v=%s" % "gM95HHI4gLk",
            "thumb_urls": (
                video_models.Video.youtube_thumbnail_urls("gM95HHI4gLk")),
            "title": "Salman Khan talk at TED 2011",
            "key": "",
        }
        if len(thumbnail_link_sets) > 1:

            day = datetime.datetime.now().day

            # Switch up the first 4 New & Noteworthy videos on a daily basis
            current_link_set_offset = day % len(thumbnail_link_sets)

            # Switch up the marquee video on a daily basis
            marquee_videos = []
            for thumbnail_link_set in thumbnail_link_sets:
                marquee_videos += filter(lambda item: item["marquee"],
                                         thumbnail_link_set)

            if marquee_videos:
                marquee_video = marquee_videos[day % len(marquee_videos)]
                marquee_video["selected"] = True

            thumbnail_link_sets = (
                thumbnail_link_sets[current_link_set_offset:]
                + thumbnail_link_sets[:current_link_set_offset])

            # If there is a set of videos that isn't full,
            # move it to the last position in the carousel.
            for i, link_set in enumerate(thumbnail_link_sets):
                if len(link_set) < ITEMS_PER_SET:
                    thumbnail_link_sets[i], thumbnail_link_sets[-1] = (
                            thumbnail_link_sets[-1], thumbnail_link_sets[i])

        content_uninitialized = (
            topic_models.TopicVersion.get_default_version() is None)

        if content_uninitialized:
            library_content = ('<h1>Content not initialized. '
                               '<a href="/devadmin/content?autoupdate=1">'
                               'Click here</a> '
                               'to autoupdate from iktel.nl.')
        elif version_number:
            layer_cache.disable()
            library_content = library.library_content_html(
                version_number=int(version_number))
        elif self.is_mobile_capable():
            # Only running ajax version of homepage for non-mobile clients
            library_content = library.library_content_html(ajax=False)
        else:
            library_content = library.library_content_html(ajax=True)

        from gae_bingo.gae_bingo import create_redirect_url

        donate_redirect_url = create_redirect_url("/donate",
                                                  "hp_donate_button_click")

        from rssblog_model import RSSBlog
        template_values = {
            'rssblog': RSSBlog.get(0, 4),
            'marquee_video': marquee_video,
            'thumbnail_link_sets': thumbnail_link_sets,
            'library_content': library_content,
            'DVD_list': DVD_list,
            'is_mobile_allowed': True,
            'approx_vid_count': video_models.Video.approx_count(),
            'link_heat': self.request_bool("heat", default=False),
            'version_number': version_number,
            'donate_redirect_url': donate_redirect_url
            }

        self.render_jinja2_template('homepage.html', template_values)

        layer_cache.enable()
Beispiel #6
0
    def get(self):
        version_number = None

        if user_models.UserData.current() and user_models.UserData.current().developer:
            version_number = self.request_string('version', default=None)

        thumbnail_link_sets = new_and_noteworthy_link_sets()

        # If all else fails, just show the TED talk on the homepage
        marquee_video = {
            "youtube_id": "gM95HHI4gLk",
            "href": "/video?v=%s" % "gM95HHI4gLk",
            "thumb_urls": video_models.Video.youtube_thumbnail_urls("gM95HHI4gLk"),
            "title": "Salman Khan talk at TED 2011",
            "key": "",
        }

        if len(thumbnail_link_sets) > 1:

            day = datetime.datetime.now().day

            # Switch up the first 4 New & Noteworthy videos on a daily basis
            current_link_set_offset = day % len(thumbnail_link_sets)

            # Switch up the marquee video on a daily basis
            marquee_videos = []
            for thumbnail_link_set in thumbnail_link_sets:
                marquee_videos += filter(lambda item: item["marquee"],
                                         thumbnail_link_set)

            if marquee_videos:
                marquee_video = marquee_videos[day % len(marquee_videos)]
                marquee_video["selected"] = True

            if len(thumbnail_link_sets[current_link_set_offset]) < ITEMS_PER_SET:
                # If the current offset lands on a set of videos that isn't a full set, just start
                # again at the first set, which is most likely full.
                current_link_set_offset = 0

            thumbnail_link_sets = thumbnail_link_sets[current_link_set_offset:] + thumbnail_link_sets[:current_link_set_offset]

        default = topic_models.TopicVersion.get_default_version()
        if App.is_dev_server and default is None:
            library_content = "<h1>Content not initialized. <a href=\"/devadmin/content?autoupdate=1\">Click here</a> to autoupdate from khanacademy.org."
        elif version_number:
            layer_cache.disable()
            library_content = library.library_content_html(version_number=int(version_number))
        elif not self.is_mobile_capable():
            # Only running ajax version of homepage for non-mobile clients
            library_content = library.library_content_html(ajax = True)
        else:
            library_content = library.library_content_html()
            
        from gae_bingo.gae_bingo import ab_test, create_redirect_url

        donate_button_test = ab_test("hp_donate_button",
                                     {"button":1, "text":99},
                                     conversion_name=['hp_donate_button_click', 'hp_donate_button_paypal'])
        donate_redirect_url = create_redirect_url("/donate", "hp_donate_button_click")

        template_values = {
                            'marquee_video': marquee_video,
                            'thumbnail_link_sets': thumbnail_link_sets,
                            'library_content': library_content,
                            'DVD_list': DVD_list,
                            'is_mobile_allowed': True,
                            'approx_vid_count': video_models.Video.approx_count(),
                            'link_heat': self.request_bool("heat", default=False),
                            'version_number': version_number,
                            'donate_button_test': donate_button_test,
                            'donate_redirect_url': donate_redirect_url
                        }

        self.render_jinja2_template('homepage.html', template_values)

        layer_cache.enable()
def bingo_redirect_url(url, conversions):
    return create_redirect_url(url, conversions)
Beispiel #8
0
 def create_baboons_signed_redirect_url(self):
     return create_redirect_url("/gae_bingo", "baboons",
                                salt=ultra_secret_salt)