Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

We can now choose whether future-dated posts are published by default…

… with a configuration variable. We still see all posts in preview mode.
commit 4b9b499251ea4d613f7bd6f3b0500c6485c5ec21 1 parent 89701e1
J. B. Rainsberger authored December 03, 2012

Showing 2 changed files with 16 additions and 2 deletions. Show diff stats Hide diff stats

  1. 17  Rakefile
  2. 1  _config.yml
17  Rakefile
@@ -47,20 +47,32 @@ end
47 47
 # Working with Jekyll #
48 48
 #######################
49 49
 
  50
+publish_future_dated_posts_switch = "" # backwards-compatible default value
  51
+
  52
+desc "Read Jekyll configuration"
  53
+task :read_jekyll_configuration do
  54
+  jekyll_configuration = YAML.load_file("./_config.yml")
  55
+
  56
+  # As of this writing, jekyll's default option is --future
  57
+  publish_future_dated_posts_option = jekyll_configuration.has_key?("publish_future_dated_posts") ? jekyll_configuration["publish_future_dated_posts"] : true
  58
+  publish_future_dated_posts_switch = publish_future_dated_posts_option ? "--future" : "--no-future"
  59
+end
  60
+
50 61
 desc "Generate jekyll site"
51 62
 task :generate do
52 63
   raise "### You haven't set anything up yet. First run `rake install` to set up an Octopress theme." unless File.directory?(source_dir)
53 64
   puts "## Generating Site with Jekyll"
54 65
   system "compass compile --css-dir #{source_dir}/stylesheets"
55  
-  system "jekyll"
  66
+  system "jekyll #{publish_future_dated_posts_switch}"
56 67
 end
  68
+task :generate => :read_jekyll_configuration
57 69
 
58 70
 desc "Watch the site and regenerate when it changes"
59 71
 task :watch do
60 72
   raise "### You haven't set anything up yet. First run `rake install` to set up an Octopress theme." unless File.directory?(source_dir)
61 73
   puts "Starting to watch source with Jekyll and Compass."
62 74
   system "compass compile --css-dir #{source_dir}/stylesheets" unless File.exist?("#{source_dir}/stylesheets/screen.css")
63  
-  jekyllPid = Process.spawn({"OCTOPRESS_ENV"=>"preview"}, "jekyll --auto")
  75
+  jekyllPid = Process.spawn({"OCTOPRESS_ENV"=>"preview"}, "jekyll --auto #{publish_future_dated_posts_switch}")
64 76
   compassPid = Process.spawn("compass watch")
65 77
 
66 78
   trap("INT") {
@@ -70,6 +82,7 @@ task :watch do
70 82
 
71 83
   [jekyllPid, compassPid].each { |pid| Process.wait(pid) }
72 84
 end
  85
+task :watch => :read_jekyll_configuration
73 86
 
74 87
 desc "preview the site in a web browser"
75 88
 task :preview do
1  _config.yml
@@ -42,6 +42,7 @@ recent_posts: 5       # Posts in the sidebar Recent Posts section
42 42
 excerpt_link: "Read on →"  # "Continue reading" link text at the bottom of excerpted articles
43 43
 
44 44
 titlecase: true       # Converts page and post titles to titlecase
  45
+publish_future_dated_posts: false
45 46
 
46 47
 # list each of the sidebar modules you want to include, in the order you want them to appear.
47 48
 # To add custom asides, create files in /source/_includes/custom/asides/ and add them to the list like 'custom/asides/custom_aside_name.html'

1 note on commit 4b9b499

J. B. Rainsberger
Owner

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

Please sign in to comment.
Something went wrong with that request. Please try again.