public
Description: A Web-2.0 style, AJAX powered lyrics database using Ruby on Rails
Homepage: http://shanesveller.com/projects/
Clone URL: git://github.com/shanesveller/rails-lyrics.git
Multi-model adjustments
shanesveller (author)
Tue Jul 15 13:03:26 -0700 2008
commit  95edfd2be7f6c951c361651e132f5605afc7be5d
tree    45fe909b8f45c5990431f6c28453a90aea8f86b8
parent  e54ffcd0d34e04fc84181e17be07f43d809d8ef9
...
3
4
5
6
7
8
9
10
...
3
4
5
 
 
6
7
8
0
@@ -3,8 +3,6 @@
0
 
0
 class ApplicationController < ActionController::Base
0
   helper :all # include all helpers, all the time
0
-
0
- layout "yui"
0
 
0
   # See ActionController::RequestForgeryProtection for details
0
   # Uncomment the :secret if you're not using the cookie session store
...
9
10
11
12
 
13
14
15
16
 
17
18
19
...
9
10
11
 
12
13
14
15
 
16
17
18
19
0
@@ -9,11 +9,11 @@ class LyricsController < ApplicationController
0
   end
0
 
0
   def current_objects
0
- @current_objects ||= Lyric.paginate :page => params[:page], :order => "artist ASC, album ASC, track ASC, title ASC"
0
+ @current_objects ||= Lyric.paginate :page => params[:page], :order => "artist_id ASC, album ASC, track ASC, title ASC"
0
   end
0
   
0
   def blank
0
- @current_objects = Lyric.blank.paginate :page => params[:page], :order => "artist ASC, album ASC, track ASC, title ASC"
0
+ @current_objects = Lyric.blank.paginate :page => params[:page], :order => "artist_id ASC, album ASC, track ASC, title ASC"
0
     render :action => 'index'
0
   end
0
   
...
 
 
1
2
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
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
...
1
2
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
0
@@ -1,28 +1,31 @@
0
+!!!
0
+
0
 %html
0
   %head
0
- %title Lyrics You Love
0
- = stylesheet_link_tag "lyl"
0
- %body
0
- #header
0
- %h1 LyricsYouLove
0
- %h2 Say something meaningful.
0
+ %title LyricsYouLove
0
+ = stylesheet_link_tag "reset-fonts-grids", "lyl"
0
   
0
- #topbar
0
- - if @user
0
- %p= "Welcome back, #{@user.login.capitalize}!"
0
-
0
- #sidebar
0
- %ul
0
- - if !@user
0
- %li= link_to "Sign In", :controller => 'sessions', :action => 'new'
0
- %li= link_to "Sign Up", :controller => 'users', :action => 'new'
0
- - if @user
0
- %li= link_to "Sign Out", :controller => 'sessions', :action => 'destroy'
0
-
0
-
0
- #content
0
- = yield
0
-
0
- #footer
0
- %p All lyrics are copyright their respective artists and are presented here for educational and reference purposes only.
0
- %p Site design and code are copyright (C) Shane Sveller 2008
0
+ #body
0
+ #doc4.yui-t1
0
+ #hd
0
+ %h1= link_to "LyricsYouLove", "/"
0
+ %h4 Say something meaningful.
0
+
0
+ #bd
0
+ #yui-main
0
+ .yui-b
0
+ .yui-ge
0
+ %div{ :class => "first yui-u" }
0
+ = yield
0
+
0
+ .yui-u
0
+ = yield :sidebar
0
+
0
+ .yui-b
0
+ #user= render :partial => 'application/user'
0
+ #search= render :partial => 'application/search'
0
+ = yield :navigation
0
+ - if @user
0
+ #admin= render :partial => 'application/admin'
0
+
0
+ #ft All lyrics are copyright their respective artist and are presented here for reference only.
...
9
10
11
12
 
 
 
 
 
 
 
13
14
15
...
21
22
23
24
25
26
27
...
9
10
11
 
12
13
14
15
16
17
18
19
20
21
...
27
28
29
 
30
31
32
0
@@ -9,7 +9,13 @@
0
 #
0
 # It's strongly recommended to check this file into your version control system.
0
 
0
-ActiveRecord::Schema.define(:version => 20080714190430) do
0
+ActiveRecord::Schema.define(:version => 20080715193737) do
0
+
0
+ create_table "albums", :force => true do |t|
0
+ t.string "title"
0
+ t.integer "year", :limit => 11
0
+ t.integer "artist_id", :limit => 11
0
+ end
0
 
0
   create_table "artists", :force => true do |t|
0
     t.string "name"
0
@@ -21,7 +27,6 @@ ActiveRecord::Schema.define(:version => 20080714190430) do
0
 
0
   create_table "lyrics", :force => true do |t|
0
     t.string "title"
0
- t.string "artist"
0
     t.string "album"
0
     t.integer "year", :limit => 11
0
     t.integer "track", :limit => 11
...
10
11
12
13
 
14
15
16
...
67
68
69
70
 
 
 
 
 
 
71
72
73
...
10
11
12
 
13
14
15
16
...
67
68
69
 
70
71
72
73
74
75
76
77
78
0
@@ -10,7 +10,7 @@ namespace :import do
0
   desc "Translate a raw iTunes XML into a more concise (and much smaller) format"
0
   task :xslt do
0
     xslt = XML::XSLT.new()
0
- xslt.xml = "db/xml/shane.xml"
0
+ xslt.xml = "db/xml/sample.xml" # CHANGEME
0
     xslt.xsl = "db/xslt/itunes3.xsl"
0
     xslt.save("db/output/shane.xml")
0
   end
0
@@ -67,7 +67,12 @@ namespace :import do
0
       title = file.split("/")[-1]
0
       title = title[0, title.length - 4]
0
       
0
- song = Lyric.find_or_initialize_by_artist_and_title(artist,title)
0
+ art = Artist.find_by_name(artist)
0
+ if !art
0
+ puts "Skipping #{title} by #{artist}"
0
+ next
0
+ end
0
+ song = Lyric.find_or_initialize_by_artist_id_and_title(art.id,title)
0
       if song.body.nil? || song.body.empty?
0
         f = File.new(file)
0
         5.times { f.gets }

Comments

    No one has commented yet.