public
Description: Open source non-commercial music platform: http://alonetone.com
Homepage: http://alonetone.com
Clone URL: git://github.com/sudara/alonetone.git
Search Repo:
Show playlists without descriptions, add playlist sorting
sudara (author)
Mon May 12 13:10:02 -0700 2008
commit  10ee09c9e49e4feeb4ab6b3ccd8ffd3419d4f7ea
tree    26bdfb37ed4e419a4a85208c34287453c4f8e14e
parent  166780ad4cf12fb7deb771cbe4c50cec78efc7ff
...
1
2
3
4
 
5
6
7
8
9
10
 
 
11
12
13
...
31
32
33
 
 
 
 
 
 
 
 
 
 
 
 
34
35
36
...
1
2
3
 
4
5
6
7
8
 
 
9
10
11
12
13
...
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
0
@@ -1,13 +1,13 @@
0
 class PlaylistsController < ApplicationController
0
   
0
   before_filter :find_user
0
- before_filter :find_playlists, :except => [:index, :new, :create]
0
+ before_filter :find_playlists, :except => [:index, :new, :create, :sort]
0
   before_filter :login_required, :except => [:index, :show]
0
 
0
   before_filter :find_tracks, :only => [:show, :edit]
0
   
0
- rescue_from ActiveRecord::RecordNotFound, :with => :not_found
0
- rescue_from NoMethodError, :with => :user_not_found
0
+ #rescue_from ActiveRecord::RecordNotFound, :with => :not_found
0
+ #rescue_from NoMethodError, :with => :user_not_found
0
   
0
   # GET /playlists
0
   # GET /playlists.xml
0
@@ -31,6 +31,18 @@
0
     end
0
   end
0
 
0
+ def sort
0
+ respond_to do |format|
0
+ format.js do
0
+ params["playlist"].each_with_index do |id, position|
0
+ Playlist.update(id, :position => position)
0
+ end
0
+ render :nothing => true
0
+ end
0
+ format.html { @playlists = @user.playlists.include_private.find(:all) }
0
+ end
0
+ end
0
+
0
   # GET /playlists/1
0
   # GET /playlists/1.xml
0
   def show
...
45
46
47
 
 
 
48
49
50
51
52
53
54
55
56
57
58
59
60
...
130
131
132
 
 
 
 
133
134
135
136
137
...
45
46
47
48
49
50
51
52
53
54
55
56
 
 
 
57
58
59
60
...
130
131
132
133
134
135
136
137
 
138
139
140
0
@@ -45,15 +45,15 @@
0
         @favorites = Track.favorites.find_all_by_user_id(@user.id, :limit => 5)
0
         @comments = @user.comments.find_all_by_spam(false, :limit => 10)
0
       end
0
+ format.fbml do
0
+ @assets = @user.assets.find(:all)
0
+ end
0
       format.xml { @assets = @user.assets.find(:all, :order => 'created_at DESC')}
0
       format.rss { @assets = @user.assets.find(:all, :order => 'created_at DESC')}
0
       format.js do render :update do |page|
0
           page.replace 'user_latest', :partial => "latest"
0
         end
0
       end
0
- format.fbml do
0
- @assets = @user.assets.find(:all)
0
- end
0
     end
0
   end
0
 
0
0
@@ -130,8 +130,11 @@
0
       format.html do
0
         if @user.save
0
           flash[:ok] = "Sweet, updated"
0
+ redirect_to edit_user_path(@user)
0
+ else
0
+ flash[:error] = "Not so fast, young one"
0
+ render :action => :edit
0
         end
0
- redirect_to :back
0
       end
0
       format.js do
0
         @user.save ? (return head(:ok)) : (return head(:bad_request))
...
2
3
4
5
 
 
6
7
8
...
2
3
4
 
5
6
7
8
9
0
@@ -2,7 +2,8 @@
0
 require 'zip/zipfilesystem'
0
 class Playlist < ActiveRecord::Base
0
   belongs_to :user, :counter_cache => true
0
-
0
+ acts_as_list :scope => :user_id, :order => :position
0
+
0
   named_scope :mixes, {:conditions => ['is_mix = ?',true]}
0
   named_scope :albums, {:conditions => ['is_mix = ? AND is_favorite = ?',false, false]}
0
   named_scope :favorites, {:conditions => ['is_favorite = ?',true]}
...
10
11
12
13
 
14
15
16
...
49
50
51
52
 
53
54
55
...
10
11
12
 
13
14
15
16
...
49
50
51
 
