• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Commit MetaInfo

Revisión3b0ded922228b54a5263ea7ed81c569f054f19a7 (tree)
Tiempo2013-04-07 12:28:37
AutorSHIMADA Keiki <shimada.cake@gmai...>
CommiterSHIMADA Keiki

Log Message

Merge remote branch 'origin/master'

Cambiar Resumen

Diferencia incremental

--- a/Gemfile
+++ b/Gemfile
@@ -1,7 +1,7 @@
11 source 'https://rubygems.org'
22
33
4-gem 'rails', '3.2.12'
4+gem 'rails', '3.2.13'
55
66 # Bundle edge Rails instead:
77 # gem 'rails', :git => 'git://github.com/rails/rails.git'
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -1,12 +1,12 @@
11 GEM
22 remote: https://rubygems.org/
33 specs:
4- actionmailer (3.2.12)
5- actionpack (= 3.2.12)
6- mail (~> 2.4.4)
7- actionpack (3.2.12)
8- activemodel (= 3.2.12)
9- activesupport (= 3.2.12)
4+ actionmailer (3.2.13)
5+ actionpack (= 3.2.13)
6+ mail (~> 2.5.3)
7+ actionpack (3.2.13)
8+ activemodel (= 3.2.13)
9+ activesupport (= 3.2.13)
1010 builder (~> 3.0.0)
1111 erubis (~> 2.7.0)
1212 journey (~> 1.0.4)
@@ -14,19 +14,19 @@ GEM
1414 rack-cache (~> 1.2)
1515 rack-test (~> 0.6.1)
1616 sprockets (~> 2.2.1)
17- activemodel (3.2.12)
18- activesupport (= 3.2.12)
17+ activemodel (3.2.13)
18+ activesupport (= 3.2.13)
1919 builder (~> 3.0.0)
20- activerecord (3.2.12)
21- activemodel (= 3.2.12)
22- activesupport (= 3.2.12)
20+ activerecord (3.2.13)
21+ activemodel (= 3.2.13)
22+ activesupport (= 3.2.13)
2323 arel (~> 3.0.2)
2424 tzinfo (~> 0.3.29)
25- activeresource (3.2.12)
26- activemodel (= 3.2.12)
27- activesupport (= 3.2.12)
28- activesupport (3.2.12)
29- i18n (~> 0.6)
25+ activeresource (3.2.13)
26+ activemodel (= 3.2.13)
27+ activesupport (= 3.2.13)
28+ activesupport (3.2.13)
29+ i18n (= 0.6.1)
3030 multi_json (~> 1.0)
3131 acts_as_paranoid (0.4.1)
3232 activerecord (~> 3.2)
@@ -57,7 +57,7 @@ GEM
5757 kaminari (0.14.1)
5858 actionpack (>= 3.0.0)
5959 activesupport (>= 3.0.0)
60- mail (2.4.4)
60+ mail (2.5.3)
6161 i18n (>= 0.4.0)
6262 mime-types (~> 1.16)
6363 treetop (~> 1.4.8)
@@ -69,8 +69,8 @@ GEM
6969 nokogiri (~> 1.4)
7070 ntlm-http (~> 0.1, >= 0.1.1)
7171 webrobots (~> 0.0, >= 0.0.9)
72- mime-types (1.21)
73- multi_json (1.6.1)
72+ mime-types (1.22)
73+ multi_json (1.7.2)
7474 mysql2 (0.3.11)
7575 net-http-digest_auth (1.2.1)
7676 net-http-persistent (2.8)
@@ -84,23 +84,23 @@ GEM
8484 rack
8585 rack-test (0.6.2)
8686 rack (>= 1.0)
87- rails (3.2.12)
88- actionmailer (= 3.2.12)
89- actionpack (= 3.2.12)
90- activerecord (= 3.2.12)
91- activeresource (= 3.2.12)
92- activesupport (= 3.2.12)
87+ rails (3.2.13)
88+ actionmailer (= 3.2.13)
89+ actionpack (= 3.2.13)
90+ activerecord (= 3.2.13)
91+ activeresource (= 3.2.13)
92+ activesupport (= 3.2.13)
9393 bundler (~> 1.0)
94- railties (= 3.2.12)
95- railties (3.2.12)
96- actionpack (= 3.2.12)
97- activesupport (= 3.2.12)
94+ railties (= 3.2.13)
95+ railties (3.2.13)
96+ actionpack (= 3.2.13)
97+ activesupport (= 3.2.13)
9898 rack-ssl (~> 1.3.2)
9999 rake (>= 0.8.7)
100100 rdoc (~> 3.4)
101101 thor (>= 0.14.6, < 2.0)
102- rake (10.0.3)
103- rdoc (3.12.1)
102+ rake (10.0.4)
103+ rdoc (3.12.2)
104104 json (~> 1.4)
105105 sass (3.2.6)
106106 sass-rails (3.2.6)
@@ -114,12 +114,12 @@ GEM
114114 tilt (~> 1.1, != 1.3.0)
115115 sqlite3 (1.3.7)
116116 test-unit (2.5.4)
117- thor (0.17.0)
118- tilt (1.3.3)
117+ thor (0.18.1)
118+ tilt (1.3.6)
119119 treetop (1.4.12)
120120 polyglot
121121 polyglot (>= 0.3.1)
122- tzinfo (0.3.35)
122+ tzinfo (0.3.37)
123123 uglifier (1.3.0)
124124 execjs (>= 0.3.0)
125125 multi_json (~> 1.0, >= 1.0.2)
@@ -138,7 +138,7 @@ DEPENDENCIES
138138 jquery-rails
139139 kaminari
140140 mysql2
141- rails (= 3.2.12)
141+ rails (= 3.2.13)
142142 sass-rails (~> 3.2.3)
143143 sqlite3
144144 test-unit
--- a/app/assets/javascripts/application.js
+++ b/app/assets/javascripts/application.js
@@ -13,4 +13,3 @@
1313 //= require jquery
1414 //= require jquery_ujs
1515 //= require jquery-ui
16-//= require_tree .
--- /dev/null
+++ b/app/assets/javascripts/common.js.coffee
@@ -0,0 +1,49 @@
1+@resize = (e) ->
2+ # フォントサイズを初期化する
3+ e.style.fontSize = '72px'
4+ # 領域のサイズとdivのサイズの割合を求める
5+ widthGap = e.clientWidth / e.scrollWidth
6+ heightGap = e.clientHeight / e.scrollHeight
7+ # 拡大率は縦横ではみ出しが大きい方に合わせる
8+ gapRatio = Math.min(widthGap, heightGap)
9+ # サイズを変更する
10+ fontSize = e.style.fontSize
11+ newFontSize = parseInt(parseInt(fontSize) * gapRatio)
12+ e.style.fontSize = newFontSize + 'px'
13+
14+wnd = null
15+target = 'projector'
16+
17+get_detail_window = ->
18+ if !wnd || !wnd.location
19+ wnd = window.open('', target)
20+ wnd
21+
22+current = 0
23+
24+# 子ウィンドウの歌詞を切り替える
25+@change_remote = (idx, url) ->
26+ detail_window = get_detail_window()
27+
28+ # 指定のURLにいなければ移動
29+ if url isnt detail_window.location.href
30+ detail_window.location = url
31+
32+ # 表示切り替えを指示
33+ detail_window.change(idx)
34+ current = idx
35+
36+@prev_remote = (url) ->
37+ return false if current <= 0
38+ current--
39+ change_remote(current, url)
40+ $('#change-button-'+ current).effect( 'highlight', '', 200 )
41+ false
42+
43+@next_remote = (url) ->
44+ return false if current >= $('.change-button').length - 1
45+ current++
46+ change_remote(current, url)
47+ $('#change-button-'+ current).effect( 'highlight', '', 200 )
48+ false
49+
--- /dev/null
+++ b/app/assets/javascripts/slides.js.coffee
@@ -0,0 +1,33 @@
1+# Place all the behaviors and hooks related to the matching controller here.
2+# All this logic will automatically be available in application.js.
3+# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
4+
5+pages = -> $('.page')
6+current = 0
7+
8+fadeOut = ->
9+ $(pages()[current]).fadeOut(200)
10+
11+fadeIn = ->
12+ $(pages()[current]).fadeIn(200)
13+
14+@change = (idx) ->
15+ fadeOut()
16+ current = idx
17+ fadeIn()
18+ resize(pages()[current])
19+
20+@prev = ->
21+ return false if current <= 0
22+ fadeOut()
23+ current--
24+ fadeIn()
25+ false
26+
27+@next = ->
28+ return false if current >= pages().length - 1
29+ fadeOut()
30+ current++
31+ fadeIn()
32+ resize(pages()[current])
33+ false
--- a/app/assets/javascripts/songs.js.coffee
+++ b/app/assets/javascripts/songs.js.coffee
@@ -2,51 +2,34 @@
22 # All this logic will automatically be available in application.js.
33 # You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
44
5-
6-@resize = (e) ->
7- # フォントサイズを初期化する
8- e.style.fontSize = '72px'
9- # 領域のサイズとdivのサイズの割合を求める
10- widthGap = e.clientWidth / e.scrollWidth
11- heightGap = e.clientHeight / e.scrollHeight
12- # 拡大率は縦横ではみ出しが大きい方に合わせる
13- gapRatio = Math.min(widthGap, heightGap)
14- # サイズを変更する
15- fontSize = e.style.fontSize
16- newFontSize = parseInt(parseInt(fontSize) * gapRatio)
17- e.style.fontSize = newFontSize + 'px'
18-
19-make_window_handler = (target) ->
20- wnd = null
21- () ->
22- if !wnd || !wnd.location
23- wnd = window.open('', target)
24- wnd
25-
26-get_detail_window = make_window_handler('projector')
27-
28-# 子ウィンドウの歌詞を切り替える
29-@change_remote = (idx, url) ->
30- detail_window = get_detail_window()
31-
32- # 指定のURLにいなければ移動
33- if url isnt detail_window.location.href
34- detail_window.location = url
35-
36- # 表示切り替えを指示
37- detail_window.change(idx)
38-
39-
40-#
41-# 子ウィンドウ側で呼び出される処理
42-#
435 phrases = () -> $('.song')
446 current = 0
457
8+fadeOut = ->
9+ $(phrases()[current]).fadeOut(200)
10+
11+fadeIn = ->
12+ $(phrases()[current]).fadeIn(200)
13+
4614 # 指定された番号の歌詞に切り替える
4715 @change = (idx) ->
48- phrases()[current].style.display = 'none'
16+ fadeOut()
4917 current = idx
50- phrases()[current].style.display = 'block'
18+ fadeIn()
5119 resize(phrases()[current])
5220
21+@prev = ->
22+ return false if current <= 0
23+ fadeOut()
24+ current--
25+ fadeIn()
26+ resize(phrases()[current])
27+ false
28+
29+@next = ->
30+ return false if current >= phrases().length - 1
31+ fadeOut()
32+ current++
33+ fadeIn()
34+ resize(phrases()[current])
35+ false
\ No newline at end of file
--- /dev/null
+++ b/app/assets/stylesheets/slides.css.scss
@@ -0,0 +1,25 @@
1+// Place all the styles related to the Slides controller here.
2+// They will automatically be included in application.css.
3+// You can use Sass (SCSS) here: http://sass-lang.com/
4+
5+#thumbnail-area {
6+ margin: 10px;
7+ width: 420px;
8+ float: left;
9+ font-size: 12px;
10+}
11+
12+.thumbnail {
13+ margin: 10px;
14+ padding: 3px;
15+ width: 400px;
16+ width: 300px;
17+ border: 1px dashed white;
18+}
19+
20+.page {
21+ margin: 0;
22+ font-size: 36px;
23+ width: 1000px;
24+ height: 720px;
25+}
--- /dev/null
+++ b/app/controllers/slides_controller.rb
@@ -0,0 +1,108 @@
1+class SlidesController < ApplicationController
2+ # GET /slides
3+ # GET /slides.json
4+ def index
5+ @slide_search_form = SlideSearchForm.new(params[:slide_search_form])
6+ @recents = Slide.recents
7+
8+ respond_to do |format|
9+ format.html # index.html.erb
10+ format.json { render json: @slides }
11+ end
12+ end
13+
14+ def list
15+ @slides = Slide.order('id').page(params[:page])
16+
17+ respond_to do |format|
18+ format.html # index.html.erb
19+ format.json { render json: @slides }
20+ end
21+ end
22+
23+ # GET /slides/1
24+ # GET /slides/1.json
25+ def show
26+ @slide = Slide.find(params[:id])
27+
28+ respond_to do |format|
29+ format.html # show.html.erb
30+ format.json { render json: @slide }
31+ end
32+ end
33+
34+ # GET /slides/1/detail
35+ def detail
36+ @slide = Slide.find(params[:id])
37+
38+ respond_to do |format|
39+ format.html # show.html.erb
40+ format.json { render json: @slide }
41+ end
42+ end
43+
44+ # GET /slides/new
45+ # GET /slides/new.json
46+ def new
47+ @slide = Slide.new
48+
49+ respond_to do |format|
50+ format.html # new.html.erb
51+ format.json { render json: @slide }
52+ end
53+ end
54+
55+ # GET /slides/1/edit
56+ def edit
57+ @slide = Slide.find(params[:id])
58+ end
59+
60+ # POST /slides
61+ # POST /slides.json
62+ def create
63+ @slide = Slide.new(params[:slide])
64+
65+ respond_to do |format|
66+ if @slide.save
67+ format.html { redirect_to @slide, notice: 'Slide was successfully created.' }
68+ format.json { render json: @slide, status: :created, location: @slide }
69+ else
70+ format.html { render action: "new" }
71+ format.json { render json: @slide.errors, status: :unprocessable_entity }
72+ end
73+ end
74+ end
75+
76+ # PUT /slides/1
77+ # PUT /slides/1.json
78+ def update
79+ @slide = Slide.find(params[:id])
80+
81+ respond_to do |format|
82+ if @slide.update_attributes(params[:slide])
83+ format.html { redirect_to @slide, notice: 'Slide was successfully updated.' }
84+ format.json { head :no_content }
85+ else
86+ format.html { render action: "edit" }
87+ format.json { render json: @slide.errors, status: :unprocessable_entity }
88+ end
89+ end
90+ end
91+
92+ # DELETE /slides/1
93+ # DELETE /slides/1.json
94+ def destroy
95+ @slide = Slide.find(params[:id])
96+ @slide.destroy
97+
98+ respond_to do |format|
99+ format.html { redirect_to slides_url }
100+ format.json { head :no_content }
101+ end
102+ end
103+
104+ def search
105+ @slide_search_form = SlideSearchForm.new(params[:slide_search_form])
106+ @slides = @slide_search_form.search.page(params[:page])
107+ end
108+end
--- a/app/controllers/songs_controller.rb
+++ b/app/controllers/songs_controller.rb
@@ -87,7 +87,7 @@ class SongsController < ApplicationController
8787 Song.transaction do
8888 @song.attributes = params[:song]
8989 @song.romanize! if params[:button] == 'roman'
90- @song.update_words_for_search
90+ @song.update_words_for_search!
9191 is_saved = @song.save
9292 end
9393
@@ -116,10 +116,6 @@ class SongsController < ApplicationController
116116
117117 def search
118118 @song_search_form = SongSearchForm.new(params[:song_search_form])
119- if @song_search_form.q.present?
120- @songs = @song_search_form.search.page(params[:page])
121- else
122- @songs = []
123- end
119+ @songs = @song_search_form.search.page(params[:page])
124120 end
125121 end
--- /dev/null
+++ b/app/helpers/slides_helper.rb
@@ -0,0 +1,2 @@
1+module SlidesHelper
2+end
--- /dev/null
+++ b/app/models/slide.rb
@@ -0,0 +1,20 @@
1+class Slide < ActiveRecord::Base
2+ acts_as_paranoid
3+ attr_accessible :author, :body, :deleted_at, :title
4+
5+ def pages
6+ normalize_eol(body.to_s).split(/\n{4,}/)
7+ end
8+
9+ def outline
10+ pages.map{ |page| page.gsub(/\n.*/, '') }
11+ end
12+
13+ def self.recents
14+ self.order('updated_at DESC').limit(10)
15+ end
16+
17+ def normalize_eol(str)
18+ str.gsub(/\r\n/,"\n").gsub(/\r/, "\n")
19+ end
20+end
--- /dev/null
+++ b/app/models/slide_search_form.rb
@@ -0,0 +1,20 @@
1+class SlideSearchForm
2+ extend ActiveModel::Naming
3+ include ActiveModel::Conversion
4+
5+ attr_accessor :q
6+
7+ def initialize(params)
8+ if params && params.has_key?(:q)
9+ self.q = params[:q]
10+ end
11+ end
12+
13+ def search
14+ slides = Slide.arel_table
15+ Slide.where(slides[:body].matches("%#{q}%"))
16+ end
17+
18+ private
19+ def persisted?; false end
20+end
\ No newline at end of file
--- a/app/models/song.rb
+++ b/app/models/song.rb
@@ -35,7 +35,7 @@ class Song < ActiveRecord::Base
3535 kananize(words)
3636 end
3737
38- def update_words_for_search
38+ def update_words_for_search!
3939 self[:words_for_search] = ruby_trim(kanji + kana)
4040 end
4141
--- a/app/views/layouts/application.html.erb
+++ b/app/views/layouts/application.html.erb
@@ -4,6 +4,8 @@
44 <title><%=h yield(:title) %></title>
55 <%= stylesheet_link_tag "application", :media => "all" %>
66 <%= javascript_include_tag "application" %>
7+ <%= javascript_include_tag "common" %>
8+ <%= javascript_include_tag params[:controller] %>
79 <%= csrf_meta_tags %>
810 <%= yield :header %>
911 </head>
--- /dev/null
+++ b/app/views/slides/_form.html.erb
@@ -0,0 +1,29 @@
1+<%= form_for(@slide) do |f| %>
2+ <% if @slide.errors.any? %>
3+ <div id="error_explanation">
4+ <h2><%= pluralize(@slide.errors.count, "error") %> prohibited this slide from being saved:</h2>
5+
6+ <ul>
7+ <% @slide.errors.full_messages.each do |msg| %>
8+ <li><%= msg %></li>
9+ <% end %>
10+ </ul>
11+ </div>
12+ <% end %>
13+
14+ <div class="field">
15+ <%= f.label :title %><br />
16+ <%= f.text_field :title %>
17+ </div>
18+ <div class="field">
19+ <%= f.label :body %><br />
20+ <%= f.text_area :body %>
21+ </div>
22+ <div class="field">
23+ <%= f.label :author %><br />
24+ <%= f.text_field :author %>
25+ </div>
26+ <div class="actions">
27+ <%= f.submit %>
28+ </div>
29+<% end %>
--- /dev/null
+++ b/app/views/slides/_list.html.erb
@@ -0,0 +1,23 @@
1+<%= paginate @slides %>
2+<table>
3+ <tr>
4+ <th>Id</th>
5+ <th>Title</th>
6+ <th>Last update</th>
7+ <th></th>
8+ <th></th>
9+ <th></th>
10+ </tr>
11+
12+ <% @slides.each do |slide| %>
13+ <tr>
14+ <td><%= slide.id %></td>
15+ <td><%= link_to slide.title, slide %></td>
16+ <td><%= slide.updated_at %></td>
17+ <td><%= link_to 'Show', slide %></td>
18+ <td><%= link_to 'Edit', edit_slide_path(slide) %></td>
19+ <td><%= link_to 'Destroy', slide, method: :delete, data: { confirm: 'Are you sure?' } %></td>
20+ </tr>
21+ <% end %>
22+</table>
23+<%= paginate @slides %>
--- /dev/null
+++ b/app/views/slides/detail.html.erb
@@ -0,0 +1,18 @@
1+<%- title @slide.title -%>
2+
3+<%- @slide.pages.each_with_index do |page, idx| -%>
4+ <%- hidden_class = idx > 0 ? 'hidden' : '' -%>
5+ <pre id="<%= 'p' + idx.to_s %>" class="page <%= hidden_class %>"><%= page %></pre>
6+<%- end -%>
7+
8+<script type="text/javascript">
9+ resize($('#p0')[0]);
10+
11+ $(document).keydown(function(event) {
12+ if (event.keyCode == 38) {
13+ return prev();
14+ } else if (event.keyCode == 40) {
15+ return next();
16+ }
17+ });
18+</script>
--- /dev/null
+++ b/app/views/slides/edit.html.erb
@@ -0,0 +1,6 @@
1+<h1>Editing slide</h1>
2+
3+<%= render 'form' %>
4+
5+<%= link_to 'Show', @slide %> |
6+<%= link_to 'Back', slides_path %>
--- /dev/null
+++ b/app/views/slides/index.html.erb
@@ -0,0 +1,28 @@
1+<%- title -%>
2+<h1>メッセージスライド</h1>
3+
4+<%= form_for @slide_search_form, url: search_slides_path, html: {method: :get} do |f| %>
5+<p>検索
6+ <%= f.text_field :q, :size => '30' %>
7+ <%= f.submit 'search' %>
8+</p>
9+<%- end -%>
10+
11+<p><%= link_to '全スライド一覧', list_slides_path %></p>
12+
13+<h2>最近の更新(Recent changes)</h2>
14+<%- if @recents.blank? -%>
15+ <p>更新はありません</p>
16+<%- end -%>
17+<ul>
18+<%- @recents.each do |slide| -%>
19+ <li><%= link_to(slide.title, slide_path(slide)) %></li>
20+<%- end -%>
21+</ul>
22+
23+<h2>menu</h2>
24+<ul>
25+ <li><%= link_to '新しいスライドの追加 - Add new Slides', new_slide_path %></li>
26+ <li><%= link_to '賛美歌詞表示 - Praise songs', songs_path %></li>
27+ <li><%= link_to '聖句検索 - Bible words', books_path %></li>
28+</ul>
--- /dev/null
+++ b/app/views/slides/list.html.erb
@@ -0,0 +1,2 @@
1+<%- title -%>
2+<%= render :partial => 'list' %>
\ No newline at end of file
--- /dev/null
+++ b/app/views/slides/new.html.erb
@@ -0,0 +1,5 @@
1+<h1>New slide</h1>
2+
3+<%= render 'form' %>
4+
5+<%= link_to 'Back', slides_path %>
--- /dev/null
+++ b/app/views/slides/search.html.erb
@@ -0,0 +1,10 @@
1+<%- title -%>
2+<%= form_for @slide_search_form, url: search_slides_path, html: {:method => :get} do |f| -%>
3+ <p>検索
4+ <%= f.text_field :q, :size => '30' %>
5+ <%= f.submit 'search' %>
6+ </p>
7+<%- end -%>
8+<%= render :partial => 'list' %>
9+
10+<%= link_to 'Back', slides_path %>
--- /dev/null
+++ b/app/views/slides/show.html.erb
@@ -0,0 +1,34 @@
1+<p id="notice"><%= notice %></p>
2+
3+<div id="thumbnail-area">
4+<%- @slide.pages.each do |page| -%>
5+<pre class="thumbnail"><%= page %></pre>
6+<%- end -%>
7+</div>
8+<script type="text/javascript">
9+ $('#thumbnail-area').draggable({axis:'y', revert: true, cursor:'move'});
10+</script>
11+
12+<div id="controll-area">
13+ <p>『 <%= @slide.title %>』</p>
14+
15+<%- @slide.outline.each_with_index do |line, idx| -%>
16+ <p><%= link_to_function(line,
17+ "change_remote(#{idx}, '#{detail_slide_url(@slide)}')",
18+ :id => "change-button-#{idx}",
19+ :class => 'change-button')%></p>
20+<%- end -%>
21+
22+<%= link_to 'ReOpen', detail_slide_path(@slide), :target => 'projector' %> |
23+<%= link_to 'Edit', edit_slide_path(@slide) %> |
24+<%= link_to 'Back', slides_path %>
25+</div>
26+<script type="text/javascript">
27+ $(document).keydown(function(event) {
28+ if (event.keyCode == 38) {
29+ return prev_remote('<%= detail_slide_url(@slide) %>');
30+ } else if (event.keyCode == 40) {
31+ return next_remote('<%= detail_slide_url(@slide) %>');
32+ }
33+ });
34+</script>
--- a/app/views/songs/_form.html.erb
+++ b/app/views/songs/_form.html.erb
@@ -41,7 +41,7 @@
4141
4242 <script type="text/javascript">
4343 $('#preview-button').on("ajax:before", function(){
44- $(this).data('params', 'words=' + encodeURIComponent($('#song_words').val()))
44+ $(this).data('params', 'words=' + encodeURIComponent($('#song_words').val()));
4545 });
4646 </script>
4747
--- a/app/views/songs/detail.html.erb
+++ b/app/views/songs/detail.html.erb
@@ -1,11 +1,16 @@
11 <%- title @song.title -%>
2-<%- content_for :header do -%>
3- <script type="text/javascript">
4- $(function() { resize($('#p0')[0]); })
5- </script>
6-<%- end -%>
7-
82 <%- @song.phrases.each_with_index do |phrase, idx| %>
93 <pre id="<%= 'p' + idx.to_s %>" class="song <%= idx > 0 ? 'hidden' : '' %>"><%= rubify phrase %></pre>
104 <%- end -%>
115
6+<script type="text/javascript">
7+ resize($('#p0')[0]);
8+
9+ $(document).keydown(function(event) {
10+ if (event.keyCode == 38) {
11+ return prev();
12+ } else if (event.keyCode == 40) {
13+ return next();
14+ }
15+ });
16+</script>
\ No newline at end of file
--- a/app/views/songs/index.html.erb
+++ b/app/views/songs/index.html.erb
@@ -1,16 +1,20 @@
11 <%- title -%>
22 <h1>PRAISE DATABASE</h1>
33
4-<%= form_for @song_search_form, :url => search_songs_path, :html => {:method => :get} do |f| -%>
4+<%= form_for @song_search_form, url: search_songs_path, html: {:method => :get} do |f| -%>
55 <p>検索
6- <%= f.text_field :q, :size => "30" %>
7- <%= f.submit "search" %>
6+ <%= f.text_field :q, :size => '30' %>
7+ <%= f.submit 'search' %>
88 </p>
9- <p><%= link_to '全曲一覧', list_songs_path %></p>
109 <%- end -%>
1110
11+<p><%= link_to '全曲一覧', list_songs_path %></p>
12+
1213 <h2>最近の更新(Recent changes)</h2>
13-<ul></ul>
14+<%- if @recents.blank? -%>
15+<p>更新はありません</p>
16+<%- end -%>
17+<ul>
1418 <%- @recents.each do |song| -%>
1519 <li><%= link_to(song.title, song_path(song)) %></li>
1620 <%- end -%>
@@ -20,6 +24,5 @@
2024 <ul>
2125 <li><%= link_to '新しい曲の追加 - Add a New Song', new_song_path %></li>
2226 <li><%= link_to '聖句検索 - Bible words', books_path %></li>
23- <li><%= link_to 'メッセージレジュメ - Message summaries', preaches_path %></li>
27+ <li><%= link_to 'メッセージレジュメ - Message summaries', slides_path %></li>
2428 </ul>
25-
--- a/app/views/songs/search.html.erb
+++ b/app/views/songs/search.html.erb
@@ -1,7 +1,7 @@
11 <%- title -%>
22 <%= form_for @song_search_form, :url => search_songs_path, :html => {:method => :get} do |f| -%>
33 <p>検索
4- <%= f.select(:code, Song.code_options, :include_blank => true) %>
4+ <%= f.select(:code, Song.code_options, :include_blank => 'コード') %>
55 <%= f.text_field :q, :size => "30" %>
66 <%= f.submit "search" %>
77 </p>
--- a/app/views/songs/show.html.erb
+++ b/app/views/songs/show.html.erb
@@ -4,7 +4,7 @@
44 <div id="boxA">
55 <pre class='small'><%= suppress_ruby @song.words %></pre>
66 <script type="text/javascript">
7- $('pre.small').draggable({axis:'y', cursor:'move'});
7+ $('pre.small').draggable({axis:'y', revert: true, cursor:'move'});
88 </script>
99 </div>
1010
@@ -12,10 +12,22 @@
1212 <p>『<%= @song.title %>』(<%= @song.code %>)</p>
1313
1414 <%- @song.outline.each_with_index do |header, idx| %>
15- <p><%= link_to_function(suppress_ruby(header), "change_remote(#{idx},'#{detail_song_url(@song)}')") %></p>
15+ <p><%= link_to_function(suppress_ruby(header),
16+ "change_remote(#{idx},'#{detail_song_url(@song)}')",
17+ :id => "change-button-#{idx}",
18+ :class => 'change-button' ) %></p>
1619 <%- end -%>
1720
1821 <%= link_to 'ReOpen', detail_song_path(@song), :target => 'projector' %> |
1922 <%= link_to 'Edit', edit_song_path(@song) %> |
2023 <%= link_to 'Back', songs_path %>
21-</div>
\ No newline at end of file
24+</div>
25+<script type="text/javascript">
26+ $(document).keydown(function(event) {
27+ if (event.keyCode == 38) {
28+ return prev_remote('<%= detail_song_url(@song) %>');
29+ } else if (event.keyCode == 40) {
30+ return next_remote('<%= detail_song_url(@song) %>');
31+ }
32+ });
33+</script>
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -1,5 +1,14 @@
11 Ginmaku::Application.routes.draw do
2- resources :preaches
2+ resources :slides do
3+ member do
4+ get :detail
5+ end
6+
7+ collection do
8+ get :search
9+ get :list
10+ end
11+ end
312
413 resources :songs do
514 member do
--- /dev/null
+++ b/test/factories/songs.rb
@@ -0,0 +1,8 @@
1+# Read about factories at https://github.com/thoughtbot/factory_girl
2+
3+FactoryGirl.define do
4+ factory :song do
5+ words 'MyText'
6+ code 'MyString'
7+ end
8+end
--- /dev/null
+++ b/test/fixtures/book_names.yml
@@ -0,0 +1,11 @@
1+# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
2+
3+one:
4+ testament: 1
5+ japanese: MyString
6+ english: MyString
7+
8+two:
9+ testament: 1
10+ japanese: MyString
11+ english: MyString
--- /dev/null
+++ b/test/fixtures/books.yml
@@ -0,0 +1,13 @@
1+# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
2+
3+one:
4+ version: 1
5+ chapter: 1
6+ verse: 1
7+ word: MyText
8+
9+two:
10+ version: 1
11+ chapter: 1
12+ verse: 1
13+ word: MyText
--- /dev/null
+++ b/test/fixtures/slides.yml
@@ -0,0 +1,13 @@
1+# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
2+
3+one:
4+ title: MyString
5+ body: MyText
6+ author: MyString
7+ deleted_at: 2013-04-01 21:54:30
8+
9+two:
10+ title: MyString
11+ body: MyText
12+ author: MyString
13+ deleted_at: 2013-04-01 21:54:30
--- /dev/null
+++ b/test/fixtures/songs.yml
@@ -0,0 +1,9 @@
1+# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
2+
3+one:
4+ code: MyString
5+ title: MyString
6+ words: MyText
7+ words_for_search: MyText
8+ cright: MyString
9+
--- /dev/null
+++ b/test/functional/slides_controller_test.rb
@@ -0,0 +1,49 @@
1+require 'test_helper'
2+
3+class SlidesControllerTest < ActionController::TestCase
4+ setup do
5+ @slide = slides(:one)
6+ end
7+
8+ test "should get index" do
9+ get :index
10+ assert_response :success
11+ assert_not_nil assigns(:slides)
12+ end
13+
14+ test "should get new" do
15+ get :new
16+ assert_response :success
17+ end
18+
19+ test "should create slide" do
20+ assert_difference('Slide.count') do
21+ post :create, slide: { author: @slide.author, body: @slide.body, deleted_at: @slide.deleted_at, title: @slide.title }
22+ end
23+
24+ assert_redirected_to slide_path(assigns(:slide))
25+ end
26+
27+ test "should show slide" do
28+ get :show, id: @slide
29+ assert_response :success
30+ end
31+
32+ test "should get edit" do
33+ get :edit, id: @slide
34+ assert_response :success
35+ end
36+
37+ test "should update slide" do
38+ put :update, id: @slide, slide: { author: @slide.author, body: @slide.body, deleted_at: @slide.deleted_at, title: @slide.title }
39+ assert_redirected_to slide_path(assigns(:slide))
40+ end
41+
42+ test "should destroy slide" do
43+ assert_difference('Slide.count', -1) do
44+ delete :destroy, id: @slide
45+ end
46+
47+ assert_redirected_to slides_path
48+ end
49+end
--- /dev/null
+++ b/test/unit/book_name_test.rb
@@ -0,0 +1,7 @@
1+require 'test_helper'
2+
3+class BookNameTest < ActiveSupport::TestCase
4+ # test "the truth" do
5+ # assert true
6+ # end
7+end
--- /dev/null
+++ b/test/unit/book_test.rb
@@ -0,0 +1,7 @@
1+require 'test_helper'
2+
3+class BookTest < ActiveSupport::TestCase
4+ # test "the truth" do
5+ # assert true
6+ # end
7+end
--- /dev/null
+++ b/test/unit/helpers/books_helper_test.rb
@@ -0,0 +1,4 @@
1+require 'test_helper'
2+
3+class BooksHelperTest < ActionView::TestCase
4+end
--- /dev/null
+++ b/test/unit/helpers/samples_helper_test.rb
@@ -0,0 +1,4 @@
1+require 'test_helper'
2+
3+class SamplesHelperTest < ActionView::TestCase
4+end
--- /dev/null
+++ b/test/unit/helpers/slides_helper_test.rb
@@ -0,0 +1,4 @@
1+require 'test_helper'
2+
3+class SlidesHelperTest < ActionView::TestCase
4+end
--- /dev/null
+++ b/test/unit/helpers/songs_helper_test.rb
@@ -0,0 +1,11 @@
1+# coding: utf-8
2+require 'test_helper'
3+
4+class SongsHelperTest < ActionView::TestCase
5+ test '.rubify' do
6+ expected = '<ruby>主<rt>しゅ</rt></ruby>'
7+ actual = rubify('主(しゅ)')
8+ assert_equal(expected, actual)
9+ end
10+
11+end
--- /dev/null
+++ b/test/unit/slide_test.rb
@@ -0,0 +1,7 @@
1+require 'test_helper'
2+
3+class SlideTest < ActiveSupport::TestCase
4+ # test "the truth" do
5+ # assert true
6+ # end
7+end
--- /dev/null
+++ b/test/unit/song_test.rb
@@ -0,0 +1,65 @@
1+# coding: utf-8
2+require 'test_helper'
3+
4+class SongTest < ActiveSupport::TestCase
5+ # test "the truth" do
6+ # assert true
7+ # end
8+
9+ setup do
10+ @song = Song.create(words:'主(しゅ)')
11+ end
12+
13+ test '.kana' do
14+ assert_equal 'しゅ', @song.kana
15+ end
16+
17+ test '.kanji' do
18+ assert_equal '主', @song.kanji
19+ end
20+
21+ test '.update_words_for_search' do
22+ @song.update_words_for_search!
23+ assert_equal ['words_for_search'], @song.changed
24+ assert_equal '主しゅ', @song.words_for_search
25+ end
26+
27+ test '.kananaize_with_space' do
28+ song = Song.new
29+ expected = "ともに よろこ び うた おう\n"
30+ actual = song.send(:kananaize_with_space, "ともに喜(よろこ)び歌(うた)おう\n")
31+ assert_equal expected, actual
32+ end
33+
34+ test '.romanize! simple' do
35+ song = Song.new(words:"ともに喜(よろこ)び歌(うた)おう\n")
36+ song.romanize!
37+ expected = "ともに喜(よろこ)び歌(うた)おう\nTOMONI YOROKO BI UTA OH\n"
38+ actual = song.words
39+ assert_equal expected, actual
40+ end
41+
42+ test '.romanize!' do
43+ before = <<ENDOF
44+イエスの勝利(しょうり)を たたえよう
45+ともに喜(よろこ)び歌(うた)おう
46+イエスは血(ち)を流(なが)し 我(われ)らに
47+命(いのち) 与(あた)えられた
48+ENDOF
49+ after = <<ENDOF
50+イエスの勝利(しょうり)を たたえよう
51+IESUNO SHORI O TATAEYO
52+ともに喜(よろこ)び歌(うた)おう
53+TOMONI YOROKO BI UTA OH
54+イエスは血(ち)を流(なが)し 我(われ)らに
55+IESUHA CHI O NAGA SHI WARE RANI
56+命(いのち) 与(あた)えられた
57+INOCHI ATA ERARETA
58+ENDOF
59+ song = Song.create(words:before)
60+ song.romanize!
61+ expected = after
62+ actual = song.words
63+ assert_equal expected, actual
64+ end
65+end