Skip to content
Browse files

totally upgraded to rails3

  • Loading branch information...
1 parent 501c651 commit 30f008f5ceefda2f4131d40ada366023d8950a3e @jlapier committed Oct 28, 2010
Showing with 10,686 additions and 602 deletions.
  1. +2 −17 .gitignore
  2. +40 −0 Gemfile
  3. +93 −0 Gemfile.lock
  4. +256 −0 README
  5. +2 −5 Rakefile
  6. +1 −156 app/controllers/application_controller.rb
  7. +0 −111 app/helpers/application_helper.rb
  8. +11 −42 app/views/layouts/application.html.erb
  9. +4 −0 config.ru
  10. +67 −0 config/application.rb
  11. +42 −0 config/application.rb.rails3
  12. +13 −110 config/boot.rb
  13. +22 −0 config/database.yml
  14. +5 −0 config/environment.rb.rails3
  15. +22 −13 config/environments/development.rb
  16. +43 −15 config/environments/production.rb
  17. +30 −17 config/environments/test.rb
  18. +7 −0 config/initializers/backtrace_silencers.rb
  19. +1 −1 config/initializers/inflections.rb
  20. +7 −0 config/initializers/secret_token.rb
  21. +8 −0 config/initializers/session_store.rb
  22. +5 −0 config/locales/en.yml
  23. +69 −0 config/newapplication.rb
  24. +81 −27 config/routes.rb
  25. +58 −0 config/routes.rb.rails3
  26. +201 −0 db/schema.rb
  27. +7 −0 db/seeds.rb
  28. 0 lib/tasks/.gitkeep
  29. +15 −19 public/404.html
  30. +15 −19 public/422.html
  31. +15 −19 public/500.html
  32. BIN public/images/rails.png
  33. +239 −0 public/index.html
  34. +965 −0 public/javascripts/controls.js
  35. +974 −0 public/javascripts/dragdrop.js
  36. +1,123 −0 public/javascripts/effects.js
  37. +6,001 −0 public/javascripts/prototype.js
  38. +175 −0 public/javascripts/rails.js
  39. 0 public/stylesheets/.gitkeep
  40. +49 −0 public/themes/colors/black and white.css
  41. BIN public/wiki_page_assets/wiki_page_1/df_31_12_linux.tar.bz2
  42. +6 −0 script/rails
  43. +9 −0 test/performance/browsing_test.rb
  44. +3 −31 test/test_helper.rb
  45. 0 vendor/plugins/.gitkeep
