Skip to content
This repository has been archived by the owner on May 24, 2022. It is now read-only.

Commit

Permalink
1. Added rake task for simple configuration of subdirectory deployment.
Browse files Browse the repository at this point in the history
2. Updated READEME documentation regarding deploying to subdirectories.
3. Fixed related mistake in pagination and header links
  • Loading branch information
imathis committed Jul 16, 2011
1 parent f81bdbc commit 1f9b596
Show file tree
Hide file tree
Showing 5 changed files with 78 additions and 18 deletions.
10 changes: 5 additions & 5 deletions .themes/classic/source/_includes/head.html
Expand Up @@ -19,14 +19,14 @@
<meta name="keywords" content="{{page.keywords}}"/> <meta name="keywords" content="{{page.keywords}}"/>
{% endif %} {% endif %}


<link href="{{ site.url }}/images/favicon.png" rel="shortcut icon" /> <link href="{{ site.root }}/images/favicon.png" rel="shortcut icon" />
<link href="{{ site.url }}/stylesheets/screen.css" media="screen, projection" rel="stylesheet" type="text/css"> <link href="{{ site.root }}/stylesheets/screen.css" media="screen, projection" rel="stylesheet" type="text/css">
<script src="{{ site.url }}/javascripts/modernizr-2.0.js"></script> <script src="{{ site.root }}/javascripts/modernizr-2.0.js"></script>
<script src="http://s3.amazonaws.com/ender-js/jeesh.min.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+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='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_analytics.html %}
{% include google_plus_one.html %} {% include google_plus_one.html %}
{% include twitter_sharing.html %} {% include twitter_sharing.html %}
Expand Down
8 changes: 4 additions & 4 deletions .themes/classic/source/index.html
Expand Up @@ -13,13 +13,13 @@
<nav role="pagination"> <nav role="pagination">
<div> <div>
{% if paginator.next_page %} {% 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 %} {% 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 %} {% 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 %} {% elsif paginator.previous_page %}
<a class="next" href="/">Newer &rarr;</a> <a class="next" href="{{ site.root }}/">Newer &rarr;</a>
{% endif %} {% endif %}
</div> </div>
</nav> </nav>
Expand Down
34 changes: 29 additions & 5 deletions README.markdown
Expand Up @@ -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. 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). 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 destination: public/octopress
url: http://imathis.github.com/octopress url: http://imathis.github.com/octopress
subscribe_rss: /octopress/atom.xml subscribe_rss: /octopress/atom.xml
root: /octopress root: /octopress


# config.rb # config.rb - for Compass & Sass
http_path = "/octopress" http_path = "/octopress"
http_images_path = "/octopress/images"
http_fonts_path = "/octopress/fonts"
css_dir = "public/octopress/stylesheets"



# Rakefile # Rakefile
public_dir = "public/octopress" public_dir = "public/octopress"

# If deploying with rsync, update your Rakefile path
document_root = "~/yoursite.com/your/path"


## License ## License
(The MIT License) (The MIT License)
Expand Down
35 changes: 34 additions & 1 deletion Rakefile
Expand Up @@ -124,7 +124,40 @@ task :push do
end end
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| task :config_deploy, :branch do |t, args|
puts "!! Please provide a deploy branch, eg. rake init_deploy[gh-pages] !!" unless args.branch 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" puts "## Creating a clean #{args.branch} branch in ./#{deploy_dir} for Github pages deployment"
Expand Down
9 changes: 6 additions & 3 deletions config.rb
@@ -1,13 +1,16 @@
# Require any additional compass plugins here. # Require any additional compass plugins here.
project_type = :stand_alone project_type = :stand_alone
# Set this to the root of your project when deployed:
# Publishing paths
http_path = "/" http_path = "/"
http_images_path = "/images"
http_fonts_path = "/fonts"
css_dir = "public/stylesheets" css_dir = "public/stylesheets"

# Local development paths
sass_dir = "sass" sass_dir = "sass"
images_dir = "source/images" images_dir = "source/images"
http_images_dir = "images"
fonts_dir = "source/fonts" fonts_dir = "source/fonts"
http_fonts_dir = "fonts"


line_comments = false line_comments = false
output_style = :compressed output_style = :compressed

0 comments on commit 1f9b596

Please sign in to comment.