Example #1
0
def topic_browser_tree(tree, level=0):
    s = ""
    class_name = "topline"
    for child in tree.children:

        if not child.has_children_of_type(["Topic", "Video", "Url"]):
            continue

        if not child.children or child.id in topic_models.Topic._super_topic_ids:
            # special cases
            if child.id == "new-and-noteworthy":
                continue
            elif child.standalone_title == "California Standards Test: Algebra I" and child.id != "algebra-i":
                child.id = "algebra-i"
            elif child.standalone_title == "California Standards Test: Geometry" and child.id != "geometry-2":
                child.id = "geometry-2"

            # show leaf node as a link
            href = "#%s" % escape(slugify(child.id))

            if level == 0:
                s += "<li class='solo'><a href='%s' data-tag='TopicBrowser' class='menulink'>%s</a></li>" % (href, escape(child.title))
            else:
                s += "<li class='%s'><a href='%s' data-tag='TopicBrowser'>%s</a></li>" % (class_name, href, escape(child.title))

        else:
            if level > 0:
                class_name += " sub"

            s += "<li class='%s'>%s <ul>%s</ul></li>" % (class_name, escape(child.title), topic_browser_tree(child, level=level + 1))

        class_name = ""

    return s
Example #2
0
def playlist_title_dicts():
    return map(
        lambda playlist: {
            "title": playlist.title,
            "key": str(playlist.key()),
            "ka_url": "/#%s" % slugify(playlist.title.lower())
        }, Playlist.all())
Example #3
0
def playlist_browser_structure(structure, class_name="", level=0):
    if type(structure) == list:

        s = ""
        class_next = "topline"
        for sub_structure in structure:
            s += playlist_browser_structure(sub_structure,
                                            class_name=class_next,
                                            level=level)
            class_next = ""
        return s

    else:

        s = ""
        name = structure["name"]

        if structure.has_key("playlist"):

            playlist_title = structure["playlist"]
            href = "#%s" % escape(slugify(playlist_title))

            # We have two special case playlist URLs to worry about for now. Should remove later.
            if playlist_title.startswith("SAT"):
                href = "/sat"

            if level == 0:
                s += "<li class='solo'><a href='%s' class='menulink'>%s</a></li>" % (
                    href, escape(name))
            else:
                s += "<li class='%s'><a href='%s'>%s</a></li>" % (
                    class_name, href, escape(name))

            if playlist_title == "History":
                s += "<li class=''><a href='#smarthistory'>Art History</a></li>"

        else:
            items = structure["items"]

            if level > 0:
                class_name += " sub"

            s += "<li class='%s'>%s <ul>%s</ul></li>" % (
                class_name, escape(name),
                playlist_browser_structure(items, level=level + 1))

        return s
Example #4
0
def playlist_browser_structure(structure, class_name="", level=0):
    if type(structure) == list:

        s = ""
        class_next = "topline"
        for sub_structure in structure:
            s += playlist_browser_structure(sub_structure, class_name=class_next, level=level)
            class_next = ""
        return s

    else:

        s = ""
        name = structure["name"]

        if structure.has_key("playlist"):

            playlist_title = structure["playlist"]
            href = "#%s" % escape(slugify(playlist_title))

            # We have two special case playlist URLs to worry about for now. Should remove later.
            if playlist_title.startswith("SAT"):
                href = "/sat"

            if level == 0:
                s += "<li class='solo'><a href='%s' class='menulink'>%s</a></li>" % (href, escape(name))
            else:
                s += "<li class='%s'><a href='%s'>%s</a></li>" % (class_name, href, escape(name))

            if playlist_title=="History":
                s += "<li class=''><a href='#smarthistory'>Art History</a></li>"

        else:
            items = structure["items"]

            if level > 0:
                class_name += " sub"

            s += "<li class='%s'>%s <ul>%s</ul></li>" % (class_name, escape(name), playlist_browser_structure(items, level=level + 1))

        return s
Example #5
0
def playlists_library_compact():
    playlists = fully_populated_playlists()

    def trimmed_video(video):
        trimmed_video_dict = {}
        trimmed_video_dict['readable_id'] = video.readable_id
        trimmed_video_dict['title'] = video.title
        trimmed_video_dict['key_id'] = video.key().id()
        return trimmed_video_dict

    playlist_dict = {}
    for playlist in playlists:
        trimmed_info = {}
        trimmed_info['title'] = playlist.title
        trimmed_info['slugged_title'] = slugify(playlist.title)
        trimmed_info['videos'] = [trimmed_video(v) for v in playlist.videos]
        playlist_dict[playlist.title] = trimmed_info

    playlist_structure = copy.deepcopy(topics_list.PLAYLIST_STRUCTURE)
    replace_playlist_values(playlist_structure, playlist_dict)

    return playlist_structure
Example #6
0
def topic_browser_tree(tree, level=0):
    s = ""
    class_name = "topline"
    for child in tree.children:

        if not child.has_children_of_type(["Topic", "Video", "Url"]):
            continue

        if not child.children or child.id in topic_models.Topic._super_topic_ids:
            # special cases
            if child.id == "new-and-noteworthy":
                continue
            elif child.standalone_title == "California Standards Test: Algebra I" and child.id != "algebra-i":
                child.id = "algebra-i"
            elif child.standalone_title == "California Standards Test: Geometry" and child.id != "geometry-2":
                child.id = "geometry-2"

            # show leaf node as a link
            href = "#%s" % escape(slugify(child.id))

            if level == 0:
                s += "<li class='solo'><a href='%s' data-tag='TopicBrowser' class='menulink'>%s</a></li>" % (
                    href, escape(child.title))
            else:
                s += "<li class='%s'><a href='%s' data-tag='TopicBrowser'>%s</a></li>" % (
                    class_name, href, escape(child.title))

        else:
            if level > 0:
                class_name += " sub"

            s += "<li class='%s'>%s <ul>%s</ul></li>" % (
                class_name, escape(
                    child.title), topic_browser_tree(child, level=level + 1))

        class_name = ""

    return s
Example #7
0
 def slug(self):
     return templatefilters.slugify(self.description)
Example #8
0
 def slug(self):
     return templatefilters.slugify(self.title)
Example #9
0
 def slug(self):
     return templatefilters.slugify(self.description)
 def safe_topic_title_filename(self):
     return slugify(self.topic_standalone_title)
 def safe_topic_title_filename(self):
     return slugify(self.topic_standalone_title)