public
Description: The kick ass (non-commercial) home for musicians and their music
Homepage: http://alonetone.com
Clone URL: git://github.com/sudara/alonetone.git
Search Repo:
mass edit of tracks. post-upload, users are now taken to edit their tracks
sudara (author)
Tue Jul 08 07:30:43 -0700 2008
commit  b7fe616ebd199efac196337e63265940347f0e5e
tree    044e1c497b14d5d2facdb2a6a54807a445d1edb5
parent  39bcb948bf2525afc45a07b083aea5bc90a83d24
...
7
8
9
10
 
11
12
13
...
109
110
111
 
 
 
 
 
 
 
 
 
 
 
 
 
112
113
114
...
141
142
143
144
145
 
 
146
147
148
...
153
154
155
156
157
158
159
160
 
 
 
 
 
 
 
 
 
 
161
162
163
 
 
164
165
166
...
7
8
9
 
10
11
12
13
...
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
...
154
155
156
 
 
157
158
159
160
161
...
166
167
168
 
 
 
 
 
169
170
171
172
173
174
175
176
177
178
179
 
 
180
181
182
183
184
0
@@ -7,7 +7,7 @@ class AssetsController < ApplicationController
0
   before_filter :find_referer, :only => :show
0
   
0
   #rescue_from NoMethodError, :with => :user_not_found
0
- rescue_from ActiveRecord::RecordNotFound, :with => :not_found
0
+ #rescue_from ActiveRecord::RecordNotFound, :with => :not_found
0
   
0
   @@valid_listeners = ['msie','webkit','gecko','mozilla','netscape','itunes']
0
   
0
@@ -109,6 +109,19 @@ class AssetsController < ApplicationController
0
     @descriptionless = @user.assets.descriptionless
0
   end
0
 
0
+ def mass_edit
0
+ @descriptionless = @user.assets.descriptionless
0
+ if params[:assets] # expects comma seperated list of ids
0
+ @assets = [@user.assets.find(params[:assets])].flatten
0
+ else
0
+ @assets = @user.assets
0
+ end
0
+ end
0
+
0
+ def mass_update
0
+
0
+ end
0
+
0
   # POST /assets
0
   # POST /assets.xml
0
   def create
0
@@ -141,8 +154,8 @@ class AssetsController < ApplicationController
0
       end
0
     end
0
     if good
0
- flash[:ok] = flashes
0
- redirect_to user_tracks_path(current_user)
0
+ flash[:ok] = flashes + "<br/>Now, check the title and add description for your track(s)"
0
+ redirect_to mass_edit_user_tracks_path(current_user, :assets => (@assets.collect(&:id)))
0
     else
0
       flash[:error] = flashes
0
       flash[:error] = "Please try again with a file that is not empty (or miniscule) and is an mp3. <br/>Click the HALP! button or email sudara@alonetone.com for more help" if @assets.size == 0
0
@@ -153,14 +166,19 @@ class AssetsController < ApplicationController
0
   # PUT /assets/1
0
   # PUT /assets/1.xml
0
   def update
0
- respond_to do |format|
0
- if @asset.update_attributes(params[:asset])
0
- flash[:ok] = 'Track updated!'
0
- format.html { redirect_to user_track_url(current_user, @asset) }
0
- format.xml { head :ok }
0
+ result = @asset.update_attributes(params[:asset])
0
+ if request.xhr?
0
+ if result
0
+ head :ok
0
+ else
0
+ head :bad_request
0
+ end
0
+ else
0
+ if result
0
+ redirect_to user_track_url(current_user, @asset)
0
       else
0
- format.html { render :action => "edit" }
0
- format.xml { render :xml => @asset.errors.to_xml }
0
+ flash[:error] = "There was an issue with updating that track"
0
+ render :action => "edit"
0
       end
0
     end
0
   end
...
1
 
 
2
3
4
...
51
52
53
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
54
55
...
1
2
3
4
5
6
...
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
0
@@ -1,4 +1,6 @@
0
 class Asset
0
+ @@launch_date = 'Tue Feb 01 00:00:00 +0100 2008'.to_time
0
+
0
   def self.most_popular(limit=10, time_period=5.days.ago)
