OSDN Git Service

index画面ができた
authorshimada <shimada.cake@gmail.com>
Sat, 15 May 2010 08:58:43 +0000 (17:58 +0900)
committershimada <shimada.cake@gmail.com>
Sat, 15 May 2010 08:58:43 +0000 (17:58 +0900)
app/controllers/songs_controller.rb
app/helpers/songs_helper.rb
app/views/song/index.html.erb [deleted file]
app/views/songs/index.html.erb [new file with mode: 0644]
config/routes.rb

index 6755560..5246677 100644 (file)
@@ -1,2 +1,9 @@
-class SongsController < ApplicationController
+class SongsController < BaseController
+def index
+end
+
+def new
+  @song = Song.new
+end
+
 end
index 75baad2..e3696c2 100644 (file)
@@ -1,2 +1,29 @@
 module SongsHelper
+  HIRAGANA = %w(
+    あ い う え お か き く け こ さ し す せ そ @
+    た ち つ て と な に ぬ ね の は ひ ふ へ ほ @
+    ま み む め も や    ゆ    よ ら り る れ ろ @
+    わ @
+  )
+  KATAKANA = %w(
+    ア イ ウ エ オ カ キ ク ケ コ サ シ ス セ ソ @
+    タ チ ツ テ ト ナ ニ ヌ ネ ノ ハ ヒ フ ヘ ホ @
+    マ ミ ム メ モ ヤ    ユ    ヨ ワ リ ル レ ロ @
+    ワ @
+  )
+  ROMAN = %w(
+    A B C D E F G H I J K L M N @
+    O P Q R S T U V W X Y Z
+  )
+  SENTINEL = '@'
+
+  def letter_links(kind)
+    kind.map do |char|
+      unless char == SENTINEL
+        link_to char, list_songs_path(:letter => char)
+      else
+        '<br />'
+      end
+    end.join " "
+  end
 end
diff --git a/app/views/song/index.html.erb b/app/views/song/index.html.erb
deleted file mode 100644 (file)
index 001239c..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-<% content_for :head do -%>
-  <title>Praise DATABASE</title>
-<% end -%>
-<h1 id="heading">Praise DATABASE</h1>
-
-<% form_for :search, :url => search_song_url do |f| -%>
-  <%= f.label :word, '検索(search)' %>
-  <%= f.text_field 'word' -%>
-  <%= f.submit 'search' %>
-<% end -%>
diff --git a/app/views/songs/index.html.erb b/app/views/songs/index.html.erb
new file mode 100644 (file)
index 0000000..fa4379e
--- /dev/null
@@ -0,0 +1,25 @@
+<% content_for :head do -%>
+  <title>Praise DATABASE</title>
+<% end -%>
+<h1 id="heading">Praise DATABASE</h1>
+
+<% form_for :search, :url => search_songs_path do |f| -%>
+  <%= f.label :word, '検索' %>
+  <%= f.text_field 'word' -%>
+  <%= f.submit 'search' %>
+<% end -%>
+
+<h2>歌いだしインデックス<br />
+First Letter Indexes</h2>
+
+<%= letter_links(SongsHelper::HIRAGANA) %>
+<%= letter_links(SongsHelper::KATAKANA) %>
+<%= letter_links(SongsHelper::ROMAN) %>
+
+<h2>操作<br />Operations</h2>
+
+<ul>
+  <li><%= link_to '新しい曲の追加 - Add a new song', new_song_path %></li>
+  <li><%= link_to '聖句検索 - Bible words' %></li>
+  <li><%= link_to 'メッセージレジュメ - Message summeries' %></li>
+</ul>
index d35527e..1ba78b2 100644 (file)
@@ -1,6 +1,6 @@
 ActionController::Routing::Routes.draw do |map|
   # The priority is based upon order of creation: first created -> highest priority.
-  map.resources :songs
+  map.resources :songs, :collection => { :search => [:get], :list => [:get] }
 
   # Sample of regular route:
   #   map.connect 'products/:id', :controller => 'catalog', :action => 'view'