Browse files

Fixed multi-blog support bug, improved docs, added DELETE_AFTER_RUN flag

* it would exit when it found no e-mail instead of moving on
	to the next blog (holdover from single-blog days)
* DELETE_AFTER_RUN flag allows people to easily tell it
	to not delete emails after a run without putting it
	in debug mode.
* Changed docs to suggest using hooks/post-commit
	to regenerate the site instead of a cron job.
  • Loading branch information...
masukomi committed Dec 23, 2011
1 parent b5a43ca commit ca14c22c65c008896850f75d9b2d11e777870ca1
Showing with 40 additions and 30 deletions.
  1. +0 −9 Gemfile.lock
  2. +36 −18
  3. +4 −3 jekyllmail.rb
@@ -1,12 +1,6 @@
- diff-lcs (1.1.3)
- fileutils (0.7)
- rmagick (>= 2.13.1)
- grit (2.4.1)
- diff-lcs (~> 1.1)
- mime-types (~> 1.15)
i18n (0.6.0)
mail (2.3.0)
i18n (>= 0.4.0)
@@ -15,7 +9,6 @@ GEM
mime-types (1.16)
nokogiri (1.5.0)
polyglot (0.3.2)
- rmagick (2.13.1)
treetop (1.4.10)
polyglot (>= 0.3.1)
@@ -24,7 +17,5 @@ PLATFORMS
- fileutils
- grit
@@ -13,6 +13,11 @@ Once it's placed those files there it will (optionally) also add them to your bl
This will work even if it's a bare repo and the `source` directory you had it save files under
is in a detached worktree.
+Please note. JekyllMail assumes that the address it is checking
+is *exclusively* for its use and will only be used to post emails
+to a single blog. JekyllMail does support multiple blogs but you
+will need a seperate e-mail account for each one.
## Usage ##
@@ -96,29 +101,40 @@ Your `pop_user` doesn't have to be an e-mail address. It might just be
It all depends on how your server is configured. It's probably best to use
something other than "jekyllmail" though.
-## Cron Jobs ##
-You need to schedule two tasks to run regularly: JekyllMail itself, and
-a script to kick-off the generation of new HTML files once JekyllMail has
-done its job and commited the new files to your blog's git repo.
-There are a variety of ways to accomplish this. The simplest way is
-probably to create a shell script.
+## Wiring Things up ##
+You need to schedule a cronjob to run regularly to kick of JekyllMail
+and check for new e-mails.
-To kick of JekyllMail it might look something like this:
+To kick of JekyllMail you'll want a script that looks something like this.
+You can use the `` file that comes with JekyllMail as
+a template.
cd /full/path/to/jekyllmail
bundle exec ruby jekyllmail.rb
-To kick off the generation of the new HTML you'll need a second
-script like this:
+Save the file anywhere that isn't served up to the public, make it executable,
+and add a new line to your [crontab]( to run it every five
+minutes or so. This is an example crontab line to do this
+ 4,9,14,19,24,29,34,39,44,49,54,59 * * * * /home/my_username/jekyllmail_repo/
+When JekyllMail finds something it will save the files in the appropriate
+locations and commit them to the appropriate git repo. When it does
+we can leverage git's `hooks/post-commit` to regenerate the HTML
+without needing to unnecessarily rebuild it on a regular interval.
+The `hooks/post-commit` file in your repo should look something like this.
+Don't forget to make it executable. You can use the `` file
+that comes with JekyllMail as a templote.
cd /full/path/to/blogs/worktree
bundle exec rake generate
Depending on your server's ruby / gem configuration you may have to add some
-additional info to the top of those ( just below the `#!/bin/sh` ). On a system
+additional info to the top of those scirpts ( just below the `#!/bin/sh` ). On a system
with a locally installed RVM and gems directory the top of your script might
look something like this:
@@ -127,16 +143,9 @@ look something like this:
-To help get you started check out the `` and ``
-scripts that come along with the repo.
For more information on configuring Jekyll/Octopress to generate HTML server-side
see this post on [Serving Octopress from a Self-Hosted Git Repository](
-Save the file anywhere that isn't served up to the public, make it executable,
-and add a new line to your [crontab]( to run it every five
-minutes or so.
## Warning ##
At the end of every run JekyllMail *deletes every e-mail* in the account.
@@ -149,6 +158,15 @@ This is for two reasons:
Ok, four reasons.
+If you want to disable this set the `DELETE_AFTER_RUN` variable to false
+## Developers ##
+There is a `DEBUG` variable at the top of the script. Setting it to `true`
+will cause a bunch of debug statements to be printed during the run
+and prevent it from deleting the e-mails at the end. It's much easier to
+work on JekyllMail when you don't have to keep sending it new e-mails.
+Have fun, and remember to send in pull-requests. :)
### Known Issues ###
Check out the [Issues page]( on
@@ -23,6 +23,7 @@
DEBUG = false
#JEKYLLMAIL_USER= Actor.from_string("JekyllMail Script <>")
@@ -46,7 +47,7 @@
directory_keys.each do | key |
blog[key].sub!(/\/$/, '') # remove any trailing slashes from directory paths
- puts "#{key}: #{blog[key]}"
+ puts "#{key}: #{blog[key]}" if DEBUG
blog['images_dir'] ||= 'images' #relative to site_url
blog['posts_dir'] ||= '_posts' #relative to source_dir
@@ -64,7 +65,7 @@
if (emails.length == 0 )
puts "No Emails found" if DEBUG
- exit 0
+ next #move on to the next blog's config
puts "#{emails.length} email(s) found" if DEBUG
@@ -246,7 +247,7 @@
- Mail.delete_all() unless DEBUG
+ Mail.delete_all() unless DEBUG == true or DELETE_AFTER_RUN == false
# when debugging it's much easier to just leave the emails there and re-use them

0 comments on commit ca14c22

Please sign in to comment.