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 """)
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)
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")
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")
def pelican_run(cmd): cmd += ' ' + program.core.remainder # allows to pass-through args to pelican pelican_main(shlex.split(cmd))
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)
def build(c): """Build local version of site""" pelican_main(["-s", SETTINGS_FILE_BASE])