Example #1
0
def make_json(base='www', ALL=False):
    chapters = get(
        english, 'select title, uri from node where content is not null')[8:-1]

    groups = []
    items = {}

    for i, (title, uri) in enumerate(chapters):
        print title,
        fname = uri_to_json_filename(uri)
        fullname = os.path.join(base, fname)
        if ALL or not os.path.isfile(fullname):
            print "writing"
            content = composer.chapter_json(title, uri)
            mkdir_p(os.path.dirname(fullname))
            open(fullname, 'w').write(json.dumps(content))
        else:
            print

        bookid = uri.split('/')[-2]
        if not bookid in items:
            bookname = title.split(' ')
            if len(bookname) > 1:
                bookname = bookname[:-1]
            bookname = ' '.join(bookname)
            groups.append(bookid)
            items[bookid] = {"title": bookname, "chapters": []}
        items[bookid]["chapters"].append([title, fname])

    all_data = json_home(groups, items)
    open(os.path.join(base, 'home.json'), 'w').write(json.dumps(all_data))
Example #2
0
def make_json(base = 'www', ALL=False):
    chapters = get(english, 'select title, uri from node where content is not null')[8:-1]

    groups = []
    items = {}

    for i, (title, uri) in enumerate(chapters):
        print title,
        fname = uri_to_json_filename(uri)
        fullname = os.path.join(base, fname)
        if ALL or not os.path.isfile(fullname):
            print "writing"
            content = composer.chapter_json(title, uri)
            mkdir_p(os.path.dirname(fullname))
            open(fullname, 'w').write(json.dumps(content))
        else:
            print

        bookid = uri.split('/')[-2]
        if not bookid in items:
            bookname = title.split(' ')
            if len(bookname) > 1:
                bookname = bookname[:-1]
            bookname = ' '.join(bookname)
            groups.append(bookid)
            items[bookid] = {"title": bookname, "chapters": []}
        items[bookid]["chapters"].append([title, fname])

    all_data = json_home(groups, items)
    open(os.path.join(base, 'home.json'), 'w').write(json.dumps(all_data))
Example #3
0
def main(base='www'):
    chapters = get(
        english, 'select title, uri from node where content is not null')[8:-1]

    groups = []
    items = {}

    for i, (title, uri) in enumerate(chapters):
        print title,
        fname = uri_to_filename(uri)
        fullname = os.path.join(base, fname)
        if ALL or not os.path.isfile(fullname):
            print "writing"
            nxt = 'index.html'
            prv = 'index.html'
            if i < len(chapters) - 1:
                nxt = uri_to_filename(chapters[i + 1][1])
            if i > 0:
                prv = uri_to_filename(chapters[i - 1][1])
            content = composer.chapter_page(title,
                                            uri,
                                            style="../chapter.css",
                                            nxt=nxt,
                                            prv=prv)
            mkdir_p(os.path.dirname(fullname))
            open(fullname, 'w').write(content)
        else:
            print

        bookid = uri.split('/')[-2]
        if not bookid in items:
            bookname = title.split(' ')
            if len(bookname) > 1:
                bookname = bookname[:-1]
            bookname = ' '.join(bookname)
            groups.append(bookid)
            items[bookid] = {"title": bookname, "chapters": []}
        items[bookid]["chapters"].append([title, fname])

    all_text = full_page(groups, items)
    open(os.path.join(base, 'index.html'), 'w').write(all_text)
Example #4
0
def main(base = 'www'):
    chapters = get(english, 'select title, uri from node where content is not null')[8:-1]

    groups = []
    items = {}

    for i, (title, uri) in enumerate(chapters):
        print title,
        fname = uri_to_filename(uri)
        fullname = os.path.join(base, fname)
        if ALL or not os.path.isfile(fullname):
            print "writing"
            nxt = 'index.html'
            prv = 'index.html'
            if i < len(chapters) - 1:
                nxt = uri_to_filename(chapters[i + 1][1])
            if i > 0:
                prv = uri_to_filename(chapters[i - 1][1])
            content = composer.chapter_page(title, uri, style="../chapter.css", nxt=nxt, prv=prv)
            mkdir_p(os.path.dirname(fullname))
            open(fullname, 'w').write(content)
        else:
            print

        bookid = uri.split('/')[-2]
        if not bookid in items:
            bookname = title.split(' ')
            if len(bookname) > 1:
                bookname = bookname[:-1]
            bookname = ' '.join(bookname)
            groups.append(bookid)
            items[bookid] = {"title": bookname, "chapters": []}
        items[bookid]["chapters"].append([title, fname])

    all_text = full_page(groups, items)
    open(os.path.join(base, 'index.html'), 'w').write(all_text)