reflect changes from the bushi.do platform

This commit is contained in:
did 2011-06-21 15:03:23 -07:00
parent 4d29500483
commit a5cd2290ea
2 changed files with 21 additions and 30 deletions

View File

@ -18,10 +18,11 @@ x pick up a theme_asset
x pull request locomedia
x refactor slugify method (use parameterize + create a module)
x contents permalink (UI)
- BUG: has_one / has_many. Delete an author
- bushido changes in the master
x BUG: has_one / has_many. Delete an author
x bushido changes in the master
? edit sidebar (inline editor). Unable to reset it
- SEO: support and support/ should be 2 different pages. Remove trailing slash
- edit sidebar (inline editor). Unable to reset it
BACKLOG:

View File

@ -5,43 +5,33 @@ module Locomotive
module Bushido
class Middleware
# BUSHIDO_JS_URL = 'http://localhost:4567/javascripts/bushido.js'
BUSHIDO_JS_URL = 'http://bushi.do/api/bushido.js'
include Rack::Utils
def initialize(app, opts = {})
@app = app
@bushido_app_name = ENV['BUSHIDO_APP']
@bushido_metrics_token = ENV['BUSHIDO_METRICS_TOKEN']
@bushido_claimed = ::Locomotive.bushido_app_claimed?
@path_regexp = %r{^/admin/}
end
def call(env)
if env['PATH_INFO'] =~ @path_regexp
status, headers, response = @app.call(env)
content = ""
response.each { |part| content += part }
# "claiming" bar + stats ?
content.gsub!(/<\/body>/i, <<-STR
<script type="text/javascript">
var _bushido_app = '#{@bushido_app_name}';
var _bushido_claimed = #{@bushido_claimed.to_s};
var _bushido_metrics_token = '#{@bushido_metrics_token}';
(function() {
var bushido = document.createElement('script'); bushido.type = 'text/javascript'; bushido.async = true;
bushido.src = '#{BUSHIDO_JS_URL}?#{::Bushido::VERSION.gsub('.', '')}';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(bushido, s);
})();
</script>
</body>
# enable chat
content.gsub!(/<\/head>/i, <<-STR
<script type="text/javascript">var _bushido_chat = true;</script>
</head>
STR
)
headers['content-length'] = bytesize(content).to_s
[status, headers, [content]]
else
@app.call(env)
end
end
end