rails 3 fixes

master
Alinson S. Xavier 12 years ago
parent e563725dc5
commit 0991d7af8e

@ -6,3 +6,7 @@ public/upload/*
*.orig
config/database.yml
config/application.rb
tmp/cache/*
*.rails2
*.sqlite3
*.pid

@ -10,17 +10,18 @@ group :assets do
gem 'uglifier', '>= 1.0.3'
end
gem 'jquery-rails'
gem 'acts_as_list', '~>0.2'
gem 'acts_as_paranoid', '~>0.4'
gem 'acts_as_versioned', :git => 'https://github.com/jwhitehorn/acts_as_versioned.git'
gem 'bluecloth', '1.0.0', :path => './vendor/gems/bluecloth'
gem 'calendar_helper', "~>0.2"
gem 'dynamic_form'
gem 'haml', '~>3.1'
gem 'hpricot', '~>0.8'
gem 'icalendar', '~>1.0'
gem 'will_paginate', "~>3.0"
gem 'calendar_helper', "~>0.2"
gem 'jquery-rails'
gem 'shoulda', "~>2.11"
gem 'acts_as_paranoid', '~>0.4'
gem 'acts_as_versioned', :git => 'https://github.com/jwhitehorn/acts_as_versioned.git'
gem 'acts_as_list', '~>0.2'
gem 'will_paginate', "~>3.0"
group :development, :production do
gem 'brazilian-rails', '3.3.0', :path => './vendor/gems/brazilian-rails/brI18n/'

@ -62,6 +62,7 @@ GEM
execjs
coffee-script-source (1.6.3)
daemons (1.1.9)
dynamic_form (1.1.4)
erubis (2.7.0)
execjs (1.4.0)
multi_json (~> 1.0)
@ -148,6 +149,7 @@ DEPENDENCIES
brazilian-rails (= 3.3.0)!
calendar_helper (~> 0.2)
coffee-rails (~> 3.2.1)
dynamic_form
haml (~> 3.1)
hpricot (~> 0.8)
icalendar (~> 1.0)

@ -35,7 +35,7 @@ class ApplicationController < ActionController::Base
respond_to do |format|
format.html {
if logged_in?
render :file => "#{RAILS_ROOT}/public/401.html", :status => 401
render :file => "#{Rails.root}/public/401.html", :status => 401
else
login_by_html
end
@ -53,7 +53,7 @@ class ApplicationController < ActionController::Base
# Registro nao encontrado
elsif (RAILS_ENV == 'production') and exception.is_a?(ActiveRecord::RecordNotFound)
respond_to do |format|
format.html { render :file => "#{RAILS_ROOT}/public/404.html", :status => 404 }
format.html { render :file => "#{Rails.root}/public/404.html", :status => 404 }
format.xml { head 404 }
end

@ -98,7 +98,7 @@ class AttachmentsController < ApplicationController
def download
send_file("#{RAILS_ROOT}/public/upload/#{@course.id}/#{@attachment.id}",
send_file("#{Rails.root}/public/upload/#{@course.id}/#{@attachment.id}",
:filename => @attachment.file_name,
:type => @attachment.content_type,
:disposition => 'inline',

@ -18,8 +18,8 @@
class WikiController < ApplicationController
verify :params => :text, :only => :preview, :redirect_to => { :action => :show }
verify :params => [:from, :to], :only => :diff, :redirect_to => { :action => :versions }
#verify :params => :text, :only => :preview, :redirect_to => { :action => :show }
#verify :params => [:from, :to], :only => :diff, :redirect_to => { :action => :versions }
#after_filter :cache_sweep, :only => [ :create, :update, :destroy, :move_up,
# :move_down, :undelete ]

@ -73,7 +73,7 @@ module ApplicationHelper
def markup_help
return "<div id='markup_help' style='display: none'>" +
File.read("#{RAILS_ROOT}/public/static/markup_help.mkd").format_wiki +
File.read("#{Rails.root}/public/static/markup_help.mkd").format_wiki +
"</div>"
end

@ -16,10 +16,11 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
class String
include ActionView::Helpers::SanitizeHelper
def format_wiki
text = BlueCloth.new(self).to_html
text = Hpricot(text, :xhtml_strict => true).to_s
return text.sanitize unless text.blank?
return sanitize text
end
end

@ -62,7 +62,7 @@ class Attachment < ActiveRecord::Base
# Salva o arquivo fisicamente no HD
def after_save
@file_path = "#{RAILS_ROOT}/public/upload/#{course.id}/#{self.id}"
@file_path = "#{Rails.root}/public/upload/#{course.id}/#{self.id}"
FileUtils.mkdir_p(File.dirname(@file_path))
if @tmp_file
@ -75,7 +75,7 @@ class Attachment < ActiveRecord::Base
# Deleta o arquivo
#def after_destroy
# @file_path = "#{RAILS_ROOT}/public/upload/#{course.id}/#{self.id}"
# @file_path = "#{Rails.root}/public/upload/#{course.id}/#{self.id}"
# File.delete(@file_path) if File.exists?(@file_path)
#end

@ -21,6 +21,8 @@ require 'tempfile'
class WikiPage < ActiveRecord::Base
attr_accessible :title, :front_page, :content, :description
# Plugins
acts_as_paranoid
acts_as_list :scope => 'course_id = #{course_id}'

@ -2,6 +2,6 @@
%h1.title Modificar arquivo
%p
- form_for :attachment, @attachment, :url => course_attachment_url, :html => { :method => 'put', :multipart => 'true' } do
= form_for @attachment, :url => course_attachment_url, :html => { :method => 'put', :multipart => 'true' } do
= render :partial => 'form'
= submit_tag 'Editar', :accesskey => 'e'

@ -2,6 +2,6 @@
%h1.title Adicionar arquivo
%p
- form_for :attachment, @attachment, :url => course_attachments_url, :html => { :method => 'post', :multipart => 'true' } do
= form_for @attachment, :url => course_attachments_url, :html => { :method => 'post', :multipart => 'true' } do
= render :partial => 'form'
= submit_tag "Criar", :accesskey => 'e'

@ -2,6 +2,6 @@
%h1.title Editar disciplina
%p
- form_tag course_path(@course.id), :method => :put do
= form_tag course_path(@course.id), :method => :put do
= render :partial => 'form'
= submit_tag 'Editar', :accesskey => 'e'

@ -1,6 +1,6 @@
%h4.title= App.title
%h1.title Adicionar disciplina
- form_tag courses_url, :method => :post do
= form_tag courses_url, :method => :post do
= render :partial => 'form'
= submit_tag "Cadastrar", :accesskey => 'e'

@ -2,6 +2,6 @@
%h1.title Editar evento
%p
- form_tag course_event_url(@course, @event), :method => :put do
= form_tag course_event_url(@course, @event), :method => :put do
= render :partial => 'form'
= submit_tag 'Editar', :accesskey => 'e'

@ -2,6 +2,6 @@
%h1.title Adicionar evento
%p
- form_tag course_events_url(@course), :method => :post do
= form_tag course_events_url(@course), :method => :post do
= render :partial => 'form'
= submit_tag "Adicionar", :accesskey => 'e'

@ -1,11 +1,11 @@
- @title = "#{App.title} - #{h(@course.full_name)}"
- @location = capture do
= link_to(App.title, index_url, :accesskey => 'z') + "&rsaquo;"
= link_to("Disciplinas", courses_url) + "&rsaquo;"
= link_to(h(@course.full_name), course_url(@course)) + "&rsaquo;"
= link_to(App.title, index_url, :accesskey => 'z') + ""
= link_to("Disciplinas", courses_url) + ""
= link_to(h(@course.full_name), course_url(@course)) + ""
= link_to("Arquivos", course_attachments_url(@course))
- if @attachment.id
= "&rsaquo;" + link_to(truncate(h(@attachment.file_name)), course_attachment_url)
= "" + link_to(truncate(h(@attachment.file_name)), course_attachment_url)
- @title = @title + " - #{truncate(h(@attachment.file_name))}"
- @left_panel = render 'courses/left_panel'

@ -1,9 +1,9 @@
- @title = "#{App.title}"
- @location = capture do
= link_to(App.title, index_url, :accesskey => 'z') + "&rsaquo;";
= link_to(App.title, index_url, :accesskey => 'z') + "";
= link_to("Disciplinas", courses_url)
- if @course and @course.id
= "&rsaquo; " + link_to(h(@course.full_name), course_url)
= " " + link_to(h(@course.full_name), course_url)
- @title = @title + " - #{h(@course.full_name)}"
- else
- @title = @title + " - Disciplinas"

@ -1,8 +1,8 @@
- @title = "#{App.title} - #{h(@course.full_name)} - Calendário"
- @location = capture do
= link_to(App.title, index_url, :accesskey => 'z') + "&rsaquo;"
= link_to("Disciplinas", courses_url) + "&rsaquo;"
= link_to(h(@course.full_name), course_url(@course)) + "&rsaquo;"
= link_to(App.title, index_url, :accesskey => 'z') + ""
= link_to("Disciplinas", courses_url) + ""
= link_to(h(@course.full_name), course_url(@course)) + ""
= link_to("Calendário", course_events_url)
- @left_panel = render 'courses/left_panel'

@ -1,9 +1,9 @@
- if @course
- @title = "#{App.title} - #{h(@course.full_name)} - Mudanças recentes"
- @location = capture do
= link_to(App.title, index_url, :accesskey => 'z') + "&rsaquo;"
= link_to("Disciplinas", courses_url) + "&rsaquo;"
= link_to(h(@course.full_name), course_url(@course)) + "&rsaquo;"
= link_to(App.title, index_url, :accesskey => 'z') + ""
= link_to("Disciplinas", courses_url) + ""
= link_to(h(@course.full_name), course_url(@course)) + ""
= link_to("Mudanças Recentes", course_log_url(@course))
- @left_panel = render 'courses/left_panel'
@ -12,7 +12,7 @@
- else
- @title = "#{App.title} - Mudanças recentes"
- @location = capture do
= link_to(App.title, index_url) + "&rsaquo;"
= link_to(App.title, index_url) + ""
= link_to("Mudanças recentes", log_url)
- @content = yield

@ -1,8 +1,8 @@
- @title = "#{App.title} - #{h(@course.full_name)} - Notícias"
- @location = capture do
= link_to(App.title, index_url, :accesskey => 'z') + "&rsaquo;"
= link_to("Disciplinas", courses_url) + "&rsaquo;"
= link_to(h(@course.full_name), course_url(@course)) + "&rsaquo;"
= link_to(App.title, index_url, :accesskey => 'z') + ""
= link_to("Disciplinas", courses_url) + ""
= link_to(h(@course.full_name), course_url(@course)) + ""
= link_to("Noticias", course_news_url(@course))
- @left_panel = render 'courses/left_panel'

@ -1,9 +1,9 @@
- @title = App.title
- @location = capture do
= link_to(App.title, index_url, :accesskey => 'z') + "&rsaquo;";
= link_to(App.title, index_url, :accesskey => 'z') + "";
= link_to("Usuários", users_path)
- if @user and @user.id
= "&rsaquo; " + link_to(h(@user.name), user_url(@user))
= " " + link_to(h(@user.name), user_url(@user))
- @title = @title + " - #{h(@user.display_name)}"
- @left_panel = render('widgets/menu_navigation') + render('widgets/menu_user')

@ -1,11 +1,11 @@
- @title = "#{App.title} - #{h(@course.full_name)}"
- @location = capture do
= link_to(App.title, index_url, :accesskey => 'z') + "&rsaquo;"
= link_to("Disciplinas", courses_url) + "&rsaquo;"
= link_to(h(@course.full_name), course_url(@course)) + "&rsaquo;"
= link_to(App.title, index_url, :accesskey => 'z') + ""
= link_to("Disciplinas", courses_url) + ""
= link_to(h(@course.full_name), course_url(@course)) + ""
= link_to("Wiki", course_wiki_url(@course))
- if @wiki_page.title?
= "&rsaquo;" + link_to(h(@wiki_page.title), course_wiki_instance_url(@course, @wiki_page))
= "" + link_to(h(@wiki_page.title), course_wiki_instance_url(@course, @wiki_page))
- @title = @title + " - #{h(@wiki_page.title)}"
- @left_panel = render 'courses/left_panel'

@ -2,6 +2,6 @@
%h1.title Editar noticia
%p
- form_tag course_news_instance_url(@course, @news), :method => :put do
= form_tag course_news_instance_url(@course, @news), :method => :put do
= render :partial => 'form'
= submit_tag 'Editar', :accesskey => 'e'

@ -1,6 +1,6 @@
%h4.title= @course.full_name
%h1.title Adicionar notícia
- form_tag course_news_url, :method => :post do
= form_tag course_news_url, :method => :post do
= render :partial => 'form'
= submit_tag "Adicionar", :accesskey => 'e'

@ -4,7 +4,7 @@
<p>
<%= error_messages_for 'user' %><br/>
<% form_tag :action => 'change_password' do %>
<%= form_tag :action => 'change_password' do %>
<label for="user_password">Nova senha</label><br/>
<%= password_field "user", "password", :size => 20, :value=>"" %><br/>

@ -4,7 +4,7 @@
<p>
<%= error_messages_for 'user' %><br/>
<% form_tag :action => 'update', :id => @user do %>
<%= form_tag :action => 'update', :id => @user do %>
<label for="user_name">Nome</label><br/>
<%= text_field "user", "name", :size => 20 %><br/>

@ -4,7 +4,7 @@
<p>
<%= error_messages_for 'user' %><br/>
<% form_tag :action=>'forgot_password' do %>
<%= form_tag :action=>'forgot_password' do %>
Email<br/>
<%= text_field "user","email" %><br/><br/>

@ -4,7 +4,7 @@
<p>
<%= error_messages_for 'user' %><br/>
<% form_tag :action=> "login" do %>
<%= form_tag :action=> "login" do %>
<label for="user_login">Login:</label><br/>
<%= text_field "user", "login", :size => 20 %><br/>

@ -13,7 +13,7 @@
<% @news_messages.each do |n| %>
<div class="line">
<h4 class="left"><%= n.timestamp.strftime("%d de %B") %></h4>
<h4><%= link_to h(n.course.full_name) , course_news_instance_url(n.course, n) %> &rsaquo;
<h4><%= link_to h(n.course.full_name) , course_news_instance_url(n.course, n) %>
<a href="#" id="new_<%=n.id%>"><%= h(n.title) %></a></h4>
<p id="new_desc_<%= n.id %>" style="display:none">
@ -48,7 +48,7 @@
<% end %>
<li>
<div class="time"><%= event.time.strftime("%H:%M") %></div>
<%= link_to h(event.course.full_name), course_event_url(event.course, event) %> &rsaquo;
<%= link_to h(event.course.full_name), course_event_url(event.course, event) %>
<a href="#" id="event_<%= event.id %>"><%= h(event.title) %></a>
<div id="desc_<%= event.id %>" class="description" style="display:none">

@ -2,7 +2,7 @@
<h1 class="title">Criar conta</h1>
<p>
<% form_tag :action=> "signup" do %>
<%= form_tag :action=> "signup" do %>
<%= error_messages_for 'user' %><br/>

@ -19,7 +19,7 @@
%td.top.aright
= n.timestamp.strftime("%d&nbsp;de&nbsp;%B")
%td
= link_to(h(n.course.full_name), course_url(n.course)) + " &rsaquo;"
= link_to(h(n.course.full_name), course_url(n.course)) + " "
= link_to(h(n.title), course_news_instance_url(n.course, n))
- unless n.body.empty?
%p= truncate(h(n.body), :length => 300)
@ -42,7 +42,7 @@
%td.top
= n.time.strftime("%H:%M")
%td.top
= link_to(h(n.course.full_name), course_url(n.course)) + " &rsaquo;"
= link_to(h(n.course.full_name), course_url(n.course)) + " "
= link_to(h(n.title), course_event_url(n.course, n))
.box

@ -4,7 +4,7 @@
%h1.title Editar perfil
%p
- form_tag user_path(@user.id), :method => 'put' do
= form_tag user_path(@user.id), :method => 'put' do
= render :partial => 'form_profile'
= submit_tag 'Editar', :accesskey => 'e'
%button#show_preview{:type => "button", :accesskey => 'v'}

@ -4,7 +4,7 @@
%p
= error_messages_for :user
- form_tag login_path do
= form_tag login_path do
%dl
%dt
%label{:for => 'user_login'} Login

@ -3,7 +3,7 @@
- if params[:key]
%p= error_messages_for :user
- form_tag recover_password_with_key_path(params[:key]) do
= form_tag recover_password_with_key_path(params[:key]) do
%dl
%dt
%label{:for => 'user_login'} Login
@ -27,7 +27,7 @@
%p Uma mensagem de confirmacão foi enviado para o seu email.
- else
- form_tag recover_password_path do
= form_tag recover_password_path do
%dl
%dt
%label{:for => 'user_email'} Email

@ -2,6 +2,6 @@
%h1.title Editar configurações
%p
- form_tag settings_url do
= form_tag settings_url do
= render :partial => 'form_settings'
= submit_tag 'Editar', :accesskey => 'e'

@ -2,6 +2,6 @@
%h1.title Nova conta
%p
- form_tag signup_path do
= form_tag signup_path do
= render :partial => 'form_settings', :locals => { :signup => true }
= submit_tag 'Criar'

@ -7,7 +7,7 @@
<li>Carregando...</li>
</ul>
<% if session[:user] %>
<% form_tag(
<%= form_tag(
{:controller => 'message', :action => 'create'}, {:id => 'shoutbox_form' }) do %>
<div>
<%= text_area :message, :body %>

@ -4,7 +4,7 @@
%h1.title= "Editar #{h(@wiki_page.title)}"
%p
- form_tag course_wiki_instance_url(@course, @wiki_page.id), :method => :put do
= form_tag course_wiki_instance_url(@course, @wiki_page.id), :method => :put do
= render :partial => 'form'
= submit_tag 'Salvar', :accesskey => 'e'
%button#show_preview{:type => "button", :accesskey => 'v'}

@ -4,7 +4,7 @@
%h1.title Adicionar página wiki
%p
- form_tag course_wiki_url(@course) do
= form_tag course_wiki_url(@course) do
= render :partial => 'form'
= submit_tag "Criar", :accesskey => 'e'
%button#show_preview{:type => "button", :accesskey => 'v'}

@ -8,7 +8,7 @@
== radios_to = #{h(@history_to)};
== radios_from = #{h(@history_from)};
- form_tag diff_course_wiki_instance_url(@course, @wiki_page), :method => :get do
= form_tag diff_course_wiki_instance_url(@course, @wiki_page), :method => :get do
%button{:type => "submit"}= "Comparar as versões selecionadas"
.box
%table

@ -10,6 +10,9 @@ end
module WikiUFC
class Application < Rails::Application
#set :haml, { :escape_html => false }
config.encoding = "utf-8"
config.filter_parameters += [:password]
config.active_support.escape_html_entities_in_json = true
@ -76,3 +79,9 @@ module WikiUFC
end
App = WikiUFC::Application.config
require "haml"
require "haml/template"
Haml::Template.options[:escape_attrs] = false
Haml::Template.options[:escape_html] = false

@ -3,3 +3,8 @@ require File.expand_path('../application', __FILE__)
# Initialize the rails application
WikiUFC::Application.initialize!
#
# Carrega as classes Message e LogEntry. O lazy loading do Rails gera
# problemas se voce definir varias classes por arquivos.
require "./app/models/message.rb"
require "./app/models/log_entry.rb"

@ -1,64 +0,0 @@
class Fixnum
def is_numeric?
true
end
end
class String
def is_numeric?
Float self rescue false
end
def html_escape
ERB::Util::html_escape(self)
end
%w[auto_link excerpt highlight sanitize simple_format strip_tags truncate word_wrap].each do |method|
eval "def #{method}(*args); ActionController::Base.helpers.#{method}(self, *args); end"
end
def pretty_url
self.mb_chars.normalize(:kd).
gsub(/[^\x00-\x7F]/n,'').
gsub(/[^a-z._0-9 -]/i,"").
gsub(/ +/,"_").
downcase.to_s
end
end
class Array
def add_condition! (condition, conjunction = 'AND')
if String === condition
add_condition!([condition])
elsif Hash === condition
add_condition!([condition.keys.map { |attr| "#{attr}=?" }.join(' AND ')] + condition.values)
elsif Array === condition
self[0] = "(#{self[0]}) #{conjunction} (#{condition.shift})" unless empty?
(self << condition).flatten!
else
raise "don't know how to handle this condition type"
end
self
end
end
module ActiveRecord
module Acts
module Versioned
module ClassMethods
def acts_as_paranoid_versioned
# protect the versioned model
self.versioned_class.class_eval do
def self.delete_all(conditions = nil); return; end
end
end
end
end
end
end
# Carrega as classes Message e LogEntry. O lazy loading do Rails gera
# problemas se voce definir varias classes por arquivos.
#require "#{RAILS_ROOT}/app/models/message.rb"
#require "#{RAILS_ROOT}/app/models/log_entry.rb"

@ -16,7 +16,7 @@ module AuthenticationSystem
def login_by_html
if !logged_in?
flash[:warning] = 'You must be logged in to access this section of the site'[:login_required]
session[:return_to] = request.request_uri
session[:return_to] = request.fullpath
redirect_to login_url
end
end

@ -0,0 +1,75 @@
class Fixnum
def is_numeric?
true
end
end
class String
def is_numeric?
Float self rescue false
end
#def html_escape
# ERB::Util::html_escape(self)
#end
#%w[auto_link excerpt highlight sanitize simple_format strip_tags truncate word_wrap].each do |method|
# eval "def #{method}(*args); ActionController::Base.helpers.#{method}(self, *args); end"
#end
def pretty_url
self.mb_chars.normalize(:kd).
gsub(/[^\x00-\x7F]/n,'').
gsub(/[^a-z._0-9 -]/i,"").
gsub(/ +/,"_").
downcase.to_s
end
end
#class Array
# def add_condition! (condition, conjunction = 'AND')
# if String === condition
# add_condition!([condition])
# elsif Hash === condition
# add_condition!([condition.keys.map { |attr| "#{attr}=?" }.join(' AND ')] + condition.values)
# elsif Array === condition
# self[0] = "(#{self[0]}) #{conjunction} (#{condition.shift})" unless empty?
# (self << condition).flatten!
# else
# raise "don't know how to handle this condition type"
# end
# self
# end
#end
#module ActiveRecord
# module Acts
# module Versioned
# module ClassMethods
# def acts_as_paranoid_versioned
# # protect the versioned model
# self.versioned_class.class_eval do
# def self.delete_all(conditions = nil); return; end
# end
# end
# end
# end
# end
#end
# disable XSS protection
module CustomHtmlSafe
def html_safe?
true
end
end
class ActionView::OutputBuffer
include CustomHtmlSafe
end
class ActionView::SafeBuffer
include CustomHtmlSafe
end
class String
include CustomHtmlSafe
end