Skip to content

Commit

Permalink
Big update to enable Cloudfuji help
Browse files Browse the repository at this point in the history
  • Loading branch information
sgrove committed May 9, 2012
1 parent b43bfe7 commit baf0fc7
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 5 deletions.
2 changes: 1 addition & 1 deletion app/assets/javascripts/backbone/views/chatbox.js.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class Kandan.Views.Chatbox extends Backbone.View


postMessageOnEnter: (event)->
if event.keyCode== 13
if event.keyCode == 13
@postMessage(event)
event.preventDefault()

Expand Down
6 changes: 6 additions & 0 deletions app/controllers/apis_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,10 @@ def active_users
format.json { render :json => ActiveUsers.all }
end
end

def me
respond_to do |format|
format.json { render :json => current_user }
end
end
end
6 changes: 2 additions & 4 deletions app/controllers/channels_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@ def index
end

respond_to do |format|
format.json do
render :text => nested_channel_data.to_json
end
format.json { render :text => nested_channel_data.to_json }
end
end

Expand All @@ -40,7 +38,7 @@ def create
end

def show
@channel = Channel.find params[:id]
@channel = Channel.where("LOWER(name) = ?", params[:id].downcase).first || Channel.find(params[:id])
respond_to do |format|
format.json { render :json => @channel }
end
Expand Down
12 changes: 12 additions & 0 deletions app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,17 @@
<audio class="audio_private"></audio>
<audio class="audio_common"></audio>
</ul>

<%- if user_signed_in? && Cloudfuji::Platform.on_cloudfuji? %>
<%= javascript_tag do %>
<%- cloudfuji_help_vars = {
"HUBOT_KANDAN_TOKEN" => User.find_by_email("hubot@cloudfuji.com").try(:authentication_token),
"HUBOT_KANDAN_HOST" => ENV['CLOUDFUJI_DOMAIN']
}
%>

window._cloudfuji_help = <%= cloudfuji_help_vars.to_json.html_safe %>;
<%- end %>
<%- end %>
</body>
</html>
9 changes: 9 additions & 0 deletions lib/tasks/cloudfuji.rake
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,14 @@ namespace :cloudfuji do
a.save!
end
end

# Create Hubot
Rake::Task['kandan:boot_hubot'].invoke
end

desc "Run on update for a Busido app. Copies config files and seeds db."
task :update => :environment do
# Create Hubot if not already present
Rake::Task['kandan:boot_hubot'].invoke
end
end
30 changes: 30 additions & 0 deletions lib/tasks/kandan.rake
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,34 @@ namespace :kandan do
end
end
end

desc "Creates the default hubot account."
task :boot_hubot => :environment do
user = User.find_by_email("hubot@cloudfuji.com")

if user.nil?
puts "Creating hubot user..."

password = ""
128.times { password << (('a'..'z').to_a + ('A'..'Z').to_a + ['!','@','#','$','%','^','&','*','(',')'].to_a).sample }

hubot = User.new
hubot.email = "hubot@cloudfuji.com"
hubot.first_name = "Hubot"
hubot.last_name = "vonGithubben"
hubot.ido_id = "a-bot-lives-in-solitude"
hubot.password = password if hubot.respond_to?("password=".to_sym)
hubot.password_confirmation = password if hubot.respond_to?("password_confirmation=".to_sym)
hubot.save!
end
end

desc "Output the hubot access key"
task :hubot_access_key => :environment do
if authentication_token = User.find_by_email("hubot@cloudfuji.com").try(:authentication_token)
puts "Your hubot access key is #{ authentication_token }"
else
puts "There's not hubot account. Run rake kandan:boot_hubot to create a bot account."
end
end
end

0 comments on commit baf0fc7

Please sign in to comment.