Permalink
Browse files

clean clean clean, make it clean! (aka stripping whitspaces) and link…

… to README
  • Loading branch information...
1 parent d319687 commit 7812279d41d4a2cab012c62e1e9a84cf69d947d5 Tobias Bielohlawek committed Feb 23, 2010
@@ -4,7 +4,7 @@
class ApplicationController < ActionController::Base
helper :all # include all helpers, all the time
protect_from_forgery # See ActionController::RequestForgeryProtection for details
-
+
# Scrub sensitive parameters from your log
filter_parameter_logging :password
end
@@ -1,5 +1,5 @@
class AssetsController < ApplicationController
-
+
def index
@assets = Asset.all( :limit => 16, :order => "created_at DESC")
render @assets and return if request.xhr?
@@ -9,18 +9,18 @@ def show
@asset = Asset.find_by_id( params[:id] )
render @asset if request.xhr?
end
-
+
def new
@asset = Asset.new
end
-
+
def create
@asset = Asset.find_or_initialize_by_uuid(params[:asset][:uuid])
@asset.update_attributes(params[:asset])
-
+
render @asset
rescue => e
render :text => "Error with uploading File: #{e.message}", :status => 500
end
-
+
end
View
@@ -1,10 +1,10 @@
class Asset < ActiveRecord::Base
-
+
has_attached_file :file
#validates_attachment_presence :file
validates_presence_of :uuid
- default_value_for :uuid do
+ default_value_for :uuid do
Asset.generate_uuid
end
@@ -18,37 +18,37 @@
<div id="percents">0%</div>
</div>
</div>
-
+
<div id="step2" style="display:none">
<div class="span-3 listnr">2.</div>
<div class="span-14 listentry2 last">
Thanks. We're producing some traffic now.<br>
- Hang on and add a title or comment:
+ Hang on and add a title or comment:
<% remote_form_for :asset, :url => assets_path, :update => "asset", :success => "$('#step3').fadeIn(800);", :html => { :id => "upload", :multipart => true } do |f| %>
<%= f.hidden_field :uuid, :value => @asset.uuid %>
-
+
<%= f.text_area :comment, :rows => 15, :cols => 5 %><br>
-
+
<%= f.submit "save"%>
<% end %>
</div>
</div>
-
+
<div id="step3" style="display:none">
<div class="span-3 listnr">3.</div>
<div class="span-14 listentry3 last">
<p>Hossa! Saved:</p>
<div id="asset"></div>
</div>
</div>
-
- <div id="step4" style="display:none">
+
+ <div id="step4" style="display:none">
<div class="span-3 listnr">&nbsp;</div>
<div class="span-14 listentry4 last">
<%= link_to "See how others produced traffic", assets_path, :id =>"others" %>
</div>
</div>
-
+
</div>
<script type="text/javascript" charset="utf-8">
@@ -69,15 +69,15 @@
this.disable();
$('#upload_button').css({background: '#DDD'});
$('#upload_button').html('uploading...');
-
+
interval = window.setInterval(function(){
jQuery.ajax({
type: "GET",
url: "/progress?X-Progress-ID=<%= @asset.uuid %>",
dataType: "json",
success: function(upload) {
if (upload.state == 'uploading') {
- upload.percents = Math.floor((upload.received / upload.size)*100);
+ upload.percents = Math.floor((upload.received / upload.size)*100);
$('#progressbar').css({width: upload.percents+'%'});
if(upload.percents > 0) upload.percents -= 1; //a bit of cheating here for better UX, as 100% upload doesn't mean it's fully finished
$('#percents').html( upload.percents + '%');
@@ -86,12 +86,12 @@
if (upload.state == 'done') {
window.clearInterval(interval);
}
-
+
if (upload.state == 'error') {
this.enable();
window.clearInterval(interval);
$('#upload_button').css({background: 'red'});
- $('#upload_button').html('error');
+ $('#upload_button').html('error');
}
}
});
@@ -100,8 +100,8 @@
},
onComplete: function(file, response) {
window.clearInterval(interval);
-
- $('#upload_button').html('done');
+
+ $('#upload_button').html('done');
$('#progressbar').css({width: '100%'});
$('#percents').html('100%'); //now we have 100%
$('#step3').fadeIn(800);
@@ -111,5 +111,5 @@
});
});
-
+
</script>
@@ -5,44 +5,46 @@
<title>The Traffic Machine | A demonstration of background File Upload with Progress Bar</title>
<%= stylesheet_link_tag 'blueprint/screen' %>
<%= stylesheet_link_tag 'styles' %>
-
+
<%= javascript_include_tag 'http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js' %>
-
+
<%= javascript_include_tag 'ajaxupload' %>
</head>
<body>
- <a href="http://github.com/rngtng/FileUploadProgress"><img style="position: absolute; top: 0; right: 0; border: 0;" src="http://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png" alt="Fork me on GitHub" /></a>
+ <a href="http://github.com/rngtng/FileUploadProgress"><img style="position: absolute; top: 0; right: 0; border: 0;" src="http://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png" alt="Fork me on GitHub" /></a>
<div id="container">
-
+
<!-- header -->
<div id="header" class="span-20">
<div class="span-11">
<h1><%= link_to "The Traffic Machine", index_path %></h1><br />
<p>a demonstration of background File Upload with Progress Bar</p>
</div>
-
+
<div class="span-9 last">
</div>
</div>
<!-- /header -->
-
+
<!-- content -->
<div class="span-17" id="content">
-
+
<%= yield -%>
-
+
</div>
<!-- /content -->
-
+
<!-- sidebar -->
<div class="span-2 push-1 last" id="sidebar">
- <p>a demo by <a href="http://www.rngtng.com">rngtng</a><br>Tobias Bielohlawek, 2010.</p>
+ <p>a demo by <a href="http://www.rngtng.com" target="_blank">rngtng</a><br>
+ Tobias Bielohlawek, 2010.<br>
+ <a href="http://github.com/rngtng/FileUploadProgress/blob/master/README.markdown" target="_blank">README</a></p>
</div>
<!-- /sidebar -->
<div class="span-17" id="footer" style="display:none">
-
+
</div>
</div>
</body>
View
@@ -1,33 +1,33 @@
set :application, "fup"
-
-set :use_sudo, false
+
+set :use_sudo, false
# If you aren't deploying to /u/apps/#{application} on the target
# servers (which is the default), you can specify the actual location
# via the :deploy_to variable:
set :deploy_to, "/kunden/warteschlange.de/produktiv/rails/fup"
-
+
# If you aren't using Subversion to manage your source code, specify
# your SCM below:
set :scm, :git
set :repository, "git://github.com/rngtng/FileUploadProgress.git"
set :branch, "master"
set :deploy_via, :remote_cache
-
+
set :user, 'ssh-21560'
set :ssh_options, { :forward_agent => true }
-
+
role :app, "fup.warteschlange.de"
role :web, "fup.warteschlange.de"
role :db, "fup.warteschlange.de", :primary => true
-
+
namespace :deploy do
desc "Restarting mod_rails with restart.txt"
task :restart, :roles => :app, :except => { :no_release => true } do
run "touch #{current_path}/tmp/restart.txt"
end
-
+
[:start, :stop].each do |t|
desc "#{t} task is a no-op with mod_rails"
task t, :roles => :app do ; end

0 comments on commit 7812279

Please sign in to comment.