Skip to main content
Join the official 2019 Python Developers SurveyStart the survey!

Simple plugin to use Lektor to abstract away git usage.

Project description

lektor-git-src-publisher

Lektor's wonderful interface enables non-technical users to modify the source of a Lektor-based site and publish the resulting website.

However, if such source code is managed with git, the user will still have to fiddle around with git clients or interfaces in order collaborate with others.

This simple plugin enables two publish targets, one to update the page's source code from a remote, and one to update the remote with the local changes.

Using this

Steps

  1. Setup the REMOTE and its authentication (out of scope for this plugin)
  2. Install lektor-git-src-publisher
  3. Add the publishers to the project
  4. lektor serve and profit!

Details

In order to install the plugin you can add following to your .lektorproject file:

[packages]
lektor-git-src-publisher = 0.1

Or follow the official plugin instructions.

In order to enable the publishers, you also modify your .lektorproject file:

[servers.update]
name = Update from Remote
enabled = yes
target = gitsrc-forcepull://master

[servers.push]
name = Push to Remote
enabled = yes
target = gitsrc-push://master

Notice that this plugin registers the gitsrc-forcepull://BRANCH and gitsrc-push://BRANCH schemas.

It is conceivable to have multiple publishers, e.g. one for a staging and one for a master branch. See the limitations.

Getting in touch / collaborating

If you just want to say hi/thanks or ask something, we are on Matrix! Get in touch with us at #oss:camilion.eu or through our website: https://camilion.eu.

If you have an issue with this plugin open an Issue.

If you have an improvement you'd like to have shipped with this plugin, either get in touch with us, or open an Issue or a Pull Request.

We mirror the code to GitHub from our infra, so PRs from any other code hosting platforms are very welcome as well.

A special mention goes to our friends at ungleich, who also needed this and provided the feedback and motivation needed to push this forward.

Limitations

Due to the way this is done, the Lektor server can be confused if you change the .lektorproject too much under its feet, simple things should be alright and, when in doubt, restart the Lektor server after making big changes.

Gory details

This plugin uses Lektor's publisher API in a non-traditional fashion, instead of publishing the resulting artifacts:

  • gitsrc-forcepull: updates the source working directory to pull remote changes.
  • gitsrc-push: auto-commits and pushes to the configured remote.

The source code is quite straight forward, when in doubt do read it!

gitsrc-forcepull

This is roughly equivalent to following pseudo-code:

# Save local changes
git stash
# Update remotes
git fetch --progress
if (BRANCH != CURRENT_BRANCH) {
    # Ensure we are working on the specified branch
    git checkout -b BRANCH -t REMOTE/BRANCH
}
# Merge changes as necessary
git merge --strategy=recursive --strategy-option=theirs
# Restore local changes
git stash pop

This needs more testing, but appears to be robust enough for simple use-cases and should certainly be enough if the user updates before making changes.

gitsrc-push

This is roughly equivalent to following pseudo-code:

# Stage local changes
git add .
# Commit staged changes
git commit -m "Updated from Lektor"
# Push
git push REMOTE BRANCH

You may want to setup the GIT_COMMITTER_NAME and GIT_COMMITTER_EMAIL environment variables before running Lektor.

Project details


Release history Release notifications

This version

0.1

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for lektor-git-src-publisher, version 0.1
Filename, size File type Python version Upload date Hashes
Filename, size lektor_git_src_publisher-0.1-py3-none-any.whl (5.7 kB) File type Wheel Python version py3 Upload date Hashes View hashes
Filename, size lektor-git-src-publisher-0.1.tar.gz (4.7 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page