While the readme comes with fairly thorough instructions, there are some differences due to how Webfaction works. If you are on another web host and are having similar issues, some of these tips may help you get things running as well.
Dropbox is not a necessary part of Second Crack, but it makes publishing to your blog much easier. In order to get Dropbox running, log into your server via SSH and follow the instructions from Dropbox.
As noted in the instructions, when you run the app for the first time you will be prompted to authorize your account. For security, I recommend setting up a secondary account on your server and then sharing your blog source folder (I will refer to this folder as “Blog”) with that secondary account.
You will also want to upload the CLI python script to your home directory on your server (/home/username). Running the script with the command “autostart” will set up your server to automatically start Dropbox so it is always running.
python dropbox.py autostart
Second Crack takes advantage of inotifywait (part of inotify-tools) to update your static files whenever Dropbox is updated. This is also optional, but without inotify-tools, your static files will only be updated whenever your cron runs the update script (more on cron later).
To install inotify-tools:
- Download the source from GitHub
Extract and upload to your home directory (/home/username)
Log in via SSH and change into the inotify-tools directory (using the cd command)
Run the following commands to install (each step may take a few minutes):
./configure --prefix=$HOME make make install
Install Second Crack Changes
After downloading Second Crack from GitHub there are a few changes that need to be made to the files.
- Rename config.php.example to config.php and open it in your favorite text editor.
Input all your settings, making sure your paths are correct (replace username with your Webfaction username).
Updater::$source_path = '/home/*username*/Dropbox/Blog'; Template::$template_dir = '/home/*username*/Dropbox/Blog/templates'; Updater::$dest_path = '/home/*username*/secondcrack/www'; Updater::$cache_path = '/home/*username*/secondcrack/cache';
- In order for Second Crack to run on Webfaction, you also need to make a change to engine/update.sh. Find all of the php commands, and change them to /usr/local/bin/php53. This allows Second Crack to run under PHP 5.3 rather than the Webfaction default of PHP 5.2.
Move the files in the “example-templates” folder to a folder called “templates” inside your “Blog” folder in Dropbox.
Upload the whole “secondcrack” folder to your home directory.
Add the following to your cron on your server (crontab -e):
* * * * * /home/*username*/secondcrack/engine/update.sh /home/*username*/Dropbox/Blog /home/*username*/secondcrack
Now that everything is set up, you can publish your first post.
Publishing in Second Crack
The template for a blog post looks like this:
My draft title ============== Tags: tag1, tag2 Type: post Draft content.
A few notes on the formatting:
the dividing line must be the same length as your title and tags are optional.
Create a “drafts” folder in your “Blog” folder and save the post as a .md file. If everything is set up, a “_previews” folder will be created inside “drafts” containing an HTML file with a preview of your post. If you are happy with how it looks, publishing is as easy as moving the .md file to the “_publish-now” folder.
I by no means am an expert, so if you find problems with my walkthrough or don’t feel I’ve explained something enough, feel free to ping me on Twitter!