Ejemplo n.º 1
0
def create_post(title, content=""):
    today = date.today()
    pth = "_posts/%s-%02d-%02d-%s.md" % (
        today.year, today.month, today.day, slugify(title)
    )
    if not path("_posts").exists():
        path("_posts").makedirs()
    if path(pth).exists():
        raise CommandError("Post already exists")
    content = post_template.substitute(title=title, content=content)
    file(pth, "w").write(content)
    print pth, "created."
Ejemplo n.º 2
0
def create_page(title, url, content=""):
    if url.startswith("/"):
        url = url[1:]
    if url.endswith("/"):
        url += "index.html"
    if not url.endswith(".html"):
        url += ".html"
    if path(url).exists():
        raise CommandError("%s already exists." % url)
    path(url).parent.makedirs()
    content = page_template.substitute(title=title, content=content)
    file(url, "w").write(content)
    print url, "created."
Ejemplo n.º 3
0
def create_page(title, url, content=""):
    if url.startswith("/"):
        url = url[1:]
    if url.endswith("/"):
        url += "index.html"
    if not url.endswith(".html"):
        url += ".html"
    if path(url).exists():
        raise CommandError("%s already exists." % url)
    if path(url).parent:
        path(url).parent.makedirs()
    content = page_template.substitute(title=title, content=content)
    file(url, "w").write(content)
    print url, "created."
Ejemplo n.º 4
0
    def handle_noargs(self, **options):
        # create empty config.yaml
        if path("config.yaml").exists():
            print "config.yaml exists, skipping."
        else:
            file("config.yaml", "w").write(config_yaml)

        # create index.html
        if path("index.html").exists():
            print "index.html exists, skipping."
        else:
            create_page(url="index.html", title="Blog", content=index_html)

        # archive, tags, categories etc will be handled by views.py in future.
        # create _posts with one dummy post
        if path("_posts").exists():
            print "_posts exists, skipping."
        else:
            create_post(dummy_post_title, dummy_post_md)

        print 'All Done.'
        print 'Run "djangothis jekyll_post" or "djangothis jekyll_page" to'
        print 'create new blog post or page.'
        print 'Run "djangothis" to start server.'
Ejemplo n.º 5
0
    def handle_noargs(self, **options):
        # create empty config.yaml
        if path("config.yaml").exists():
            print "config.yaml exists, skipping."
        else:
            file("config.yaml", "w").write(config_yaml)

        # create index.html
        if path("index.html").exists():
            print "index.html exists, skipping."
        else:
            create_page(url="index.html", title="Blog", content=index_html)

        # archive, tags, categories etc will be handled by views.py in future.
        # create _posts with one dummy post
        if path("_posts").exists():
            print "_posts exists, skipping."
        else:
            create_post(dummy_post_title, dummy_post_md)

        print 'All Done.'
        print 'Run "djangothis jekyll_post" or "djangothis jekyll_page" to'
        print 'create new blog post or page.'
        print 'Run "djangothis" to start server.'