Skip to content

Commit

Permalink
Tweak URL path prefix patch to address feedback from xaviershay
Browse files Browse the repository at this point in the history
When reviewing my pull request, xaviershay requested these changes:

* Use ActionController::Base.config.relative_url_root instead of
  ENV['RAILS_RELATIVE_URL_ROOT'] in the UrlHelper and rackup.ru
* Mention the feature in the README, because it won't be found in
  config/application.rb

Implement these, but use Rails.configuration instead of
ActionController::Base.config, as it seems like the current Rails best
practice.
  • Loading branch information
Marcel M. Cary committed Apr 18, 2013
1 parent 925cf43 commit 06bdeaf
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
6 changes: 6 additions & 0 deletions README.textile
Expand Up @@ -38,6 +38,12 @@ Enki is a compact, easily extendable base for your blog. It does this by being h
* If you're not using OpenID you're a chump * If you're not using OpenID you're a chump
* Hacking code is the easiest way to customize something * Hacking code is the easiest way to customize something


h2. URL path prefix

Enki can run your blog with a URL path prefix. For example, you can run it at example.com/*blog* instead of blog.example.com. You can do so with the RAILS_RELATIVE_URL_ROOT environment variable, set either before starting the server or in config/application.rb before Enki::Application. Uncommenting this line in config/application.rb will enable this behavior in all environments:

<pre><code>ENV['RAILS_RELATIVE_URL_ROOT'] = '/blog'</code></pre>

h2. How it differs from Mephisto h2. How it differs from Mephisto


Mephisto is feature packed and quite customizable. It can however be daunting trying to find your way around the code, which isn’t so good if you’re trying to hack in your own features. Enki strips out a lot of the features that you probably don’t need (multiple authors and liquid templates, for example), and focuses on keeping a tight code base that is easy to comprehend and extend. Mephisto is feature packed and quite customizable. It can however be daunting trying to find your way around the code, which isn’t so good if you’re trying to hack in your own features. Enki strips out a lot of the features that you probably don’t need (multiple authors and liquid templates, for example), and focuses on keeping a tight code base that is easy to comprehend and extend.
Expand Down
2 changes: 1 addition & 1 deletion app/helpers/url_helper.rb
Expand Up @@ -2,7 +2,7 @@ module UrlHelper
def post_path(post, options = {}) def post_path(post, options = {})
suffix = options[:anchor] ? "##{options[:anchor]}" : "" suffix = options[:anchor] ? "##{options[:anchor]}" : ""
path = post.published_at.strftime("/%Y/%m/%d/") + post.slug + suffix path = post.published_at.strftime("/%Y/%m/%d/") + post.slug + suffix
path = "#{ENV['RAILS_RELATIVE_URL_ROOT']}#{path}" path = "#{Rails.configuration.action_controller.relative_url_root}#{path}"
path = URI.join(enki_config[:url], path) if options[:only_path] == false path = URI.join(enki_config[:url], path) if options[:only_path] == false
path path
end end
Expand Down
2 changes: 1 addition & 1 deletion config.ru
Expand Up @@ -2,6 +2,6 @@


require ::File.expand_path('../config/environment', __FILE__) require ::File.expand_path('../config/environment', __FILE__)


map ENV['RAILS_RELATIVE_URL_ROOT'] || "/" do map Rails.configuration.action_controller.relative_url_root || "/" do
run Enki::Application run Enki::Application
end end

0 comments on commit 06bdeaf

Please sign in to comment.