def new_post(filename): try: load_config() load_base() load_path() initial_content = 'title: Your post title\ndate: %s\n\nStart writing here...' % datetime.now().strftime('%Y-%m-%d %H:%M:%S') write(g.path.posts, filename + '.md', initial_content) puts(colored.green('New post is written successfully.')) except: puts(colored.red('Post cannot be written.'))
def rsync(): try: load_config() cmd = "rsync -avz site {user}@{host}:{dest}".format( user=g.config.user, host=g.config.host, dest=g.config.dest, ) os.system(cmd) puts(colored.green('Deploy is complete.')) except: puts(colored.red('rsync failed.'))
def generate(): try: load_config() load_base() load_path() load_template_config() load_jinja() reset() handle_posts() handle_pages() copy_assets() puts(colored.green('Complete.')) except: puts(colored.red('Generated fail, please check if all files are in the directory.'))