Skip to content
This repository has been archived by the owner on Jan 2, 2018. It is now read-only.

Commit

Permalink
Merge branch 'english'
Browse files Browse the repository at this point in the history
* english:
  optimized navigation code and renamed folders
  A paragraph about Sequel::Model.raise_on_typecast_failure
  Add a link back to the full Sequel plugins list.
  • Loading branch information
mattetti committed Jan 31, 2009
2 parents 9f9cc3d + e633549 commit af39ad9
Show file tree
Hide file tree
Showing 31 changed files with 26 additions and 10 deletions.
4 changes: 2 additions & 2 deletions app/helpers/global_helpers.rb
Expand Up @@ -24,10 +24,10 @@ def rtl_support_class
def page_nav_links(format = 'markdown')
return if params[:action] != 'show' || @page.nil? # Don't need navigation for the TOC (index).
links = []
links << previous_page_url
links << previous_page_url unless @page.previous_file.include?('table-of-contents')
# Stick a link to the TOC in the middle of the array.
links << link_to(language_text(language, 'Home'), url(:toc, :language => language))
links << next_page_url
links << next_page_url unless @page.next_file.include?('table-of-contents')
links.join(' | ')
end

Expand Down
13 changes: 7 additions & 6 deletions app/models/page.rb
Expand Up @@ -38,7 +38,7 @@ def next_file
return @next_file unless @next_file.nil?
n_file = Dir["#{Merb.root}/book-content/#{language}/#{chapter_number}-*/#{page_number + 1}-*.*"].entries.first
if n_file.nil?
n_file = Dir["#{Merb.root}/book-content/#{language}/#{chapter_number + 1}-*/**"].entries.first
n_file = Dir["#{Merb.root}/book-content/#{language}/#{chapter_number + 1}-*/toc.*"].entries.first
# We're on the last page of the last chapter, just return the TOC.
n_file = "#{Merb.root}/book-content/#{language}/table-of-contents" if n_file.nil?
end
Expand All @@ -61,7 +61,8 @@ def previous_file
return @previous_file unless @previous_file.nil?
p_file = Dir["#{Merb.root}/book-content/#{language}/#{chapter_number}-*/#{page_number - 1}-*.*"].entries.first
if p_file.nil?
p_file = Dir["#{Merb.root}/book-content/#{language}/#{chapter_number - 1}-*/**"].entries.last
p_file = Dir["#{Merb.root}/book-content/#{language}/#{chapter_number - 1}-*/[0-9]*?*.*"].entries.last
p_file = Dir["#{Merb.root}/book-content/#{language}/#{chapter_number - 1}-*/toc.*"].entries.first if p_file.nil?
# We're on the last page of the last chapter, just return the TOC.
p_file = "#{Merb.root}/book-content/#{language}/table-of-contents" if p_file.nil?
end
Expand Down Expand Up @@ -91,8 +92,8 @@ def find_page_file
end

def extract_chapter_and_page_number
file =~ /book-content\/\w{2}\/(\d{1,})-[a-z-]+\/(\d{1,})-[a-z-]+[.]\w+/
@chapter_number, @page_number = $1.to_i, $2.to_i
file =~ /book-content\/\w{2}\/(\d{1,})-[a-z-]+\/((\d{1,})-[a-z-]+|toc)[.]\w+/
@chapter_number, @page_number = $1.to_i, $3.to_i
end

def extract_next_chapter_and_page_name
Expand All @@ -105,8 +106,8 @@ def extract_previous_chapter_and_page_name

# Returns an array with the chapter name and the page name of the file to process
def extract_chapter_and_page_number_for_file(file_to_process)
file_to_process.grep(/book-content\/\w{2}\/\d{1,}-([a-z-]+)\/\d{1,}-([a-z-]+)[.]\w+/)
[$1, $2]
file_to_process.grep(/book-content\/\w{2}\/\d{1,}-([a-z-]+)\/(\d{1,}-([a-z-]+)|(toc))[.]\w+/)
[$1, $3]
end

end
Expand Up @@ -48,7 +48,18 @@ If validation fails, errors can be accessed on the object with the `#errors` met
=> 'is too short'
{:lang=ruby html_use_syntax=true}


By default, Sequel will also not allow unexpected data into a column.
If the table schema prevents a column from containing a nil value, it can not be set to nil.
Sequel attempts to typecast entered values to match their column type.
This can be disabled by setting the class attr\_accesor `raise_on_typecast_failure` to false.

a => Address.new(:user_id => 1, :city => 'A City')
a.user_id = nil
Sequel::Error::InvalidValue: nil/NULL is not allowed for the user_id column
Address.raise_on_typecast_failure = false
a.user_id = nil
=> nil

A full set of documentation for model validations can be found in the [Merb::Sequel documentation][]


Expand Down
Expand Up @@ -5,6 +5,8 @@ Sequel Plugins are libraries packaged as gems which can add useful functionality
Plugins are named like `sequel_pluginname`.
They're used in models by declaring `is :pluginname`.
Plugins for Sequel are painless to use, and are easy to write.
These are just a few examples.
Jeremy Evans maintains a more [complete list of plugins][].


##Useful Plugins
Expand Down Expand Up @@ -79,6 +81,8 @@ There is, however, a migration included in the plugin source.
Sequel\_taggable depends on the sequel\_polymophic plugin.
Here's the [sequel\_taggable source][].

[complete list of plugins]: http://sequel.rubyforge.org/plugins.html

[sequel_timestamped source]: http://github.com/bricooke/sequel_timestamped/tree/master

[sequel_notnaughty source]: http://github.com/boof/sequel_notnaughty/tree/master
Expand All @@ -87,4 +91,4 @@ Here's the [sequel\_taggable source][].

[sequel_polymorphic source]: http://github.com/jackdempsey/sequel_polymorphic/tree/master

[sequel_taggable source]: http://github.com/jackdempsey/sequel_taggable/tree/master
[sequel_taggable source]: http://github.com/jackdempsey/sequel_taggable/tree/master

0 comments on commit af39ad9

Please sign in to comment.