Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Support blog content living in a completely different repository. #289

Closed
wants to merge 22 commits into from

4 participants

@simensen

This code jumps off of #284 and is a much better idea of where I'm trying to go with this. It is possible that that PR can be ignored, but it is a nice reference for how I got from there to here.

Unfortunately, I ended up with a bunch of my other pull request commits embedded in this one. I think that is alright, we can change it later if needed... for now I want to use this just to show how this can work and start getting some feedback on whether or not this will ever make its way into core Octopress. :)

This PR allows me to have the following in my _localconfig.yml:

---
url: http://srcmvn.com
title: Source Maven
subtitle: Code Partition for Beau Simensen
author: Beau Simensen

# Key part is overriding the default '.' to make Octopress look
# for project files (sass and source) in another location.
octopress_project_path: /home/altern8/workspaces/srcmvn.com

This will instruct Octopress to look in a completely different location for sass and source directories. It does this by way of some magic in Octopress.config that constructs most of the paths from their component parts.

Both config.ru and config.rb needed to be updated to reference some of these configuration values. Rakefile needed (and still needs) a lot of work to be completely compatible with these changes. Jekyll uses some of the generate files in the _config.yml that is now written to the (potentially relocated) source/ directory.

This is just a start. I have the install, generate, watch, and preview tasks all working. Some of the other tasks should work out of the box, but others will need a lot of work.

I now have the guts of my site checked into its own repository and completely isolated from Octopress.

https://github.com/simensen/srcmvn.com

And the only modified file in my Octopress directory isn't even in the Octopress repository:

altern8@cirrus:~/workspaces/octopress$ git status
# On branch move_rakefile_configs_external_project
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#   _localconfig.yml
nothing added to commit but untracked files present (use "git add" to track)

My next trick will be to figure out how to get this file out of here as well and move it into my other repository. :)

I'd be super happy to discuss this direction with someone!

simensen added some commits
@simensen simensen Add support for pubsubhubbub pings. ac82f81
@simensen simensen Add support for pubsubhubbub pings. a3cc932
@simensen simensen _config.yml should be generated by merging _baseconfig.yml and option…
…ally _localconfig.yml
8a1d493
@simensen simensen Provide a stub _localconfig.yml.dist and we really should *not* be ig…
…noring _localconfig.yml
2f78782
@simensen simensen rsync deployment was referring to public_dir configuration instead of…
… destination for the local source to be synced.
81a0559
@simensen simensen Deploy config reading depends on deploy_config configuration value so…
… we should read local configuration first in case it is set there.
5c03764
@simensen simensen :copydot needs to do something smarter if destination directory does …
…not exist
f7c968d
@simensen simensen Found a way to keep _config.yml filename. :) 622f8b4
@simensen simensen Ignore the Jekyll config that may or may not live in source/ 637eb4a
@simensen simensen Experimental support of external projects. (keeping a blog outside of…
… the octopress directory)
eef9619
@simensen simensen Forgot to include the updates to the classic theme's atom template. 941a3be
@simensen simensen Merge branch 'move_rakefile_configs_pubsubhubbub' into move_rakefile_…
…configs_external_project
6ca99b6
@simensen simensen The changes to this file sipped by last night. Woops. 82d1333
@simensen simensen Cleaned things up to make css-dir easier to handle with compass configs. 8276fb2
@simensen simensen Document a couple of important configuration settings. 45e31b1
@simensen simensen Found this critical bug on a live deploy. Joy. f5d5232
@imathis
Owner

This is interesting. It'll take me a while to digest this, but I'll check it out. Thanks. :)

@simensen

Sounds good! I've been camping in #octopress off and on if you want to talk about it interactively sometime.

Long-term, I'd like to support being able to have themes and plugins able to be managed elsewhere as well. At least for the latter, that might actually be a Jekyll upgrade.

I'm new to Compass and SASS, too, so I'm not sure I understand that well enough at this point. It seems like a good chunk of the Compass related configuration in config.rb are relative paths to the project directory, which made everything a little more complicated to figure out.

This is probably the most Ruby I've done. Ever. So I'm sure there are some things I could be doing differently. And I'd be happy to tweak this in a way that would best fit your design goals.

@simensen

With the last few commits I'm now able to do the following:

