diff options
Diffstat (limited to 'railties')
-rw-r--r-- | railties/CHANGELOG | 4 | ||||
-rw-r--r-- | railties/Rakefile | 2 | ||||
-rw-r--r-- | railties/builtin/controllers/rails_info_controller.rb | 11 | ||||
-rw-r--r-- | railties/html/images/rails.png | bin | 0 -> 1787 bytes | |||
-rw-r--r-- | railties/html/index.html | 343 | ||||
-rw-r--r-- | railties/lib/initializer.rb | 3 | ||||
-rw-r--r-- | railties/lib/rails_generator/generators/applications/app/app_generator.rb | 1 | ||||
-rw-r--r-- | railties/lib/rails_info.rb | 10 | ||||
-rw-r--r-- | railties/lib/railties_path.rb | 2 | ||||
-rw-r--r-- | railties/lib/tasks/javascripts.rake | 2 | ||||
-rw-r--r-- | railties/test/rails_info_controller_test.rb | 54 |
11 files changed, 357 insertions, 75 deletions
diff --git a/railties/CHANGELOG b/railties/CHANGELOG index f98bde50f0..6df4aeea07 100644 --- a/railties/CHANGELOG +++ b/railties/CHANGELOG @@ -1,3 +1,7 @@ +*SVN* + +* Added an omnipresent RailsInfoController with a properties action that delivers an HTML rendering of Rails::Info (but only when local_request? is true). Added a new default index.html which fetches this with Ajax. [Sam Stephenson] + *0.14.3 (RC4)* (November 7th, 2005) * Add 'add_new_scripts' rake task for adding new rails scripts to script/* [Jamis Buck] diff --git a/railties/Rakefile b/railties/Rakefile index 2f31df3809..e425f9a4dd 100644 --- a/railties/Rakefile +++ b/railties/Rakefile @@ -34,7 +34,7 @@ PUBLIC_DIRS = %w( images javascripts stylesheets ) TEST_DIRS = %w( fixtures unit functional mocks mocks/development mocks/test ) LOG_FILES = %w( server.log development.log test.log production.log ) -HTML_FILES = %w( 404.html 500.html index.html robots.txt favicon.ico +HTML_FILES = %w( 404.html 500.html index.html robots.txt favicon.ico images/rails.png javascripts/prototype.js javascripts/effects.js javascripts/dragdrop.js javascripts/controls.js ) BIN_FILES = %w( about breakpointer console destroy generate performance/benchmarker performance/profiler process/reaper process/spawner process/spinner runner server plugin ) diff --git a/railties/builtin/controllers/rails_info_controller.rb b/railties/builtin/controllers/rails_info_controller.rb new file mode 100644 index 0000000000..ca2801e075 --- /dev/null +++ b/railties/builtin/controllers/rails_info_controller.rb @@ -0,0 +1,11 @@ +module Controllers #:nodoc: + class RailsInfoController < ApplicationController + def properties + if local_request? + render :inline => Rails::Info.to_html + else + render :text => '<p>For security purposes, this information is only available to local requests.</p>', :status => 500 + end + end + end +end
\ No newline at end of file diff --git a/railties/html/images/rails.png b/railties/html/images/rails.png Binary files differnew file mode 100644 index 0000000000..b8441f182e --- /dev/null +++ b/railties/html/images/rails.png diff --git a/railties/html/index.html b/railties/html/index.html index d780f8e029..952ee4febb 100644 --- a/railties/html/index.html +++ b/railties/html/index.html @@ -1,78 +1,279 @@ -<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" - "http://www.w3.org/TR/html4/loose.dtd"> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" + "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> -<head> - <title>Rails: Welcome on board</title> - <style> - body { background-color: #fff; color: #333; } + <head> + <meta http-equiv="Content-type" content="text/html; charset=utf-8" /> + <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; + } - body, p, ol, ul, td { - font-family: verdana, arial, helvetica, sans-serif; - font-size: 12px; - line-height: 18px; - } + #footer { + clear: both; + } + - li { - margin-bottom: 7px; - } + #header, #about, #getting-started { + padding-left: 75px; + padding-right: 30px; + } - pre { - background-color: #eee; - padding: 10px; - font-size: 11px; - } - a { color: #000; } - a:visited { color: #666; } - a:hover { color: #fff; background-color:#000; } - </style> -</head> -<body> + #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: -11px; + } + #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.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; + } + + + #search { + margin: 0; + padding-top: 10px; + padding-bottom: 10px; + font-size: 11px; + } + #search input { + font-size: 11px; + margin: 2px; + } + #search-text {width: 170px} + + + #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" src="javascripts/prototype.js"></script> + <script type="text/javascript" src="javascripts/effects.js"></script> + <script type="text/javascript"> + function about() { + if (Element.empty('about-content')) { + new Ajax.Updater('about-content', 'rails_info/properties', { + method: 'get', + onFailure: function() {Element.classNames('about-content').add('failure')}, + onComplete: function() {new Effect.BlindDown('about-content', {duration: 0.25})} + }); + } else { + new Effect[Element.visible('about-content') ? + 'BlindUp' : 'BlindDown']('about-content', {duration: 0.25}); + } + } + + window.onload = function() { + $('search-text').value = ''; + $('search').onsubmit = function() { + $('search-text').value = 'site:rubyonrails.com ' + $F('search-text'); + } + } + </script> + </head> + <body> + <div id="page"> + <div id="sidebar"> + <ul id="sidebar-items"> + <li> + <form id="search" action="http://www.google.com/search" method="get"> + <input type="hidden" name="hl" value="en" /> + <input type="text" id="search-text" name="q" value="site:rubyonrails.com " /> + <input type="submit" value="Search" /> the Rails site + </form> + </li> + + <li> + <h3>Join the community</h3> + <ul class="links"> + <li><a href="http://www.rubyonrails.com/">Ruby on Rails</a></li> + <li><a href="http://weblog.rubyonrails.com/">Official weblog</a></li> + <li><a href="http://lists.rubyonrails.org/">Mailing lists</a></li> + <li><a href="http://wiki.rubyonrails.com/rails/pages/IRC">IRC channel</a></li> + <li><a href="http://wiki.rubyonrails.com/">Wiki</a></li> + <li><a href="http://dev.rubyonrails.com/">Bug tracker</a></li> + </ul> + </li> + + <li> + <h3>Browse the documentation</h3> + <ul class="links"> + <li><a href="http://manuals.rubyonrails.com/">Manuals</a></li> + <li><a href="http://api.rubyonrails.com/">All APIs</a></li> + <li><a href="http://ar.rubyonrails.com/">Active Record</a></li> + <li><a href="http://ap.rubyonrails.com/">Action Pack</a></li> + <li><a href="http://as.rubyonrails.com/">Active Support</a></li> + </ul> + </li> + </ul> + </div> -<h1>Congratulations, you've put Ruby on Rails!</h1> + <div id="content"> + <div id="header"> + <h1>Welcome aboard</h2> + <h2>You’re riding the Rails!</h2> + </div> -<p><b>Before you move on</b>, verify that the following conditions have been met:</p> - -<ol> - <li>The log and public directories must be writable to the web server (<code>chmod -R 775 log</code> and <code>chmod -R 775 public</code>). - <li> - The shebang line in the public/dispatch* files must reference your Ruby installation. <br/> - You might need to change it to <code>#!/usr/bin/env ruby</code> or point directly at the installation. - </li> - <li> - Rails on Apache needs to have the cgi handler and mod_rewrite enabled. <br/> - Somewhere in your httpd.conf, you should have:<br/> - <code>AddHandler cgi-script .cgi</code><br/> - <code>LoadModule rewrite_module libexec/httpd/mod_rewrite.so</code><br/> - <code>AddModule mod_rewrite.c</code> - </li> -</ol> - -<p>Take the following steps to get started:</p> - -<ol> - <li>Create empty development and test databases for your application.<br/> - <small>Recommendation: Use *_development and *_test names, such as basecamp_development and basecamp_test</small><br/> - <small>Warning: Don't point your test database at your development database, it'll destroy the latter on test runs!</small> - <li>Edit config/database.yml with your database settings. - <li>Create controllers and models using the generator in <code>script/generate</code> <br/> - <small>Help: Run the generator with no arguments for documentation</small> - <li>See all the tests run by running <code>rake</code>. - <li>Develop your Rails application! - <li>Setup Apache with <a href="http://www.fastcgi.com">FastCGI</a> (and <a href="http://raa.ruby-lang.org/list.rhtml?name=fcgi">Ruby bindings</a>), if you need better performance - <li>Remove the dispatches you don't use (so if you're on FastCGI, delete/move dispatch.rb, dispatch.cgi and gateway.cgi)</li> -</ol> - -<p> - Trying to setup a default page for Rails using Routes? You'll have to delete this file (public/index.html) to get under way. Then define a new route in <tt>config/routes.rb</tt> of the form: - <pre> map.connect '', :controller => 'wiki/page', :action => 'show', :title => 'Welcome'</pre> -</p> - -<p> - Having problems getting up and running? First try debugging it yourself by looking at the log files. <br/> - Then try the friendly Rails community <a href="http://www.rubyonrails.org">on the web</a> or <a href="http://www.rubyonrails.org/show/IRC">on IRC</a> - (<a href="irc://irc.freenode.net/#rubyonrails">FreeNode#rubyonrails</a>). -</p> - -</body> -</html> + <div id="about"> + <h3><a href="rails_info/properties" onclick="about(); return false">About your application’s environment</a></h3> + <div id="about-content" style="display: none"></div> + </div> + + <div id="getting-started"> + <h1>Getting started</h1> + <h2>Here’s how to get rolling:</h2> + + <ol> + <li> + <h2>Create your databases and edit <tt>database.yml</tt></h2> + <p>Instructions here</p> + </li> + + <li> + <h2>Use <tt>script/generate</tt> to create your models and controllers</h2> + <p>Instructions here</p> + </li> + + <li> + <h2>Set up a default route and remove or rename this file</h2> + <p>Instructions here</p> + </li> + </ol> + </div> + </div> + + <div id="footer"> </div> + </div> + </body> +</html>
\ No newline at end of file diff --git a/railties/lib/initializer.rb b/railties/lib/initializer.rb index 31edd69f46..1535b7213f 100644 --- a/railties/lib/initializer.rb +++ b/railties/lib/initializer.rb @@ -1,5 +1,6 @@ require 'logger' require 'set' +require File.join(File.dirname(__FILE__), 'railties_path') RAILS_ENV = (ENV['RAILS_ENV'] || 'development').dup unless defined?(RAILS_ENV) @@ -488,7 +489,7 @@ module Rails end def default_controller_paths - [ File.join(root_path, 'app', 'controllers'), File.join(root_path, 'components') ] + [ File.join(root_path, 'app', 'controllers'), File.join(root_path, 'components'), File.join(RAILTIES_PATH, 'builtin', 'controllers') ] end def default_dependency_mechanism diff --git a/railties/lib/rails_generator/generators/applications/app/app_generator.rb b/railties/lib/rails_generator/generators/applications/app/app_generator.rb index 01f371ce42..aee2cced24 100644 --- a/railties/lib/rails_generator/generators/applications/app/app_generator.rb +++ b/railties/lib/rails_generator/generators/applications/app/app_generator.rb @@ -64,6 +64,7 @@ class AppGenerator < Rails::Generator::Base m.template "html/favicon.ico", "public/favicon.ico" m.template "html/robots.txt", "public/robots.txt" + m.file "html/images/rails.png", "public/images/rails.png" # Javascripts m.file "html/javascripts/prototype.js", "public/javascripts/prototype.js" diff --git a/railties/lib/rails_info.rb b/railties/lib/rails_info.rb index c0237dab7c..5c71a289c2 100644 --- a/railties/lib/rails_info.rb +++ b/railties/lib/rails_info.rb @@ -42,6 +42,16 @@ module Rails alias inspect to_s + def to_html + returning table = '<table>' do + properties.each do |(name, value)| + table << %(<tr><td class="name">#{CGI.escapeHTML(name)}</td>) + table << %(<td class="value">#{CGI.escapeHTML(value)}</td></tr>) + end + table << '</table>' + end + end + protected def svn_info Dir.chdir("#{RAILS_ROOT}/vendor/rails") do diff --git a/railties/lib/railties_path.rb b/railties/lib/railties_path.rb index b08ced8be5..817940504d 100644 --- a/railties/lib/railties_path.rb +++ b/railties/lib/railties_path.rb @@ -1 +1 @@ -RAILTIES_PATH = File.expand_path(File.dirname(__FILE__))
\ No newline at end of file +RAILTIES_PATH = File.expand_path(File.join(File.dirname(__FILE__), '..'))
\ No newline at end of file diff --git a/railties/lib/tasks/javascripts.rake b/railties/lib/tasks/javascripts.rake index 91965c8918..5fc01562e8 100644 --- a/railties/lib/tasks/javascripts.rake +++ b/railties/lib/tasks/javascripts.rake @@ -2,5 +2,5 @@ desc "Update your javascripts from your current rails install." task :update_javascripts do require 'railties_path' - FileUtils.cp(Dir[RAILTIES_PATH + '/../html/javascripts/*.js'], RAILS_ROOT + '/public/javascripts/') + FileUtils.cp(Dir[RAILTIES_PATH + '/html/javascripts/*.js'], RAILS_ROOT + '/public/javascripts/') end diff --git a/railties/test/rails_info_controller_test.rb b/railties/test/rails_info_controller_test.rb new file mode 100644 index 0000000000..1488387f3c --- /dev/null +++ b/railties/test/rails_info_controller_test.rb @@ -0,0 +1,54 @@ +$:.unshift File.dirname(__FILE__) + "/../lib" +$:.unshift File.dirname(__FILE__) + "/../builtin/controllers" +$:.unshift File.dirname(__FILE__) + "/../../actionpack/lib" +$:.unshift File.dirname(__FILE__) + "/../../activesupport/lib" + +require 'test/unit' +require 'action_controller' +require 'action_controller/test_process' +require 'rails_info' + +module Controllers; def self.const_available?(constant); false end end + +class ApplicationController < ActionController::Base + @local_request = false + class << self + cattr_accessor :local_request + end + +protected + def local_request? + self.class.local_request + end +end + +ActionController::Routing::Routes.draw do |map| + map.connect ':controller/:action/:id' +end + +require 'rails_info_controller' + +# Re-raise errors caught by the controller. +class Controllers::RailsInfoController; def rescue_action(e) raise e end; end + +class RailsInfoControllerTest < Test::Unit::TestCase + def setup + @controller = Controllers::RailsInfoController.new + @request = ActionController::TestRequest.new + @response = ActionController::TestResponse.new + end + + def test_rails_info_properties_table_rendered_for_local_request + Controllers::RailsInfoController.local_request = true + get :properties + assert_tag :tag => 'table' + assert_response :success + end + + def test_rails_info_properties_error_rendered_for_non_local_request + Controllers::RailsInfoController.local_request = false + get :properties + assert_tag :tag => 'p' + assert_response 500 + end +end |