public
Fork of sudara/alonetone
Description: alonetone - a damn fine musician's home. Upload mp3s, create playlists, track listens, get your widget on. (looking for dev help!)
Homepage: http://alonetone.com
Clone URL: git://github.com/taansen/alonetone.git
* individual track page enhancements
* link from each track to individual track page
* introduce 'hotness'
* fix a few bugglets
sudara (author)
Thu Mar 13 07:19:06 -0700 2008
commit  ef80289d5ab19d8d85b37fb6881d1f41502dd479
tree    a03ac04c3cca579d542f36e627d712bdb0677b28
parent  0af32347ae2fd0da54398c90afc78e6b28fb51cd
...
34
35
36
 
37
38
39
...
44
45
46
47
48
49
50
51
52
53
54
 
 
 
 
 
 
 
 
 
 
55
56
57
58
59
60
61
 
62
63
64
...
126
127
128
129
 
130
131
132
...
34
35
36
37
38
39
40
...
45
46
47
 
 
 
 
 
48
 
 
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
 
65
66
67
68
...
130
131
132
 
133
134
135
136
0
@@ -34,6 +34,7 @@ class AssetsController < ApplicationController
0
         @assets = [@asset]
0
         @listens = @asset.listens.find(:all)
0
         @comments = @asset.comments.find_all_by_spam(false)
0
+ @listeners = @asset.listeners.first(5)
0
       end
0
       format.mp3 do
0
         register_listen
0
@@ -44,21 +45,24 @@ class AssetsController < ApplicationController
0
 
0
   # aka home page
0
   def latest
0
- limit = (params[:latest] && params[:latest].to_i < 50) ? params[:latest] : 5
0
- @page_title = "Latest #{limit} uploaded mp3s on alonetone" if params[:latest]
0
- @assets = Asset.latest(limit)
0
- @popular = Asset.most_popular(limit)
0
- @playlists = Playlist.latest(6)
0
     respond_to do |wants|
0
- wants.html
0
- wants.rss
0
+ wants.html do
0
+ limit = (params[:latest] && params[:latest].to_i < 50) ? params[:latest] : 5
0
+ @page_title = "Latest #{limit} uploaded mp3s on alonetone" if params[:latest]
0
+ @assets = Asset.latest(limit)
0
+ @popular = Asset.find(:all, :limit => limit, :order => 'hotness DESC')
0
+ @playlists = Playlist.latest(6)
0
+ end
0
+ wants.rss do
0
+ @assets = Asset.latest(50)
0
+ end
0
     end
0
   end
0
   
0
   def top
0
     top = (params[:top] && params[:top].to_i < 50) ? params[:top] : 20
0
     @page_title = "Top #{top} tracks on alonetone"
0
- @popular = Asset.most_popular(top)
0
+ @popular = Asset.find(:all, :limit => top, :order => 'hotness DESC')
0
     respond_to do |wants|
0
       wants.html { render :action => 'latest'}
0
       wants.rss
0
@@ -126,7 +130,7 @@ class AssetsController < ApplicationController
0
     respond_to do |format|
0
       if @asset.update_attributes(params[:asset])
0
         flash[:ok] = 'Track updated!'
0
- format.html { redirect_to edit_user_track_url(current_user, @asset) }
0
+ format.html { redirect_to user_track_url(current_user, @asset) }
0
         format.xml { head :ok }
0
       else
0
         format.html { render :action => "edit" }
...
24
25
26
 
 
 
 
 
 
 
 
27
28
29
...
24
25
26
27
28
29
30
31
32
33
34
35
36
37
0
@@ -24,6 +24,14 @@ class CommentsController < ApplicationController
0
     end
0
   end
0
   
0
+
0
+ def destroy
0
+ @comment = Comment.find(params[:id])
0
+ redirect_to :back
0
+
0
+ end
0
+
0
+
0
   protected
0
   
0
   
...
44
45
46
47
 
48
49
50
...
44
45
46
 
47
48
49
50
0
@@ -44,7 +44,7 @@ class PlaylistsController < ApplicationController
0
   # GET /playlists/1/edit
0
   def edit
0
     # allow them to add their own assets