altern8@cirrus:~/workspaces/octopress$ env SITE_CONFIG=../srcmvn.com/config.yml rake generate
## Generating Site with Jekyll
unchanged screen.scss
Configuration from /home/altern8/workspaces/srcmvn.com/source/_config.yml
unchanged screen.scss
Building site: /home/altern8/workspaces/srcmvn.com/source -> /home/altern8/workspaces/srcmvn.com/public
Successfully generated site: /home/altern8/workspaces/srcmvn.com/source -> /home/altern8/workspaces/srcmvn.com/public

Which means I'm able to host all of my custom stuff outside of the Octopress directory itself.

I think it is worth noting that although the main reason I'm doing this is to be able to host my content outside of the Octopress directory (and thus be able to manage several blogs and sites from one Octopress clone), the more tangible benefit is cleaning up the Rake code such that there isn't a mixture of strings and variables scattered throughout.

For instance, if File.directory?(source_dir) || File.directory?("sass") becomes if File.directory?(source_dir) || File.directory?(sass_dir)...

Also, all of this code should be 100% backwards compatible with the existing Octopress directory. I've only added the idea of an octopress_project_path and octopress_core_path, both of which default to ., or the current directory. This means that a user (such as myself) can opt to change the project path to point elsewhere.

@imathis
Owner

You're a maniac. I can't wait to try this out :)

simensen added some commits
@simensen simensen Added a single cache folder (.cache) that lives with the project, upd…
…ated gist and pygments code to use this. The :clean task is now cleaner and more generic. Other plugins that need to leverage cache can now reference config['octopress_paths_config'] and :clean will no longer need to be updated.
6e3832b
@simensen simensen Added ability to add tasks on the fly without modifying Rakefile. Mov…
…ed :ping task to :pubsubhubbub_ping as an example of this new functionality. Project tasks override core tasks if two are specified with the same name.
d05d746
@simensen

The Rakefile/tasks tweak is something I've been wanting to make for a few days but it relies quite a bit on the work done in the config building stuff.

I think I should hold off on making more tweaks to this branch/pull request until there has been a chance to discuss this more. I don't want to add too many more features in it as it might complicate the core issue, but it is also nice to be able to show some of the things that will be doable with some of these changes.

All in all I'd be happy to redo a bunch of this in a slightly different way if needed. For example, maybe the naming conventions I've used are all wrong... :)

:)

@simensen

@imathis let me know if and when you are ready to talk about this.i have put a hold on further tweaks as most anything else i'll do will probably depend on these changes. :) feel free to fire away with any questions/concerns you might have and i'll get back to you as quickly as i can!

@dudebout

That seems like a very good feature.

@bilke

+1

@imathis imathis closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Nov 15, 2011
  1. @simensen
Commits on Nov 17, 2011
  1. @simensen
  2. @simensen
  3. @simensen
  4. @simensen

    rsync deployment was referring to public_dir configuration instead of…

    simensen authored
    … destination for the local source to be synced.
  5. @simensen

    Deploy config reading depends on deploy_config configuration value so…

    simensen authored
    … we should read local configuration first in case it is set there.
  6. @simensen
  7. @simensen
  8. @simensen
Commits on Nov 18, 2011
  1. @simensen
  2. @simensen
  3. @simensen
  4. @simensen
  5. @simensen
  6. @simensen
  7. @simensen
Commits on Nov 21, 2011
  1. @simensen
  2. @simensen
  3. @simensen
  4. @simensen

    Added a single cache folder (.cache) that lives with the project, upd…

    simensen authored
    …ated gist and pygments code to use this. The :clean task is now cleaner and more generic. Other plugins that need to leverage cache can now reference config['octopress_paths_config'] and :clean will no longer need to be updated.
Commits on Nov 22, 2011
  1. @simensen

    Added ability to add tasks on the fly without modifying Rakefile. Mov…

    simensen authored
    …ed :ping task to :pubsubhubbub_ping as an example of this new functionality. Project tasks override core tasks if two are specified with the same name.
  2. @simensen
