clean ups

This commit is contained in:
Reinier Balt 2011-02-26 14:20:51 +01:00
parent b53fbc64dc
commit 36f007a087
6 changed files with 19 additions and 29 deletions

View file

@ -4,19 +4,6 @@
require_dependency "login_system" require_dependency "login_system"
require_dependency "tracks/source_view" require_dependency "tracks/source_view"
require "redcloth"
require 'date'
require 'time'
# Commented the following line because of #744. It prevented rake db:migrate to
# run because this tag went looking for the taggings table that did not exist
# when you feshly create a new database Old comment: We need this in development
# mode, or you get 'method missing' errors
#
# Tag
class CannotAccessContext < RuntimeError; end
class ApplicationController < ActionController::Base class ApplicationController < ActionController::Base
@ -24,12 +11,11 @@ class ApplicationController < ActionController::Base
helper :application helper :application
include LoginSystem include LoginSystem
helper_method :current_user, :prefs helper_method :current_user, :prefs, :format_date, :markdown
layout proc{ |controller| controller.mobile? ? "mobile" : "standard" } layout proc{ |controller| controller.mobile? ? "mobile" : "standard" }
exempt_from_layout /\.js\.erb$/ exempt_from_layout /\.js\.erb$/
before_filter :set_session_expiration before_filter :set_session_expiration
before_filter :set_time_zone before_filter :set_time_zone
before_filter :set_zindex_counter before_filter :set_zindex_counter
@ -38,11 +24,6 @@ class ApplicationController < ActionController::Base
prepend_before_filter :enable_mobile_content_negotiation prepend_before_filter :enable_mobile_content_negotiation
after_filter :set_charset after_filter :set_charset
include ActionView::Helpers::TextHelper
include ActionView::Helpers::SanitizeHelper
extend ActionView::Helpers::SanitizeHelper::ClassMethods
helper_method :format_date, :markdown
# By default, sets the charset to UTF-8 if it isn't already set # By default, sets the charset to UTF-8 if it isn't already set
def set_charset def set_charset
headers["Content-Type"] ||= "text/html; charset=UTF-8" headers["Content-Type"] ||= "text/html; charset=UTF-8"
@ -149,7 +130,7 @@ class ApplicationController < ActionController::Base
def markdown(text) def markdown(text)
RedCloth.new(text).to_html RedCloth.new(text).to_html
end end
# Here's the concept behind this "mobile content negotiation" hack: In # Here's the concept behind this "mobile content negotiation" hack: In
# addition to the main, AJAXy Web UI, Tracks has a lightweight low-feature # addition to the main, AJAXy Web UI, Tracks has a lightweight low-feature
# 'mobile' version designed to be suitablef or use from a phone or PDA. It # 'mobile' version designed to be suitablef or use from a phone or PDA. It

View file

@ -1,3 +1,5 @@
class CannotAccessContext < RuntimeError; end
class BackendController < ApplicationController class BackendController < ApplicationController
wsdl_service_name 'Backend' wsdl_service_name 'Backend'
web_service_api TodoApi web_service_api TodoApi

View file

@ -47,10 +47,11 @@ class ProjectsController < ApplicationController
init_data_for_sidebar unless mobile? init_data_for_sidebar unless mobile?
@page_title = t('projects.page_title', :project => @project.name) @page_title = t('projects.page_title', :project => @project.name)
@not_done = @project.todos.active_or_hidden @not_done = @project.todos.active_or_hidden(:include => [:tags, :context, :predecessors])
@deferred = @project.deferred_todos @deferred = @project.deferred_todos(:include => [:tags, :context, :predecessors])
@pending = @project.pending_todos @pending = @project.pending_todos(:include => [:tags, :context, :predecessors])
@done = @project.todos.find_in_state(:all, :completed, :order => "todos.completed_at DESC", :limit => current_user.prefs.show_number_completed, :include => [:context]) @done = @project.todos.find_in_state(:all, :completed,
:order => "todos.completed_at DESC", :limit => current_user.prefs.show_number_completed, :include => [:context, :tags, :predecessors])
@count = @not_done.size @count = @not_done.size
@down_count = @count + @deferred.size + @pending.size @down_count = @count + @deferred.size + @pending.size
@ -59,6 +60,7 @@ class ProjectsController < ApplicationController
@default_tags = @project.default_tags @default_tags = @project.default_tags
@new_note = current_user.notes.new @new_note = current_user.notes.new
@new_note.project_id = @project.id @new_note.project_id = @project.id
@contexts = current_user.contexts
respond_to do |format| respond_to do |format|
format.html format.html
format.m &render_project_mobile format.m &render_project_mobile

View file

@ -13,6 +13,10 @@ class TodosController < ApplicationController
protect_from_forgery :except => :check_deferred protect_from_forgery :except => :check_deferred
# these are needed for todo_feed_content. TODO: remove this view stuff from controller
include ActionView::Helpers::SanitizeHelper
extend ActionView::Helpers::SanitizeHelper::ClassMethods
def index def index
@projects = current_user.projects.find(:all, :include => [:default_context]) @projects = current_user.projects.find(:all, :include => [:default_context])
@contexts = current_user.contexts.find(:all) @contexts = current_user.contexts.find(:all)
@ -981,6 +985,7 @@ class TodosController < ApplicationController
end end
def todo_feed_content def todo_feed_content
# TODO: move view stuff into view, also the includes at the top
lambda do |i| lambda do |i|
item_notes = sanitize(markdown( i.notes )) if i.notes? item_notes = sanitize(markdown( i.notes )) if i.notes?
due = "<div>#{t('todos.feeds.due', :date => format_date(i.due))}</div>\n" if i.due? due = "<div>#{t('todos.feeds.due', :date => format_date(i.due))}</div>\n" if i.due?

View file

@ -1,7 +1,7 @@
<% <%
@initial_context_name = @context.name unless @context.nil? @initial_context_name = @context.name unless @context.nil?
@initial_context_name ||= @project.default_context.name unless @project.nil? || @project.default_context.nil? @initial_context_name ||= @project.default_context.name unless @project.nil? || @project.default_context.nil?
@initial_context_name ||= current_user.contexts.first.name unless current_user.contexts.first.nil? @initial_context_name ||= @contexts.first.name unless @contexts.first.nil?
@initial_project_name = @project.name unless @project.nil? @initial_project_name = @project.name unless @project.nil?
-%> -%>
<div id="todo_new_action_container"> <div id="todo_new_action_container">

View file

@ -7,8 +7,8 @@ Given /^I have logged in as "(.*)" with password "(.*)"$/ do |username, password
if response.respond_to? :selenium if response.respond_to? :selenium
selenium.wait_for_page_to_load(5000) selenium.wait_for_page_to_load(5000)
end end
logout_string = @mobile_interface ? "Logout" : "Logout \(#{username}\)" logout_regexp = @mobile_interface ? "Logout" : "Logout \(#{username}\)"
response.should contain(/#{logout_string}/) response.should contain(logout_regexp)
@current_user = User.find_by_login(username) @current_user = User.find_by_login(username)
end end