diff --git a/app/controllers/pages_controller.rb b/app/controllers/pages_controller.rb new file mode 100644 index 0000000..95217e1 --- /dev/null +++ b/app/controllers/pages_controller.rb @@ -0,0 +1,2 @@ +class PagesController < ApplicationController +end \ No newline at end of file diff --git a/app/helpers/pages_helper.rb b/app/helpers/pages_helper.rb new file mode 100644 index 0000000..2c057fd --- /dev/null +++ b/app/helpers/pages_helper.rb @@ -0,0 +1,2 @@ +module PagesHelper +end diff --git a/app/models/page.rb b/app/models/page.rb new file mode 100644 index 0000000..e1088fc --- /dev/null +++ b/app/models/page.rb @@ -0,0 +1,37 @@ +## +# This is a representation of a page of the wiki. My wiki is awfully simple +# because i don't like too many features. This works and it has many different +# associations. All of the major models has_one of these and it belongs_to +# some kind of polymorphic owner. +# +# Bonuses: +# * Uses RedCloth markup. +# * Automatically converts/caches HTML +# * Allows any character or space in the name +# * Uses [[ and ]] for WikiWord representation. +# +class Page < ActiveRecord::Base + acts_as_versioned + + belongs_to :owner, :polymorphic => true + validates_presence_of :title + validates_uniqueness_of :title + validates_format_of :title, :with => /[A-Za-z0-9 ]/, + :message => 'may only contain letters, numbers and spaces' + before_save :update_html + + protected + + ## + # Updates the HTML chunk from the RedCloth source. + # + def update_html + # need to filter HTML first... remove