diff --git a/.themes/classic/source/_includes/head.html b/.themes/classic/source/_includes/head.html index 4321492..2654ec4 100644 --- a/.themes/classic/source/_includes/head.html +++ b/.themes/classic/source/_includes/head.html @@ -19,14 +19,14 @@ {% endif %} - - - + + + - + - + {% include google_analytics.html %} {% include google_plus_one.html %} {% include twitter_sharing.html %} diff --git a/.themes/classic/source/index.html b/.themes/classic/source/index.html index 5a88f72..0655c13 100644 --- a/.themes/classic/source/index.html +++ b/.themes/classic/source/index.html @@ -13,13 +13,13 @@ blog_index: true diff --git a/README.markdown b/README.markdown index 79ef8e1..4e09b3e 100644 --- a/README.markdown +++ b/README.markdown @@ -118,22 +118,46 @@ The `config_deploy` rake task takes a branch name as an argument and creates a [ This prepares your branch for easy deployment. The `rake deploy` task copies the generated blog from the `public` directory to the `_deploy` directory, adds new files, removes old files, sets a commit message, and pushes to Github. Github will queue your site for publishing (which usually occurs instantly or within minutes if it's your first commit). -**Please note,** Github's project pages will be published to a subdirectory and you'll have to make sure you set up your urls correctly in your configs. -For Octopress my cofigs would be set up like this: +### Deploying to a Subdirectory (Github Project Pages does this) - # _config.yaml +If you're deploying to a subdirectory on your site, or if you're using Github's project pages, make sure you set up your urls correctly in your configs. +You can do this automatically: + + rake set_root_dir[your/path] + + # To go back to publishing to the document root + rake set_root_dir[/] + +Then update your `_config.yml` and `Rakefile` as follows: + + # Change the url in _config.yml + url: http://yoursite.com/your/path + + # If deploying with rsync, update your Rakefile path + document_root = "~/yoursite.com/your/path" + +To manually configure deployment to a subdirectory, you'll change `_config.yml`, `config.rb` and `Rakefile` + + # Example for deploying to Octopress's Github Pages + + # _config.yml destination: public/octopress url: http://imathis.github.com/octopress subscribe_rss: /octopress/atom.xml root: /octopress - # config.rb + # config.rb - for Compass & Sass http_path = "/octopress" + http_images_path = "/octopress/images" + http_fonts_path = "/octopress/fonts" + css_dir = "public/octopress/stylesheets" + # Rakefile public_dir = "public/octopress" - + # If deploying with rsync, update your Rakefile path + document_root = "~/yoursite.com/your/path" ## License (The MIT License) diff --git a/Rakefile b/Rakefile index e588f9a..b5ececb 100644 --- a/Rakefile +++ b/Rakefile @@ -124,7 +124,40 @@ task :push do end end -desc "setup _deploy folder and deploy branch" +desc "Update configurations to support publishing to root or sub directory" +task :set_root_dir, :dir do |t, args| + puts ">>> !! Please provide a directory, eg. rake config_dir[publishing/subdirectory]" unless args.dir + if args.dir + if args.dir == "/" + dir = "" + else + dir = "/" + args.dir.sub(/(\/*)(.+)/, "\\2").sub(/\/$/, ''); + end + rakefile = IO.read(__FILE__) + rakefile.sub!(/public_dir(\s*)=(\s*)(["'])[\w\-\/]*["']/, "public_dir\\1=\\2\\3public#{dir}\\3") + File.open(__FILE__, 'w') do |f| + f.write rakefile + end + compass_config = IO.read('config.rb') + compass_config.sub!(/http_path(\s*)=(\s*)(["'])[\w\-\/]*["']/, "http_path\\1=\\2\\3#{dir}/\\3") + compass_config.sub!(/http_images_path(\s*)=(\s*)(["'])[\w\-\/]*["']/, "http_images_path\\1=\\2\\3#{dir}/images\\3") + compass_config.sub!(/http_fonts_path(\s*)=(\s*)(["'])[\w\-\/]*["']/, "http_fonts_path\\1=\\2\\3#{dir}/fonts\\3") + compass_config.sub!(/css_dir(\s*)=(\s*)(["'])[\w\-\/]*["']/, "css_dir\\1=\\2\\3public#{dir}/stylesheets\\3") + File.open('config.rb', 'w') do |f| + f.write compass_config + end + jekyll_config = IO.read('_config.yml') + jekyll_config.sub!(/^destination:.+$/, "destination: public#{dir}") + jekyll_config.sub!(/^subscribe_rss:.+$/, "subscribe_rss: #{dir}/atom.xml") + jekyll_config.sub!(/^root:.*$/, "root: #{dir}") + File.open('_config.yml', 'w') do |f| + f.write jekyll_config + end + mkdir_p "public#{dir}" + end +end + +desc "Setup _deploy folder and deploy branch" task :config_deploy, :branch do |t, args| puts "!! Please provide a deploy branch, eg. rake init_deploy[gh-pages] !!" unless args.branch puts "## Creating a clean #{args.branch} branch in ./#{deploy_dir} for Github pages deployment" diff --git a/config.rb b/config.rb index 164a834..066427e 100644 --- a/config.rb +++ b/config.rb @@ -1,13 +1,16 @@ # Require any additional compass plugins here. project_type = :stand_alone -# Set this to the root of your project when deployed: + +# Publishing paths http_path = "/" +http_images_path = "/images" +http_fonts_path = "/fonts" css_dir = "public/stylesheets" + +# Local development paths sass_dir = "sass" images_dir = "source/images" -http_images_dir = "images" fonts_dir = "source/fonts" -http_fonts_dir = "fonts" line_comments = false output_style = :compressed