The Editor

Contents
  1. Starting It
  2. The Post List
  3. Writing
  4. Images
  5. Adding Images
  6. Inserting
  7. Other Actions
  8. Publish
  9. Limits

coffer dev --edit serves an editor for blog posts in your browser. You write Markdown on the left and see the real page, built by coffer in your theme, on the right. You can drop photos on it, put them in the post, and publish the post with one button.

The editor is part of coffer dev. It runs on your machine and is never part of a build. It changes only posts: not projects, the home page, tags.yaml or coffer.yaml.

Starting It

coffer dev --edit [--config <path>] [--port <number>] [--host <address>]

Without --edit nothing changes. With it, the terminal prints one more line for each site:

workshop: http://localhost:4000/ (drafts and scheduled posts included)
workshop editor: http://localhost:4000/__coffer/edit/?token=...

Open the editor link. The token in it is new on every run. The browser keeps it in a cookie, and the address bar shows the link without it. Every editor page answers 403 without the cookie.

To use the editor from a phone or a tablet, for example to drop photos straight from it, start coffer dev with --host 0.0.0.0 and open the link with the address of your computer. The terminal then prints The editor accepts changes from any device on this network that has the link. Share the link only with devices you trust.

The Post List

The first page lists every post of every blog of the site, newest first. Drafts and scheduled posts are included and marked. A box filters the list by title and tags.

New post asks for a blog and a title, and optionally a date, tags and a slug. It does what coffer new does, and always makes a folder post ({slug}/index.md), because only a folder post has a place for its images.

A post with broken front matter is listed with its error. Open it to fix it.

Writing

The left pane is the Markdown file. What you see is what is in the file: coffer never changes your quotes, dashes or ... in the source. The preview shows them typeset, as the typography rules of the post’s language make them.

  • A form above the text holds title, date, tags, summary and draft. More front matter shows all other keys as YAML. Under the title, a muted line shows the title as the page will show it.
  • Directives such as :::carousel and ::video are highlighted. An unknown directive is underlined.
  • Text in an HTML comment is dimmed. Ctrl+/ comments out the selected lines.
  • A line with an image shows a small thumbnail under it. A file that does not exist is underlined in red.
  • The preview reloads after each rebuild and keeps its scroll position. Scrolling one pane scrolls the other. Ctrl+\ hides the preview.
  • Problems of this post lists the errors and warnings of the last build for this post, such as a missing alt text. Each one links to its place in the text.

The editor saves the file 1 second after you stop typing, and when you leave the page. It saves text with errors too, so no work is lost. If the file changes on disk (another editor, git pull), the editor stops saving and asks whether to load the new version or overwrite it with yours.

Images

The deck under the text shows the image files in the post’s folder: JPEG, PNG, WebP and HEIC. Each card shows a thumbnail and the file name. Marks show if the post uses the image, if it is the cover, and if the file holds a GPS position. Images that the post does not use yet come first.

Adding Images

Drop files on the editor, paste an image, or press + Add images (on a phone this opens the photo library). Files are saved beside the post with a safe name: lower case, with other characters changed to -, so IMG 4021.HEIC becomes img-4021.heic. An existing file is never overwritten; a new file gets -2, -3 and so on. A file with the same content as one that exists is not saved again.

Other formats are refused with the reason. Videos are not added by the editor yet. A post can still use them: write the ::video line yourself, see Videos.

A post that is a single file (lathe.md) has no folder. The editor offers to convert it to lathe/index.md. The address of the post does not change.

Inserting

Select one or more cards and press Insert. For each image the dialog asks for:

  • Alt text. It is required. Tick Decorative for an image that needs none.
  • Caption. Optional.
  • File name. The editor suggests a name made from the alt text when the current name comes from a camera, such as img-4021. A changed name renames the file.

One image becomes ![alt](file "caption"). Several images can become a carousel or separate images. Inserting is one undo step.

Other Actions

Each card has a menu:

  • Set as cover writes cover in the front matter.
  • Rename renames the file and every reference to it in the post.
  • Delete removes the file after a confirmation. It is refused while the post uses the image.
  • Location shows the position in the original, the policy that applies and what the published image will carry. You can set strip, coarse or keep for this image.

Publish

Publish commits the open post and pushes it with git, using your own git configuration, credentials and hooks. The editor stores no credentials. It does these steps:

  1. Saves the post.
  2. Builds the site as coffer build does and shows errors and warnings. Errors stop the process.
  3. For a draft, asks whether to remove draft or push it as a draft.
  4. Shows the files that will be committed: the post and the files in its folder. Nothing outside the folder is included, and other staged work stays as it is.
  5. Asks for a commit message. The default is Publish: {title} or Update: {title}.
  6. Commits, then pushes the current branch to its upstream. Hooks run. With media originals and no installed hooks, the editor locks and uploads the originals first.

The editor refuses, and says what to do in a terminal, when the folder is not in a git repository, git is on a detached HEAD or in the middle of a merge or rebase, the branch has no upstream, or the branch is behind its upstream. It never pulls, merges or forces a push.

If the commit works and the push fails, the commit stays and the button changes to Push again.

Publish handles one post. Changes to other files are listed as not included. Git must be on the PATH. Git cannot ask for a password in the browser, so set up a credential helper or an SSH key first.

Limits

  • Markdown only: there is no rich-text mode.
  • No renaming or deleting of posts, and no other git operation than Publish.
  • No image editing.
  • One person at a time.

View this page on GitHub