0
     popular = Listen.count(:all,:include => :asset, :group => 'listens.asset_id', :limit => limit, :conditions => ["listens.created_at > ? AND (listens.listener_id IS NULL OR listens.listener_id != listens.track_owner_id)", time_period], :order => 'count_all DESC')
0
     find(popular.collect{|pop| pop.first}, :include => :user)
0
@@ -51,4 +53,31 @@ class Asset
0
       else 0.5
0
     end
0
   end
0
+
0
+ def self.monthly_chart
0
+ monthly_counts = []
0
+ sum_up_the_months(@@launch_date){|date, sum| monthly_counts << [sum, date]}
0
+ data = monthly_counts.collect(&:first)
0
+ labels = monthly_counts.collect(&:last)
0
+ chart = Gchart.line(:size => '500x150', :data => data, :background => 'e1e2e1', :axis_with_labels => 'r,x', :axis_labels => ["0|#{(data.max.to_f/2).round}|#{data.max}","#{labels.join('|')}"], :line_colors =>'cc3300', :custom => 'chbh=35,15' )
0
+ end
0
+
0
+
0
+ private
0
+
0
+ # iterate through the months
0
+ def self.sum_up_the_months(date = Time.now, &block)
0
+ sum = 0
0
+ while date < Time.now
0
+ result, label = monthly_sum_for(date)
0
+ sum = sum + result
0
+ yield label, sum
0
+ date += 1.month
0
+ end
0
+ end
0
+
0
+ def self.monthly_sum_for(date=Time.now, sum =0)
0
+ # [count, year_month_label]
0
+ [sum + self.count(:all, :conditions => ['created_at > ? AND created_at < ?',date.beginning_of_month, date.end_of_month]), "#{date.strftime('%b %y')}"]
0
+ end
0
 end
0
\ No newline at end of file
...
25
26
27
28
 
29
30
31
...
25
26
27
 
28
29
30
31
0
@@ -25,7 +25,7 @@ class Listen < ActiveRecord::Base
0
   end
0
   
0
   def self.source_chart
0
- data = self.count(:all, :group => :source, :order => 'count_all DESC', :limit => 8, :conditions => ['listens.created_at > ?',30.days.ago.at_midnight])
0
+ data = self.count(:all, :group => :source, :order => 'count_all DESC', :limit => 10, :conditions => ['listens.created_at > ?',30.days.ago.at_midnight])
0
     various = self.count(:all, :conditions => ['listens.created_at > ?',30.days.ago.at_midnight]) - data.collect(&:last).sum
0
     data << ['various other sources', various]
0
     Gchart.pie(:size => '500x125', :background => 'e1e2e1', :data => data.collect(&:last), :labels => data.collect{|d| CGI.escape(d.first.to_s)})
...
15
16
17
 
 
 
 
18
19
20
21
22
23
24
 
25
26
27
...
15
16
17
18
19
20
21
22
23
24
25
26
27
 
28
29
30
31
0
@@ -15,13 +15,17 @@
0
         <div class="description_panel panel no_border">
0
             <h3><%=h asset.name %></h3>
0
             <%= truncate((asset.description), 260) %>
0
+ <% if authorized_for(asset) && !asset.present?(:description) %>
0
+ <span class="hint"><%= link_to 'Add a description now',edit_user_track_path(asset.user, asset),:class => :hint %> to help listeners find your music</span>
0
+ <% end %>
0
+
0
         </div>
0
   
0
    <div class="stats_panel panel no_border">
0
    Uploaded <strong><%= time_ago_in_words asset.created_at %></strong> ago<br/>
0
    Listened to <strong><%= asset.listens_count %></strong> times<br/>
0
    <% if asset.comments.size > 0 %>
0
- Commented on <strong><%= pluralize asset.comments.size, 'times' %></strong><br/>
0
+ Commented on <strong><%= pluralize asset.comments.public.size, 'times' %></strong><br/>
0
    <% end %>
0
    <% if asset.favorites_count > 0 %>
0
      Favorited by <strong><%= pluralize asset.favorites_count, 'alonetoner' %></strong>
...
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
 
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
 
