FilesSubmittedBranchesLabelsClientsUsersJobsHelp
Tree viewShow file textShow revision historyShow/hide recent activityInformation
//depot/projects/wiki/app/models/page.rb#2

//depot/projects/wiki/app/models/page.rb#2 – edit change 227 (text) ·revision history

1require 'redcloth'
2
3class Page < ActiveRecord::Base
4 WIKI_WORD = /\b([A-Z][a-z]+(?:[A-Z][a-z]+)+)\b/
5
6 validates_presence_of :name
7 validates_uniqueness_of :name
8 validates_format_of :name, :with => /^#{WIKI_WORD.source}$/,
9 :message => "must be a WikiWord"
10
11 def to_html
12 html = RedCloth.new(body.to_s).to_html
13 html.gsub!(/<\/?script[^>]*>/i, '')
14 html.gsub!(/\son\w+\s*=/i, ' x-nope=')
15 html.gsub(WIKI_WORD) { "<a href=\"/wiki/show/#{$1}\">#{$1}</a>" }
16 end
17end

P4Web/LINUX26X86/2005.1/82295 · Copyright © 1995-2005 Perforce Software · ttul.org