Permalink
Browse files

Remove other bible feature remnants.

  • Loading branch information...
1 parent b2ba60f commit 25b409c65f919a53696bafa5ecf97ab946d83d5d @seven1m seven1m committed Jun 24, 2013
Showing with 0 additions and 264 deletions.
  1. +0 −65 app/controllers/bibles_controller.rb
  2. +0 −4 config/routes.rb
  3. +0 −191 script/bible
  4. +0 −4 test/integration/routes_test.rb
@@ -1,65 +0,0 @@
-class BiblesController < ApplicationController
-
- before_filter :convert_reference_into_book_and_chapter, only: %w(show)
- before_filter :get_filename, only: %w(show)
- before_filter :redirect_to_normalized_url, only: %w(show)
-
- def show
- if params[:chapter].to_i == 0 and not request.xhr?
- redirect_to_complete_url
- else
- unless @chapter_filename
- respond_to do |format|
- error = 'The bible reference you provided could not be found. Please check the address and try again.'
- format.html { render text: error, layout: true, status: 400 }
- format.js { render(:update) { |p| p.alert(error) } }
- end
- end
- end
- end
-
- private
-
- def redirect_to_complete_url
- if params[:book] != 'x'
- book = Verse.normalize_book(params[:book]).downcase
- chapter = 1
- else
- book, chapter = Verse.random_book_and_chapter
- end
- redirect_to bible_path(book: CGI.escape(book), chapter: chapter)
- end
-
- def convert_reference_into_book_and_chapter
- if params[:reference].to_s =~ /(\d?[a-z]+)\s([\d\-,;\s]+)/i
- params[:book] = $1
- params[:chapter] = $2
- end
- end
-
- def get_filename
- params[:book].gsub!(/\+/, ' ')
- if @book = Verse.normalize_book(params[:book]) and @chapter = params[:chapter].to_i
- @reference = "#{@book} #{@chapter}"
- @chapter_filename = "#{Rails.root}/app/views/bibles/#{@book}/#{'%03d' % @chapter}.erb"
- @chapter_filename = nil unless File.exists?(@chapter_filename)
- end
- end
-
- def redirect_to_normalized_url
- return unless @chapter_filename
- url_book = @book.downcase
- if url_book != params[:book]
- respond_to do |format|
- url = bible_path(book: url_book, chapter: params[:chapter])
- format.html { redirect_to url }
- format.js { render(:update) { |p| p.redirect_to url } }
- end
- end
- end
-
- def feature_enabled?
- false # for now
- end
-
-end
View
@@ -156,10 +156,6 @@
end
end
- match 'bible(/:book(/:chapter))' => 'bibles#show',
- :defaults => {:book => 'x', :chapter => '0'},
- :constraints => {:book => /[A-Za-z0-9 \+(%20)]+/, :chapter => /\d{1,3}/}
-
resources :pages, :path => 'pages/admin' do
resources :attachments
end
View
@@ -1,191 +0,0 @@
-#!/usr/bin/env ruby
-
-require File.dirname(__FILE__) + '/../config/environment'
-require 'cgi'
-require 'rexml/document'
-require 'rexml/streamlistener'
-include REXML
-
-class BibleWebVersionXmlStream
- attr_accessor :books, :verses
-
- def initialize(filename)
- @filename = filename
- end
-
- def parse_verses
- @books = []; @verses = []
- listener = BibleWebVersionXmlListener.new(self)
- parser = Parsers::StreamParser.new(File.new(@filename), listener)
- parser.parse
- clean_verses
- end
-
- def clean_verses
- @verses.each do |verse|
- verse[-2].strip! # text
- verse[-1].strip! # html
- end
- @verses.delete_if { |v| v[-2] == '' }
- nil
- end
-end
-
-class BibleWebVersionXmlListener
- BOOKS_ABBR = {
- 'Gen' => 'Genesis',
- 'Exod' => 'Exodus',
- 'Lev' => 'Leviticus',
- 'Num' => 'Numbers',
- 'Deut' => 'Deuteronomy',
- 'Josh' => 'Joshua',
- 'Judg' => 'Judges',
- 'Ruth' => 'Ruth',
- '1Sam' => '1 Samuel',
- '2Sam' => '2 Samuel',
- '1Kgs' => '1 Kings',
- '2Kgs' => '2 Kings',
- '1Chr' => '1 Chronicles',
- '2Chr' => '2 Chronicles',
- 'Ezra' => 'Ezra',
- 'Neh' => 'Nehemiah',
- 'Esth' => 'Esther',
- 'Job' => 'Job',
- 'Ps' => 'Psalms',
- 'Prov' => 'Proverbs',
- 'Eccl' => 'Ecclesiastes',
- 'Song' => 'Song of Solomon',
- 'Isa' => 'Isaiah',
- 'Jer' => 'Jeremiah',
- 'Lam' => 'Lamentations',
- 'Ezek' => 'Ezekiel',
- 'Dan' => 'Daniel',
- 'Hos' => 'Hosea',
- 'Joel' => 'Joel',
- 'Amos' => 'Amos',
- 'Obad' => 'Obadiah',
- 'Jonah' => 'Jonah',
- 'Mic' => 'Micah',
- 'Nah' => 'Nahum',
- 'Hab' => 'Habakkuk',
- 'Zeph' => 'Zephaniah',
- 'Hag' => 'Haggai',
- 'Zech' => 'Zechariah',
- 'Mal' => 'Malachi',
- 'Matt' => 'Matthew',
- 'Mark' => 'Mark',
- 'Luke' => 'Luke',
- 'John' => 'John',
- 'Acts' => 'Acts',
- 'Rom' => 'Romans',
- '1Cor' => '1 Corinthians',
- '2Cor' => '2 Corinthians',
- 'Gal' => 'Galatians',
- 'Eph' => 'Ephesians',
- 'Phil' => 'Philippians',
- 'Col' => 'Colossians',
- '1Thess'=> '1 Thessalonians',
- '2Thess'=> '2 Thessalonians',
- '1Tim' => '1 Timothy',
- '2Tim' => '2 Timothy',
- 'Titus' => 'Titus',
- 'Phlm' => 'Philemon',
- 'Heb' => 'Hebrews',
- 'Jas' => 'James',
- '1Pet' => '1 Peter',
- '2Pet' => '2 Peter',
- '1John' => '1 John',
- '2John' => '2 John',
- '3John' => '3 John',
- 'Jude' => 'Jude',
- 'Rev' => 'Revelation'
- }
- INDENT_SPACE = '<span class="indent">&nbsp;&nbsp;</span>'
- LINE_BREAK = '<br/>'
-
- include StreamListener
-
- def initialize(stream)
- @stream = stream
- end
-
- def tag_start(name, attributes)
- if name == 'div' and attributes['type'] == 'book'
- if book = BOOKS_ABBR[attributes['osisID']]
- @stream.books << book
- @book = book
- else
- @book = nil
- end
- elsif name == 'verse' and verse = attributes['sID']
- @chapter, @verse = verse.split('.')[1..-1].map { |p| p.to_i } # "Gen.1.1"
- elsif name == 'verse' and attributes['eID']
- @chapter, @verse = nil, nil
- elsif name == 'note'
- @skip_text = true
- elsif name == 'l' and attributes['type'] == "x-secondary"
- @indent = true
- end
- end
-
- def text(content)
- if @book and @chapter and @verse and not @skip_text
- text = BibleWebVersionXmlListener.clean_verse(content)
- html = BibleWebVersionXmlListener.htmlize_verse(BibleWebVersionXmlListener.clean_verse(content))
- if @indent
- html = INDENT_SPACE + html
- @indent = false
- end
- if @stream.verses.any? and @stream.verses.last[0..2] == [@book, @chapter, @verse]
- @stream.verses.last[-2] += text
- @stream.verses.last[-1] += html
- else
- @stream.verses << [@book, @chapter, @verse, text, html]
- print "#{@book} #{@chapter}:#{@verse} \r"
- end
- end
- end
-
- def tag_end(name)
- if name == 'note'
- @skip_text = false
- elsif name == 'l' and @stream.verses.any? and @book and @verse
- @stream.verses.last[-1] += LINE_BREAK
- end
- end
-
- class << self
- def clean_verse(verse)
- verse.gsub(/\r?\n/, ' ').gsub(/\s+/, ' ')
- end
- def htmlize_verse(verse)
- CGI.escapeHTML(verse).gsub(//, '&#8220;').gsub(//, '&#8221;').gsub(//, '&#8216;').gsub(//, '&#8217;')
- end
- end
-end
-
-
-if $0 == __FILE__
- require 'fileutils'
- bible = BibleWebVersionXmlStream.new(ARGV.first)
- bible.parse_verses
- chapters = bible.verses.group_by { |v| "#{v[0]}-#{'%03d' % v[1]}" }
- chapters.each do |chapter, verses|
- print "#{chapter} \r"
- FileUtils.mkdir_p("app/views/bibles/#{chapter.split('-').first}")
- File.open("app/views/bibles/#{chapter.sub('-', '/')}.erb", 'w') do |file|
- file.write "<div class=\"chapter\" id=\"#{chapter}\">\n"
- book_name = chapter.split('-').first
- book_name = 'Psalm' if book_name == 'Psalms'
- chapter_num = chapter.split('-').last.to_i
- file.write " <h2>#{book_name} #{chapter_num}</h2>\n"
- verses.each do |verse|
- verse_num = verse[2]
- html = verse[-1]
- file.write(" <span class=\"verse\" title=\"#{book_name} #{chapter_num}:#{verse_num}\" id=\"#{book_name.gsub(/\s/, '_')}-#{chapter_num}-#{verse_num}\">#{html}</span>\n")
- end
- file.write "</div>"
- end
- end
- puts
-end
@@ -12,10 +12,6 @@ class RoutesTest < ActionController::IntegrationTest
assert_equal '/news', news_items_path
end
- should "route to bible" do
- assert_recognizes({controller: 'bibles', action: 'show', book: 'John', chapter: '0'}, '/bible/John')
- end
-
should "route to pages" do
assert_recognizes({controller: 'pages', action: 'show_for_public', path: 'home'}, '/pages/home')
end

0 comments on commit 25b409c

Please sign in to comment.