52
53
54
55
0
@@ -10,7 +10,7 @@
0
   
0
   # Can create music
0
   has_many :assets, :dependent => :destroy, :order => 'created_at DESC'
0
- has_many :playlists, :dependent => :destroy, :order => 'playlists.created_at DESC'
0
+ has_many :playlists, :dependent => :destroy, :order => 'playlists.position'
0
   has_one :pic, :as => :picable
0
   has_many :comments, :dependent => :destroy, :order => 'created_at DESC'
0
   has_many :user_reports, :dependent => :destroy, :order => 'created_at DESC'
0
@@ -49,7 +49,7 @@
0
   validates_format_of :login, :with => Format::STRING, :message => ' must be lowercase and only made from numbers and letters'
0
   validates_length_of :login, :within => 3..40
0
   validates_length_of :display_name, :within => 3..50, :allow_blank => true
0
- validates_length_of :bio, :within => 0..200, :message => "can't be so long, sorry!", :on => :update
0
+ validates_length_of :bio, :within => 0..500, :message => "can't be empty (or longer than 600 characters)", :on => :update
0
   
0
   validates_format_of :identity_url, :with => /^https?:\/\//i, :allow_nil => true
0
   validates_format_of :itunes, :with => /^phobos.apple.com\/WebObjects\/MZStore.woa\/wa\/viewPodcast\?id=/i, :allow_blank => true, :message => 'link must be a link to the itunes store'
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
0
@@ -1 +1,15 @@
0
+<% notice_for('sort_playlists',"Sorting your playlists...") do %>
0
+ <ol>
0
+ <li>Simply Drag them bad boys around</li>
0
+ <li>Remember that the first 4 show more prominently on your home page!</li>
0
+ </ol>
0
+<% end %>
0
+
0
+<%= link_to '',sort_user_playlists_path(@user), :id => 'sort_url' %>
0
+
0
+<ul id="sort_playlists">
0
+ <%= render :partial => 'shared/playlist', :collection => @playlists %>
0
+</ul>
0
+
0
+<div class="clearfix"> </div>
...
1
 
2
3
4
 
5
6
7
 
...
 
1
2
3
 
4
5
6
 
7
0
@@ -1,8 +1,8 @@
0
-<li class="small_playlists">
0
+<% content_tag_for :li, playlist, :class=>'small_playlists' do %>
0
   <%= link_to(image_tag('jewel-case-125.png'), user_playlist_path(playlist.user.login, playlist), :class => 'jewel_case_125') %>
0
 
0
- <%= image_tag(playlist.cover(:large), :class => 'cover_125') %>
0
+ <%= image_tag(playlist.cover(:large), :class => 'cover_125') %>
0
   
0
   <%= link_to(h(playlist.title)+(playlist.present?(:year) ? " (#{playlist.year})" : ''), user_playlist_path(playlist.user.login, playlist), :class => 'small_playlist_title' ) %>
0
-</li>
0
+<% end %>
...
 
 
1
2
3
4
5
...
1
2
3
 
4
5
6
0
@@ -1,5 +1,6 @@
0
+<%= error_messages_for :user %>
0
+
0
 <% render(:layout => 'user') do %>
0
- <%= error_messages_for :user %>
0
   <% content_for :left do %>
0
   <div class="edit_profile box">
0
     <h2 class="box">Edit your profile</h2>
...
60
61
62
63
 
64
65
66
...
74
75
76
77
 
78
79
80
...
60
61
62
 
63
64
65
66
...
74
75
76
 
77
78
79
80
0
@@ -60,7 +60,7 @@
0
    # TODO - figure out a way to use :member_path with rails 2
0
    # http://dev.rubyonrails.org/changeset/8227
0
    # for now, i have to specify port to allow :permalink and :id to be sent at the same time
0
- user.resources :playlists, :collection => {:latest => :get}, :member=> {:set_playlist_title => :post, :set_playlist_description => :post, :attach_pic => :post, :remove_track => :any, :sort_tracks => :post, :add_track => :post, :destroy => :any},:path_prefix => ':login' do |playlist|
0
+ user.resources :playlists, :collection => {:latest => :get, :sort => :any}, :member=> {:set_playlist_title => :post, :set_playlist_description => :post, :attach_pic => :post, :remove_track => :any, :sort_tracks => :post, :add_track => :post, :destroy => :any},:path_prefix => ':login' do |playlist|
0
      playlist.resources :comments
0
    end
0
   end
