Esempio n. 1
0
def move(path, date=None):
    '''
    Moves a page given its path.
    '''
    page = Page(title=None, path=path)
    if os.path.exists(page.path):
        raise Exception("Page '%s' already exists" % (page.path, ))
    shutil.move(path, page.path)
    if not master.exists_doc(page.docname):
        master.append_doc(page.docname)
    return page
Esempio n. 2
0
def move(path, date=None):
    '''
    Moves a post given its path.
    '''
    post = Post(title=None, path=path, date=date)
    if os.path.exists(post.path):
        raise Exception("Post '%s' already exists" % (post.path, ))
    shutil.move(path, post.path)
    if not master.exists_doc(post.docname):
        master.prepend_doc(post.docname)
    return post
Esempio n. 3
0
def create(title, template=None):
    '''
    Creates a new page given its title.
    '''
    page = Page(title, path=None)
    if os.path.exists(page.path):
        raise Exception("Page '%s' already exists at '%s" % (title, page.path))
    page.write(template=template)
    if not master.exists_doc(page.docname):
        master.append_doc(page.docname)
    return page
Esempio n. 4
0
def move(path, date=None):
    '''
    Moves a page given its path.
    '''
    page = Page(title=None, path=path)
    if os.path.exists(page.path):
        raise Exception("Page '%s' already exists at '%s" %
                        (title, page.path))
    shutil.move(path, page.path)
    if not master.exists_doc(page.docname):
        master.append_doc(page.docname)
    return page
Esempio n. 5
0
def create(title):
    '''
    Creates a new page given its title.
    '''
    page = Page(title, path=None)
    if os.path.exists(page.path):
        raise Exception("Page '%s' already exists at '%s" %
                        (title, page.path))
    page.write()
    if not master.exists_doc(page.docname):
        master.append_doc(page.docname)
    return page
Esempio n. 6
0
def move(path, date=None):
    '''
    Moves a post given its path.
    '''
    post = Post(title=None, path=path, date=date)
    if os.path.exists(post.path):
        raise Exception("Post '%s' already exists" %
                        (post.path,))
    shutil.move(path, post.path)
    if not master.exists_doc(post.docname):
        master.prepend_doc(post.docname)
    return post
Esempio n. 7
0
def move(path, date=None):
    '''
    Moves a post given its path.
    '''
    post = Post(title=None, path=path, date=date)

    target_dir = os.path.dirname(post.path)
    utils.move(path, target_dir)

    if not master.exists_doc(post.docname):
        master.prepend_doc(post.docname)
    return post
Esempio n. 8
0
def create(title, date=None, template=None):
    '''
    Creates a new post given its title.
    '''
    post = Post(title, path=None, date=date)
    if os.path.exists(post.path):
        raise Exception("Post '%s' already exists at '%s" % (title, post.path))

    post.write(template=template)
    if not master.exists_doc(post.docname):
        master.prepend_doc(post.docname)
    return post
Esempio n. 9
0
def create(title, date=None, template=None):
    '''
    Creates a new post given its title.
    '''
    post = Post(title, path=None, date=date)
    if os.path.exists(post.path):
        raise Exception("Post '%s' already exists at '%s" %
                        (title, post.path))

    post.write(template=template)
    if not master.exists_doc(post.docname):
        master.prepend_doc(post.docname)
    return post
Esempio n. 10
0
def post(twinkerer, cmd_args):
    user_id_ = twinkerer.me['id']
    title_ = twinkerer.build_title(cmd_args.from_date, cmd_args.to_date)
    post_ = twinkerer.create_post(title_, cmd_args.post_date)
    post_content = ''
    timeline_ = twinkerer.fetch_timeline(
        user_id_,
        cmd_args.from_datetime,
        cmd_args.to_datetime,
    )
    post_content = ''.join([tl.as_html() for tl in timeline_])
    result_ = post_.write(post_content, author="default",
              categories="none", tags="none",
              template=None)
    if not master.exists_doc(post_.docname):
        master.prepend_doc(post_.docname)
    return post_