This page is out of date. Refresh to see the latest.
View
1  .gitignore
@@ -7,6 +7,7 @@ _deploy
public
sass.old
source.old
+source/_config.yml
source/_stash
source/stylesheets/screen.css
vendor
View
1  .themes/classic/source/atom.xml
@@ -7,6 +7,7 @@ layout: nil
<title>{{ site.title }}</title>
<link href="{{ site.url }}/atom.xml" rel="self"/>
<link href="{{ site.url }}/"/>
+ {% if site.hub_url %}<link href="{{ site.hub_url }}" rel="hub"/>{% endif %}
<updated>{{ site.time | date_to_xmlschema }}</updated>
<id>{{ site.url }}/</id>
<author>
View
43 Rakefile
@@ -3,7 +3,7 @@ require "bundler/setup"
require "stringex"
require "./lib/octopress.rb"
-config = Octopress.config
+config = Octopress.config File.dirname(__FILE__)
# --------------------------------- #
# get configs from _config.yml #
@@ -11,9 +11,10 @@ config = Octopress.config
#
deploy_config = config['deploy_config']
-public_dir = config['destination'] # compiled site directory
-style_dir = config['stylesheets'] # stylesheet directory
-source_dir = config['source'] # source file directory
+public_dir = config['octopress_paths_public'] # compiled site directory
+style_dir = config['octopress_paths_stylesheets'] # stylesheet directory
+source_dir = config['octopress_paths_source'] # source file directory
+sass_dir = config['octopress_paths_sass'] # sass directory
blog_index_dir = config['blog_index_dir'] # directory for your blog's index page (if you put your index in source/blog/index.html, set this to 'source/blog')
new_post_ext = config['new_post_ext'] # default new post file extension when using the new_post task
new_page_ext = config['new_page_ext'] # default new page file extension when using the new_page task
@@ -22,22 +23,22 @@ server_port = config['server_port'] # port for preview server eg. localh
## -- Misc Rakefile Configs -- ##
-themes_dir = '.themes' # directory for blog files
-stash_dir = '_stash' # directory to stash posts for speedy generation
-posts_dir = '_posts' # directory for blog files
+themes_dir = config['octopress_paths_themes'] # directory for blog files
+stash_dir = '_stash' # directory to stash posts for speedy generation
+posts_dir = '_posts' # directory for blog files
desc "Initial setup for Octopress: copies the default theme into the path of Jekyll's generator. Rake install defaults to rake install[classic] to install a different theme run rake install[some_theme_name]"
task :install, :theme do |t, args|
- if File.directory?(source_dir) || File.directory?("sass")
+ if File.directory?(source_dir) || File.directory?(sass_dir)
abort("rake aborted!") if Octopress.ask("A theme is already installed, proceeding will overwrite existing files. Are you sure?", ['y', 'n']) == 'n'
end
# copy theme into working Jekyll directories
theme = args.theme || 'classic'
- puts "## Copying "+theme+" theme into ./#{source_dir} and ./sass"
+ puts "## Copying "+theme+" theme into #{source_dir} and #{sass_dir}"
mkdir_p source_dir
cp_r "#{themes_dir}/#{theme}/source/.", source_dir
- mkdir_p "sass"
- cp_r "#{themes_dir}/#{theme}/sass/.", "sass"
+ mkdir_p sass_dir
+ cp_r "#{themes_dir}/#{theme}/sass/.", sass_dir
mkdir_p "#{source_dir}/#{posts_dir}"
mkdir_p public_dir
end
@@ -50,15 +51,15 @@ 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 #{style_dir.sub(/#{public_dir}/, source_dir)}"
- system "jekyll"
+ system "compass compile"
+ system "jekyll #{source_dir} #{public_dir}"
end
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."
- jekyllPid = Process.spawn("jekyll --auto")
+ jekyllPid = Process.spawn("jekyll --auto #{source_dir} #{public_dir}")
compassPid = Process.spawn("compass watch")
trap("INT") {
@@ -73,7 +74,7 @@ desc "preview the site in a web browser"
task :preview 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. Starting Rack on port #{server_port}"
- jekyllPid = Process.spawn("jekyll --auto")
+ jekyllPid = Process.spawn("jekyll --auto #{source_dir} #{public_dir}")
compassPid = Process.spawn("compass watch")
rackupPid = Process.spawn("rackup --port #{server_port}")
@@ -160,7 +161,7 @@ end
desc "Clean out caches: .pygments-cache, .gist-cache, .sass-cache"
task :clean do
- rm_rf [".pygments-cache/**", ".gist-cache/**", ".sass-cache/**", "source/stylesheets/screen.css"]
+ ["#{config['octopress_paths_cache']}/**", "#{style_dir}/screen.css"].each { |dir| rm_rf Dir.glob(dir) }
end
desc "Move sass to sass.old, install sass theme updates, replace sass/custom with sass.old/custom"
@@ -224,7 +225,10 @@ task :copydot do
exclusions = [".", "..", ".DS_Store"]
Dir["#{source_dir}/**/.*"].each do |file|
if !File.directory?(file) && !exclusions.include?(File.basename(file))
- cp(file, file.gsub(/#{source_dir}/, "#{public_dir}"));
+ copied_file = file.gsub(/#{source_dir}/, "#{public_dir}")
+ if File.directory?(copied_file)
+ cp(file, copied_file)
+ end
end
end
end
@@ -257,6 +261,11 @@ def ok_failed(condition)
end
+config['octopress_paths_tasks'].each do |tasks_dir|
+ Dir.glob("#{tasks_dir}/*.rake").each { |r| import r }
+end
+
+
desc "list tasks"
task :list do
puts "Tasks: #{(Rake::Task.tasks - [Rake::Task[:list]]).join(', ')}"
View
30 _config.yml
@@ -14,6 +14,24 @@ subscribe_email:
# RSS feeds can list your email address if you like
email:
+# Where the Octopress code lives
+octopress_core_path: .
+
+# Where the project lives
+octopress_project_path: .
+
+octopress_core_plugins_name: plugins
+octopress_core_themes_name: .themes
+octopress_core_tasks_name: tasks
+octopress_project_destination_name: public
+octopress_project_source_name: source
+octopress_project_cache_name: .cache
+octopress_project_tasks_name: tasks
+octopress_project_stylesheets_name: stylesheets
+octopress_project_sass_dir_name: sass
+octopress_project_sass_images_dir_name: images
+octopress_project_sass_fonts_dir_name: fonts
+
# ----------------------- #
# Deployment #
# ----------------------- #
@@ -28,16 +46,17 @@ deploy_config:
# If publishing to a subdirectory as in http://site.com/project set 'root: /project'
root: /
permalink: /blog/:year/:month/:day/:title/
-source: source
-destination: public
-stylesheets: public/stylesheets
-plugins: plugins
+#source: source
+#destination: public
+#stylesheets: public/stylesheets
+#plugins: plugins
blog_index_dir: source
code_dir: downloads/code
category_dir: blog/categories
new_post_ext: markdown
new_page_ext: markdown
server_port: 4000
+jekyll_config: source/_config.yml
markdown: rdiscount
pygments: false # default python pygments have been replaced by pygments.rb
@@ -92,3 +111,6 @@ disqus_short_name:
# Google Analytics
google_analytics_tracking_id:
+
+# pubsubhubbub
+hub_url:
View
19 _localconfig.yml.dist
@@ -0,0 +1,19 @@
+# ------------------------------ #
+# Local Configuration #
+# ------------------------------ #
+
+#
+# The purpose of this file is to optionally keep track of your
+# configuration outside of _baseconfig.yml.
+#
+# Any value that you could otherwise set in _baseconfig.yml
+# can be set here as well.
+#
+# To use, copy _localconfig.yml.dist to _localconfig.yml and
+# issue any rake command.
+#
+
+#url: http://yourfancyurl.com
+#title: My Fancy Blog
+#subtitle: A fancy blogging framework for hackers.
+#author: Your Fancy Name
View
16 config.rb
@@ -1,7 +1,8 @@
+require 'rake/dsl_definition'
require 'rake'
require './lib/octopress.rb'
-config = Octopress.config
+config = Octopress.config File.dirname(__FILE__)
root_dir = config['root'].sub(/\/$/, '')
@@ -10,14 +11,15 @@
# Publishing paths
http_path = config['root']
-http_images_path = "#{root_dir}/images"
-http_fonts_path = "#{root_dir}/fonts"
-css_dir = config['stylesheets']
+http_images_path = "#{root_dir}/#{config['octopress_sass_images_dir_name']}"
+http_fonts_path = "#{root_dir}/#{config['octopress_sass_fonts_dir_name']}"
+css_dir = "#{config['octopress_source_dir_name']}/#{config['octopress_stylesheets_dir_name']}"
# Local development paths
-sass_dir = "sass"
-images_dir = "#{config['source']}/images"
-fonts_dir = "#{config['source']}/fonts"
+project_path = config['octopress_paths_sass_project_path']
+sass_dir = config['octopress_sass_dir_name']
+images_dir = "#{config['octopress_source_dir_name']}/#{config['octopress_sass_images_dir_name']}"
+fonts_dir = "#{config['octopress_source_dir_name']}/#{config['octopress_sass_fonts_dir_name']}"
line_comments = false
output_style = :compressed
View
5 config.ru
@@ -6,6 +6,8 @@ require './lib/octopress.rb'
# The project root directory
$root = ::File.dirname(__FILE__)
+config = Octopress.config File.dirname(__FILE__)
+
class SinatraStaticServer < Sinatra::Base
get(/.+/) do
@@ -17,7 +19,8 @@ class SinatraStaticServer < Sinatra::Base
end
def send_sinatra_file(path, &missing_file_block)
- file_path = File.join(File.dirname(__FILE__), Octopress.config['destination'], path)
+ config = Octopress.config File.dirname(__FILE__)
+ file_path = File.join(Octopress.config['octopress_paths_public'], path)
file_path = File.join(file_path, 'index.html') unless file_path =~ /\.[a-z]+$/i
File.exist?(file_path) ? send_file(file_path) : missing_file_block.call
end
View
55 lib/octopress.rb
@@ -8,17 +8,64 @@ module Octopress
extend SetupDeployment::ClassMethods
extend Deployment::ClassMethods
- def self.config
+ def self.config(dir_string = nil)
+ dir_string ||= File.dirname(File.dirname(__FILE__))
@config ||= lambda do
begin
- config_file = File.expand_path "../_config.yml", File.dirname(__FILE__)
+ config_file = File.expand_path "_config.yml", dir_string
config = YAML::load(File.open(config_file))
+ # Include optional configuration containing local settings
+ localconfig_file = File.expand_path "_localconfig.yml", dir_string
+ config.merge! YAML::load(File.open(localconfig_file)) if File.exists?(localconfig_file)
+
+ # Include optional site configuration
+ if ENV['SITE_CONFIG']
+ siteconfig_file = File.expand_path ENV['SITE_CONFIG'], dir_string
+ config.merge! YAML::load(File.open(siteconfig_file)) if File.exists?(siteconfig_file)
+ end
+
# Include optional configuration file for deployment settings
if config['deploy_config']
- deployconfig_file = File.expand_path "../#{config['deploy_config']}.yml", File.dirname(__FILE__)
+ deployconfig_file = File.expand_path "#{config['deploy_config']}.yml", dir_string
config.merge! YAML::load(File.open(deployconfig_file)) if File.exists?(deployconfig_file)
end
+
+ config['octopress_paths_source'] = File.expand_path "#{config['octopress_project_path']}/#{config['octopress_project_source_name']}", dir_string
+ config['octopress_paths_cache'] = File.expand_path "#{config['octopress_project_path']}/#{config['octopress_project_cache_name']}", dir_string
+ config['octopress_paths_public'] = File.expand_path "#{config['octopress_project_path']}/#{config['octopress_project_destination_name']}", dir_string
+ config['octopress_paths_stylesheets'] = File.expand_path "#{config['octopress_paths_source']}/#{config['octopress_project_stylesheets_name']}", dir_string
+ config['octopress_paths_plugins'] = File.expand_path "#{config['octopress_core_path']}/#{config['octopress_core_plugins_name']}", dir_string
+ config['octopress_paths_jekyll_config'] = File.expand_path "#{config['octopress_project_path']}/#{config['octopress_project_source_name']}/_config.yml", dir_string
+ config['octopress_paths_sass'] = File.expand_path "#{config['octopress_project_path']}/#{config['octopress_project_sass_dir_name']}", dir_string
+ config['octopress_paths_sass_project_path'] = File.expand_path "#{config['octopress_project_path']}", dir_string
+ config['octopress_sass_dir_name'] = config['octopress_project_sass_dir_name']
+ config['octopress_sass_images_dir_name'] = config['octopress_project_sass_images_dir_name']
+ config['octopress_sass_fonts_dir_name'] = config['octopress_project_sass_fonts_dir_name']
+ config['octopress_paths_themes'] = File.expand_path "#{config['octopress_core_path']}/#{config['octopress_core_themes_name']}"
+ config['octopress_source_dir_name'] = config['octopress_project_source_name']
+ config['octopress_stylesheets_dir_name'] = config['octopress_project_stylesheets_name']
+ core_tasks_dir = File.expand_path "#{config['octopress_core_path']}/#{config['octopress_core_tasks_name']}", dir_string
+ project_tasks_dir = File.expand_path "#{config['octopress_project_path']}/#{config['octopress_project_tasks_name']}", dir_string
+ config['octopress_paths_tasks'] = [core_tasks_dir]
+ if core_tasks_dir != project_tasks_dir
+ config['octopress_paths_tasks'].push(project_tasks_dir)
+ end
+
+ # These settings are very important to Jekyll.
+ config['source'] = config['octopress_paths_source']
+ config['plugins'] = config['octopress_paths_plugins']
+ config['destination'] = config['octopress_paths_public']
+
+ # Write out a combined configuration file (for jekyllL)
+ combined_config_file = config['octopress_paths_jekyll_config']
+ if File.exists?(File.dirname(combined_config_file))
+ File.open(combined_config_file, 'w') do |f|
+ f.write "# This file is automatically generated.\n"
+ f.write config.to_yaml
+ end
+ end
+
config
rescue
puts "YAML Exception reading Octopress config"
@@ -48,4 +95,4 @@ def self.ask(message, args)
answer
end
-end
+end
View
2  lib/octopress/deployment.rb
@@ -14,7 +14,7 @@ def get_deployment_platforms
def deploy_rsync
puts "## Deploying website via Rsync"
- ok_failed system("rsync -avze 'ssh -p #{self.config['ssh_port']}' --delete #{self.config['public_dir']}/ #{self.config['ssh_user']}:#{self.config['document_root']}")
+ ok_failed system("rsync -avze 'ssh -p #{self.config['ssh_port']}' --delete #{self.config['destination']}/ #{self.config['ssh_user']}:#{self.config['document_root']}")
end
View
3  lib/octopress/setup_deployment.rb
@@ -1,3 +1,6 @@
+require 'rake/dsl_definition'
+require 'rake'
+
# Polyfill for __method__ for Ruby versions older than 1.9
__method__ ||= lambda do
caller[0] =~ /`([^']*)'/ and $1
View
4 plugins/gist_tag.rb
@@ -9,14 +9,16 @@
require 'digest/md5'
require 'net/https'
require 'uri'
+require './lib/octopress.rb'
module Jekyll
class GistTag < Liquid::Tag
def initialize(tag_name, text, token)
super
+ config = Octopress.config
@text = text
@cache_disabled = false
- @cache_folder = File.expand_path "../.gist-cache", File.dirname(__FILE__)
+ @cache_folder = "#{config['octopress_paths_cache']}/gist-cache"
FileUtils.mkdir_p @cache_folder
end
View
5 plugins/pygments_code.rb
@@ -1,8 +1,11 @@
require 'pygments'
require 'fileutils'
require 'digest/md5'
+require './lib/octopress.rb'
-PYGMENTS_CACHE_DIR = File.expand_path('../../.pygments-cache', __FILE__)
+config = Octopress.config
+
+PYGMENTS_CACHE_DIR = "#{config['octopress_paths_cache']}/pygments-cache"
FileUtils.mkdir_p(PYGMENTS_CACHE_DIR)
module HighlightCode
View
14 tasks/pubsubhubbub_ping.rake
@@ -0,0 +1,14 @@
+config = Octopress.config
+
+desc "Notify pubsubhubbub hub of new content"
+task :pubsubhubbub_ping do
+ raise "!! No hub URL specified (please specify hub_url in _config.yml)" unless config['hub_url']
+ require 'net/http'
+ require 'uri'
+ atom_url = config['url'] + "/atom.xml"
+ resp, data = Net::HTTP.post_form(URI.parse(config['hub_url']),
+ {'hub.mode' => 'publish',
+ 'hub.url' => atom_url})
+ raise "!! Hub notification error: #{resp.code} #{resp.msg}, #{data}" unless resp.code == "204"
+ puts "## Notified hub (" + config['hub_url'] + ") that feed #{atom_url} has been updated"
+end
Something went wrong with that request. Please try again.