Commit 9b7e7c9176e56164336425ef575cfc65857a7301

started cleaning up the helpers but we need to move all of that to a Page model
  
11class Pages < Application
22
33 def index
4 page_file = find_toc
5 raise NotFound unless page_file
4 @page_file = find_toc
5 raise NotFound unless @page_file
66
7 text = File.open(page_file).read
7 text = File.open(@page_file).read
88 render Maruku::new(text).to_html
99 end
1010
1111 def show
12 chapter = params[:chapter]
13 page_name = params[:page_name]
12 @chapter = params[:chapter]
13 @page_name = params[:page_name]
1414
15 page_file = find_page_file(chapter, page_name)
16 raise NotFound unless page_file
15 @page_file = find_page_file(@chapter, @page_name)
16 raise NotFound unless @page_file
1717
18 text = File.open(page_file).read
18 text = File.open(@page_file).read
1919 render Maruku::new(text).to_html
2020 end
2121
  
2222
2323 # Returns links to the previous and next pages.
2424 def page_nav_links(format = 'markdown')
25 return unless params[:action] == 'show' # Don't need navigation for the TOC (index).
25 return if params[:action] != 'show' # Don't need navigation for the TOC (index).
2626 links = []
27 chapter = params[:chapter]
28 page_name = params[:page_name]
29 current_file = Dir["#{Merb.root}/book-content/#{language}/*-#{chapter}/*-#{page_name||"*"}.#{format}"].entries.first
30 if current_file
31 current_file.grep(/book-content\/\w{2}\/(\d{1,})-[a-z-]+\/(\d{1,})-[a-z-]+[.]\w+/)
32 chapter_number, page_number = $1, $2
33 end
27 @current_file =~ /book-content\/\w{2}\/(\d{1,})-[a-z-]+\/(\d{1,})-[a-z-]+[.]\w+/
28 chapter_number, page_number = $1, $2
3429
3530 chapter_name, page_name = extract_previous_page(chapter_number, page_number)
3631 links << previous_page(chapter_name, page_name)