0
@@ -74,7 +74,7 @@
0
   #map.connect ':controller/:action/:id'
0
   
0
   map.root :controller => 'assets', :action => 'latest'
0
- map.user_home ':login', :controller => 'users', :action => 'show'
0
+ map.user_home ':login', :controller => 'users', :action => 'show'
0
   map.user_feeds ':login.:format', :controller => 'users', :action => 'show'
0
   
0
 end
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
0
@@ -1 +1,17 @@
0
+class TweakPlaylists < ActiveRecord::Migration
0
+ def self.up
0
+ Playlist.find_all_by_description('').each do |playlist|
0
+ playlist.description = playlist.title
0
+ playlist.save
0
+ end
0
+
0
+ Playlist.find_all_by_private(nil).each do |playlist|
0
+ playlist.private = false
0
+ playlist.save
0
+ end
0
+ end
0
+
0
+ def self.down
0
+ end
0
+end
...
 
 
 
 
 
 
 
 
 
 
...
1
2
3
4
5
6
7
8
9
10
0
@@ -1 +1,11 @@
0
+class AddPositionToPlaylists < ActiveRecord::Migration
0
+ def self.up
0
+ add_column :playlists, :position, :integer
0
+ add_index :playlists, :position
0
+ end
0
+
0
+ def self.down
0
+ drop_column :playlits, :position
0
+ end
0
+end
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
0
@@ -1 +1,15 @@
0
+class SetPositionToReflectDate < ActiveRecord::Migration
0
+ def self.up
0
+ User.find(:all).each do |user|
0
+ if user.playlists.size > 0
0
+ user.playlists.find(:all, :order => 'created_at ASC').each do |playlist|
0
+ playlist.insert_at
0
+ end
0
+ end
0
+ end
0
+ end
0
+
0
+ def self.down
0
+ end
0
+end
...
606
607
608
 
 
 
 
 
 
 
 
 
 
 
 
 
609
...
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
0
@@ -606,5 +606,18 @@
0
   $('#single_track .comment_form form').attach(CommentForm);
0
   $('#single_track a.add_to_favorites').attach(FavoriteToggle);
0
 
0
+ // sort playlists
0
+ $('#sort_playlists').sortable({
0
+ revert: true,
0
+ scroll: true,
0
+ cursor: 'move',
0
+ scrollSensitivity: 100,
0
+ update: function(){
0
+ $.post($('#sort_url').attr('href'),
0
+ $.param({'authenticity_token':window.authenticityToken})+'&'+
0
+ $('#sort_playlists').sortable('serialize'))
0
+ }
0
+ });
0
+
0
 });
...
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
 
 
 
 
 
 
 
 
 
 
 
 
 
49
50
51
...
153
154
155
 
 
 
 
 
 
 
...
32
33
34
 
 
 
 
 
 
 
 
 
 
 
 
 
 
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
...
152
153
154
155
156
157
158
159
160
161
0
@@ -32,20 +32,19 @@
0
   :overflow hidden
0
   :margin 0 70px
0
   
0
- ul
0
- li.small_playlists
0
- :position relative
0
- :float left
0
- :width 146px
0
- :height 168px
0
- :margin-right 50px
0
- :margin-bottom 100px
0
- a.small_playlist_title
0
- :display block
0
- :text-align center
0
- :font-size = 12px
0
- :margin-left 1px
0
- :margin-top 10px
0
+li.small_playlists
0
+ :position relative
0
+ :float left
0
+ :width 146px
0
+ :height 168px
0
+ :margin-right 50px
0
+ :margin-bottom 100px
0
+ a.small_playlist_title
0
+ :display block
0
+ :text-align center
0
+ :font-size = 12px
0
+ :margin-left 1px
0
+ :margin-top 10px
0
        
0
 a.jewel_case_125
0
   :position absolute
0
@@ -153,4 +152,11 @@
0
     .asset, .track
0
       :width 420px
0
     :padding 0px 0 0 0
0
+
0
+#sort_playlists
0
+ :width 100%
0
+ :position relative
0
+ :height 1000px
0
+ li.small_playlists
0
+ :margin-bottom 20px
...
170
171
172
173
 
174
175
176
...
170
171
172
 
173
174
175
176
0
@@ -170,7 +170,7 @@
0
 a.hidden
0
   :display none
0
   
0
-div.fieldWithErrors input
0
+.fieldWithErrors input, .fieldWithErrors textarea
0
   :border = !orange 2px solid
0
   
0
 input.facebook

Comments

    No one has commented yet.