46
47
48
...
3
4
5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6
7
8
9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
11
12
13
0
@@ -3,46 +3,11 @@
0
   <%= error_messages_for :asset %>
0
 
0
   <% content_for :left do %>
0
- <div class="edit_track box" style="position:relative;">
0
- <h2 class="box">Editing "<%=h @asset.name %>"</h2>
0
-
0
- <%= link_to "delete track", destroy_user_track_path(@user, @asset), :id => 'delete_track_button', :class => 'confirm_before_delete delete button'%>
0
-
0
- <div class="static_content" style="position:relative;">
0
-
0
- <% form_for(:asset, :url => user_track_path(current_user, @asset), :html => { :method => :put }) do |f| %>
0
- The title of this track/song/piece
0
- <p> <%= f.text_field :title, :value => @asset.name %> </p>
0
- Tell everyone a story or describe this music for us
0
- <p> <%= f.text_area :description, :rows => 5, :cols => 50 %> </p>
0
- <!--<p><%#= f.text_area :lyrics, :rows => 20, :cols => 50%></p> -->
0
- </div>
0
- <div class="static_content">
0
- Have a youtube video of this song?<br/>
0
- <small>http://www.youtube.com/watch?v=</small><%= f.text_field :youtube_embed, :size => 15 %>
0
- </div>
0
- <div class="submit_wrapper static_content">
0
- <%= submit_tag "Update" %>
0
- </div>
0
- <% end %>
0
- </div>
0
+ <%= render :partial => 'edit' %>
0
   <% end %>
0
  
0
  <% content_for :right do %>
0
- <% if @descriptionless %>
0
- <h2 class="box">Other tracks that need your love</h2>
0
- <div class="box">
0
- <div class="static_content">
0
- Adding a description helps listeners find your music.<br/><br/>
0
- The following tracks of yours could use a description:<br/>
0
- <ul>
0
- <% @descriptionless.each do |track| %>
0
- <li><%= link_to "#{h track.name}", edit_user_track_path(@user, track.permalink)%> <small>(<%=track.created_at.to_date.to_s(:short)%></small>)</li>
0
- <% end %>
0
- </ul>
0
- </div>
0
- </div>
0
- <% end %>
0
+ <%= render :partial => 'descriptionless'%>
0
  <% end %>
0
  
0
  
...
41
42
43
44
 
45
46
47
...
41
42
43
 
44
45
46
47
0
@@ -41,7 +41,7 @@
0
   </div>
0
   <div class=" static_content">
0
 
0
- <strong>If you upload copyrighted music we will ban your account, your IP address and report you to the gerbils in tuxedos</strong><br/>
0
+ <strong><span style="red">If you upload copyrighted music we will ban your account, your IP address and report you to the gerbils in tuxedos<span></strong><br/>
0
     We support filesharing but please don't abuse us, or else.</br>
0
   </div>
0
   <div class=" static_content">
...
7
8
9
10
 
11
12
13
...
18
19
20
 
 
 
 
 
21
22
23
24
25
26
 
27
28
29
30
31
32
 
33
 
 
 
34
35
36
...
7
8
9
 
10
11
12
13
...
18
19
20
21
22
23
24
25
26
27
28
29
30
 
31
32
33
34
35
36
 
37
38
39
40
41
42
43
44
0
@@ -7,7 +7,7 @@
0
     .static_content
0
       %strong
0
         =Asset.count
0
- original tracks
0
+ original &amp; legally uploaded mp3s
0
       %br
0
       %strong
0
         =Asset.days
0
@@ -18,19 +18,27 @@
0
       gigabytes of ones and zeros
0
   .box
0
     %h2.box
0
+ Uploads per month
0
+ .static_content
0
+ =image_tag Asset.monthly_chart
0
+ .box
0
+ %h2.box
0
       Listens per day
0
     .static_content
0
       =image_tag Listen.last_30_days_chart
0
   .box
0
     %h2.box
0
- Monthly Listens since launch
0
+ Monthly Listens* since launch
0
     .static_content
0
       =image_tag Listen.monthly_chart
0
       %br
0
       %strong
0
         =Listen.monthly_listen_count_for[0]
0
- listens so far for
0
+ Listens so far for
0
       =Listen.monthly_listen_count_for[1]