0
- @assets = @user.assets.paginate(:all, :limit => 10, :per_page => 10, :order => 'created_at', :page => params[:page])
0
+ @assets = @user.assets.paginate(:all, :limit => 10, :per_page => 10, :order => 'created_at DESC', :page => params[:page])
0
     @listens = @user.listens.find(:all, :limit => 10, :order => 'listens.created_at DESC')
0
     respond_to do |format|
0
       format.html
...
37
38
39
40
 
41
42
43
...
37
38
39
 
40
41
42
43
0
@@ -37,7 +37,7 @@ class UsersController < ApplicationController
0
   def show
0
     respond_to do |format|
0
       format.html do
0
- @page_title = @user.name + "'s music, albums, and playlists on alonetone"
0
+ @page_title = @user.name + " on alonetone - latest music & playlists"
0
         @tab = 'your_stuff' if current_user == @user
0
         @assets = @user.assets.paginate(:all, :per_page => 5, :page=>params[:page])
0
         @playlists = @user.playlists.find(:all,:conditions => [ "tracks_count > 0"])
...
52
53
54
55
 
56
57
58
...
52
53
54
 
55
56
57
58
0
@@ -52,7 +52,7 @@ module ApplicationHelper
0
   end
0
 
0
   def link_to_play(asset, referer=nil)
0
- link_to truncate(h(asset.name),25), formatted_user_track_path(asset.user.login, asset.permalink, :mp3), :id=>"play-#{asset.id}", :referer => referer
0
+ link_to truncate(h(asset.name),35), formatted_user_track_path(asset.user.login, asset.permalink, :mp3), :id=>"play-#{asset.id}", :referer => referer
0
   end
0
   
0
   def user_bar_for(user)
...
1
 
 
 
 
2
3
...
1
2
3
4
5
6
7
0
@@ -1,3 +1,7 @@
0
 module UsersHelper
0
+
0
+ def user_image_link(user, size = :large)
0
+ link_to(image_tag(user.avatar(size),:alt => "#{user.name} on alonetone"), user_home_path(user), :alt => "#{user.name} on alonetone")
0
+ end
0
 
0
 end
...
37
38
39
40
 
41
42
43
...
168
169
170
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
171
172
173
...
37
38
39
 
40
41
42
43
...
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
0
@@ -37,7 +37,7 @@ class Asset < ActiveRecord::Base
0
   belongs_to :user, :counter_cache => true
0
   
0
   has_many :listens, :dependent => :destroy
0
- has_many :listeners, :through => :listens
0
+ has_many :listeners, :through => :listens, :order => 'listens.created_at DESC', :uniq => true, :limit => 20
0
   
0
   has_many :comments, :as => :commentable, :dependent => :destroy, :order => 'created_at DESC'
0
   
0
@@ -168,6 +168,44 @@ class Asset < ActiveRecord::Base
0
     end
0
   end
0
   
0
+ def self.update_hotness
0
+ Asset.find(:all).each do |a|
0
+ a.update_attribute(:hotness, a.calculate_hotness)
0
+ end
0
+ end
0
+
0
+ def calculate_hotness
0
+ # hotness = listens not originating from own user within last 7 days * num of alonetoners who listened to it / age
0
+ ratio = (recent_listen_count.to_f * unique_listener_count.to_f) * age_ratio * listens_per_day * (comment.size + 1)
0
+ end
0
+
0
+ def recent_listen_count(from = 7.days.ago, to = 1.days.ago)
0
+ listens.count(:all, :conditions => ['listens.created_at > ? AND listens.created_at < ? AND listens.listener_id != ?',from, to, self.user_id])
0
+ end
0
+
0
+ def listens_per_day
0
+ listens.count(:all, :conditions => ['listens.listener_id != ?', self.user_id]).to_f / days_old
0
+ end
0
+
0
+ def unique_listener_count
0
+ listens.count(:listener_id, :distinct => true)
0
+ end
0
+
0
+ def days_old
0
+ ((Time.now - created_at) / 60 / 60 / 24 ).ceil
0
+ end
0
+
0
+ def age_ratio
0
+ case days_old
0
+ when 0..3 then 6.0
0
+ when 4..7 then 4.0
0
+ when 8..15 then 2.0
0
+ when 16..30 then 1.0
0
+ when 31..90 then 0.8
0
+ else 0.3
0
+ end
0
+ end
0
+
0
   def length
