aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrandon Mathis <brandon@imathis.com>2011-07-16 14:52:50 -0400
committerBrandon Mathis <brandon@imathis.com>2011-07-16 14:52:50 -0400
commit1f9b596b821685edcdaebaa885b1c6a4a22d1487 (patch)
tree4fe8f607e5cb6edaf2b8307f0b9227564d4f727e
parentf81bdbc1a8e341d9d3fe1eba3b77beadfe59b3d6 (diff)
downloadmy_new_personal_website-1f9b596b821685edcdaebaa885b1c6a4a22d1487.tar.xz
my_new_personal_website-1f9b596b821685edcdaebaa885b1c6a4a22d1487.zip
1. Added rake task for simple configuration of subdirectory deployment.
2. Updated READEME documentation regarding deploying to subdirectories. 3. Fixed related mistake in pagination and header links
-rw-r--r--.themes/classic/source/_includes/head.html10
-rw-r--r--.themes/classic/source/index.html8
-rw-r--r--README.markdown34
-rw-r--r--Rakefile35
-rw-r--r--config.rb9
5 files changed, 78 insertions, 18 deletions
diff --git a/.themes/classic/source/_includes/head.html b/.themes/classic/source/_includes/head.html
index 43214921..2654ec48 100644
--- a/.themes/classic/source/_includes/head.html
+++ b/.themes/classic/source/_includes/head.html
@@ -19,14 +19,14 @@
<meta name="keywords" content="{{page.keywords}}"/>
{% endif %}
- <link href="{{ site.url }}/images/favicon.png" rel="shortcut icon" />
- <link href="{{ site.url }}/stylesheets/screen.css" media="screen, projection" rel="stylesheet" type="text/css">
- <script src="{{ site.url }}/javascripts/modernizr-2.0.js"></script>
+ <link href="{{ site.root }}/images/favicon.png" rel="shortcut icon" />
+ <link href="{{ site.root }}/stylesheets/screen.css" media="screen, projection" rel="stylesheet" type="text/css">
+ <script src="{{ site.root }}/javascripts/modernizr-2.0.js"></script>
<script src="http://s3.amazonaws.com/ender-js/jeesh.min.js"></script>
- <script src="{{ site.url }}/javascripts/octopress.js" type="text/javascript"></script>
+ <script src="{{ site.root }}/javascripts/octopress.js" type="text/javascript"></script>
<link href='http://fonts.googleapis.com/css?family=PT+Serif:regular,italic,bold,bolditalic' rel='stylesheet' type='text/css'>
<link href='http://fonts.googleapis.com/css?family=PT+Sans:regular,italic,bold,bolditalic' rel='stylesheet' type='text/css'>
- <link href="{{ site.url }}/atom.xml" rel="alternate" title="{{site.title}}" type="application/atom+xml"/>
+ <link href="{{ site.root }}/atom.xml" rel="alternate" title="{{site.title}}" type="application/atom+xml"/>
{% 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 5a88f720..0655c139 100644
--- a/.themes/classic/source/index.html
+++ b/.themes/classic/source/index.html
@@ -13,13 +13,13 @@ blog_index: true
<nav role="pagination">
<div>
{% if paginator.next_page %}
- <a class="prev" href="/page{{paginator.next_page}}/">&larr; Older</a>
+ <a class="prev" href="{{ site.root }}/page{{paginator.next_page}}/">&larr; Older</a>
{% endif %}
- <a href="/blog/archives">Blog Archives</a>
+ <a href="{{ site.root }}/blog/archives">Blog Archives</a>
{% if paginator.previous_page and paginator.previous_page > 1 %}
- <a class="next" href="/page{{paginator.previous_page}}/">Newer &rarr;</a>
+ <a class="next" href="{{ site.root }}/page{{paginator.previous_page}}/">Newer &rarr;</a>
{% elsif paginator.previous_page %}
- <a class="next" href="/">Newer &rarr;</a>
+ <a class="next" href="{{ site.root }}/">Newer &rarr;</a>
{% endif %}
</div>
</nav>
diff --git a/README.markdown b/README.markdown
index 79ef8e18..4e09b3e3 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 e588f9a3..b5ececbe 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 164a8348..066427ed 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