View
19 .gitignore
@@ -1,19 +1,4 @@
+.bundle
+db/*.sqlite3
log/*.log
tmp/**/*
-.DS_Store
-config/database.yml
-db/schema.rb
-db/*.sqlite3
-db/development_structure.sql
-*~
-cache
-.*.swp
-.*.swo
-nbproject/
-spec/spec.opts.netbeans
-public/content_page_assets/
-public/wiki_page_assets/
-public/user_assets/
-public/themes
-public/images/favorite.png
-coverage/
View
40 Gemfile
@@ -0,0 +1,40 @@
+source 'http://rubygems.org'
+
+gem 'rails', '3.0.1'
+
+# Bundle edge Rails instead:
+# gem 'rails', :git => 'git://github.com/rails/rails.git'
+
+gem 'sqlite3-ruby', :require => 'sqlite3'
+
+# Use unicorn as the web server
+# gem 'unicorn'
+
+# Deploy with Capistrano
+# gem 'capistrano'
+
+# To use debugger
+# gem 'ruby-debug'
+
+# Bundle the extra gems:
+# gem 'bj'
+# gem 'nokogiri'
+# gem 'sqlite3-ruby', :require => 'sqlite3'
+# gem 'aws-s3', :require => 'aws/s3'
+
+gem 'RedCloth'
+gem 'authlogic'
+gem 'authlogic-oid', :require => 'authlogic_openid'
+gem 'ruby-openid', :require => 'openid'
+#source 'http://gemcutter.org'
+gem 'will_paginate' #, '~> 2.3.11'
+
+# Bundle gems for the local environment. Make sure to
+# put test-only gems in this group so their generators
+# and rake tasks are available in development mode:
+group :development, :test do
+ gem 'rspec', '>= 1.2.0'
+ gem 'rspec-rails', '>= 1.2.0'
+ #source 'http://gemcutter.org'
+ gem 'factory_girl' #, '>= 1.2.4'
+end
View
93 Gemfile.lock
@@ -0,0 +1,93 @@
+GEM
+ remote: http://rubygems.org/
+ specs:
+ RedCloth (4.2.3)
+ abstract (1.0.0)
+ actionmailer (3.0.1)
+ actionpack (= 3.0.1)
+ mail (~> 2.2.5)
+ actionpack (3.0.1)
+ activemodel (= 3.0.1)
+ activesupport (= 3.0.1)
+ builder (~> 2.1.2)
+ erubis (~> 2.6.6)
+ i18n (~> 0.4.1)
+ rack (~> 1.2.1)
+ rack-mount (~> 0.6.12)
+ rack-test (~> 0.5.4)
+ tzinfo (~> 0.3.23)
+ activemodel (3.0.1)
+ activesupport (= 3.0.1)
+ builder (~> 2.1.2)
+ i18n (~> 0.4.1)
+ activerecord (3.0.1)
+ activemodel (= 3.0.1)
+ activesupport (= 3.0.1)
+ arel (~> 1.0.0)
+ tzinfo (~> 0.3.23)
+ activeresource (3.0.1)
+ activemodel (= 3.0.1)
+ activesupport (= 3.0.1)
+ activesupport (3.0.1)
+ arel (1.0.1)
+ activesupport (~> 3.0.0)
+ authlogic (2.1.6)
+ activesupport
+ authlogic-oid (1.0.4)
+ authlogic
+ builder (2.1.2)
+ erubis (2.6.6)
+ abstract (>= 1.0.0)
+ factory_girl (1.3.2)
+ i18n (0.4.1)
+ mail (2.2.5)
+ activesupport (>= 2.3.6)
+ mime-types
+ treetop (>= 1.4.5)
+ mime-types (1.16)
+ polyglot (0.3.1)
+ rack (1.2.1)
+ rack-mount (0.6.13)
+ rack (>= 1.0.0)
+ rack-test (0.5.4)
+ rack (>= 1.0)
+ rails (3.0.1)
+ actionmailer (= 3.0.1)
+ actionpack (= 3.0.1)
+ activerecord (= 3.0.1)
+ activeresource (= 3.0.1)
+ activesupport (= 3.0.1)
+ bundler (~> 1.0.0)
+ railties (= 3.0.1)
+ railties (3.0.1)
+ actionpack (= 3.0.1)
+ activesupport (= 3.0.1)
+ rake (>= 0.8.4)
+ thor (~> 0.14.0)
+ rake (0.8.7)
+ rspec (1.3.0)
+ rspec-rails (1.3.2)
+ rack (>= 1.0.0)
+ rspec (>= 1.3.0)
+ ruby-openid (2.1.8)
+ sqlite3-ruby (1.3.1)
+ thor (0.14.0)
+ treetop (1.4.8)
+ polyglot (>= 0.3.1)
+ tzinfo (0.3.23)
+ will_paginate (2.3.15)
+
+PLATFORMS
+ ruby
+
+DEPENDENCIES
+ RedCloth
+ authlogic
+ authlogic-oid
+ factory_girl
+ rails (= 3.0.1)
+ rspec (>= 1.2.0)
+ rspec-rails (>= 1.2.0)
+ ruby-openid
+ sqlite3-ruby
+ will_paginate
View
256 README
@@ -0,0 +1,256 @@
+== Welcome to Rails
+
+Rails is a web-application framework that includes everything needed to create
+database-backed web applications according to the Model-View-Control pattern.
+
+This pattern splits the view (also called the presentation) into "dumb"
+templates that are primarily responsible for inserting pre-built data in between
+HTML tags. The model contains the "smart" domain objects (such as Account,
+Product, Person, Post) that holds all the business logic and knows how to
+persist themselves to a database. The controller handles the incoming requests
+(such as Save New Account, Update Product, Show Post) by manipulating the model
+and directing data to the view.
+
+In Rails, the model is handled by what's called an object-relational mapping
+layer entitled Active Record. This layer allows you to present the data from
+database rows as objects and embellish these data objects with business logic
+methods. You can read more about Active Record in
+link:files/vendor/rails/activerecord/README.html.
+
+The controller and view are handled by the Action Pack, which handles both
+layers by its two parts: Action View and Action Controller. These two layers
+are bundled in a single package due to their heavy interdependence. This is
+unlike the relationship between the Active Record and Action Pack that is much
+more separate. Each of these packages can be used independently outside of
+Rails. You can read more about Action Pack in
+link:files/vendor/rails/actionpack/README.html.
+
+
+== Getting Started
+
+1. At the command prompt, create a new Rails application:
+ <tt>rails new myapp</tt> (where <tt>myapp</tt> is the application name)
+
+2. Change directory to <tt>myapp</tt> and start the web server:
+ <tt>cd myapp; rails server</tt> (run with --help for options)
+
+3. Go to http://localhost:3000/ and you'll see:
+ "Welcome aboard: You're riding Ruby on Rails!"
+
+4. Follow the guidelines to start developing your application. You can find
+the following resources handy:
+
+* The Getting Started Guide: http://guides.rubyonrails.org/getting_started.html
+* Ruby on Rails Tutorial Book: http://www.railstutorial.org/
+
+
+== Debugging Rails
+
+Sometimes your application goes wrong. Fortunately there are a lot of tools that
+will help you debug it and get it back on the rails.
+
+First area to check is the application log files. Have "tail -f" commands
+running on the server.log and development.log. Rails will automatically display
+debugging and runtime information to these files. Debugging info will also be
+shown in the browser on requests from 127.0.0.1.
+
+You can also log your own messages directly into the log file from your code
+using the Ruby logger class from inside your controllers. Example:
+
+ class WeblogController < ActionController::Base
+ def destroy
+ @weblog = Weblog.find(params[:id])
+ @weblog.destroy
+ logger.info("#{Time.now} Destroyed Weblog ID ##{@weblog.id}!")
+ end
+ end
+
+The result will be a message in your log file along the lines of:
+
+ Mon Oct 08 14:22:29 +1000 2007 Destroyed Weblog ID #1!
+
+More information on how to use the logger is at http://www.ruby-doc.org/core/
+
+Also, Ruby documentation can be found at http://www.ruby-lang.org/. There are
+several books available online as well:
+
+* Programming Ruby: http://www.ruby-doc.org/docs/ProgrammingRuby/ (Pickaxe)
+* Learn to Program: http://pine.fm/LearnToProgram/ (a beginners guide)
+
+These two books will bring you up to speed on the Ruby language and also on
+programming in general.
+
+
+== Debugger
+
+Debugger support is available through the debugger command when you start your
+Mongrel or WEBrick server with --debugger. This means that you can break out of
+execution at any point in the code, investigate and change the model, and then,
+resume execution! You need to install ruby-debug to run the server in debugging
+mode. With gems, use <tt>sudo gem install ruby-debug</tt>. Example:
+
+ class WeblogController < ActionController::Base
+ def index
+ @posts = Post.find(:all)
+ debugger
+ end
+ end
+
+So the controller will accept the action, run the first line, then present you
+with a IRB prompt in the server window. Here you can do things like:
+
+ >> @posts.inspect
+ => "[#<Post:0x14a6be8
+ @attributes={"title"=>nil, "body"=>nil, "id"=>"1"}>,
+ #<Post:0x14a6620
+ @attributes={"title"=>"Rails", "body"=>"Only ten..", "id"=>"2"}>]"
+ >> @posts.first.title = "hello from a debugger"
+ => "hello from a debugger"
+
+...and even better, you can examine how your runtime objects actually work:
+
+ >> f = @posts.first
+ => #<Post:0x13630c4 @attributes={"title"=>nil, "body"=>nil, "id"=>"1"}>
+ >> f.
+ Display all 152 possibilities? (y or n)
+
+Finally, when you're ready to resume execution, you can enter "cont".
+
+
+== Console
+
+The console is a Ruby shell, which allows you to interact with your
+application's domain model. Here you'll have all parts of the application
+configured, just like it is when the application is running. You can inspect
+domain models, change values, and save to the database. Starting the script
+without arguments will launch it in the development environment.
+
+To start the console, run <tt>rails console</tt> from the application
+directory.
+
+Options:
+
+* Passing the <tt>-s, --sandbox</tt> argument will rollback any modifications
+ made to the database.
+* Passing an environment name as an argument will load the corresponding
+ environment. Example: <tt>rails console production</tt>.
+
+To reload your controllers and models after launching the console run
+<tt>reload!</tt>
+
+More information about irb can be found at:
+link:http://www.rubycentral.com/pickaxe/irb.html
+
+
+== dbconsole
+
+You can go to the command line of your database directly through <tt>rails
+dbconsole</tt>. You would be connected to the database with the credentials
+defined in database.yml. Starting the script without arguments will connect you
+to the development database. Passing an argument will connect you to a different
+database, like <tt>rails dbconsole production</tt>. Currently works for MySQL,
+PostgreSQL and SQLite 3.
+
+== Description of Contents
+
+The default directory structure of a generated Ruby on Rails application:
+
+ |-- app
+ | |-- controllers
+ | |-- helpers
+ | |-- models
+ | `-- views
+ | `-- layouts
+ |-- config
+ | |-- environments
+ | |-- initializers
+ | `-- locales
+ |-- db
+ |-- doc
+ |-- lib
+ | `-- tasks
+ |-- log
+ |-- public
+ | |-- images
+ | |-- javascripts
+ | `-- stylesheets
+ |-- script
+ | `-- performance
+ |-- test
+ | |-- fixtures
+ | |-- functional
+ | |-- integration
+ | |-- performance
+ | `-- unit
+ |-- tmp
+ | |-- cache
+ | |-- pids
+ | |-- sessions
+ | `-- sockets
+ `-- vendor
+ `-- plugins
+
+app
+ Holds all the code that's specific to this particular application.
+
+app/controllers
+ Holds controllers that should be named like weblogs_controller.rb for
+ automated URL mapping. All controllers should descend from
+ ApplicationController which itself descends from ActionController::Base.
+
+app/models
+ Holds models that should be named like post.rb. Models descend from
+ ActiveRecord::Base by default.
+
+app/views
+ Holds the template files for the view that should be named like
+ weblogs/index.html.erb for the WeblogsController#index action. All views use
+ eRuby syntax by default.
+
+app/views/layouts
+ Holds the template files for layouts to be used with views. This models the
+ common header/footer method of wrapping views. In your views, define a layout
+ using the <tt>layout :default</tt> and create a file named default.html.erb.
+ Inside default.html.erb, call <% yield %> to render the view using this
+ layout.
+
+app/helpers
+ Holds view helpers that should be named like weblogs_helper.rb. These are
+ generated for you automatically when using generators for controllers.
+ Helpers can be used to wrap functionality for your views into methods.
+
+config
+ Configuration files for the Rails environment, the routing map, the database,
+ and other dependencies.
+
+db
+ Contains the database schema in schema.rb. db/migrate contains all the
+ sequence of Migrations for your schema.
+
+doc
+ This directory is where your application documentation will be stored when
+ generated using <tt>rake doc:app</tt>
+
+lib
+ Application specific libraries. Basically, any kind of custom code that
+ doesn't belong under controllers, models, or helpers. This directory is in
+ the load path.
+
+public
+ The directory available for the web server. Contains subdirectories for
+ images, stylesheets, and javascripts. Also contains the dispatchers and the
+ default HTML files. This should be set as the DOCUMENT_ROOT of your web
+ server.
+
+script
+ Helper scripts for automation and generation.
+
+test
+ Unit and functional tests along with fixtures. When using the rails generate
+ command, template test files will be generated for you and placed in this
+ directory.
+
+vendor
+ External libraries that the application depends on. Also includes the plugins
+ subdirectory. If the app has frozen rails, those gems also go here, under
+ vendor/rails/. This directory is in the load path.
View
7 Rakefile
@@ -1,10 +1,7 @@
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
-require(File.join(File.dirname(__FILE__), 'config', 'boot'))
-
+require File.expand_path('../config/application', __FILE__)
require 'rake'
-require 'rake/testtask'
-require 'rake/rdoctask'
-require 'tasks/rails'
+RailsCMSWikiForum::Application.load_tasks
View
157 app/controllers/application_controller.rb
@@ -1,158 +1,3 @@
-# Filters added to this controller apply to all controllers in the application.
-# Likewise, all the methods added will be available for all controllers.
-
class ApplicationController < ActionController::Base
- include ExceptionNotifiable
-
- helper :all
- helper_method :current_user_session, :current_user
- filter_parameter_logging :password, :password_confirmation
-
- before_filter :get_menus, :get_layout
-
-
- # checks to see if user is a member of a given access group - if not,
- # redirect to account controller
- # for multiple groups, if user is in any of the given groups, they have access
- def require_group_access(group_access_list)
- if require_user
- group_access_list = [group_access_list] unless group_access_list.is_a? Array
- in_a_group = group_access_list.inject(false) { |n,m| n or current_user.has_group_access?(m) }
- unless in_a_group
- store_location
- flash[:notice] = "You must be a member of one of a group with access of: #{group_access_list.join(" or ")}."
- redirect_to account_url
- end
- return in_a_group
- else
- return false
- end
- end
-
- def require_forum_read_access
- if require_user
- unless current_user.has_read_access_to?(@forum)
- flash[:notice] = "You do not have permission to view that forum."
- redirect_to forums_url
- end
- else
- return false
- end
- end
-
- def require_forum_write_access
- if require_user
- unless current_user.has_write_access_to?(@forum)
- flash[:notice] = "You do not have post or edit in that forum."
- redirect_to forums_url
- end
- else
- return false
- end
- end
-
- def require_wiki_read_access
- if require_user
- unless current_user.has_read_access_to?(@wiki)
- flash[:notice] = "You do not have permission to view that wiki."
- redirect_to wikis_url
- end
- else
- return false
- end
- end
-
- def require_wiki_write_access
- if require_user
- unless current_user.has_write_access_to?(@wiki)
- flash[:notice] = "You do not have permission to edit that wiki."
- redirect_to wikis_url
- end
- else
- return false
- end
- end
-
- private
- def get_menus
- @side_menu = ContentPage.get_side_menu
- @top_menu = ContentPage.get_top_menu
- end
-
- def get_layout
- @theme_base = SiteSetting.read_or_write_default_setting 'theme base', 'default'
- @theme_layout = SiteSetting.read_or_write_default_setting 'theme layout', 'default'
- @layout_file = File.join(RAILS_ROOT, "/themes/layouts/#{@theme_layout}.html.erb")
- @theme_colors = SiteSetting.read_or_write_default_setting 'theme colors', 'black and white'
- @custom_colors_timestamp = SiteSetting.read_or_write_default_setting 'custom colors timestamp', nil
- @css_override = SiteSetting.read_or_write_default_setting 'css override', nil
- @css_override_timestamp = SiteSetting.read_or_write_default_setting 'css override timestamp', nil
- end
-
- def current_user_session
- return @current_user_session if defined?(@current_user_session)
- @current_user_session = UserSession.find
- end
-
- def current_user
- return @current_user if defined?(@current_user)
- @current_user = current_user_session && current_user_session.record
- end
-
- def require_user
- if current_user
- true
- else
- store_location
- flash[:warning] = "You must be logged in to access this page."
- redirect_to login_path
- false
- end
- end
-
- def require_admin_user
- unless current_user and current_user.is_admin?
- flash[:error] = "You do not have permission to access that page."
- redirect_to login_path
- return false
- end
- end
-
- def require_moderator_user
- get_forum
- unless current_user and current_user.is_moderator_for_forum?(@forum)
- flash[:error] = "You do not have permission to access that page."
- redirect_to '/'
- return false
- end
- end
-
- def require_no_user
- if current_user
- store_location
- flash[:warning] = "You must be logged out to access this page."
- redirect_to account_url
- return false
- end
- end
-
- def store_location
- session[:return_to] = request.request_uri
- end
-
- def redirect_back_or_default(default)
- redirect_to(session[:return_to] || default)
- session[:return_to] = nil
- end
-
- # takes a file upload object and the relative directory to save it to
- # returns the relative location of the uploaded file
- def write_file(uploaded_file, rel_dir)
- file_name = uploaded_file.original_filename
- actual_dir = File.join(RAILS_ROOT, 'public', rel_dir)
- FileUtils.mkdir_p actual_dir
- File.open(File.join(actual_dir, file_name), 'wb') do |f|
- f.write(uploaded_file.read)
- end
- end
+ protect_from_forgery
end
View
111 app/helpers/application_helper.rb
@@ -1,113 +1,2 @@
-# Methods added to this helper will be available to all templates in the application.
module ApplicationHelper
-
- def top_menu
- @top_menu ? @top_menu.body_for_display : "TODO: create the top menu"
- end
-
- def side_menu
- @side_menu ? @side_menu.body_for_display : "TODO: create the side menu"
- end
-
- def logo_image
- image_tag(site_logo)
- end
-
- def site_title
- @site_title ||= SiteSetting.read_setting('site title') || "A Site"
- end
-
- def page_title
- pre = case action_name
- when "edit" then "Editing "
- when "new" then "Creating "
- else
- ""
- end
- if @content_page
- "#{pre}#{@content_page.name}"
- elsif @category
- "#{pre}Category: #{@category.name}"
- elsif @wiki_page
- "#{pre}Wiki Page: #{@wiki_page.title}"
- elsif @wiki_tag
- "#{pre}Wiki Tag: #{@wiki_tag.name}"
- elsif @wiki
- "#{pre}Wiki: #{@wiki.name}"
- elsif @message_post
- "#{pre}Message Post: #{@message_post.subject}"
- elsif @forum
- "#{pre}Forum: #{@forum.title}"
- elsif @user
- "#{pre}User: #{@user.login}"
- elsif @user_group
- "#{pre}User Group: #{@user_group.name}"
- else
- controller_name.titleize
- end
- end
-
- def site_logo
- @site_logo ||= SiteSetting.read_setting('site logo') || "GenericLogo.png"
- end
-
- def site_footer
- @site_footer ||= SiteSetting.read_setting('site footer') ||
- "Content on this site is the copyright of the owners of #{request.host} and is provided as-is without warranty."
- end
-
- def user_box
- #out = "#{pluralize User.logged_in.count, 'user'} currently logged in<br />\n"
- out = ""
-
- if current_user
- out += "Welcome, #{current_user.first_name}!<br />\n"
- out += link_to("My Account", account_path) + " | " +
- link_to("Logout", user_session_path, :method => :delete,
- :confirm => "Are you sure you want to logout?")
- out += "<br/>"
- other_links = []
- other_links << link_to('Site Admin', admin_site_settings_path) if current_user.is_admin?
- if current_user.has_access_to_any_wikis?
- if current_user.wikis.size == 1
- other_links << link_to('Wiki', current_user.wikis.first)
- else
- other_links << link_to('Wikis', wikis_path)
- end
- end
- if current_user.has_access_to_any_forums?
- if current_user.forums.size == 1
- other_links << link_to('Forum', current_user.forums.first)
- else
- other_links << link_to('Forums', forums_path)
- end
- end
- out += other_links.join(' | ')
- else
- out += link_to("Register", new_account_path) + " | " +
- link_to( "Log In", new_user_session_path)
- end
- out
- end
-
- def images_list
- Dir[File.join(RAILS_ROOT, 'public', 'images', "*.{png,jpg,gif}")].map { |f| File.basename f }.sort
- end
-
- def theme_layouts_list
- Dir[File.join(RAILS_ROOT, 'themes', 'layouts', "*.html.erb")].map { |f| File.basename(f, '.html.erb') }.sort
- end
-
- def is_admin?
- current_user and current_user.is_admin?
- end
-
- # TODO: change this to use the zoned plugin or something
- def post_time(time)
- if (Time.now - time) > 2600000
- time.strftime "on %b %d, %Y"
- else
- time_ago_in_words(time) + " ago"
- end
- end
end
View
53 app/views/layouts/application.html.erb
@@ -1,45 +1,14 @@
<!DOCTYPE html>
<html>
- <head>
- <meta http-equiv="content-type" content="text/html;charset=UTF-8" />
- <link rel="icon" type="image/png" href="/images/favorite.png"/>
- <title><%= [site_title, page_title].reject(&:blank?).join(' - ') %></title>
- <link rel="stylesheet" href="/stylesheets/blueprint/screen.css" type="text/css" media="screen, projection" />
- <link rel="stylesheet" href="/stylesheets/blueprint/print.css" type="text/css" media="print" />
- <link rel="stylesheet" href="/stylesheets/blueprint/plugins/fancy-type/screen.css" type="text/css" />
- <link rel="stylesheet" href="/stylesheets/blueprint/plugins/silksprite/sprite.css" type="text/css" />
- <!--[if lt IE 8]>
- <link rel="stylesheet" href="/stylesheets/blueprint/ie.css" type="text/css" media="screen, projection">
- <![endif]-->
- <%= stylesheet_link_tag 'error_messages' %>
- <%= stylesheet_link_tag 'text_and_colors' %>
- <%= stylesheet_link_tag 'application' %>
- <link rel="stylesheet" href="/tablesorter/blue/style.css" type="text/css" media="screen"/>
- <link type="text/css" href="/stylesheets/smoothness/jquery-ui-1.7.2.custom.css" rel="stylesheet" />
- <link rel="stylesheet" href="<%= url_for(:controller => '/themes', :action => :colors,
- :name => @theme_colors, :format => 'css') %>?<%= @custom_colors_timestamp %>" type="text/css" media="screen"/>
- <% if @css_override %>
- <link rel="stylesheet" href="<%= url_for(:controller => '/themes', :action => :css,
- :name => 'override', :format => 'css') %>?<%= @css_override_timestamp %>" type="text/css" media="screen"/>
- <% end %>
-
- <% if RAILS_ENV == "production" %>
- <script type="text/javascript" src="http://jqueryjs.googlecode.com/files/jquery-1.3.2.min.js"></script>
- <% else %>
- <%= javascript_include_tag 'jquery-1.3.2.min' %>
- <% end %>
- <script type="text/javascript" src="/ckeditor/ckeditor.js"></script>
- <%= javascript_include_tag 'jquery.tablesorter.min', 'jquery.string.1.0-min', 'lowpro.jquery', 'behaviors' %>
- <script type="text/javascript" src="/javascripts/jquery-ui-1.7.2.custom.min.js"></script>
- <script type="text/javascript">
- jQuery(function($) {
- $('a.show_hide_link').attach(ShowHideLink);
- });
- </script>
- <%= yield :javascript %>
- </head>
- <body>
- <%= Template.new(@layout_file).render_template(self) %>
- </body>
-</html>
+<head>
+ <title>RailsCMSWikiForum</title>
+ <%= stylesheet_link_tag :all %>
+ <%= javascript_include_tag :defaults %>
+ <%= csrf_meta_tag %>
+</head>
+<body>
+
+<%= yield %>
+</body>
+</html>
View
4 config.ru
@@ -0,0 +1,4 @@
+# This file is used by Rack-based servers to start the application.
+
+require ::File.expand_path('../config/environment', __FILE__)
+run RailsCMSWikiForum::Application
View
67 config/application.rb
@@ -0,0 +1,67 @@
+require File.expand_path('../boot', __FILE__)
+
+require 'rails/all'
+
+# If you have a Gemfile, require the gems listed there, including any gems
+# you've limited to :test, :development, or :production.
+Bundler.require(:default, Rails.env) if defined?(Bundler)
+
+module Rails-CMS-Wiki-Forum
+ class Application < Rails::Application
+ # Settings in config/environments/* take precedence over those specified here.
+ # Application configuration should go into files in config/initializers
+ # -- all .rb files in that directory are automatically loaded.
+ # See Rails::Configuration for more options.
+
+ # Skip frameworks you're not going to use. To use Rails without a database
+ # you must remove the Active Record framework.
+ # config.frameworks -= [ :active_record, :active_resource, :action_mailer ]
+
+ # Only load the plugins named here, in the order given. By default, all plugins
+ # in vendor/plugins are loaded in alphabetical order.
+ # :all can be used as a placeholder for all plugins not explicitly named
+ # config.plugins = [ :exception_notification, :ssl_requirement, :all ]
+
+ # Add additional load paths for your own custom dirs
+ # config.load_paths += %W( #{RAILS_ROOT}/extras )
+
+ # Force all environments to use the same logger level
+ # (by default production uses :info, the others :debug)
+ # config.log_level = :debug
+
+ # Make Time.zone default to the specified zone, and make Active Record store time values
+ # in the database in UTC, and return them converted to the specified local zone.
+ # Run "rake -D time" for a list of tasks for finding time zone names. Comment line to use default local time.
+ config.time_zone = 'UTC'
+
+ # Your secret key for verifying cookie session data integrity.
+ # If you change this key, all old sessions will become invalid!
+ # Make sure the secret is at least 30 characters and all random,
+ # no regular words or you'll be exposed to dictionary attacks.
+
+# do I need this?
+# config.action_controller.session = {
+# :key => '_site_on_rails_session',
+# :secret => '42b1a00f9cc222749e00675885e0ff4a2de996cd1586e15cfcb7fa34a76a8e8423f8217986b675df3f1c28c056455fc63d6f98eee85c176b377988b5b72ef15d'
+# }
+
+ # Use the database for sessions instead of the cookie-based default,
+ # which shouldn't be used to store highly confidential information
+ # (create the session table with "rake db:sessions:create")
+ #config.action_controller.session_store = :active_record_store
+
+ # Use SQL instead of Active Record's schema dumper when creating the test database.
+ # This is necessary if your schema can't be completely dumped by the schema dumper,
+ # like if you have constraints or database-specific column types
+ # config.active_record.schema_format = :sql
+
+ # Activate observers that should always be running
+ config.active_record.observers = [:wiki_page_observer, :user_observer]
+
+ # Configure the default encoding used in templates for Ruby 1.9.
+ config.encoding = "utf-8"
+
+ # Configure sensitive parameters which will be filtered from the log file.
+ config.filter_parameters += [:password]
+ end
+end
View
42 config/application.rb.rails3
@@ -0,0 +1,42 @@
+require File.expand_path('../boot', __FILE__)
+
+require 'rails/all'
+
+# If you have a Gemfile, require the gems listed there, including any gems
+# you've limited to :test, :development, or :production.
+Bundler.require(:default, Rails.env) if defined?(Bundler)
+
+module RailsCMSWikiForum
+ class Application < Rails::Application
+ # Settings in config/environments/* take precedence over those specified here.
+ # Application configuration should go into files in config/initializers
+ # -- all .rb files in that directory are automatically loaded.
+
+ # Custom directories with classes and modules you want to be autoloadable.
+ # config.autoload_paths += %W(#{config.root}/extras)
+
+ # Only load the plugins named here, in the order given (default is alphabetical).
+ # :all can be used as a placeholder for all plugins not explicitly named.
+ # config.plugins = [ :exception_notification, :ssl_requirement, :all ]
+
+ # Activate observers that should always be running.
+ # config.active_record.observers = :cacher, :garbage_collector, :forum_observer
+
+ # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
+ # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
+ # config.time_zone = 'Central Time (US & Canada)'
+
+ # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
+ # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
+ # config.i18n.default_locale = :de
+
+ # JavaScript files you want as :defaults (application.js is always included).
+ # config.action_view.javascript_expansions[:defaults] = %w(jquery rails)
+
+ # Configure the default encoding used in templates for Ruby 1.9.
+ config.encoding = "utf-8"
+
+ # Configure sensitive parameters which will be filtered from the log file.
+ config.filter_parameters += [:password]
+ end
+end
View
123 config/boot.rb
@@ -1,110 +1,13 @@
-# Don't change this file!
-# Configure your app in config/environment.rb and config/environments/*.rb
-
-RAILS_ROOT = "#{File.dirname(__FILE__)}/.." unless defined?(RAILS_ROOT)
-
-module Rails
- class << self
- def boot!
- unless booted?
- preinitialize
- pick_boot.run
- end
- end
-
- def booted?
- defined? Rails::Initializer
- end
-
- def pick_boot
- (vendor_rails? ? VendorBoot : GemBoot).new
- end
-
- def vendor_rails?
- File.exist?("#{RAILS_ROOT}/vendor/rails")
- end
-
- def preinitialize
- load(preinitializer_path) if File.exist?(preinitializer_path)
- end
-
- def preinitializer_path
- "#{RAILS_ROOT}/config/preinitializer.rb"
- end
- end
-
- class Boot
- def run
- load_initializer
- Rails::Initializer.run(:set_load_path)
- end
- end
-
- class VendorBoot < Boot
- def load_initializer
- require "#{RAILS_ROOT}/vendor/rails/railties/lib/initializer"
- Rails::Initializer.run(:install_gem_spec_stubs)
- Rails::GemDependency.add_frozen_gem_path
- end
- end
-
- class GemBoot < Boot
- def load_initializer
- self.class.load_rubygems
- load_rails_gem
- require 'initializer'
- end
-
- def load_rails_gem
- if version = self.class.gem_version
- gem 'rails', version
- else
- gem 'rails'
- end
- rescue Gem::LoadError => load_error
- $stderr.puts %(Missing the Rails #{version} gem. Please `gem install -v=#{version} rails`, update your RAILS_GEM_VERSION setting in config/environment.rb for the Rails version you do have installed, or comment out RAILS_GEM_VERSION to use the latest version installed.)
- exit 1
- end
-
- class << self
- def rubygems_version
- Gem::RubyGemsVersion rescue nil
- end
-
- def gem_version
- if defined? RAILS_GEM_VERSION
- RAILS_GEM_VERSION
- elsif ENV.include?('RAILS_GEM_VERSION')
- ENV['RAILS_GEM_VERSION']
- else
- parse_gem_version(read_environment_rb)
- end
- end
-
- def load_rubygems
- min_version = '1.3.2'
- require 'rubygems'
- unless rubygems_version >= min_version
- $stderr.puts %Q(Rails requires RubyGems >= #{min_version} (you have #{rubygems_version}). Please `gem update --system` and try again.)
- exit 1
- end
-
- rescue LoadError
- $stderr.puts %Q(Rails requires RubyGems >= #{min_version}. Please install RubyGems and try again: http://rubygems.rubyforge.org)
- exit 1
- end
-
- def parse_gem_version(text)
- $1 if text =~ /^[^#]*RAILS_GEM_VERSION\s*=\s*["']([!~<>=]*\s*[\d.]+)["']/
- end
-
- private
- def read_environment_rb
- File.read("#{RAILS_ROOT}/config/environment.rb")
- end
- end
- end
-end
-
-# All that for this:
-Rails.boot!
+require 'rubygems'
+
+# Set up gems listed in the Gemfile.
+gemfile = File.expand_path('../../Gemfile', __FILE__)
+begin
+ ENV['BUNDLE_GEMFILE'] = gemfile
+ require 'bundler'
+ Bundler.setup
+rescue Bundler::GemNotFound => e
+ STDERR.puts e.message
+ STDERR.puts "Try running `bundle install`."
+ exit!
+end if File.exist?(gemfile)
View
22 config/database.yml
@@ -0,0 +1,22 @@
+# SQLite version 3.x
+# gem install sqlite3-ruby (not necessary on OS X Leopard)
+development:
+ adapter: sqlite3
+ database: db/development.sqlite3
+ pool: 5
+ timeout: 5000
+
+# Warning: The database defined as "test" will be erased and
+# re-generated from your development database when you run "rake".
+# Do not set this db to the same as development or production.
+test:
+ adapter: sqlite3
+ database: db/test.sqlite3
+ pool: 5
+ timeout: 5000
+
+production:
+ adapter: sqlite3
+ database: db/production.sqlite3
+ pool: 5
+ timeout: 5000
View
5 config/environment.rb.rails3
@@ -0,0 +1,5 @@
+# Load the rails application
+require File.expand_path('../application', __FILE__)
+
+# Initialize the rails application
+RailsCMSWikiForum::Application.initialize!
View
35 config/environments/development.rb
@@ -1,17 +1,26 @@
-# Settings specified here will take precedence over those in config/environment.rb
+RailsCMSWikiForum::Application.configure do
+ # Settings specified here will take precedence over those in config/environment.rb
-# In the development environment your application's code is reloaded on
-# every request. This slows down response time but is perfect for development
-# since you don't have to restart the webserver when you make code changes.
-config.cache_classes = false
+ # In the development environment your application's code is reloaded on
+ # every request. This slows down response time but is perfect for development
+ # since you don't have to restart the webserver when you make code changes.
+ config.cache_classes = false
-# Log error messages when you accidentally call methods on nil.
-config.whiny_nils = true
+ # Log error messages when you accidentally call methods on nil.
+ config.whiny_nils = true
-# Show full error reports and disable caching
-config.action_controller.consider_all_requests_local = true
-config.action_view.debug_rjs = true
-config.action_controller.perform_caching = true
+ # Show full error reports and disable caching
+ config.consider_all_requests_local = true
+ config.action_view.debug_rjs = true
+ config.action_controller.perform_caching = false
+
+ # Don't care if the mailer can't send
+ config.action_mailer.raise_delivery_errors = false
+
+ # Print deprecation notices to the Rails logger
+ config.active_support.deprecation = :log
+
+ # Only use best-standards-support built into browsers
+ config.action_dispatch.best_standards_support = :builtin
+end
-# Don't care if the mailer can't send
-config.action_mailer.raise_delivery_errors = false
View
58 config/environments/production.rb
@@ -1,21 +1,49 @@
-# Settings specified here will take precedence over those in config/environment.rb
+RailsCMSWikiForum::Application.configure do
+ # Settings specified here will take precedence over those in config/environment.rb
-# The production environment is meant for finished, "live" apps.
-# Code is not reloaded between requests
-config.cache_classes = true
+ # The production environment is meant for finished, "live" apps.
+ # Code is not reloaded between requests
+ config.cache_classes = true
-# Use a different logger for distributed setups
-# config.logger = SyslogLogger.new
+ # Full error reports are disabled and caching is turned on
+ config.consider_all_requests_local = false
+ config.action_controller.perform_caching = true
-# Full error reports are disabled and caching is turned on
-config.action_controller.consider_all_requests_local = false
-config.action_controller.perform_caching = true
+ # Specifies the header that your server uses for sending files
+ config.action_dispatch.x_sendfile_header = "X-Sendfile"
-# Use a different cache store in production
-# config.cache_store = :mem_cache_store
+ # For nginx:
+ # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect'
-# Enable serving of images, stylesheets, and javascripts from an asset server
-# config.action_controller.asset_host = "http://assets.example.com"
+ # If you have no front-end server that supports something like X-Sendfile,
+ # just comment this out and Rails will serve the files
-# Disable delivery errors, bad email addresses will be ignored
-# config.action_mailer.raise_delivery_errors = false
+ # See everything in the log (default is :info)
+ # config.log_level = :debug
+
+ # Use a different logger for distributed setups
+ # config.logger = SyslogLogger.new
+
+ # Use a different cache store in production
+ # config.cache_store = :mem_cache_store
+
+ # Disable Rails's static asset server
+ # In production, Apache or nginx will already do this
+ config.serve_static_assets = false
+
+ # Enable serving of images, stylesheets, and javascripts from an asset server
+ # config.action_controller.asset_host = "http://assets.example.com"
+
+ # Disable delivery errors, bad email addresses will be ignored
+ # config.action_mailer.raise_delivery_errors = false
+
+ # Enable threaded mode
+ # config.threadsafe!
+
+ # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
+ # the I18n.default_locale when a translation can not be found)
+ config.i18n.fallbacks = true
+
+ # Send deprecation notices to registered listeners
+ config.active_support.deprecation = :notify
+end
View
47 config/environments/test.rb
@@ -1,22 +1,35 @@
-# Settings specified here will take precedence over those in config/environment.rb
+RailsCMSWikiForum::Application.configure do
+ # Settings specified here will take precedence over those in config/environment.rb
-# The test environment is used exclusively to run your application's
-# test suite. You never need to work with it otherwise. Remember that
-# your test database is "scratch space" for the test suite and is wiped
-# and recreated between test runs. Don't rely on the data there!
-config.cache_classes = true
+ # The test environment is used exclusively to run your application's
+ # test suite. You never need to work with it otherwise. Remember that
+ # your test database is "scratch space" for the test suite and is wiped
+ # and recreated between test runs. Don't rely on the data there!
+ config.cache_classes = true
-# Log error messages when you accidentally call methods on nil.
-config.whiny_nils = true
+ # Log error messages when you accidentally call methods on nil.
+ config.whiny_nils = true
-# Show full error reports and disable caching
-config.action_controller.consider_all_requests_local = true
-config.action_controller.perform_caching = false
+ # Show full error reports and disable caching
+ config.consider_all_requests_local = true
+ config.action_controller.perform_caching = false
-# Disable request forgery protection in test environment
-config.action_controller.allow_forgery_protection = false
+ # Raise exceptions instead of rendering exception templates
+ config.action_dispatch.show_exceptions = false
-# Tell Action Mailer not to deliver emails to the real world.
-# The :test delivery method accumulates sent emails in the
-# ActionMailer::Base.deliveries array.
-config.action_mailer.delivery_method = :test
+ # Disable request forgery protection in test environment
+ config.action_controller.allow_forgery_protection = false
+
+ # Tell Action Mailer not to deliver emails to the real world.
+ # The :test delivery method accumulates sent emails in the
+ # ActionMailer::Base.deliveries array.
+ config.action_mailer.delivery_method = :test
+
+ # Use SQL instead of Active Record's schema dumper when creating the test database.
+ # This is necessary if your schema can't be completely dumped by the schema dumper,
+ # like if you have constraints or database-specific column types
+ # config.active_record.schema_format = :sql
+
+ # Print deprecation notices to the stderr
+ config.active_support.deprecation = :stderr
+end
View
7 config/initializers/backtrace_silencers.rb
@@ -0,0 +1,7 @@
+# Be sure to restart your server when you modify this file.
+
+# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
+# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
+
+# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
+# Rails.backtrace_cleaner.remove_silencers!
View
2 config/initializers/inflections.rb
@@ -1,6 +1,6 @@
# Be sure to restart your server when you modify this file.
-# Add new inflection rules using the following format
+# Add new inflection rules using the following format
# (all these examples are active by default):
# ActiveSupport::Inflector.inflections do |inflect|
# inflect.plural /^(ox)$/i, '\1en'
View
7 config/initializers/secret_token.rb
@@ -0,0 +1,7 @@
+# Be sure to restart your server when you modify this file.
+
+# Your secret key for verifying the integrity of signed cookies.
+# If you change this key, all old signed cookies will become invalid!
+# Make sure the secret is at least 30 characters and all random,
+# no regular words or you'll be exposed to dictionary attacks.
+RailsCMSWikiForum::Application.config.secret_token = '58ad6fb2397274dd148301fb2e8b9cefe97082862cc957029966cd1438fd2e47c91ffcfd689242d3c46e13f0230da88f10af2865382a9176edfc7d57940f0382'
View
8 config/initializers/session_store.rb
@@ -0,0 +1,8 @@
+# Be sure to restart your server when you modify this file.
+
+RailsCMSWikiForum::Application.config.session_store :cookie_store, :key => '_Rails-CMS-Wiki-Forum_session'
+
+# Use the database for sessions instead of the cookie-based default,
+# which shouldn't be used to store highly confidential information
+# (create the session table with "rake db:sessions:create")
+# RailsCMSWikiForum::Application.config.session_store :active_record_store
View
5 config/locales/en.yml
@@ -0,0 +1,5 @@
+# Sample localization file for English. Add more files in this directory for other locales.
+# See http://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
+
+en:
+ hello: "Hello world"
View
69 config/newapplication.rb
@@ -0,0 +1,69 @@
+(in /home/jason/dev/projects/Rails-CMS-Wiki-Forum)
+# Put this in config/application.rb
+require File.expand_path('../boot', __FILE__)
+
+module Rails-CMS-Wiki-Forum
+ class Application < Rails::Application
+ # Settings in config/environments/* take precedence over those specified here.
+ # Application configuration should go into files in config/initializers
+ # -- all .rb files in that directory are automatically loaded.
+ # See Rails::Configuration for more options.
+
+ # Skip frameworks you're not going to use. To use Rails without a database
+ # you must remove the Active Record framework.
+ # config.frameworks -= [ :active_record, :active_resource, :action_mailer ]
+
+ # Specify gems that this application depends on.
+ # They can then be installed with "rake gems:install" on new installations.
+ # config.gem "bj"
+ # config.gem "hpricot", :version => '0.6', :source => "http://code.whytheluckystiff.net"
+ # config.gem "aws-s3", :lib => "aws/s3"
+ config.gem "RedCloth"
+ config.gem "authlogic"
+ config.gem "authlogic-oid", :lib => "authlogic_openid"
+ config.gem "ruby-openid", :lib => "openid"
+ config.gem "rspec", :lib => false, :version => ">= 1.2.0"
+ config.gem "rspec-rails", :lib => false, :version => ">= 1.2.0"
+ config.gem 'will_paginate', :version => '~> 2.3.11', :source => 'http://gemcutter.org'
+ config.gem "factory_girl", :source => "http://gemcutter.org", :version => '>= 1.2.4'
+
+ # Only load the plugins named here, in the order given. By default, all plugins
+ # in vendor/plugins are loaded in alphabetical order.
+ # :all can be used as a placeholder for all plugins not explicitly named
+ # config.plugins = [ :exception_notification, :ssl_requirement, :all ]
+
+ # Add additional load paths for your own custom dirs
+ # config.load_paths += %W( #{RAILS_ROOT}/extras )
+
+ # Force all environments to use the same logger level
+ # (by default production uses :info, the others :debug)
+ # config.log_level = :debug
+
+ # Make Time.zone default to the specified zone, and make Active Record store time values
+ # in the database in UTC, and return them converted to the specified local zone.
+ # Run "rake -D time" for a list of tasks for finding time zone names. Comment line to use default local time.
+ config.time_zone = 'UTC'
+
+ # Your secret key for verifying cookie session data integrity.
+ # If you change this key, all old sessions will become invalid!
+ # Make sure the secret is at least 30 characters and all random,
+ # no regular words or you'll be exposed to dictionary attacks.
+ config.action_controller.session = {
+ :key => '_site_on_rails_session',
+ :secret => '42b1a00f9cc222749e00675885e0ff4a2de996cd1586e15cfcb7fa34a76a8e8423f8217986b675df3f1c28c056455fc63d6f98eee85c176b377988b5b72ef15d'
+ }
+
+ # Use the database for sessions instead of the cookie-based default,
+ # which shouldn't be used to store highly confidential information
+ # (create the session table with "rake db:sessions:create")
+ #config.action_controller.session_store = :active_record_store
+
+ # Use SQL instead of Active Record's schema dumper when creating the test database.
+ # This is necessary if your schema can't be completely dumped by the schema dumper,
+ # like if you have constraints or database-specific column types
+ # config.active_record.schema_format = :sql
+
+ # Activate observers that should always be running
+ config.active_record.observers = [:wiki_page_observer, :user_observer]
+ end
+end
View
108 config/routes.rb
@@ -1,38 +1,92 @@
-ActionController::Routing::Routes.draw do |map|
- map.resources :wikis, :member => { :tagcloud => :get, :tag_index => :get } do |wiki|
- wiki.resources :wiki_pages, :member => { :upload_handler => :post, :page_link_handler => :get, :delete_asset => :post,
- :un_edit => :post, :history => :get }, :collection => { :search => :get, :live_search => :post }
- wiki.resources :wiki_comments, :collection => { :daily => :get, :weekly => :get }
- end
+(in /home/jason/dev/projects/Rails-CMS-Wiki-Forum)
+RailsCmsWikiForum::Application.routes.draw do
+ resources :wikis do
+
+
+ resources :wiki_pages do
+ collection do
+ post :live_search
+ get :search
+ end
+ member do
+ get :page_link_handler
+ post :delete_asset
+ post :un_edit
+ post :upload_handler
+ get :history
+ end
+
+ end
- map.wiki_pages_show_by_title '/wikis/:wiki_id/page/:title', :controller => 'wiki_pages', :action => 'show_by_title'
- map.wiki_tag '/wikis/:id/tag/:tag_name', :controller => 'wikis', :action => 'list_by_tag'
+ resources :wiki_comments do
+ collection do
+ get :weekly
+ get :daily
+ end
+
+
+ end
+ end
- map.connect 'themes/:action', :controller => 'themes'
- map.connect 'themes/:action/:name.:format', :controller => 'themes'
+ match '/wikis/:wiki_id/page/:title' => 'wiki_pages#show_by_title', :as => :wiki_pages_show_by_title
+ match '/wikis/:id/tag/:tag_name' => 'wikis#list_by_tag', :as => :wiki_tag
+ match 'themes/:action' => 'themes#index'
+ match 'themes/:action/:name.:format' => 'themes#index'
+ resources :site_settings do
+ collection do
+ get :admin
+ post :update_site_settings
+ end
- map.resources :site_settings, :collection => { :update_site_settings => :post, :admin => :get }
+
+ end
- map.resources :content_pages, :member => { :upload_handler => :post, :delete_asset => :post,
- :un_edit => :post }, :collection => { :search => :get }
+ resources :content_pages do
+ collection do
+ get :search
+ end
+ member do
+ post :delete_asset
+ post :un_edit
+ post :upload_handler
+ end
+
+ end
- map.resources :categories
+ resources :categories
+ match '/tagcloud.:format' => 'wiki_pages#tagcloud'
+ resources :forums do
+
- map.connect '/tagcloud.:format', :controller => 'wiki_pages', :action => 'tagcloud'
+ resources :message_posts
+ end
+ resource :account
+ resources :users do
+ collection do
+ get :reg_pass_required
+ end
+ member do
+ post :upload_handler
+ end
+
+ end
- map.resources :forums, :member => { :search => :get } do |forum|
- forum.resources :message_posts
+ resources :user_groups do
+ collection do
+ get :emails
+ end
+ member do
+ post :add_users
+ post :drop_user
+ get :add_members
+ end
+
end
- map.resource :account, :controller => "users"
- map.resources :users, :collection => { :reg_pass_required => :get }, :member => { :upload_handler => :post }
- map.resources :user_groups, :member => { :drop_user => :post, :add_members => :get, :add_users => :post },
- :collection => { :emails => :get }
- map.resource :user_session
- map.resources :password_resets
-
- map.register '/register', :controller => 'users', :action => 'new'
- map.login '/login', :controller => 'user_sessions', :action => "new"
- map.root :controller => 'content_pages', :action => 'home'
+ resource :user_session
+ resources :password_resets
+ match '/register' => 'users#new', :as => :register
+ match '/login' => 'user_sessions#new', :as => :login
+ match '/' => 'content_pages#home'
end
View
58 config/routes.rb.rails3
@@ -0,0 +1,58 @@
+RailsCMSWikiForum::Application.routes.draw do
+ # The priority is based upon order of creation:
+ # first created -> highest priority.
+
+ # Sample of regular route:
+ # match 'products/:id' => 'catalog#view'
+ # Keep in mind you can assign values other than :controller and :action
+
+ # Sample of named route:
+ # match 'products/:id/purchase' => 'catalog#purchase', :as => :purchase
+ # This route can be invoked with purchase_url(:id => product.id)
+
+ # Sample resource route (maps HTTP verbs to controller actions automatically):
+ # resources :products
+
+ # Sample resource route with options:
+ # resources :products do
+ # member do
+ # get 'short'
+ # post 'toggle'
+ # end
+ #
+ # collection do
+ # get 'sold'
+ # end
+ # end
+
+ # Sample resource route with sub-resources:
+ # resources :products do
+ # resources :comments, :sales
+ # resource :seller
+ # end
+
+ # Sample resource route with more complex sub-resources
+ # resources :products do
+ # resources :comments
+ # resources :sales do
+ # get 'recent', :on => :collection
+ # end
+ # end
+
+ # Sample resource route within a namespace:
+ # namespace :admin do
+ # # Directs /admin/products/* to Admin::ProductsController
+ # # (app/controllers/admin/products_controller.rb)
+ # resources :products
+ # end
+
+ # You can have the root of your site routed with "root"
+ # just remember to delete public/index.html.
+ # root :to => "welcome#index"
+
+ # See how all your routes lay out with "rake routes"
+
+ # This is a legacy wild controller route that's not recommended for RESTful applications.
+ # Note: This route will make all actions in every controller accessible via GET requests.
+ # match ':controller(/:action(/:id(.:format)))'
+end
View
201 db/schema.rb
@@ -0,0 +1,201 @@
+# This file is auto-generated from the current state of the database. Instead of editing this file,
+# please use the migrations feature of Active Record to incrementally modify your database, and
+# then regenerate this schema definition.
+#
+# Note that this schema.rb definition is the authoritative source for your database schema. If you need
+# to create the application database on another system, you should be using db:schema:load, not running
+# all the migrations from scratch. The latter is a flawed and unsustainable approach (the more migrations
+# you'll amass, the slower it'll run and the greater likelihood for issues).
+#
+# It's strongly recommended to check this file into your version control system.
+
+ActiveRecord::Schema.define(:version => 20100420230938) do
+
+ create_table "categories", :force => true do |t|
+ t.string "name"
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ end
+
+ create_table "categories_content_pages", :id => false, :force => true do |t|
+ t.integer "category_id"
+ t.integer "content_page_id"
+ end
+
+ add_index "categories_content_pages", ["category_id"], :name => "index_categories_content_pages_on_category_id"
+ add_index "categories_content_pages", ["content_page_id"], :name => "index_categories_content_pages_on_content_page_id"
+
+ create_table "content_pages", :force => true do |t|
+ t.string "name"
+ t.text "body"
+ t.string "special"
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ t.boolean "is_preview_only"
+ t.datetime "started_editing_at"
+ t.integer "editing_user_id"
+ t.date "publish_on"
+ end
+
+ create_table "forums", :force => true do |t|
+ t.string "title"
+ t.text "description"
+ t.integer "position"
+ t.boolean "moderator_only"
+ t.integer "newest_message_post_id"
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ end
+
+ create_table "message_posts", :force => true do |t|
+ t.string "subject"
+ t.text "body", :limit => 16777215
+ t.integer "forum_id"
+ t.integer "parent_id"
+ t.integer "user_id"
+ t.integer "to_user_id"
+ t.integer "thread_id"
+ t.datetime "replied_to_at"
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ end
+
+ add_index "message_posts", ["created_at"], :name => "index_messages_on_created_at"
+ add_index "message_posts", ["forum_id"], :name => "index_messages_on_forum_id"
+ add_index "message_posts", ["parent_id"], :name => "index_messages_on_parent_id"
+ add_index "message_posts", ["thread_id"], :name => "index_messages_on_thread_id"
+ add_index "message_posts", ["to_user_id"], :name => "index_messages_on_to_user_id"
+ add_index "message_posts", ["user_id"], :name => "index_messages_on_user_id"
+
+ create_table "sessions", :force => true do |t|
+ t.string "session_id", :null => false
+ t.text "data"
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ end
+
+ add_index "sessions", ["session_id"], :name => "index_sessions_on_session_id"
+ add_index "sessions", ["updated_at"], :name => "index_sessions_on_updated_at"
+
+ create_table "site_settings", :force => true do |t|
+ t.string "setting_name"
+ t.string "setting_string_value"
+ t.text "setting_text_value"
+ t.integer "setting_number_value"
+ t.boolean "yamled"
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ end
+
+ create_table "user_groups", :force => true do |t|
+ t.string "name"
+ t.text "special", :limit => 255
+ end
+
+ create_table "user_groups_users", :id => false, :force => true do |t|
+ t.integer "user_id"
+ t.integer "user_group_id"
+ end
+
+ add_index "user_groups_users", ["user_group_id"], :name => "index_user_groups_users_on_user_group_id"
+ add_index "user_groups_users", ["user_id"], :name => "index_user_groups_users_on_user_id"
+
+ create_table "users", :force => true do |t|
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ t.string "login", :null => false
+ t.string "email", :null => false
+ t.string "crypted_password", :null => false
+ t.string "password_salt", :null => false
+ t.string "persistence_token", :null => false
+ t.string "perishable_token", :null => false
+ t.integer "login_count", :default => 0, :null => false
+ t.datetime "last_request_at"
+ t.datetime "last_login_at"
+ t.datetime "current_login_at"
+ t.string "last_login_ip"
+ t.string "current_login_ip"
+ t.boolean "is_admin"
+ t.string "first_name"
+ t.string "last_name"
+ t.text "user_defined_fields"
+ t.string "requested_user_group_ids"
+ end
+
+ add_index "users", ["email"], :name => "index_users_on_email"
+ add_index "users", ["last_request_at"], :name => "index_users_on_last_request_at"
+ add_index "users", ["login"], :name => "index_users_on_login"
+ add_index "users", ["perishable_token"], :name => "index_users_on_perishable_token"
+ add_index "users", ["persistence_token"], :name => "index_users_on_persistence_token"
+
+ create_table "wiki_comments", :force => true do |t|
+ t.integer "wiki_page_id"
+ t.integer "user_id"
+ t.text "body"
+ t.integer "looking_at_version"
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ t.integer "about_wiki_page_id"
+ t.integer "wiki_id"
+ end
+
+ add_index "wiki_comments", ["wiki_id"], :name => "index_wiki_comments_on_wiki_id"
+ add_index "wiki_comments", ["wiki_page_id"], :name => "index_wiki_comments_on_wiki_page_id"
+
+ create_table "wiki_page_versions", :force => true do |t|
+ t.integer "wiki_page_id"
+ t.integer "version"
+ t.string "title"
+ t.string "url_title"
+ t.integer "modifying_user_id"
+ t.text "body"
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ t.datetime "started_editing_at"
+ t.integer "editing_user_id"
+ t.integer "wiki_id"
+ end
+
+ add_index "wiki_page_versions", ["wiki_id"], :name => "index_wiki_page_versions_on_wiki_id"
+ add_index "wiki_page_versions", ["wiki_page_id"], :name => "index_wiki_page_versions_on_wiki_page_id"
+
+ create_table "wiki_pages", :force => true do |t|
+ t.string "title"
+ t.string "url_title"
+ t.integer "modifying_user_id"
+ t.text "body"
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ t.integer "version"
+ t.datetime "started_editing_at"
+ t.integer "editing_user_id"
+ t.integer "wiki_id"
+ end
+
+ add_index "wiki_pages", ["modifying_user_id"], :name => "index_wiki_pages_on_modifying_user_id"
+ add_index "wiki_pages", ["url_title"], :name => "index_wiki_pages_on_url_title"
+ add_index "wiki_pages", ["wiki_id"], :name => "index_wiki_pages_on_wiki_id"
+
+ create_table "wiki_pages_wiki_tags", :id => false, :force => true do |t|
+ t.integer "wiki_tag_id"
+ t.integer "wiki_page_id"
+ end
+
+ add_index "wiki_pages_wiki_tags", ["wiki_page_id"], :name => "index_wiki_pages_wiki_tags_on_wiki_page_id"
+ add_index "wiki_pages_wiki_tags", ["wiki_tag_id"], :name => "index_wiki_pages_wiki_tags_on_wiki_tag_id"
+
+ create_table "wiki_tags", :force => true do |t|
+ t.string "name"
+ t.integer "wiki_id"
+ end
+
+ add_index "wiki_tags", ["name"], :name => "index_wiki_tags_on_name"
+
+ create_table "wikis", :force => true do |t|
+ t.string "name"
+ t.text "description"
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ end
+
+end
View
7 db/seeds.rb
@@ -0,0 +1,7 @@
+# This file should contain all the record creation needed to seed the database with its default values.
+# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
+#
+# Examples:
+#
+# cities = City.create([{ :name => 'Chicago' }, { :name => 'Copenhagen' }])
+# Mayor.create(:name => 'Daley', :city => cities.first)
View
0 lib/tasks/.gitkeep
No changes.
View
34 public/404.html
@@ -1,23 +1,19 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-
+<!DOCTYPE html>
+<html>
<head>
- <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<title>The page you were looking for doesn't exist (404)</title>
- <style type="text/css">
- body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
- div.dialog {
- width: 25em;
- padding: 0 4em;
- margin: 4em auto 0 auto;
- border: 1px solid #ccc;
- border-right-color: #999;
- border-bottom-color: #999;
- }
- h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
- </style>
+ <style type="text/css">
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
+ div.dialog {
+ width: 25em;
+ padding: 0 4em;
+ margin: 4em auto 0 auto;
+ border: 1px solid #ccc;
+ border-right-color: #999;
+ border-bottom-color: #999;
+ }
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
+ </style>
</head>
<body>
@@ -27,4 +23,4 @@
<p>You may have mistyped the address or the page may have moved.</p>
</div>
</body>
-</html>
+</html>
View
34 public/422.html
@@ -1,23 +1,19 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-
+<!DOCTYPE html>
+<html>
<head>
- <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<title>The change you wanted was rejected (422)</title>
- <style type="text/css">
- body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
- div.dialog {
- width: 25em;
- padding: 0 4em;
- margin: 4em auto 0 auto;
- border: 1px solid #ccc;
- border-right-color: #999;
- border-bottom-color: #999;
- }
- h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
- </style>
+ <style type="text/css">
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
+ div.dialog {
+ width: 25em;
+ padding: 0 4em;
+ margin: 4em auto 0 auto;
+ border: 1px solid #ccc;
+ border-right-color: #999;
+ border-bottom-color: #999;
+ }
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
+ </style>
</head>
<body>
@@ -27,4 +23,4 @@
<p>Maybe you tried to change something you didn't have access to.</p>
</div>
</body>
-</html>
+</html>
View
34 public/500.html
@@ -1,23 +1,19 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-
+<!DOCTYPE html>
+<html>
<head>
- <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<title>We're sorry, but something went wrong (500)</title>
- <style type="text/css">
- body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
- div.dialog {
- width: 25em;
- padding: 0 4em;
- margin: 4em auto 0 auto;
- border: 1px solid #ccc;
- border-right-color: #999;
- border-bottom-color: #999;
- }
- h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
- </style>
+ <style type="text/css">
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
+ div.dialog {
+ width: 25em;
+ padding: 0 4em;
+ margin: 4em auto 0 auto;
+ border: 1px solid #ccc;
+ border-right-color: #999;
+ border-bottom-color: #999;
+ }
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
+ </style>
</head>
<body>
@@ -27,4 +23,4 @@
<p>We've been notified about this issue and we'll take a look at it shortly.</p>
</div>
</body>
-</html>
+</html>
View
BIN public/images/rails.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
239 public/index.html
@@ -0,0 +1,239 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>Ruby on Rails: Welcome aboard</title>
+ <style type="text/css" media="screen">
+ body {
+ margin: 0;
+ margin-bottom: 25px;
+ padding: 0;
+ background-color: #f0f0f0;
+ font-family: "Lucida Grande", "Bitstream Vera Sans", "Verdana";
+ font-size: 13px;
+ color: #333;
+ }
+
+ h1 {
+ font-size: 28px;
+ color: #000;
+ }
+
+ a {color: #03c}
+ a:hover {
+ background-color: #03c;
+ color: white;
+ text-decoration: none;
+ }
+
+
+ #page {
+ background-color: #f0f0f0;
+ width: 750px;
+ margin: 0;
+ margin-left: auto;
+ margin-right: auto;
+ }
+
+ #content {
+ float: left;
+ background-color: white;
+ border: 3px solid #aaa;
+ border-top: none;
+ padding: 25px;
+ width: 500px;
+ }
+
+ #sidebar {
+ float: right;
+ width: 175px;
+ }
+
+ #footer {
+ clear: both;
+ }
+
+
+ #header, #about, #getting-started {
+ padding-left: 75px;
+ padding-right: 30px;
+ }
+
+
+ #header {
+ background-image: url("images/rails.png");
+ background-repeat: no-repeat;
+ background-position: top left;
+ height: 64px;
+ }
+ #header h1, #header h2 {margin: 0}
+ #header h2 {
+ color: #888;
+ font-weight: normal;
+ font-size: 16px;
+ }
+
+
+ #about h3 {
+ margin: 0;
+ margin-bottom: 10px;
+ font-size: 14px;
+ }
+
+ #about-content {
+ background-color: #ffd;
+ border: 1px solid #fc0;
+ margin-left: -55px;
+ margin-right: -10px;
+ }
+ #about-content table {
+ margin-top: 10px;
+ margin-bottom: 10px;
+ font-size: 11px;
+ border-collapse: collapse;
+ }
+ #about-content td {
+ padding: 10px;
+ padding-top: 3px;
+ padding-bottom: 3px;
+ }
+ #about-content td.name {color: #555}
+ #about-content td.value {color: #000}
+
+ #about-content ul {
+ padding: 0;
+ list-style-type: none;
+ }
+
+ #about-content.failure {
+ background-color: #fcc;
+ border: 1px solid #f00;
+ }
+ #about-content.failure p {
+ margin: 0;
+ padding: 10px;
+ }
+
+
+ #getting-started {
+ border-top: 1px solid #ccc;
+ margin-top: 25px;
+ padding-top: 15px;
+ }
+ #getting-started h1 {
+ margin: 0;
+ font-size: 20px;
+ }
+ #getting-started h2 {
+ margin: 0;
+ font-size: 14px;
+ font-weight: normal;
+ color: #333;
+ margin-bottom: 25px;
+ }
+ #getting-started ol {
+ margin-left: 0;
+ padding-left: 0;
+ }
+ #getting-started li {
+ font-size: 18px;
+ color: #888;
+ margin-bottom: 25px;
+ }
+ #getting-started li h2 {
+ margin: 0;
+ font-weight: normal;
+ font-size: 18px;
+ color: #333;
+ }
+ #getting-started li p {
+ color: #555;
+ font-size: 13px;
+ }
+
+
+ #sidebar ul {
+ margin-left: 0;
+ padding-left: 0;
+ }
+ #sidebar ul h3 {
+ margin-top: 25px;
+ font-size: 16px;
+ padding-bottom: 10px;
+ border-bottom: 1px solid #ccc;
+ }
+ #sidebar li {
+ list-style-type: none;
+ }
+ #sidebar ul.links li {
+ margin-bottom: 5px;
+ }
+
+ </style>
+ <script type="text/javascript">
+ function about() {
+ info = document.getElementById('about-content');
+ if (window.XMLHttpRequest)
+ { xhr = new XMLHttpRequest(); }
+ else
+ { xhr = new ActiveXObject("Microsoft.XMLHTTP"); }
+ xhr.open("GET","rails/info/properties",false);
+ xhr.send("");
+ info.innerHTML = xhr.responseText;
+ info.style.display = 'block'
+ }
+ </script>
+ </head>
+ <body>
+ <div id="page">
+ <div id="sidebar">
+ <ul id="sidebar-items">
+ <li>
+ <h3>Browse the documentation</h3>
+ <ul class="links">
+ <li><a href="http://api.rubyonrails.org/">Rails API</a></li>
+ <li><a href="http://stdlib.rubyonrails.org/">Ruby standard library</a></li>
+ <li><a href="http://corelib.rubyonrails.org/">Ruby core</a></li>
+ <li><a href="http://guides.rubyonrails.org/">Rails Guides</a></li>
+ </ul>
+ </li>
+ </ul>
+ </div>
+
+ <div id="content">
+ <div id="header">
+ <h1>Welcome aboard</h1>
+ <h2>You&rsquo;re riding Ruby on Rails!</h2>
+ </div>
+
+ <div id="about">
+ <h3><a href="rails/info/properties" onclick="about(); return false">About your application&rsquo;s environment</a></h3>
+ <div id="about-content" style="display: none"></div>
+ </div>
+
+ <div id="getting-started">
+ <h1>Getting started</h1>
+ <h2>Here&rsquo;s how to get rolling:</h2>
+
+ <ol>
+ <li>
+ <h2>Use <code>rails generate</code> to create your models and controllers</h2>
+ <p>To see all available options, run it without parameters.</p>
+ </li>
+
+ <li>
+ <h2>Set up a default route and remove or rename this file</h2>
+ <p>Routes are set up in config/routes.rb.</p>
+ </li>
+
+ <li>
+ <h2>Create your database</h2>
+ <p>Run <code>rake db:migrate</code> to create your database. If you're not using SQLite (the default), edit <code>config/database.yml</code> with your username and password.</p>
+ </li>
+ </ol>
+ </div>
+ </div>
+
+ <div id="footer">&nbsp;</div>
+ </div>
+ </body>
+</html>
View
965 public/javascripts/controls.js
@@ -0,0 +1,965 @@
+// script.aculo.us controls.js v1.8.3, Thu Oct 08 11:23:33 +0200 2009
+
+// Copyright (c) 2005-2009 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
+// (c) 2005-2009 Ivan Krstic (http://blogs.law.harvard.edu/ivan)
+// (c) 2005-2009 Jon Tirsen (http://www.tirsen.com)
+// Contributors:
+// Richard Livsey
+// Rahul Bhargava
+// Rob Wills
+//
+// script.aculo.us is freely distributable under the terms of an MIT-style license.
+// For details, see the script.aculo.us web site: http://script.aculo.us/
+
+// Autocompleter.Base handles all the autocompletion functionality
+// that's independent of the data source for autocompletion. This
+// includes drawing the autocompletion menu, observing keyboard
+// and mouse events, and similar.
+//
+// Specific autocompleters need to provide, at the very least,
+// a getUpdatedChoices function that will be invoked every time
+// the text inside the monitored textbox changes. This method
+// should get the text for which to provide autocompletion by
+// invoking this.getToken(), NOT by directly accessing
+// this.element.value. This is to allow incremental tokenized
+// autocompletion. Specific auto-completion logic (AJAX, etc)
+// belongs in getUpdatedChoices.
+//
+// Tokenized incremental autocompletion is enabled automatically
+// when an autocompleter is instantiated with the 'tokens' option
+// in the options parameter, e.g.:
+// new Ajax.Autocompleter('id','upd', '/url/', { tokens: ',' });
+// will incrementally autocomplete with a comma as the token.
+// Additionally, ',' in the above example can be replaced with
+// a token array, e.g. { tokens: [',', '\n'] } which
+// enables autocompletion on multiple tokens. This is most
+// useful when one of the tokens is \n (a newline), as it
+// allows smart autocompletion after linebreaks.
+
+if(typeof Effect == 'undefined')
+ throw("controls.js requires including script.aculo.us' effects.js library");
+
+var Autocompleter = { };
+Autocompleter.Base = Class.create({
+ baseInitialize: function(element, update, options) {
+ element = $(element);
+ this.element = element;
+ this.update = $(update);
+ this.hasFocus = false;
+ this.changed = false;
+ this.active = false;
+ this.index = 0;
+ this.entryCount = 0;
+ this.oldElementValue = this.element.value;
+
+ if(this.setOptions)
+ this.setOptions(options);
+ else
+ this.options = options || { };
+
+ this.options.paramName = this.options.paramName || this.element.name;
+ this.options.tokens = this.options.tokens || [];
+ this.options.frequency = this.options.frequency || 0.4;
+ this.options.minChars = this.options.minChars || 1;
+ this.options.onShow = this.options.onShow ||
+ function(element, update){
+ if(!update.style.position || update.style.position=='absolute') {
+ update.style.position = 'absolute';
+ Position.clone(element, update, {
+ setHeight: false,
+ offsetTop: element.offsetHeight
+ });
+ }
+ Effect.Appear(update,{duration:0.15});
+ };
+ this.options.onHide = this.options.onHide ||
+ function(element, update){ new Effect.Fade(update,{duration:0.15}) };
+
+ if(typeof(this.options.tokens) == 'string')
+ this.options.tokens = new Array(this.options.tokens);
+ // Force carriage returns as token delimiters anyway
+ if (!this.options.tokens.include('\n'))
+ this.options.tokens.push('\n');
+
+ this.observer = null;
+
+ this.element.setAttribute('autocomplete','off');
+
+ Element.hide(this.update);
+
+ Event.observe(this.element, 'blur', this.onBlur.bindAsEventListener(this));
+ Event.observe(this.element, 'keydown', this.onKeyPress.bindAsEventListener(this));
+ },
+
+ show: function() {
+ if(Element.getStyle(this.update, 'display')=='none') this.options.onShow(this.element, this.update);
+ if(!this.iefix &&
+ (Prototype.Browser.IE) &&
+ (Element.getStyle(this.update, 'position')=='absolute')) {