0
+ %br
0
+ %small
0
+ * Please note that as of April-July 2008, alonetone began to filter out all hits by search engines & spiders
0
   .box
0
     %h2.box
0
       Where folks listen from
...
67
68
69
70
 
71
72
73
...
67
68
69
 
70
71
72
73
0
@@ -67,7 +67,7 @@ ActionController::Routing::Routes.draw do |map|
0
   map.resources :users, :controller => :users, :member => {:attach_pic => :post, :sudo => :any, :toggle_favorite => :any} do |user|
0
     user.resources :source_files, :path_prefix => ':login'
0
     # TODO: Confusing, because Tracks is also a model. Don't confuse this route, this is indeed for the Assets model
0
- user.resources :tracks, :controller => :assets, :member => {:share => :get, :destroy => :any}, :collection => {:latest => :get, :search => :post}, :path_prefix => ':login', :member_path => ':login/tracks/:id' do |track|
0
+ user.resources :tracks, :controller => :assets, :member => {:share => :get, :destroy => :any}, :collection => {:latest => :get, :search => :post, :mass_edit => :get}, :path_prefix => ':login', :member_path => ':login/tracks/:id' do |track|
0
       track.resources :comments
0
     end
0
    
...
383
384
385
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
386
387
388
...
649
650
651
 
 
 
652
653
654
...
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
...
682
683
684
685
686
687
688
689
690
0
@@ -383,6 +383,39 @@ CommentForm = $.klass(Remote.Form, {
0
     }
0
 });
0
 
0
+EditForm = $.klass(Remote.Form,{
0
+ initialize : function($super,options) {
0
+ this.submitButton = $('.comment_submit', this.element);
0
+ this.submitText = this.submitButton.val();
0
+ this.spinner = $('.small_spinner',this.element);
0
+ this.resultBox = $('.comment_waiting', this.element);
0
+ this.textarea = $('textarea', this.element);
0
+ $super();
0
+ },
0
+ beforeSend:function(){
0
+ this.spinner.show();
0
+ this.disable();
0
+ },
0
+ complete:function(){
0
+ this.spinner.hide();
0
+ this.enable();
0
+ },
0
+ success:function(){
0
+ this.resultBox.text('Saved, thanks!').fadeIn(100);
0
+ },
0
+ error: function(){
0
+ this.resultBox.text("Didn't work. Try again?").fadeIn(100);
0
+ },
0
+ disable:function(){
0
+ this.submitButton.attr('disabled','disabled').
0
+ val('saving...');
0
+ },
0
+ enable:function(){
0
+ this.submitButton.removeAttr('disabled').
0
+ val(this.submitText);
0
+ }
0
+});
0
+
0
 Track = $.klass({
0
   initialize: function() {
0
     this.playButton = $(".play-button",this.element);
0
@@ -649,6 +682,9 @@ jQuery(function($) {
0
   
0
   // facebox
0
   $('a[rel*=facebox]').facebox();
0
+
0
+ // mass editing (ajax)
0
+ $('#mass_edit .edit_track form').attach(EditForm);
0
 
0
 });
0
 
...
141
142
143
144
 
 
145
146
147
...
141
142
143
 
144
145
146
147
148
0
@@ -141,7 +141,8 @@ div.tabs,div.big_tabs
0
   .admin_panel
0
     :font-size 12px
0
   .description_panel
0
- :padding-top 0px
0
+ :padding-top 5px
0
+ :font-size 12px
0
     p
0
       :padding-right 30px
0
     
...
283
284
285
286
 
287
 
 
 
 
 
 
288
289
290
...
283
284
285
 
286
287
288
289
290
291
292
293
294
295
296
0
@@ -283,8 +283,14 @@ a.button
0
   a
0
     :text-decoration underline
0
 
0
-.static_content h3
0
+.static_content h3, .panel h3
0
   :font-weight bold
0
+ :margin-bottom 3px
0
+ :font-size 14px
0
+
0
+span.hint, .content a.hint, .content a.hint:visited
0
+ :font-size 12px
0
+ :color = !orange
0
   
0
 blockquote
0
   :border 1px solid

Comments

    No one has commented yet.