Skip to content

Commit

Permalink
We can now choose whether future-dated posts are published by default…
Browse files Browse the repository at this point in the history
… with a configuration variable. We still see all posts in preview mode.
  • Loading branch information
jbrains committed Dec 3, 2012
1 parent 89701e1 commit 4b9b499
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
17 changes: 15 additions & 2 deletions Rakefile
Expand Up @@ -47,20 +47,32 @@ end
# Working with Jekyll #
#######################

publish_future_dated_posts_switch = "" # backwards-compatible default value

desc "Read Jekyll configuration"
task :read_jekyll_configuration do
jekyll_configuration = YAML.load_file("./_config.yml")

# As of this writing, jekyll's default option is --future
publish_future_dated_posts_option = jekyll_configuration.has_key?("publish_future_dated_posts") ? jekyll_configuration["publish_future_dated_posts"] : true
publish_future_dated_posts_switch = publish_future_dated_posts_option ? "--future" : "--no-future"
end

desc "Generate jekyll site"
task :generate do
raise "### You haven't set anything up yet. First run `rake install` to set up an Octopress theme." unless File.directory?(source_dir)
puts "## Generating Site with Jekyll"
system "compass compile --css-dir #{source_dir}/stylesheets"
system "jekyll"
system "jekyll #{publish_future_dated_posts_switch}"
end
task :generate => :read_jekyll_configuration

desc "Watch the site and regenerate when it changes"
task :watch do
raise "### You haven't set anything up yet. First run `rake install` to set up an Octopress theme." unless File.directory?(source_dir)
puts "Starting to watch source with Jekyll and Compass."
system "compass compile --css-dir #{source_dir}/stylesheets" unless File.exist?("#{source_dir}/stylesheets/screen.css")
jekyllPid = Process.spawn({"OCTOPRESS_ENV"=>"preview"}, "jekyll --auto")
jekyllPid = Process.spawn({"OCTOPRESS_ENV"=>"preview"}, "jekyll --auto #{publish_future_dated_posts_switch}")
compassPid = Process.spawn("compass watch")

trap("INT") {
Expand All @@ -70,6 +82,7 @@ task :watch do

[jekyllPid, compassPid].each { |pid| Process.wait(pid) }
end
task :watch => :read_jekyll_configuration

desc "preview the site in a web browser"
task :preview do
Expand Down
1 change: 1 addition & 0 deletions _config.yml
Expand Up @@ -42,6 +42,7 @@ recent_posts: 5 # Posts in the sidebar Recent Posts section
excerpt_link: "Read on →" # "Continue reading" link text at the bottom of excerpted articles

titlecase: true # Converts page and post titles to titlecase
publish_future_dated_posts: false

# list each of the sidebar modules you want to include, in the order you want them to appear.
# To add custom asides, create files in /source/_includes/custom/asides/ and add them to the list like 'custom/asides/custom_aside_name.html'
Expand Down

1 comment on commit 4b9b499

@jbrains
Copy link
Owner Author

@jbrains jbrains commented on 4b9b499 Dec 3, 2012

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since jekyll already has a --no-future option, why don't we use it?

Please sign in to comment.