diff --git a/pelican/tools/pelican_quickstart.py b/pelican/tools/pelican_quickstart.py index 77657162..cb3ac807 100755 --- a/pelican/tools/pelican_quickstart.py +++ b/pelican/tools/pelican_quickstart.py @@ -86,6 +86,14 @@ class _DEFAULT_PATH_TYPE(str): # noqa: SLOT000 _DEFAULT_PATH = _DEFAULT_PATH_TYPE(os.curdir) +RSYNC_EXCLUDES = """\ +# Files to exclude with rsync(1) during publishing. +# See the INCLUDE/EXCLUDE PATTERN RULES section of the rsync man page. + +.DS_Store +""" + + def ask(question, answer=str, default=None, length=None): if answer is str: r = "" @@ -391,8 +399,30 @@ needed by Pelican. render_jinja_template("publishconf.py.jinja2", CONF, "publishconf.py") if automation: - render_jinja_template("tasks.py.jinja2", CONF, "tasks.py") - render_jinja_template("Makefile.jinja2", CONF, "Makefile") + try: + with open(os.path.join(CONF['basedir'], 'tasks.py'), + 'w', 'utf-8') as fd: + _template = _jinja_env.get_template('tasks.py.jinja2') + fd.write(_template.render(**CONF)) + fd.close() + except OSError as e: + print('Error: {0}'.format(e)) + try: + with open(os.path.join(CONF['basedir'], 'Makefile'), + 'w', 'utf-8') as fd: + py_v = 'python3' + _template = _jinja_env.get_template('Makefile.jinja2') + fd.write(_template.render(py_v=py_v, **CONF)) + fd.close() + except OSError as e: + print('Error: {0}'.format(e)) + try: + with open(os.path.join(CONF['basedir'], 'rsync_excludes.txt'), + 'w', 'utf-8') as fd: + fd.write(RSYNC_EXCLUDES) + fd.close() + except OSError as e: + print('Error: {0}'.format(e)) print("Done. Your new project is available at {}".format(CONF["basedir"])) diff --git a/pelican/tools/templates/Makefile.jinja2 b/pelican/tools/templates/Makefile.jinja2 index 67571b47..6e4d4052 100644 --- a/pelican/tools/templates/Makefile.jinja2 +++ b/pelican/tools/templates/Makefile.jinja2 @@ -132,7 +132,7 @@ sftp_upload: publish {% set upload = upload + ["rsync_upload"] %} rsync_upload: publish - rsync -e "ssh -p $(SSH_PORT)" -P -rvzc --include tags --cvs-exclude --delete "$(OUTPUTDIR)"/ "$(SSH_USER)@$(SSH_HOST):$(SSH_TARGET_DIR)" + rsync -e "ssh -p $(SSH_PORT)" -P -rvzc --include tags --cvs-exclude --exclude-from=rsync_excludes.txt --delete $(OUTPUTDIR)/ $(SSH_USER)@$(SSH_HOST):$(SSH_TARGET_DIR) {% endif %} {% if dropbox %} diff --git a/pelican/tools/templates/tasks.py.jinja2 b/pelican/tools/templates/tasks.py.jinja2 index 26af6f0d..8e047104 100644 --- a/pelican/tools/templates/tasks.py.jinja2 +++ b/pelican/tools/templates/tasks.py.jinja2 @@ -169,7 +169,7 @@ def publish(c): """Publish to production via rsync""" pelican_run("-s {settings_publish}".format(**CONFIG)) c.run( - 'rsync --delete --exclude ".DS_Store" -pthrvz -c ' + 'rsync --delete --exclude-from=rsync_excludes.txt -pthrvz -c ' '-e "ssh -p {ssh_port}" ' "{} {ssh_user}@{ssh_host}:{ssh_path}".format( CONFIG["deploy_path"].rstrip("/") + "/", **CONFIG