Permalink
Browse files

Merging back the Rails 3 branch.

That was faster than I thought :)
  • Loading branch information...
1 parent a3210ef commit af7f255ac6f7258ceadc23ef1dfaf683feab6bb0 Daniel Martin committed Oct 1, 2010
Showing 1,847 changed files with 4,537 additions and 232,509 deletions.
View
12 Gemfile
@@ -0,0 +1,12 @@
+source 'http://rubygems.org'
+
+gem 'rails', '3.0.0'
+
+gem 'sqlite3-ruby', :require => 'sqlite3'
+
+# 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 'webrat'
+# end
View
@@ -1,19 +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'
-
-
-# TODO: add a task to backup, delete database, empty password, create empty database.
-begin
- require 'delayed/tasks'
-rescue LoadError
- STDERR.puts "Run `rake gems:install` to install delayed_job"
-end
+Dradis::Application.load_tasks
@@ -11,8 +11,6 @@ class ApplicationController < ActionController::Base
# Be sure to include AuthenticationSystem in Application Controller instead
include AuthenticatedSystem
- filter_parameter_logging :password, :password_confirmation
-
before_filter :show_first_time_wizard
# This filter would display the 'First Time' wizard the first time dradis is
@@ -8,7 +8,7 @@ def index
@attachments = Node.find(params[:node_id]).attachments
respond_to do |format|
format.html{ render :action => 'index'}
- format.json{ render :json => @attachments }
+ format.json{ render :text => '[' + @attachments.collect(&:to_json).join(',') + ']' }
end
@attachments.each do |a| a.close end
end
@@ -30,14 +30,15 @@ def create
# It is possible to rename attachments and this function provides that
# functionality.
def update
- attachment = Attachment.find(params[:id], :conditions => {:node_id => Node.find(params[:node_id]).id})
+ filename = [params[:id],params[:format]].join('.')
+ attachment = Attachment.find(filename, :conditions => {:node_id => Node.find(params[:node_id]).id})
attachment.close
new_name = CGI::unescape( params[:rename] )
destination = File.expand_path( File.join( Attachment.pwd, params[:node_id], new_name ) )
if !File.exist?(destination) && ( !destination.match(/^#{Attachment.pwd}/).nil? )
File.rename( attachment.fullpath, destination )
end
- redirect_to :action => 'show', :id => params[:rename]
+ redirect_to "#{node_path(attachment.node_id)}/attachments/#{CGI::escape(new_name)}"
end
# This function will send the Attachment file to the browser. It will try to
@@ -47,7 +48,7 @@ def update
def show
# we send the file name as the id, the rails parser however split the filename
# at the fullstop so we join it again
- filename = params[:id]
+ filename = [params[:id],params[:format]].join('.')
@attachment = Attachment.find(filename, :conditions => {:node_id => Node.find(params[:node_id]).id})
# Figure out the best way of displaying the file (by default send the it as
@@ -77,7 +78,7 @@ def show
def destroy
# we send the file name as the id, the rails parser however split the filename
# at the fullstop so we join it again
- filename = params[:id]
+ filename = [params[:id],params[:format]].join('.')
@attachment = Attachment.find(filename, :conditions => {:node_id => Node.find(params[:node_id]).id})
@attachment.delete
redirect_to node_attachments_path(params[:node_id])
@@ -13,7 +13,7 @@ class JsonController < ApplicationController
def nodes
parent_id = params[:node] == 'root-node' ? nil : params[:node].to_i
nodes = Node.find(:all, :conditions => {:parent_id => parent_id})
- render :text => nodes.to_json
+ render :text => '[' + nodes.collect(&:to_json).join(',') + ']'
end
# Create a new Node from its :label and :parent_id
View
@@ -19,7 +19,7 @@ def to_json(options={})
json << '"'
if (self.children.any?)
json << ', "children":'
- json << self.children.to_json
+ json << '[' + self.children.collect(&:to_json).join(',') + ']'
else
#json << ',"leaf":true'
end
@@ -12,7 +12,7 @@
<div style="height: 100px; overflow: hidden;">
<%= image_tag 'banner.png', :style=>'margin-top: -20px;' %>
</div>
-<%= @content_for_layout %>
+<%= yield %>
<% if flash[:notice] %><div id="notice"><%= flash[:notice] %></div><% end %>
<% if flash[:error] %><div id="error"><%= flash[:error] %></div><% end %>
<noscript><div id="nojs">Please enable JavaScript support.</div></noscript>
@@ -39,6 +39,8 @@
<!-- RSS feed -->
<link rel="alternate" type="application/rss+xml" title="RSS 2.0" href="/feeds" />
+
+ <%= csrf_meta_tag %>
</head>
<body>
<noscript>
@@ -2,6 +2,7 @@
<head>
<title>Welcome to dradis</title>
<%= stylesheet_link_tag 'welcome.css' %>
+ <%= csrf_meta_tag %>
</head>
<body>
<div class="main main_margin">
@@ -10,7 +11,7 @@
<div class="content_top"></div>
<div class="content">
<div class="text">
- <%= @content_for_layout %>
+ <%= yield %>
<% if flash[:notice] %><div id="notice"><%= flash[:notice] %></div><% end %>
<% if flash[:error] %><div id="error"><%= flash[:error] %></div><% end %>
<noscript><div id="nojs">Please enable JavaScript support.</div></noscript>
@@ -6,6 +6,7 @@
<title>Upload Manager - <%= Core::VERSION::string %></title>
<%= javascript_include_tag 'jquery-1.4.2.min', 'jquery.form', 'upload', :cache => 'upload_manager' %>
+ <%= csrf_meta_tag %>
<%= stylesheet_link_tag 'clean/reset',
'clean/defaults',
@@ -82,11 +82,11 @@
<!-- Tabbed bar code-->
<ul class="tab">
- <%= menu_tabs %>
+ <%= menu_tabs.html_safe %>
</ul>
<div id="back"><a href="/">&lsaquo; back to the app.</a></div>
- <%= @content_for_layout %>
+ <%= yield %>
<div id="footer">
<br/>
effective information sharing<br/>
@@ -1,4 +1,4 @@
- <% form_for :meta_server do |f| -%>
+ <%= form_for :meta_server, :url => {:action => :get_projects}, :remote => :true do |f| -%>
<fieldset>
<legend>Meta-Server options</legend>
<div>
@@ -18,9 +18,7 @@
<%= f.password_field :password, :class => 'password' %>
</div>
<% if flash[:meta_server] %><div id="error"><%= flash[:meta_server] %></div><% end %>
- <div class="right"><%= submit_to_remote 'remote', 'Get Projects',
- :html => {:class => 'submit'},
- :url=>{:action=>:get_projects} %></div>
+ <div class="right"><%= submit_tag 'Get Projects' %></div>
</fieldset>
<% end %>
<% if @projects %>
@@ -28,6 +28,6 @@
</tbody>
</table>
<p class="links">
- <%= link_to_remote 'Refresh', :url => {:action => :get_projects}, :class => 'submit' %>
- <%= link_to_remote 'Change Meta-Server', :url => {:action => :change_metaserver}, :class => 'submit' %>
+ <%= link_to 'Refresh', :url => {:action => :get_projects}, :class => 'submit', :remote => true %>
+ <%= link_to 'Change Meta-Server', :url => {:action => :change_metaserver}, :class => 'submit', :remote => true %>
</p>
@@ -1,5 +1,5 @@
<div id="server_init">
- <% form_tag :action => 'setup' do -%>
+ <%= form_tag :action => 'setup' do -%>
<h2>Server password</h2>
<div>This server does not have a password yet, please set up one:</div>
<div class="form_group">
@@ -1,7 +1,7 @@
<p id="wizard">Not familiar with Dradis? Checkout the <a href="/wizard">Wizard</a>.</p>
<p>You will only be able to log in if you know this server's password.</p>
-<% form_tag session_path do -%>
+<%= form_tag session_path do -%>
<p><label for="login">Login</label><br/>
<%= text_field_tag 'login', '[choose a username]', :style => 'color: #777;', :class => 'text' %></p>
@@ -4,7 +4,7 @@
uploaded them you can process with the different plugins available. </p>
<div class="block">
- <% form_tag '/upload/create', :multipart => true do %>
+ <%= form_tag '/upload/create', :multipart => true do %>
<%= select_tag 'uploader', options_from_collection_for_select( Plugins::Upload::included_modules, 'name', 'name' ) %>
<%= file_field_tag 'file' %>
<%= hidden_field_tag 'item_id' %>
View
@@ -0,0 +1,4 @@
+# This file is used by Rack-based servers to start the application.
+
+require ::File.expand_path('../config/environment', __FILE__)
+run Dradis::Application
View
@@ -0,0 +1,58 @@
+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 Dradis
+ 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)
+ config.autoload_paths += %W(#{config.root}/lib)
+
+ # 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 ]
+
+ if (
+ (File.basename($0) == 'rake') &&
+ (%w{create drop migrate reset seed}.any? { |task| ARGV.include?("db:#{task}")||ARGV.include?("dradis:#{task}") })
+ )
+ # Running rake, disable import/export plugins. See r874
+ # http://dradis.svn.sourceforge.net/viewvc/dradis/server/trunk/config/environment.rb?view=log#rev874
+ #
+ # At least include the project_management plugin that will allow us to
+ # create a project package (for backup) and is known not to interact with
+ # the DB
+ config.plugins = [:acts_as_tree, :project_management ]
+ else
+ config.active_record.observers = :revision_observer
+ end
+
+ # 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()
+
+ # 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, :password_confirmation]
+ end
+end
Oops, something went wrong.

0 comments on commit af7f255

Please sign in to comment.