0
     self.class.formatted_time(self[:length])
0
   end
...
12
13
14
 
15
16
17
...
12
13
14
15
16
17
18
0
@@ -12,6 +12,7 @@
0
   <div class="listens"><%= asset.listens_count %></div>
0
   <div class="when"><%= time_ago_in_words asset.created_at %> ago</div>
0
   <div class="download-button button"><%= link_to '<i>download</i>', formatted_user_track_path(asset.user, asset.permalink, :mp3, :referer => 'download') %></div>
0
+ <div class="track-info"><%= link_to 'details', user_track_path(asset.user, asset.permalink) %></div>
0
   <div class="track-right">
0
     <% if authorized_for(asset) %>
0
       <div class="delete-button button <%= 'admin' if admin? %>" style="display:none;">
...
1
2
3
 
4
5
6
7
8
9
 
10
11
12
...
16
17
18
19
20
21
 
 
 
 
22
23
24
...
1
2
3
4
5
6
7
8
9
 
10
11
12
13
...
17
18
19
 
 
 
20
21
22
23
24
25
26
0
@@ -1,12 +1,13 @@
0
 <% render(:layout => 'users/user') do %>
0
   
0
   <div id="single_track">
0
+ <h2><%= @asset.name %></h2>
0
     <%= render :partial => 'assets/assets'%>
0
   </div>
0
   
0
   <div id="track details">
0
     <% if @asset.description && !@asset.description.empty? %>
0
- <h3>About this track</h3>
0
+ <h2 class="big">About this track</h2>
0
       <p><%= @asset.description %></p>
0
     <% end %>
0
     <% if @asset.youtube_embed && !@asset.youtube_embed.empty? %>
0
@@ -16,9 +17,10 @@
0
   
0
    <%= render :partial => 'shared/comments' if @comments && @comments.size > 0%>
0
   
0
-
0
- <%= @asset.name %> was uploaded by <%=@user.name %> on <%= @asset.created_at.to_date.to_s(:long) %>
0
-
0
+ <%= render :partial => 'users'%>
0
+
0
+ <div class="clear"> </div>
0
+ <%= render :partial => 'stats'%>
0
   
0
 <% end %>
0
 
...
9
10
11
 
 
12
13
14
...
9
10
11
12
13
14
15
16
0
@@ -9,6 +9,8 @@
0
     <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
0
     <meta name="verify-v1" content="aaIrlgAaz4LTgcMLni358eS3yFVofWVpOykHzegpXS4=" />
0
     <%= yield :css %>
0
+ <link rel="alternate" type="application/rss+xml" title="Latest uploaded mp3s on alonetone" href="/latest.rss"/>
0
+
0
     <%= javascript_include_tag 'prototype', 'effects', 'slider', 'dragdrop', 'controls','lowpro','soundmanager', 'application', :cache => true %>
0
     <!-- <script type="text/javascript" src="http://static.robotreplay.com/nitobi.replay.js"></script> -->
0
   </head>
...
34
35
36
37
 
38
39
40
 
41
42
43
...
34
35
36
 
37
38
39
 
40
41
42
43
0
@@ -34,10 +34,10 @@ xml.urlset "xmlns" => "http://www.google.com/schemas/sitemap/0.84" do
0
       xml.priority 0.6
0
     end if user.playlists_count > 0
0
     
0
- if user.assets.size > 0
0
+ if user.assets_count > 0
0
       user.assets.each do |asset|
0
         xml.url do
0
- xml.loc user_track_url(user, asset)
0
+ xml.loc user_track_url(user, asset.permalink)
0
           xml.lastmod w3c_date(asset.created_at)
0
           xml.changefreq 'weekly'
0
           xml.priority 0.5
...
10
11
12
13
14
15
 
16
17
18
...
10
11
12
 
13
 
14
15
16
17
0
@@ -10,9 +10,8 @@
0
   </div>
0
   
0
   <p class="comment_date">
0
-
0
     <%= time_ago_in_words(comment.created_at)%> ago<br/>
