File tree Expand file tree Collapse file tree 3 files changed +33
-7
lines changed
Expand file tree Collapse file tree 3 files changed +33
-7
lines changed Original file line number Diff line number Diff line change 1+ class BooksController < ApplicationController
2+ # NOTE: The following URLs are hard-coded by published books.
3+ # And the books are just a few, so not a big problem for now.
4+
5+ # GET /sotechsha[2]
6+ def sotechsha1_index ; render ( "books/sotechsha1/index" ) ; end
7+ def sotechsha2_index ; render ( "books/sotechsha2/index" ) ; end
8+
9+ # GET /sotechsha[2]/:page
10+ def sotechsha1_show ; render_book_page ( params ) ; end
11+ def sotechsha2_show ; render_book_page ( params ) ; end
12+
13+ private
14+
15+ def render_book_page ( params )
16+ book_name = params [ :action ] . split ( '_' ) . first
17+ Book . exist? ( book_name , params [ :page ] ) ?
18+ render ( "books/#{ book_name } /#{ params [ :page ] } " ) :
19+ redirect_to ( '/' + book_name ) # TODO: Show flash
20+ end
21+ end
Original file line number Diff line number Diff line change @@ -19,7 +19,9 @@ def find(title)
1919 end
2020
2121 def exist? ( title , filename )
22- self . find ( title ) . map ( &:filename ) . include? ( filename )
22+ filename . nil? ?
23+ self . find ( title ) . any? :
24+ self . find ( title ) . map ( &:filename ) . include? ( filename + ".html" )
2325 end
2426 end
2527
Original file line number Diff line number Diff line change 9696 get "/.well-known/acme-challenge/:id" => "static_pages#lets_encrypt"
9797 get "/.well-known/security.txt" => "static_pages#security"
9898
99- # CoderDojo Books from Sotechsha
100- get "/sotechsha" => "sotechsha_pages#index"
101- get "/sotechsha/:page" => "sotechsha_pages#show"
102-
103- get "/sotechsha2" => "sotechsha2_pages#index"
104- get "/sotechsha2/:page" => "sotechsha2_pages#show"
99+ # CoderDojo Books such as published from ソーテック社
100+ #get "/sotechsha" => "sotechsha_pages#index"
101+ #get "/sotechsha/:page" => "sotechsha_pages#show"
102+ get "/sotechsha1" , to : redirect ( '/sotechsha' )
103+ get "/sotechsha" => "books#sotechsha1_index"
104+ get "/sotechsha/:page" => "books#sotechsha1_show"
105+ get "/sotechsha2" => "books#sotechsha2_index"
106+ get "/sotechsha2/:page" => "books#sotechsha2_show"
107+ #get "/sotechsha/sozai", to: redirect('/sotechsha/gazou')
105108
106109 # Check development sent emails
107110 mount LetterOpenerWeb ::Engine , at : "/letter_opener" if Rails . env . development?
You can’t perform that action at this time.
0 commit comments