Revisión | 3b0ded922228b54a5263ea7ed81c569f054f19a7 (tree) |
---|---|
Tiempo | 2013-04-07 12:28:37 |
Autor | SHIMADA Keiki <shimada.cake@gmai...> |
Commiter | SHIMADA Keiki |
Merge remote branch 'origin/master'
@@ -1,7 +1,7 @@ | ||
1 | 1 | source 'https://rubygems.org' |
2 | 2 | |
3 | 3 | |
4 | -gem 'rails', '3.2.12' | |
4 | +gem 'rails', '3.2.13' | |
5 | 5 | |
6 | 6 | # Bundle edge Rails instead: |
7 | 7 | # gem 'rails', :git => 'git://github.com/rails/rails.git' |
@@ -1,12 +1,12 @@ | ||
1 | 1 | GEM |
2 | 2 | remote: https://rubygems.org/ |
3 | 3 | 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) | |
10 | 10 | builder (~> 3.0.0) |
11 | 11 | erubis (~> 2.7.0) |
12 | 12 | journey (~> 1.0.4) |
@@ -14,19 +14,19 @@ GEM | ||
14 | 14 | rack-cache (~> 1.2) |
15 | 15 | rack-test (~> 0.6.1) |
16 | 16 | sprockets (~> 2.2.1) |
17 | - activemodel (3.2.12) | |
18 | - activesupport (= 3.2.12) | |
17 | + activemodel (3.2.13) | |
18 | + activesupport (= 3.2.13) | |
19 | 19 | 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) | |
23 | 23 | arel (~> 3.0.2) |
24 | 24 | 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) | |
30 | 30 | multi_json (~> 1.0) |
31 | 31 | acts_as_paranoid (0.4.1) |
32 | 32 | activerecord (~> 3.2) |
@@ -57,7 +57,7 @@ GEM | ||
57 | 57 | kaminari (0.14.1) |
58 | 58 | actionpack (>= 3.0.0) |
59 | 59 | activesupport (>= 3.0.0) |
60 | - mail (2.4.4) | |
60 | + mail (2.5.3) | |
61 | 61 | i18n (>= 0.4.0) |
62 | 62 | mime-types (~> 1.16) |
63 | 63 | treetop (~> 1.4.8) |
@@ -69,8 +69,8 @@ GEM | ||
69 | 69 | nokogiri (~> 1.4) |
70 | 70 | ntlm-http (~> 0.1, >= 0.1.1) |
71 | 71 | 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) | |
74 | 74 | mysql2 (0.3.11) |
75 | 75 | net-http-digest_auth (1.2.1) |
76 | 76 | net-http-persistent (2.8) |
@@ -84,23 +84,23 @@ GEM | ||
84 | 84 | rack |
85 | 85 | rack-test (0.6.2) |
86 | 86 | 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) | |
93 | 93 | 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) | |
98 | 98 | rack-ssl (~> 1.3.2) |
99 | 99 | rake (>= 0.8.7) |
100 | 100 | rdoc (~> 3.4) |
101 | 101 | 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) | |
104 | 104 | json (~> 1.4) |
105 | 105 | sass (3.2.6) |
106 | 106 | sass-rails (3.2.6) |
@@ -114,12 +114,12 @@ GEM | ||
114 | 114 | tilt (~> 1.1, != 1.3.0) |
115 | 115 | sqlite3 (1.3.7) |
116 | 116 | 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) | |
119 | 119 | treetop (1.4.12) |
120 | 120 | polyglot |
121 | 121 | polyglot (>= 0.3.1) |
122 | - tzinfo (0.3.35) | |
122 | + tzinfo (0.3.37) | |
123 | 123 | uglifier (1.3.0) |
124 | 124 | execjs (>= 0.3.0) |
125 | 125 | multi_json (~> 1.0, >= 1.0.2) |
@@ -138,7 +138,7 @@ DEPENDENCIES | ||
138 | 138 | jquery-rails |
139 | 139 | kaminari |
140 | 140 | mysql2 |
141 | - rails (= 3.2.12) | |
141 | + rails (= 3.2.13) | |
142 | 142 | sass-rails (~> 3.2.3) |
143 | 143 | sqlite3 |
144 | 144 | test-unit |
@@ -13,4 +13,3 @@ | ||
13 | 13 | //= require jquery |
14 | 14 | //= require jquery_ujs |
15 | 15 | //= require jquery-ui |
16 | -//= require_tree . |
@@ -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 | + |
@@ -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 |
@@ -2,51 +2,34 @@ | ||
2 | 2 | # All this logic will automatically be available in application.js. |
3 | 3 | # You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/ |
4 | 4 | |
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 | -# | |
43 | 5 | phrases = () -> $('.song') |
44 | 6 | current = 0 |
45 | 7 | |
8 | +fadeOut = -> | |
9 | + $(phrases()[current]).fadeOut(200) | |
10 | + | |
11 | +fadeIn = -> | |
12 | + $(phrases()[current]).fadeIn(200) | |
13 | + | |
46 | 14 | # 指定された番号の歌詞に切り替える |
47 | 15 | @change = (idx) -> |
48 | - phrases()[current].style.display = 'none' | |
16 | + fadeOut() | |
49 | 17 | current = idx |
50 | - phrases()[current].style.display = 'block' | |
18 | + fadeIn() | |
51 | 19 | resize(phrases()[current]) |
52 | 20 | |
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 |
@@ -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 | +} |
@@ -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 |
@@ -87,7 +87,7 @@ class SongsController < ApplicationController | ||
87 | 87 | Song.transaction do |
88 | 88 | @song.attributes = params[:song] |
89 | 89 | @song.romanize! if params[:button] == 'roman' |
90 | - @song.update_words_for_search | |
90 | + @song.update_words_for_search! | |
91 | 91 | is_saved = @song.save |
92 | 92 | end |
93 | 93 |
@@ -116,10 +116,6 @@ class SongsController < ApplicationController | ||
116 | 116 | |
117 | 117 | def search |
118 | 118 | @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]) | |
124 | 120 | end |
125 | 121 | end |
@@ -0,0 +1,2 @@ | ||
1 | +module SlidesHelper | |
2 | +end |
@@ -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 |
@@ -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 |
@@ -35,7 +35,7 @@ class Song < ActiveRecord::Base | ||
35 | 35 | kananize(words) |
36 | 36 | end |
37 | 37 | |
38 | - def update_words_for_search | |
38 | + def update_words_for_search! | |
39 | 39 | self[:words_for_search] = ruby_trim(kanji + kana) |
40 | 40 | end |
41 | 41 |
@@ -4,6 +4,8 @@ | ||
4 | 4 | <title><%=h yield(:title) %></title> |
5 | 5 | <%= stylesheet_link_tag "application", :media => "all" %> |
6 | 6 | <%= javascript_include_tag "application" %> |
7 | + <%= javascript_include_tag "common" %> | |
8 | + <%= javascript_include_tag params[:controller] %> | |
7 | 9 | <%= csrf_meta_tags %> |
8 | 10 | <%= yield :header %> |
9 | 11 | </head> |
@@ -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 %> |
@@ -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 %> |
@@ -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> |
@@ -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 %> |
@@ -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> |
@@ -0,0 +1,2 @@ | ||
1 | +<%- title -%> | |
2 | +<%= render :partial => 'list' %> | |
\ No newline at end of file |
@@ -0,0 +1,5 @@ | ||
1 | +<h1>New slide</h1> | |
2 | + | |
3 | +<%= render 'form' %> | |
4 | + | |
5 | +<%= link_to 'Back', slides_path %> |
@@ -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 %> |
@@ -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> |
@@ -41,7 +41,7 @@ | ||
41 | 41 | |
42 | 42 | <script type="text/javascript"> |
43 | 43 | $('#preview-button').on("ajax:before", function(){ |
44 | - $(this).data('params', 'words=' + encodeURIComponent($('#song_words').val())) | |
44 | + $(this).data('params', 'words=' + encodeURIComponent($('#song_words').val())); | |
45 | 45 | }); |
46 | 46 | </script> |
47 | 47 |
@@ -1,11 +1,16 @@ | ||
1 | 1 | <%- title @song.title -%> |
2 | -<%- content_for :header do -%> | |
3 | - <script type="text/javascript"> | |
4 | - $(function() { resize($('#p0')[0]); }) | |
5 | - </script> | |
6 | -<%- end -%> | |
7 | - | |
8 | 2 | <%- @song.phrases.each_with_index do |phrase, idx| %> |
9 | 3 | <pre id="<%= 'p' + idx.to_s %>" class="song <%= idx > 0 ? 'hidden' : '' %>"><%= rubify phrase %></pre> |
10 | 4 | <%- end -%> |
11 | 5 | |
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 |
@@ -1,16 +1,20 @@ | ||
1 | 1 | <%- title -%> |
2 | 2 | <h1>PRAISE DATABASE</h1> |
3 | 3 | |
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| -%> | |
5 | 5 | <p>検索 |
6 | - <%= f.text_field :q, :size => "30" %> | |
7 | - <%= f.submit "search" %> | |
6 | + <%= f.text_field :q, :size => '30' %> | |
7 | + <%= f.submit 'search' %> | |
8 | 8 | </p> |
9 | - <p><%= link_to '全曲一覧', list_songs_path %></p> | |
10 | 9 | <%- end -%> |
11 | 10 | |
11 | +<p><%= link_to '全曲一覧', list_songs_path %></p> | |
12 | + | |
12 | 13 | <h2>最近の更新(Recent changes)</h2> |
13 | -<ul></ul> | |
14 | +<%- if @recents.blank? -%> | |
15 | +<p>更新はありません</p> | |
16 | +<%- end -%> | |
17 | +<ul> | |
14 | 18 | <%- @recents.each do |song| -%> |
15 | 19 | <li><%= link_to(song.title, song_path(song)) %></li> |
16 | 20 | <%- end -%> |
@@ -20,6 +24,5 @@ | ||
20 | 24 | <ul> |
21 | 25 | <li><%= link_to '新しい曲の追加 - Add a New Song', new_song_path %></li> |
22 | 26 | <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> | |
24 | 28 | </ul> |
25 | - |
@@ -1,7 +1,7 @@ | ||
1 | 1 | <%- title -%> |
2 | 2 | <%= form_for @song_search_form, :url => search_songs_path, :html => {:method => :get} do |f| -%> |
3 | 3 | <p>検索 |
4 | - <%= f.select(:code, Song.code_options, :include_blank => true) %> | |
4 | + <%= f.select(:code, Song.code_options, :include_blank => 'コード') %> | |
5 | 5 | <%= f.text_field :q, :size => "30" %> |
6 | 6 | <%= f.submit "search" %> |
7 | 7 | </p> |
@@ -4,7 +4,7 @@ | ||
4 | 4 | <div id="boxA"> |
5 | 5 | <pre class='small'><%= suppress_ruby @song.words %></pre> |
6 | 6 | <script type="text/javascript"> |
7 | - $('pre.small').draggable({axis:'y', cursor:'move'}); | |
7 | + $('pre.small').draggable({axis:'y', revert: true, cursor:'move'}); | |
8 | 8 | </script> |
9 | 9 | </div> |
10 | 10 |
@@ -12,10 +12,22 @@ | ||
12 | 12 | <p>『<%= @song.title %>』(<%= @song.code %>)</p> |
13 | 13 | |
14 | 14 | <%- @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> | |
16 | 19 | <%- end -%> |
17 | 20 | |
18 | 21 | <%= link_to 'ReOpen', detail_song_path(@song), :target => 'projector' %> | |
19 | 22 | <%= link_to 'Edit', edit_song_path(@song) %> | |
20 | 23 | <%= 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> |
@@ -1,5 +1,14 @@ | ||
1 | 1 | 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 | |
3 | 12 | |
4 | 13 | resources :songs do |
5 | 14 | member do |
@@ -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 |
@@ -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 |
@@ -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 |
@@ -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 |
@@ -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 | + |
@@ -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 |
@@ -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 |
@@ -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 |
@@ -0,0 +1,4 @@ | ||
1 | +require 'test_helper' | |
2 | + | |
3 | +class BooksHelperTest < ActionView::TestCase | |
4 | +end |
@@ -0,0 +1,4 @@ | ||
1 | +require 'test_helper' | |
2 | + | |
3 | +class SamplesHelperTest < ActionView::TestCase | |
4 | +end |
@@ -0,0 +1,4 @@ | ||
1 | +require 'test_helper' | |
2 | + | |
3 | +class SlidesHelperTest < ActionView::TestCase | |
4 | +end |
@@ -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 |
@@ -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 |
@@ -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 |