0
- said about the track <span class="comment_about"><%=h comment.commentable.name %></span><br/>
0
+ said about the track <span class="comment_about"><%= link_to h(comment.commentable.name), user_track_path(comment.commentable.user,comment.commentable) %></span><br/>
0
   </p>
0
   
0
   <p class="comment_body">
...
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
 
25
26
27
28
29
...
10
11
12
 
 
 
 
 
 
 
 
 
 
 
 
13
14
 
 
15
16
0
@@ -10,20 +10,7 @@
0
 
0
 <%= will_paginate @users %>
0
 
0
- <% @users.each do |user|-%>
0
- <% div_for(user, :class => 'user-index') do %>
0
- <%= link_to(image_tag(user.avatar(:large)), user_home_path(user)) %><br/>
0
-
0
- <%= link_to h(user.name), user_home_path(user), :class => (user.admin? ? "admin name" : 'name') %>
0
- <span class="details" style="display:none;">
0
- <%= link_to(pluralize(user.assets_count, 'track'), user_tracks_path(user)) if user.assets_count > 0 %><br/>
0
- <%= link_to(pluralize(user.playlists_count, 'playlist'), user_playlists_path(user)) if user.playlists_count > 0 %>
0
- <% if admin? %>
0
- <%= link_to 'delete', user_path(user), :method => :delete, :confirm => "This will delete this user entirely, including all #{user.assets_count} tracks and #{user.playlists_count} playlists" %>
0
- <% end %>
0
- </span>
0
+ <%= render :partial => 'shared/user', :collection => @users %>
0
 
0
- <% end %>
0
- <% end %>
0
 <div style="float:none;clear:both;"> </div>
0
 </div>
...
1
2
3
4
 
5
6
7
...
17
18
19
20
 
21
22
23
24
25
26
...
1
2
3
 
4
5
6
7
...
17
18
19
 
20
21
22
 
23
24
25
0
@@ -1,7 +1,7 @@
0
 xml.instruct! :xml, :version=>"1.0", :encoding=>"UTF-8"
0
 xml.rss "xmlns:itunes"=> "http://www.itunes.com/dtds/podcast-1.0.dtd", "version"=>"2.0" do
0
   xml.channel do
0
- xml.title "Latest music from #{@user.name} on alonetone.com"
0
+ xml.title "#{@user.name} on alonetone.com"
0
     
0
     xml.link user_home_url(@user)
0
     xml.description h(@user.bio)
0
@@ -17,10 +17,9 @@ xml.rss "xmlns:itunes"=> "http://www.itunes.com/dtds/podcast-1.0.dtd", "version"
0
     
0
     
0
     xml.itunes :author,   @user.name
0
- xml.itunes :subtitle, "Latest music from #{@user.name} on alonetone.com"
0
+ xml.itunes :subtitle, "#{@user.name} on alonetone.com"
0
     xml.itunes :summary,   @user.bio || "Latest music from #{@user.name} on alonetone.com"
0
     xml.itunes :keywords, 'independant free alonetone musician artist latest upcoming'
0
- xml.itunes :explicit, 'clean'
0
     xml.itunes :image, :href=>@user.avatar(:album)
0
     
0
     xml.itunes :owner do
...
221
222
223
 
 
 
224
225
226
...
264
265
266
 
 
 
 
 
 
 
267
268
269
...
221
222
223
224
225
226
227
228
229
...
267
268
269
270
271
272
273
274
275
276
277
278
279
0
@@ -221,6 +221,9 @@ a.delete
0
   margin-bottom: 25px
0
   float: none
0
   :clear both
0
+ a
0
+ :color = !dark_grey
0
+ :font-size = 12px
0
   .reporting_user, .comment_user
0
     :float left
0
     :margin 0px 10px 10px 0px
0
@@ -264,6 +267,13 @@ a.delete
0
       :line-height 16px
0
     .comment_body
0
       color = !dark_grey
0
+
0
+// recent listeners
0
+
0
+#recent_listeners
0
+ div
0
+ :float left
0
+ :margin 10px
0
 
0
 // user wrapper
0
 
...
198
199
200
201
202
 
 
 
203
204
205
...
236
237
238
239
 
