示例#1
0
def get_carousel():
    template_url = 'framework/node/template-node-img-url-src.html'
    carousel_url = [
        {
            'url': '#',
            'src': 'activity_icon102',
            'active': '1'
        },
        {
            'url': '#',
            'src': 'activity_icon103'
        },
        {
            'url': '#',
            'src': 'activity_icon104'
        },
    ]

    carousel = create_html_node('carousel')
    carousel.set_id('carousel-images')

    for item in carousel_url:
        node = create_html_template(template_url)
        for k in item:
            if k == 'src':
                node.set_attr(k, ResourceManager.singleton().get_path(item[k]))
            else:
                node.set_attr(k, item[k])
        carousel.add_child(node)

    return carousel
示例#2
0
def get_book_catalog(book_id):
    books = Book.objects.filter(id=book_id)
    if books is None or len(books) == 0:
        return
    book = books[0]

    catalog = create_html_node('catalog')
    for top, dirs, files in os.walk('static/book/%s' % book.book_dir):
        for file in files:
            item = create_html_template("")
            item.set_attr('text', file)
            item.set_attr('url', 'book/index?id=book_chapter_content&book=%s&chapter=%s' % (book_id, file))
            catalog.add_child(item)

    return catalog
示例#3
0
def get_navigation():
    template_url = 'framework/node/template-node-a-url-span-text.html'
    header_url = [
        {
            'url': '/',
            'span': 'glyphicon glyphicon-home',
            'text': 'ui_home',
            'active': '1'
        },
        {
            'url': 'book',
            'span': 'glyphicon glyphicon-book',
            'text': 'ui_book'
        },
        {
            'url': 'audio',
            'span': 'glyphicon glyphicon-headphones',
            'text': 'ui_audio'
        },
        {
            'url': 'video',
            'span': 'glyphicon glyphicon-film',
            'text': 'ui_video'
        },
        {
            'url': 'account',
            'span': 'glyphicon glyphicon-user',
            'text': 'ui_account'
        },
    ]

    navigation = create_html_node('navigation')

    for item in header_url:
        node = create_html_template(template_url)
        for k in item:
            if k == 'text':
                node.set_attr(k, TextManager.singleton().get_text(item[k]))
            else:
                node.set_attr(k, item[k])

        navigation.add_child(node)

    return navigation
示例#4
0
def get_book_breadcrumb(book_id, chapter_id):
    books = Book.objects.filter(id=book_id)
    if books is None or len(books) == 0:
        return
    book = books[0]

    template_url = "framework/template-breadcrumb.html"
    item_url = [
        {'url': 'book/index?id=book_chapter&book=%s' % book_id, 'text': book.name},
        {'active': '1', 'text': chapter_id},
    ]

    breadcrumb = create_html_node('breadcrumb')

    for item in item_url:
        node = create_html_template(template_url)
        for k in item:
            node.set_attr(k, item[k])
        breadcrumb.add_child(node)

    return breadcrumb