示例#1
0
def verify(c, domain=None, opengraph=False, disqus=False):
    """
    Run checks locally on candidate site to publish.
    """
    pelican_main(["-s", PUBLISH_FILE_BASE, "--output", "dist"])
    if domain:
        with open("dist/CNAME", "w") as f:
            f.write(domain)
        with open("dist/robots.txt", "w") as f:
            f.write(
                dedent(f"""
                User-agent: *
                Disallow: /drafts/
                Sitemap: http://{domain}/sitemap.xml
            """))

    weblint_options = f"--set=OPENGRAPH={opengraph} --set=DISQUS={disqus}"
    try:
        c.run(f"""
            export DOMAIN={domain}
            export WEBLINT_OPTS='{weblint_options}'
            export DOCKERFILE_VERIFY='{DOCKERFILE_VERIFY}'
            docker-compose -f {COMPOSE_YAML} up --build --abort-on-container-exit --exit-code-from verify --renew-anon-volumes
            """)
    finally:
        c.run(f"""
            export DOMAIN={domain}
            export WEBLINT_OPTS='{weblint_options}'
            export DOCKERFILE_VERIFY='{DOCKERFILE_VERIFY}'
            docker-compose -f {COMPOSE_YAML} down --rmi local --remove-orphans
            """)
示例#2
0
    def substart():
        pelican_settings_name = get_pelican_settings_file()
        pelican_settings_path = os.path.join(settings.PELICAN_PATH,
                                             pelican_settings_name + '.py')

        pelican_main(settings.PELICAN_PATH,
                     settings=pelican_settings_path,
                     autoreload=True)
示例#3
0
def stage(c, domain=None):
    pelican_main(["-s", PUBLISH_FILE_BASE, "--output", "dist"])
    if domain:
        with open("dist/CNAME", "w") as f:
            f.write(domain)
        with open("dist/robots.txt", "w") as f:
            f.write(
                dedent(f"""
                User-agent: *
                Disallow: /drafts/
                Sitemap: http://{domain}/sitemap.xml
            """))
    c.run("docker run -v $PWD/dist:/usr/share/nginx/html -p 80:80 nginx")
示例#4
0
def publish(c, domain=None):
    """Build local version of site"""
    pelican_main(["-s", PUBLISH_FILE_BASE, "--output", "dist"])
    commit_message = "'Publish site on {}'".format(
        datetime.date.today().isoformat())

    if domain:
        with open("dist/CNAME", "w") as f:
            f.write(domain)
        with open("dist/robots.txt", "w") as f:
            f.write(
                dedent(f"""
                User-agent: *
                Disallow: /drafts/
                Sitemap: http://{domain}/sitemap.xml
            """))
    c.run("ghp-import -b gh-pages " f"-m {commit_message} " "dist -p")
示例#5
0
def pelican_run(cmd):
    cmd += ' ' + program.core.remainder  # allows to pass-through args to pelican
    pelican_main(shlex.split(cmd))
示例#6
0
    def substart():
        pelican_settings_name = get_pelican_settings_file()
        pelican_settings_path = os.path.join(settings.PELICAN_PATH, pelican_settings_name+'.py')

        pelican_main(settings.PELICAN_PATH, settings=pelican_settings_path, autoreload=True)
示例#7
0
def build(c):
    """Build local version of site"""
    pelican_main(["-s", SETTINGS_FILE_BASE])