240
241
 
 
242
243
244
...
281
282
283
 
 
 
 
 
 
 
284
285
286
...
369
370
371
 
 
372
373
374
375
 
376
377
378
...
380
381
382
383
 
384
385
 
386
387
388
...
427
428
429
430
 
431
432
433
434
435
 
 
 
 
 
 
436
437
 
438
439
440
...
486
487
488
489
 
490
491
492
...
198
199
200
 
 
201
202
203
204
205
206
...
237
238
239
 
240
241
242
243
244
245
246
247
...
284
285
286
287
288
289
290
291
292
293
294
295
296
...
379
380
381
382
383
384
385
386
 
387
388
389
390
...
392
393
394
 
395
396
 
397
398
399
400
...
439
440
441
 
442
443
444
445
446
447
448
449
450
451
452
453
454
 
455
456
457
458
...
504
505
506
 
507
508
509
510
0
@@ -198,8 +198,9 @@
0
       :overflow hidden
0
       :height 18px
0
     a
0
- :color = !grey
0
- :font-size 15px
0
+ :color = !dark_grey
0
+ :font-weight bold
0
+ :font-size 12px
0
       :padding-left 10px
0
       :text-decoration none
0
       :background-color transparent
0
@@ -236,9 +237,11 @@
0
       &.button.over
0
         :background-position -44px
0
     div.title
0
- :width 220px
0
+ :width 250px
0
       :overflow hidden
0
       :height 25px
0
+ :margin-top 12px
0
+ :line-height 2.2em
0
       a:hover
0
         :color = !orange
0
     div.time, div.listens
0
@@ -281,6 +284,13 @@
0
           :display none
0
         &:hover
0
           :background-position -44px
0
+ div.track-info
0
+ :width 50px
0
+ :margin-top 12px
0
+ a
0
+ :font-size 10px
0
+ :color = !grey
0
+ :text-decoration underline
0
     .track-right
0
       :float right
0
       :margin-top 0
0
@@ -369,10 +379,12 @@ img.cover_125
0
   margin-left: 17px
0
   margin-top: 4px
0
 
0
+
0
+// widths of all playlists and track collections
0
 #user_latest, #user_tracks, #user_playlists, #edit_playlist, #latest, #popular, #single_track
0
   :margin-top 30px
0
   :margin-right 90px
0
- :width 450px
0
+ :width 600px
0
   .playlist-wrapper
0
     .stash, .playlist
0
       div.artist
0
@@ -380,9 +392,9 @@ img.cover_125
0
 #edit_playlist
0
   :width 400px
0
 #user_listens
0
- :width 550px
0
+ :width 650px
0
 #user_track_plays
0
- :width 750px
0
+ :width 800px
0
   .playlist-wrapper
0
     #track_plays
0
       div.asset
0
@@ -427,14 +439,20 @@ img.cover_125
0
 
0
 // display date uploaded instead of # listens on the home page
0
 div#latest
0
- :width 650px
0
+ :width 700px
0
   .playlist-wrapper .stash
0
     div.when, div.artist
0
       :display block
0
     div.listens
0
       :display none
0
+div#single_track
0
+ .playlist-wrapper .stash
0
+ div.track-info
0
+ :display none
0
+ div.title
0
+ :width 250px
0
 div#popular
0
- :width 550px
0
+ :width 600px
0
   .playlist-wrapper .stash
0
     div.artist
0
       :display block
0
@@ -486,7 +504,7 @@ div#popular
0
   :height 16px
0
   :float left
0
 
0
-#user_home
0
+#user_home, #recent_listeners, #track_stats, #single_track
0
   h2
0
     :font-size 20px
0
     :font-weight bold
...
33
34
35
 
 
 
 
 
 
36
37
38
...
33
34
35
36
37
38
39
40
41
42
43
44
0
@@ -33,6 +33,12 @@ h2
0
   &.spacey
0
     :margin-bottom 2em
0
     :margin-top -0.7em
0
+ &.big
0
+ :font-size 20px
0
+ :font-weight bold
0
+ :color = !dark_grey
0
+ :margin-bottom 1em
0
+ :text-shadow none
0
 
0
 h3
0
   :font-size 1.3333333333333333em

Comments

    No one has commented yet.