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 pull request locomedia
x refactor slugify method (use parameterize + create a module) x refactor slugify method (use parameterize + create a module)
x contents permalink (UI) x contents permalink (UI)
- BUG: has_one / has_many. Delete an author x BUG: has_one / has_many. Delete an author
- bushido changes in the master 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 - SEO: support and support/ should be 2 different pages. Remove trailing slash
- edit sidebar (inline editor). Unable to reset it
BACKLOG: BACKLOG:

View File

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