Using the Python script … works. But it’s not very comfortable. Editing Markdown files with your favourite app on the desktop is great. But you just want to paste a Soundcloud URL, quickly check the result and be done with it. Executing the script, running ‘jekyll serve’, committing and pushing is just too much work. Especially for someone who doesn’t program and understands Git. Like a user.

So I created an admin page with Backbone.js that is accessible at /admin. I used the Github API wrapper Octokit.js to read and write to the repository.

For this to work, you need to configure your Github username (or organization) and your repository in _config.yml.

admin:
  github_username: vicox
  github_repo: soundblog
  soundcloud_client_id: 0686300807bd25cd798c519f70192c31

Logging In

When you go to /admin, you must first log in with your Github credentials. Using OAuth was not an option because Github requires a client secret to get an OAuth token and, of course, I don’t want to put my secret into the javascripts. Prose has written a small Node.js server called Gatekeeper that does exactly that on the server side. But I think the blog should not depend on any server and run solely on Github pages.

The login only lets you in if you are a collaborator of the configured repository.

Login

Listing

The list of posts just displays the file names in descending order. To display anything else, you would have to make a call for each file to get the content and then parse it to get the metadata. Too much work - just displaying the file name.

List

Creating

First must paste a Soundcloud track or playlist URL. The Soundcloud API will be queried (with the client ID configured the config) to retrieve the track ID to generate the embed code. Then you get to check if the embedded track looks right and can edit the title and posting date if you want. On submit, a new Markdown file is created and written to your Github repository.

Create

Editing

You can edit the title and date of a post. If you change the title and the time, the Markdown file will be updated. If you also change the date, a new file with the new date will be created and the old one deleted. I tried to use the move method from Octokit to rename the file, but it doesn’t work. Github returns the error

Must supply tree.sha or tree.content

when a tree is POSTed. I couldn’t find the cause or a similar implementation that worked to see the difference. Everyone just seems to delete the old file and create a new one :-/

Edit

Deleting

This one is easy. It just deletes the file.

Delete