Skip to content

Commit

Permalink
ajax reloading and eager loading to projects#show
Browse files Browse the repository at this point in the history
  • Loading branch information
ceritium committed Dec 15, 2010
1 parent 2d1b552 commit 8eda4ad
Show file tree
Hide file tree
Showing 9 changed files with 33 additions and 24 deletions.
1 change: 0 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ gem "shout-bot"
gem "tinder"



group :development, :test do

gem "capybara"
Expand Down
6 changes: 2 additions & 4 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,11 @@ GEM
rack-test (>= 0.5.4)
selenium-webdriver (>= 0.0.27)
xpath (~> 0.1.2)
celerity (0.8.4)
celerity (0.8.5)
childprocess (0.1.4)
ffi (~> 0.6.3)
columnize (0.3.2)
configuration (1.2.0)
context (0.0.16)
crack (0.1.8)
culerity (0.2.12)
daemons (1.1.0)
Expand Down Expand Up @@ -126,7 +125,7 @@ GEM
ruby_core_source (0.1.4)
archive-tar-minitar (>= 0.5.2)
rubyzip (0.9.4)
selenium-webdriver (0.1.0)
selenium-webdriver (0.1.1)
childprocess (= 0.1.4)
ffi (~> 0.6.3)
json_pure
Expand Down Expand Up @@ -160,7 +159,6 @@ PLATFORMS

DEPENDENCIES
capybara
context
crack
database_cleaner
delayed_job
Expand Down
6 changes: 5 additions & 1 deletion app/controllers/projects_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@ def index
end

def show
@builds = @project.builds.order("created_at DESC").limit(@project.max_builds)
@builds = @project.builds.order("created_at DESC").limit(@project.max_builds).includes(:project, :parts).all
respond_to do |format|
format.html{}
format.js{}
end
end

def feed
Expand Down
19 changes: 10 additions & 9 deletions app/views/projects/_builds.html.haml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
- @builds.each do |build|
%div{:class => "#{build.status} project", :id => dom_id(build)}
- unless BigTuna.read_only?
.info
= form_tag(build_path(build), :method => "DELETE") do
%button.crit_button{:type => "submit"} Delete
%h3= link_to(build.display_name, build_path(build, :stderr => build.status == Build::STATUS_OK ? nil : 1))
%table.value_list
= render :partial => "builds/build_data", :locals => {:build => build}
#builds
- @builds.each do |build|
%div{:class => "#{build.status} project", :id => dom_id(build)}
- unless BigTuna.read_only?
.info
= form_tag(build_path(build), :method => "DELETE") do
%button.crit_button{:type => "submit"} Delete
%h3= link_to(build.display_name, build_path(build, :stderr => build.status == Build::STATUS_OK ? nil : 1))
%table.value_list
= render :partial => "builds/build_data", :locals => {:build => build}
7 changes: 4 additions & 3 deletions app/views/projects/index.html.haml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#listing
= render :partial => 'projects'

%script
$(document).ready(function(){setInterval('reloadProjects()', 5000);});

- content_for :sidebar do
- unless BigTuna.read_only?
%li= link_to("New project", new_project_path, :class => 'black_button')

%script
$(document).ready(function(){setInterval(reloadProjects, 5000);});
5 changes: 5 additions & 0 deletions app/views/projects/show.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@
%br

= render :partial => 'builds'

%script
= "$(document).ready(function(){setInterval('reloadBuilds(#{@project.id})', 5000);});"


- content_for :sidebar do
- unless BigTuna.read_only?
%li= link_to("Edit", edit_project_path(@project), :class => "black_button")
Expand Down
1 change: 1 addition & 0 deletions app/views/projects/show.js.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
$("#builds").html("<%= escape_javascript(render(:partial => 'builds')) %>");
9 changes: 3 additions & 6 deletions config/deploy.rb.sample
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
require "bundler/capistrano"

set :application, "bigtuna"
set :domain, "your.domain"
set :repository, "git@your.domain:big_tuna.git"
Expand All @@ -24,16 +26,12 @@ namespace :deploy do
run "touch #{current_release}/tmp/restart.txt"
end

desc "Run bundler task to bundle app"
task :bundle, :roles => :app do
run "cd #{current_release} && bundle install --path #{deploy_to}/shared/bundle --without test:development"
end

desc "Updates the symlink for config files to the just deployed release."
task :symlink_configs do
run "ln -nfs #{shared_path}/config/database.yml #{release_path}/config/database.yml"
run "ln -nfs #{shared_path}/builds #{release_path}/builds"
run "ln -nfs #{shared_path}/config/email.yml #{release_path}/config/email.yml"
run "ln -nfs #{shared_path}/config/bigtuna.yml #{release_path}/config/bigtuna.yml"
end

task :bootstrap do
Expand All @@ -45,6 +43,5 @@ namespace :deploy do
end
end

after "deploy:update_code", "deploy:bundle"
after "deploy:finalize_update", "deploy:symlink_configs"
before "deploy:restart", "deploy:bootstrap"
3 changes: 3 additions & 0 deletions public/javascripts/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@ function reloadProjects(){
$.ajax({method: 'get',url : '/projects.js'});
}

function reloadBuilds(project_id){
$.ajax({method: 'get',url : '/projects/' + project_id + '.js'});
}

0 comments on commit 8eda4ad

Please sign in to comment.