diff --git a/.gitignore b/.gitignore
index 95666115a0..f976d0d4a9 100644
--- a/.gitignore
+++ b/.gitignore
@@ -4,4 +4,7 @@ log/*.log
tmp/**/*
config/config.yml
config/deploy.rb
-config/mongoid.yml
\ No newline at end of file
+config/mongoid.yml
+.rvmrc
+*~
+*.rbc
diff --git a/.rspec b/.rspec
index 53607ea52b..f518044217 100644
--- a/.rspec
+++ b/.rspec
@@ -1 +1,4 @@
--colour
+--tty
+--drb
+--format documentation
diff --git a/Gemfile b/Gemfile
index 61e1d07e76..044a001d00 100644
--- a/Gemfile
+++ b/Gemfile
@@ -1,19 +1,28 @@
source 'http://rubygems.org'
-gem 'rails', '3.0.0.rc'
-gem 'libxml-ruby'
-gem 'bson_ext', :require => nil
-gem 'mongoid', '2.0.0.beta.15'
+gem 'rails', '3.0.5'
+gem 'nokogiri'
+gem 'mongoid', '2.0.0.rc.8'
gem 'haml'
gem 'will_paginate'
-gem 'devise', '1.1.1'
+gem 'devise', '~> 1.1.8'
+gem 'lighthouse-api'
+gem 'redmine_client', :git => "git://github.com/oruen/redmine_client.git"
+gem 'mongoid_rails_migrations'
+gem 'useragent', '~> 0.3.1'
+gem 'pivotal-tracker'
+
+platform :ruby do
+ gem 'bson_ext', '~> 1.2'
+end
group :development, :test do
- gem 'rspec-rails', '>= 2.0.0.beta.19'
+ gem 'rspec-rails', '~> 2.5'
+ gem 'webmock', :require => false
end
group :test do
- gem 'rspec', '>= 2.0.0.beta.19'
- gem 'database_cleaner', '0.5.2'
+ gem 'rspec', '~> 2.5'
+ gem 'database_cleaner', '~> 0.6.0'
gem 'factory_girl_rails'
end
diff --git a/Gemfile.lock b/Gemfile.lock
index 68a23b873b..b99c0c6437 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -1,122 +1,155 @@
+GIT
+ remote: git://github.com/oruen/redmine_client.git
+ revision: 0df20a8b695869b03cfa129560b938a0af346add
+ specs:
+ redmine_client (0.0.1)
+ activeresource (>= 2.3.0)
+
GEM
remote: http://rubygems.org/
specs:
abstract (1.0.0)
- actionmailer (3.0.0.rc)
- actionpack (= 3.0.0.rc)
- mail (~> 2.2.5)
- actionpack (3.0.0.rc)
- activemodel (= 3.0.0.rc)
- activesupport (= 3.0.0.rc)
+ actionmailer (3.0.5)
+ actionpack (= 3.0.5)
+ mail (~> 2.2.15)
+ actionpack (3.0.5)
+ activemodel (= 3.0.5)
+ activesupport (= 3.0.5)
builder (~> 2.1.2)
erubis (~> 2.6.6)
- i18n (~> 0.4.1)
+ i18n (~> 0.4)
rack (~> 1.2.1)
- rack-mount (~> 0.6.9)
- rack-test (~> 0.5.4)
- tzinfo (~> 0.3.22)
- activemodel (3.0.0.rc)
- activesupport (= 3.0.0.rc)
+ rack-mount (~> 0.6.13)
+ rack-test (~> 0.5.7)
+ tzinfo (~> 0.3.23)
+ activemodel (3.0.5)
+ activesupport (= 3.0.5)
builder (~> 2.1.2)
- i18n (~> 0.4.1)
- activerecord (3.0.0.rc)
- activemodel (= 3.0.0.rc)
- activesupport (= 3.0.0.rc)
- arel (~> 0.4.0)
- tzinfo (~> 0.3.22)
- activeresource (3.0.0.rc)
- activemodel (= 3.0.0.rc)
- activesupport (= 3.0.0.rc)
- activesupport (3.0.0.rc)
- arel (0.4.0)
- activesupport (>= 3.0.0.beta)
- bcrypt-ruby (2.1.2)
- bson (1.0.4)
- bson_ext (1.0.4)
+ i18n (~> 0.4)
+ activerecord (3.0.5)
+ activemodel (= 3.0.5)
+ activesupport (= 3.0.5)
+ arel (~> 2.0.2)
+ tzinfo (~> 0.3.23)
+ activeresource (3.0.5)
+ activemodel (= 3.0.5)
+ activesupport (= 3.0.5)
+ activesupport (3.0.5)
+ addressable (2.2.5)
+ arel (2.0.9)
+ bcrypt-ruby (2.1.4)
+ bson (1.3.0)
+ bson_ext (1.3.0)
builder (2.1.2)
- database_cleaner (0.5.2)
- devise (1.1.1)
+ crack (0.1.8)
+ database_cleaner (0.6.7)
+ devise (1.1.9)
bcrypt-ruby (~> 2.1.2)
- warden (~> 0.10.7)
+ warden (~> 1.0.2)
diff-lcs (1.1.2)
erubis (2.6.6)
abstract (>= 1.0.0)
- factory_girl (1.3.2)
- factory_girl_rails (1.0)
+ factory_girl (1.3.3)
+ factory_girl_rails (1.0.1)
factory_girl (~> 1.3)
- rails (>= 3.0.0.beta4)
- haml (3.0.16)
- i18n (0.4.1)
+ railties (>= 3.0.0)
+ haml (3.0.25)
+ happymapper (0.3.2)
+ libxml-ruby (~> 1.1.3)
+ i18n (0.5.0)
libxml-ruby (1.1.4)
- mail (2.2.5)
+ lighthouse-api (2.0)
+ activeresource (>= 3.0.0)
+ activesupport (>= 3.0.0)
+ mail (2.2.17)
activesupport (>= 2.3.6)
- mime-types
- treetop (>= 1.4.5)
+ i18n (>= 0.4.0)
+ mime-types (~> 1.16)
+ treetop (~> 1.4.8)
mime-types (1.16)
- mongo (1.0.6)
- bson (>= 1.0.4)
- mongoid (2.0.0.beta.15)
- activemodel (= 3.0.0.rc)
- bson (= 1.0.4)
- mongo (= 1.0.6)
- tzinfo (= 0.3.22)
+ mongo (1.3.0)
+ bson (>= 1.3.0)
+ mongoid (2.0.0.rc.8)
+ activemodel (~> 3.0)
+ mongo (~> 1.2)
+ tzinfo (~> 0.3.22)
will_paginate (~> 3.0.pre)
- nokogiri (1.4.3.1)
+ mongoid_rails_migrations (0.0.10)
+ activesupport (~> 3.0.0)
+ bundler (>= 0.9.19)
+ rails (~> 3.0.0)
+ railties (~> 3.0.0)
+ nokogiri (1.4.4)
+ pivotal-tracker (0.2.0)
+ builder
+ happymapper (>= 0.2.4)
+ nokogiri (~> 1.4.1)
+ rest-client (~> 1.5.1)
polyglot (0.3.1)
- rack (1.2.1)
- rack-mount (0.6.9)
+ rack (1.2.2)
+ rack-mount (0.6.14)
rack (>= 1.0.0)
- rack-test (0.5.4)
+ rack-test (0.5.7)
rack (>= 1.0)
- rails (3.0.0.rc)
- actionmailer (= 3.0.0.rc)
- actionpack (= 3.0.0.rc)
- activerecord (= 3.0.0.rc)
- activeresource (= 3.0.0.rc)
- activesupport (= 3.0.0.rc)
- bundler (>= 1.0.0.rc.1)
- railties (= 3.0.0.rc)
- railties (3.0.0.rc)
- actionpack (= 3.0.0.rc)
- activesupport (= 3.0.0.rc)
- rake (>= 0.8.3)
- thor (~> 0.14.0)
+ rails (3.0.5)
+ actionmailer (= 3.0.5)
+ actionpack (= 3.0.5)
+ activerecord (= 3.0.5)
+ activeresource (= 3.0.5)
+ activesupport (= 3.0.5)
+ bundler (~> 1.0)
+ railties (= 3.0.5)
+ railties (3.0.5)
+ actionpack (= 3.0.5)
+ activesupport (= 3.0.5)
+ rake (>= 0.8.7)
+ thor (~> 0.14.4)
rake (0.8.7)
- rspec (2.0.0.beta.19)
- rspec-core (= 2.0.0.beta.19)
- rspec-expectations (= 2.0.0.beta.19)
- rspec-mocks (= 2.0.0.beta.19)
- rspec-core (2.0.0.beta.19)
- rspec-expectations (2.0.0.beta.19)
- diff-lcs (>= 1.1.2)
- rspec-mocks (2.0.0.beta.19)
- rspec-rails (2.0.0.beta.19)
- rspec (= 2.0.0.beta.19)
- webrat (>= 0.7.2.beta.1)
- thor (0.14.0)
- treetop (1.4.8)
+ rest-client (1.5.1)
+ mime-types (>= 1.16)
+ rspec (2.5.0)
+ rspec-core (~> 2.5.0)
+ rspec-expectations (~> 2.5.0)
+ rspec-mocks (~> 2.5.0)
+ rspec-core (2.5.1)
+ rspec-expectations (2.5.0)
+ diff-lcs (~> 1.1.2)
+ rspec-mocks (2.5.0)
+ rspec-rails (2.5.0)
+ actionpack (~> 3.0)
+ activesupport (~> 3.0)
+ railties (~> 3.0)
+ rspec (~> 2.5.0)
+ thor (0.14.6)
+ treetop (1.4.9)
polyglot (>= 0.3.1)
- tzinfo (0.3.22)
- warden (0.10.7)
+ tzinfo (0.3.26)
+ useragent (0.3.1)
+ warden (1.0.3)
rack (>= 1.0.0)
- webrat (0.7.2.beta.1)
- nokogiri (>= 1.2.0)
- rack (>= 1.0)
- rack-test (>= 0.5.3)
+ webmock (1.6.2)
+ addressable (>= 2.2.2)
+ crack (>= 0.1.7)
will_paginate (3.0.pre2)
PLATFORMS
ruby
DEPENDENCIES
- bson_ext
- database_cleaner (= 0.5.2)
- devise (= 1.1.1)
+ bson_ext (~> 1.2)
+ database_cleaner (~> 0.6.0)
+ devise (~> 1.1.8)
factory_girl_rails
haml
- libxml-ruby
- mongoid (= 2.0.0.beta.15)
- rails (= 3.0.0.rc)
- rspec (>= 2.0.0.beta.19)
- rspec-rails (>= 2.0.0.beta.19)
+ lighthouse-api
+ mongoid (= 2.0.0.rc.8)
+ mongoid_rails_migrations
+ nokogiri
+ pivotal-tracker
+ rails (= 3.0.5)
+ redmine_client!
+ rspec (~> 2.5)
+ rspec-rails (~> 2.5)
+ useragent (~> 0.3.1)
+ webmock
will_paginate
diff --git a/README.md b/README.md
index 3a5c213ead..6817566d12 100644
--- a/README.md
+++ b/README.md
@@ -1,8 +1,8 @@
Errbit: The open source self-hosted error catcher
=================================================
-Errbit is an open source, self-hosted error catcher. It is [Hoptoad](http://hoptoadapp.com)
-API compliant so you can just point the Hoptoad notifier at your Errbit server if you are
+Errbit is an open source, self-hosted error catcher. It is [Hoptoad](http://hoptoadapp.com)
+API compliant so you can just point the Hoptoad notifier at your Errbit server if you are
already using Hoptoad.
Errbit may be a good fit for you if:
@@ -22,90 +22,116 @@ Installation
*Note*: This app is intended for people with experience deploying and maintining
Rails applications. If you're uncomfortable with any step below then Errbit is not
-for you. Checkout [Hoptoad](http://hoptoadapp.com) from the guys over at
+for you. Checkout [Hoptoad](http://hoptoadapp.com) from the guys over at
[Thoughtbot](http://thoughtbot.com), which Errbit is based on.
**Set your local box or server(Ubuntu):**
- 1. Install MongoDB
- * Follow the directions [here](http://www.mongodb.org/display/DOCS/Ubuntu+and+Debian+packages), then:
-
- aptitude update
- aptitude install mongodb
-
+ 1. Install MongoDB. Follow the directions [here](http://www.mongodb.org/display/DOCS/Ubuntu+and+Debian+packages), then:
+
+ aptitude update
+ aptitude install mongodb
+
2. Install libxml
-
- apt-get install libxml2 libxml2-dev libxslt-dev
-
+
+ apt-get install libxml2 libxml2-dev libxslt-dev
+
3. Install Bundler
-
- gem install bundler --pre
-
+
+ gem install bundler
+
**Running Locally:**
1. Bootstrap Errbit. This will copy over config.yml and also seed the database.
- rake errbit:bootstrap
+ rake errbit:bootstrap
2. Update the config.yml and mongoid.yml files with information about your environment
3. Install dependencies
-
- bundle install
-
+
+ bundle install
+
4. Start Server
-
- script/rails server
+
+ script/rails server
**Deploying:**
1. Bootstrap Errbit. This will copy over config.yml and also seed the database.
- rake errbit:bootstrap
+ rake errbit:bootstrap
2. Update the deploy.rb file with information about your server
3. Setup server and deploy
-
- cap deploy:setup deploy
+
+ cap deploy:setup deploy
**Deploying to Heroku:**
1. Clone the repository
- git clone http://github.com/jdpace/errbit.git
+ git clone http://github.com/jdpace/errbit.git
2. Create & configure for Heroku
- gem install heroku
- heroku create
- heroku addons:add mongohq:free
- heroku addons:add sendgrid:free
- heroku config:add HEROKU=true
- heroku config:add ERRBIT_HOST=some-hostname.example.com
- heroku config:add ERRBIT_EMAIL_FROM=example@example.com
- git push heroku master
+ gem install heroku
+ heroku create
+ heroku addons:add mongohq:free
+ heroku addons:add sendgrid:free
+ heroku config:add HEROKU=true
+ heroku config:add ERRBIT_HOST=some-hostname.example.com
+ heroku config:add ERRBIT_EMAIL_FROM=example@example.com
+ git push heroku master
3. Seed the DB (_NOTE_: No bootstrap task is used on Heroku!)
- heroku rake db:seed
+ heroku rake db:seed
4. Enjoy!
+Upgrading
+---------
+*Note*: If upgrading from a version of Errbit that used Notices embedded in Errs please run:
+
+ 1. git pull origin master ( assuming origin is the github.com/jdpace/errbit repo )
+ 2. rake db:migrate
+
+Lighthouseapp integration
+-------------------------
+
+* Account is the name of your subdomain, i.e. **litcafe** for project at http://litcafe.lighthouseapp.com/projects/73466-face/overview
+* Errbit uses token-based authentication. Get your API Token or visit [http://help.lighthouseapp.com/kb/api/how-do-i-get-an-api-token](http://help.lighthouseapp.com/kb/api/how-do-i-get-an-api-token) to learn how to get it.
+* Project id is number identifier of your project, i.e. **73466** for project at http://litcafe.lighthouseapp.com/projects/73466-face/overview
+
+Redmine integration
+-------------------------
+
+* Account is the host of your redmine installation, i.e. **http://redmine.org**
+* Errbit uses token-based authentication. Get your API Key or visit [http://www.redmine.org/projects/redmine/wiki/Rest_api#Authentication](http://www.redmine.org/projects/redmine/wiki/Rest_api#Authentication) to learn how to get it.
+* Project id is an identifier of your project, i.e. **chilliproject** for project at http://www.redmine.org/projects/chilliproject
+
+Pivotal Tracker integration
+-------------------------
+
+* Errbit uses token-based authentication. Get your API Key or visit [http://www.pivotaltracker.com/help/api](http://www.pivotaltracker.com/help/api) to learn how to get it.
+* Project id is an identifier of your project, i.e. **24324** for project at http://www.pivotaltracker.com/projects/24324
+
TODO
----
-* Add a deployment view
* Add ability for watchers to be configured for types of notifications they should receive
Special Thanks
--------------
* [Michael Parenteau](http://michaelparenteau.com) - For rocking the Errbit design and providing a great user experience.
+* [Nick Recobra aka oruen](https://github.com/oruen) - Nick is Errbit's first core contributor. He's been working hard at making Errbit more awesome.
* [Relevance](http://thinkrelevance.com) - For giving me Open-source Fridays to work on Errbit and all my awesome co-workers for giving feedback and inspiration.
* [Thoughtbot](http://thoughtbot.com) - For being great open-source advocates and setting the bar with [Hoptoad](http://hoptoadapp.com).
Contributing
------------
-
+
* Fork the project.
* Make your feature addition or bug fix.
* Add tests for it. This is important so I don't break it in a
diff --git a/Rakefile b/Rakefile
index a7ba95e87a..37764344dc 100644
--- a/Rakefile
+++ b/Rakefile
@@ -8,4 +8,18 @@ require 'bundler'
Errbit::Application.load_tasks
Rake::Task[:default].clear
+
+namespace :spec do
+ desc "Preparing test env"
+ task :prepare do
+ tmp_env = Rails.env
+ Rails.env = "test"
+ %w( errbit:bootstrap ).each do |task|
+ Rake::Task[task].invoke
+ end
+ Rails.env = tmp_env
+ end
+end
+
+Rake::Task["spec"].prerequisites.push("spec:prepare")
task :default => ['spec']
\ No newline at end of file
diff --git a/app/controllers/apps_controller.rb b/app/controllers/apps_controller.rb
index e357d5ad45..f3a31cbab0 100644
--- a/app/controllers/apps_controller.rb
+++ b/app/controllers/apps_controller.rb
@@ -1,28 +1,38 @@
class AppsController < ApplicationController
-
+
before_filter :require_admin!, :except => [:index, :show]
before_filter :find_app, :except => [:index, :new, :create]
-
+
def index
@apps = current_user.admin? ? App.all : current_user.apps.all
end
-
+
def show
- @errs = @app.errs.paginate
+ respond_to do |format|
+ format.html do
+ @errs = @app.errs.ordered.paginate(:page => params[:page], :per_page => current_user.per_page)
+ @deploys = @app.deploys.order_by(:created_at.desc).limit(5)
+ end
+ format.atom do
+ @errs = @app.errs.unresolved.ordered
+ end
+ end
end
-
+
def new
@app = App.new
@app.watchers.build
+ @app.issue_tracker = IssueTracker.new
end
-
+
def edit
@app.watchers.build if @app.watchers.none?
+ @app.issue_tracker = IssueTracker.new if @app.issue_tracker.nil?
end
-
+
def create
@app = App.new(params[:app])
-
+
if @app.save
flash[:success] = 'Great success! Configure your app with the API key below'
redirect_to app_path(@app)
@@ -30,8 +40,8 @@ def create
render :new
end
end
-
- def update
+
+ def update
if @app.update_attributes(params[:app])
flash[:success] = "Good news everyone! '#{@app.name}' was successfully updated."
redirect_to app_path(@app)
@@ -39,18 +49,18 @@ def update
render :edit
end
end
-
+
def destroy
@app.destroy
flash[:success] = "'#{@app.name}' was successfully destroyed."
redirect_to apps_path
end
-
+
protected
-
+
def find_app
@app = App.find(params[:id])
-
+
# Mongoid Bug: could not chain: current_user.apps.find_by_id!
# apparently finding by 'watchers.email' and 'id' is broken
raise(Mongoid::Errors::DocumentNotFound.new(App,@app.id)) unless current_user.admin? || current_user.watching?(@app)
diff --git a/app/controllers/deploys_controller.rb b/app/controllers/deploys_controller.rb
index f026c8901e..aa75a879a4 100644
--- a/app/controllers/deploys_controller.rb
+++ b/app/controllers/deploys_controller.rb
@@ -1,16 +1,39 @@
class DeploysController < ApplicationController
-
+
+ protect_from_forgery :except => :create
+ skip_before_filter :verify_authenticity_token, :only => :create
skip_before_filter :authenticate_user!, :only => :create
-
+
def create
@app = App.find_by_api_key!(params[:api_key])
- @deploy = @app.deploys.create!({
- :username => params[:deploy][:local_username],
- :environment => params[:deploy][:rails_env],
- :repository => params[:deploy][:scm_repository],
- :revision => params[:deploy][:scm_revision]
- })
+ if params[:deploy]
+ deploy = {
+ :username => params[:deploy][:local_username],
+ :environment => params[:deploy][:rails_env],
+ :repository => params[:deploy][:scm_repository],
+ :revision => params[:deploy][:scm_revision],
+ :message => params[:deploy][:message]
+ }
+ end
+
+ # handle Heroku's HTTP post deployhook format
+ deploy ||= {
+ :username => params[:user],
+ :environment => params[:rack_env].try(:downcase) || params[:app],
+ :repository => "git@heroku.com:#{params[:app]}.git",
+ :revision => params[:head],
+ }
+
+ @deploy = @app.deploys.create!(deploy)
render :xml => @deploy
end
-
+
+ def index
+ # See AppsController#find_app for the reasoning behind this code.
+ app = App.find(params[:app_id])
+ raise(Mongoid::Errors::DocumentNotFound.new(App,app.id)) unless current_user.admin? || current_user.watching?(app)
+
+ @deploys = app.deploys.order_by(:created_at.desc).paginate(:page => params[:page], :per_page => 10)
+ end
+
end
\ No newline at end of file
diff --git a/app/controllers/errs_controller.rb b/app/controllers/errs_controller.rb
index 12856ac9ed..3b18616a69 100644
--- a/app/controllers/errs_controller.rb
+++ b/app/controllers/errs_controller.rb
@@ -1,45 +1,83 @@
class ErrsController < ApplicationController
-
+
before_filter :find_app, :except => [:index, :all]
-
+ before_filter :find_err, :except => [:index, :all]
+
def index
app_scope = current_user.admin? ? App.all : current_user.apps
- @errs = Err.for_apps(app_scope).unresolved.ordered.paginate(:page => params[:page])
+ respond_to do |format|
+ format.html do
+ @errs = Err.for_apps(app_scope).unresolved.ordered.paginate(:page => params[:page], :per_page => current_user.per_page)
+ end
+ format.atom do
+ @errs = Err.for_apps(app_scope).unresolved.ordered
+ end
+ end
end
-
+
def all
app_scope = current_user.admin? ? App.all : current_user.apps
- @errs = Err.for_apps(app_scope).ordered.paginate(:page => params[:page])
+ @errs = Err.for_apps(app_scope).ordered.paginate(:page => params[:page], :per_page => current_user.per_page)
end
-
+
def show
- @err = @app.errs.find(params[:id])
- page = (params[:notice] || @err.notices.count)
+ page = (params[:notice] || @err.notices_count)
page = 1 if page.to_i.zero?
@notices = @err.notices.ordered.paginate(:page => page, :per_page => 1)
@notice = @notices.first
end
-
+
+ def create_issue
+ set_tracker_params
+
+ if @app.issue_tracker
+ @app.issue_tracker.create_issue @err
+ else
+ flash[:error] = "This up has no issue tracker setup."
+ end
+ redirect_to app_err_path(@app, @err)
+ rescue ActiveResource::ConnectionError => e
+ Rails.logger.error e.to_s
+ flash[:error] = "There was an error during issue creation. Check your tracker settings or try again later."
+ redirect_to app_err_path(@app, @err)
+ end
+
+ def clear_issue
+ @err.update_attribute :issue_link, nil
+ redirect_to app_err_path(@app, @err)
+ end
+
def resolve
- @err = @app.errs.find(params[:id])
-
- # Deal with bug in mogoid where find is returning an Enumberable obj
+ # Deal with bug in mongoid where find is returning an Enumberable obj
@err = @err.first if @err.respond_to?(:first)
-
+
@err.resolve!
-
+
flash[:success] = 'Great news everyone! The err has been resolved.'
- redirect_to errs_path
+
+ redirect_to :back
+ rescue ActionController::RedirectBackError
+ redirect_to app_path(@app)
end
-
+
protected
-
+
def find_app
@app = App.find(params[:app_id])
-
+
# Mongoid Bug: could not chain: current_user.apps.find_by_id!
# apparently finding by 'watchers.email' and 'id' is broken
raise(Mongoid::Errors::DocumentNotFound.new(App,@app.id)) unless current_user.admin? || current_user.watching?(@app)
end
-
+
+ def find_err
+ @err = @app.errs.find(params[:id])
+ end
+
+ def set_tracker_params
+ IssueTracker.default_url_options[:host] = request.host
+ IssueTracker.default_url_options[:port] = request.port
+ IssueTracker.default_url_options[:protocol] = request.scheme
+ end
+
end
diff --git a/app/controllers/notices_controller.rb b/app/controllers/notices_controller.rb
index bdf7374830..69bff71f77 100644
--- a/app/controllers/notices_controller.rb
+++ b/app/controllers/notices_controller.rb
@@ -4,7 +4,8 @@ class NoticesController < ApplicationController
skip_before_filter :authenticate_user!, :only => :create
def create
- @notice = Notice.from_xml(request.raw_post)
+ # params[:data] if the notice came from a GET request, raw_post if it came via POST
+ @notice = Notice.from_xml(params[:data] || request.raw_post)
respond_with @notice
end
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
index 70aaa70634..1165185f8d 100644
--- a/app/controllers/users_controller.rb
+++ b/app/controllers/users_controller.rb
@@ -6,7 +6,7 @@ class UsersController < ApplicationController
before_filter :require_user_edit_priviledges, :only => [:edit, :update]
def index
- @users = User.paginate(:page => params[:page])
+ @users = User.paginate(:page => params[:page], :per_page => current_user.per_page)
end
def show
@@ -23,6 +23,9 @@ def edit
def create
@user = User.new(params[:user])
+ # Set protected attributes
+ @user.admin = params[:user].try(:[], :admin) if current_user.admin?
+
if @user.save
flash[:success] = "#{@user.name} is now part of the team. Be sure to add them as a project watcher."
redirect_to user_path(@user)
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index de6be7945c..a831f1f0c9 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -1,2 +1,45 @@
module ApplicationHelper
+
+
+ def lighthouse_tracker? object
+ object.issue_tracker_type == "lighthouseapp"
+ end
+
+ def user_agent_graph(error)
+ tallies = tally(error.notices) {|notice| pretty_user_agent(notice.user_agent)}
+ create_percentage_table(tallies, :total => error.notices.count)
+ end
+
+ def pretty_user_agent(user_agent)
+ (user_agent.nil? || user_agent.none?) ? "N/A" : "#{user_agent.browser} #{user_agent.version}"
+ end
+
+ def tally(collection, &block)
+ collection.inject({}) do |tallies, item|
+ value = yield item
+ tallies[value] = (tallies[value] || 0) + 1
+ tallies
+ end
+ end
+
+ def create_percentage_table(tallies, options={})
+ total = (options[:total] || total_from_tallies(tallies))
+ percent = 100.0 / total.to_f
+ rows = tallies.map {|value, count| [(count.to_f * percent), value]} \
+ .sort {|a, b| a[0] <=> b[0]}
+ render :partial => "errs/tally_table", :locals => {:rows => rows}
+ end
+
+ def total_from_tallies(tallies)
+ tallies.values.inject(0) {|sum, n| sum + n}
+ end
+ private :total_from_tallies
+
+ def redmine_tracker? object
+ object.issue_tracker_type == "redmine"
+ end
+
+ def pivotal_tracker? object
+ object.issue_tracker_type == "pivotal"
+ end
end
diff --git a/app/helpers/errs_helper.rb b/app/helpers/errs_helper.rb
new file mode 100644
index 0000000000..a84e12d182
--- /dev/null
+++ b/app/helpers/errs_helper.rb
@@ -0,0 +1,10 @@
+module ErrsHelper
+
+ def last_notice_at err
+ err.last_notice_at || err.created_at
+ end
+
+ def err_confirm
+ Errbit::Config.confirm_resolve_err === false ? nil : 'Seriously?'
+ end
+end
\ No newline at end of file
diff --git a/app/helpers/form_helper.rb b/app/helpers/form_helper.rb
index b10a2b0201..078fc7faad 100644
--- a/app/helpers/form_helper.rb
+++ b/app/helpers/form_helper.rb
@@ -6,7 +6,7 @@ def errors_for(document)
content_tag(:div, :class => 'error-messages') do
body = content_tag(:h2, 'Dang. The following errors are keeping this from being a success.')
body += content_tag(:ul) do
- document.errors.full_messages.inject('') {|errs, msg| errs += content_tag(:li, msg) }
+ document.errors.full_messages.inject('') {|errs, msg| errs += content_tag(:li, h(msg)) }.html_safe
end
end
end
diff --git a/app/helpers/notices_helper.rb b/app/helpers/notices_helper.rb
new file mode 100644
index 0000000000..bd4974b183
--- /dev/null
+++ b/app/helpers/notices_helper.rb
@@ -0,0 +1,6 @@
+# encoding: utf-8
+module NoticesHelper
+ def notice_atom_summary notice
+ render :partial => "notices/atom_entry.html.haml", :locals => {:notice => notice}
+ end
+end
\ No newline at end of file
diff --git a/app/mailers/mailer.rb b/app/mailers/mailer.rb
index 06f65eee7d..db3e1cbb31 100644
--- a/app/mailers/mailer.rb
+++ b/app/mailers/mailer.rb
@@ -1,24 +1,25 @@
class Mailer < ActionMailer::Base
default :from => Errbit::Config.email_from
-
+
def err_notification(notice)
@notice = notice
@app = notice.err.app
-
+
+ puts "To: #{@app.watchers.map(&:address).join(", ")}"
mail({
:to => @app.watchers.map(&:address),
- :subject => "[#{@app.name}] #{@notice.err.message}"
+ :subject => "[#{@app.name}][#{@notice.err.environment}] #{@notice.err.message}"
})
end
-
+
def deploy_notification(deploy)
@deploy = deploy
@app = deploy.app
-
+
mail({
:to => @app.watchers.map(&:address),
:subject => "[#{@app.name}] Deployed to #{@deploy.environment} by #{@deploy.username}"
})
end
-
-end
\ No newline at end of file
+
+end
diff --git a/app/models/app.rb b/app/models/app.rb
index 42c317ad18..4771706f2c 100644
--- a/app/models/app.rb
+++ b/app/models/app.rb
@@ -1,43 +1,76 @@
class App
include Mongoid::Document
include Mongoid::Timestamps
-
+
field :name, :type => String
field :api_key
field :resolve_errs_on_deploy, :type => Boolean, :default => false
- key :name
-
+ field :notify_on_errs, :type => Boolean, :default => true
+ field :notify_on_deploys, :type => Boolean, :default => true
+
+ # Some legacy apps may have sting as key instead of BSON::ObjectID
+ identity :type => String
+ # There seems to be a Mongoid bug making it impossible to use String identity with references_many feature:
+ # https://github.com/mongoid/mongoid/issues/703
+ # Using 32 character string as a workaround.
+ before_create do |r|
+ r.id = ActiveSupport::SecureRandom.hex
+ end
+
embeds_many :watchers
embeds_many :deploys
+ embeds_one :issue_tracker
references_many :errs, :dependent => :destroy
-
+
before_validation :generate_api_key, :on => :create
-
+
validates_presence_of :name, :api_key
validates_uniqueness_of :name, :allow_blank => true
validates_uniqueness_of :api_key, :allow_blank => true
validates_associated :watchers
-
+ validate :check_issue_tracker
+
accepts_nested_attributes_for :watchers, :allow_destroy => true,
:reject_if => proc { |attrs| attrs[:user_id].blank? && attrs[:email].blank? }
-
+ accepts_nested_attributes_for :issue_tracker, :allow_destroy => true,
+ :reject_if => proc { |attrs| !%w(lighthouseapp redmine pivotal).include?(attrs[:issue_tracker_type]) }
+
# Mongoid Bug: find(id) on association proxies returns an Enumerator
def self.find_by_id!(app_id)
where(:_id => app_id).first || raise(Mongoid::Errors::DocumentNotFound.new(self,app_id))
end
-
+
def self.find_by_api_key!(key)
where(:api_key => key).first || raise(Mongoid::Errors::DocumentNotFound.new(self,key))
end
-
+
def last_deploy_at
deploys.last && deploys.last.created_at
end
-
+
+ # Legacy apps don't have notify_on_errs and notify_on_deploys params
+ def notify_on_errs
+ !(self[:notify_on_errs] == false)
+ end
+ alias :notify_on_errs? :notify_on_errs
+
+ def notify_on_deploys
+ !(self[:notify_on_deploys] == false)
+ end
+ alias :notify_on_deploys? :notify_on_deploys
+
protected
-
+
def generate_api_key
self.api_key ||= ActiveSupport::SecureRandom.hex
end
-
+
+ def check_issue_tracker
+ if issue_tracker.present?
+ issue_tracker.valid?
+ issue_tracker.errors.full_messages.each do |error|
+ errors[:base] << error
+ end if issue_tracker.errors
+ end
+ end
end
diff --git a/app/models/deploy.rb b/app/models/deploy.rb
index 9158db5f98..3e9a79010a 100644
--- a/app/models/deploy.rb
+++ b/app/models/deploy.rb
@@ -6,6 +6,9 @@ class Deploy
field :repository
field :environment
field :revision
+ field :message
+
+ index :created_at, Mongo::DESCENDING
embedded_in :app, :inverse_of => :deploys
@@ -25,7 +28,7 @@ def resolve_app_errs
protected
def should_notify?
- app.watchers.any?
+ app.notify_on_deploys? && app.watchers.any?
end
def should_resolve_app_errs?
diff --git a/app/models/err.rb b/app/models/err.rb
index 496c773cd6..4652588070 100644
--- a/app/models/err.rb
+++ b/app/models/err.rb
@@ -1,7 +1,7 @@
class Err
include Mongoid::Document
include Mongoid::Timestamps
-
+
field :klass
field :component
field :action
@@ -9,39 +9,45 @@ class Err
field :fingerprint
field :last_notice_at, :type => DateTime
field :resolved, :type => Boolean, :default => false
-
+ field :issue_link, :type => String
+ field :notices_count, :type => Integer, :default => 0
+ field :message
+
+ index :last_notice_at
+ index :app_id
+
referenced_in :app
- embeds_many :notices
-
+ references_many :notices
+
validates_presence_of :klass, :environment
-
+
scope :resolved, where(:resolved => true)
scope :unresolved, where(:resolved => false)
scope :ordered, order_by(:last_notice_at.desc)
scope :in_env, lambda {|env| where(:environment => env)}
scope :for_apps, lambda {|apps| where(:app_id.in => apps.all.map(&:id))}
-
+
def self.for(attrs)
app = attrs.delete(:app)
app.errs.where(attrs).first || app.errs.create!(attrs)
end
-
+
def resolve!
self.update_attributes!(:resolved => true)
end
-
+
def unresolved?
!resolved?
end
-
+
def where
where = component.dup
where << "##{action}" if action.present?
where
end
-
+
def message
- notices.first.message || klass
+ super || klass
end
-
-end
\ No newline at end of file
+
+end
diff --git a/app/models/issue_tracker.rb b/app/models/issue_tracker.rb
new file mode 100644
index 0000000000..7a6dc235eb
--- /dev/null
+++ b/app/models/issue_tracker.rb
@@ -0,0 +1,102 @@
+class IssueTracker
+ include Mongoid::Document
+ include Mongoid::Timestamps
+ include HashHelper
+ include Rails.application.routes.url_helpers
+ default_url_options[:host] = Errbit::Application.config.action_mailer.default_url_options[:host]
+
+ validate :check_params
+
+ embedded_in :app, :inverse_of => :issue_tracker
+
+ field :account, :type => String
+ field :api_token, :type => String
+ field :project_id, :type => String
+ field :issue_tracker_type, :type => String, :default => 'lighthouseapp'
+
+ def create_issue err
+ case issue_tracker_type
+ when 'lighthouseapp'
+ create_lighthouseapp_issue err
+ when 'redmine'
+ create_redmine_issue err
+ when 'pivotal'
+ create_pivotal_issue err
+ end
+ end
+
+ protected
+ def create_redmine_issue err
+ token = api_token
+ acc = account
+ RedmineClient::Base.configure do
+ self.token = token
+ self.site = acc
+ end
+ issue = RedmineClient::Issue.new(:project_id => project_id)
+ issue.subject = issue_title err
+ issue.description = self.class.redmine_body_template.result(binding)
+ issue.save!
+ err.update_attribute :issue_link, "#{RedmineClient::Issue.site.to_s.sub(/#{RedmineClient::Issue.site.path}$/, '')}#{RedmineClient::Issue.element_path(issue.id, :project_id => project_id)}".sub(/\.xml\?project_id=#{project_id}$/, "\?project_id=#{project_id}")
+ end
+
+ def create_pivotal_issue err
+ PivotalTracker::Client.token = api_token
+ PivotalTracker::Client.use_ssl = true
+ project = PivotalTracker::Project.find project_id.to_i
+ story = project.stories.create :name => issue_title(err), :story_type => 'bug', :description => self.class.pivotal_body_template.result(binding)
+ err.update_attribute :issue_link, "https://www.pivotaltracker.com/story/show/#{story.id}"
+ end
+
+ def create_lighthouseapp_issue err
+ Lighthouse.account = account
+ Lighthouse.token = api_token
+
+ # updating lighthouse account
+ Lighthouse::Ticket.site
+
+ ticket = Lighthouse::Ticket.new(:project_id => project_id)
+ ticket.title = issue_title err
+
+ ticket.body = self.class.lighthouseapp_body_template.result(binding)
+
+ ticket.tags << "errbit"
+ ticket.save!
+ err.update_attribute :issue_link, "#{Lighthouse::Ticket.site.to_s.sub(/#{Lighthouse::Ticket.site.path}$/, '')}#{Lighthouse::Ticket.element_path(ticket.id, :project_id => project_id)}".sub(/\.xml$/, '')
+ end
+
+ def issue_title err
+ "[#{ err.environment }][#{ err.where }] #{err.message.to_s.truncate(100)}"
+ end
+
+ def check_params
+ blank_flag_fields = %w(api_token project_id)
+ blank_flag_fields << 'account' if %w(lighthouseapp redmine).include? issue_tracker_type
+ blank_flags = blank_flag_fields.map {|m| self[m].blank? }
+ if blank_flags.any? && !blank_flags.all?
+ message = case issue_tracker_type
+ when 'lighthouseapp'
+ "You must specify your Lighthouseapp account, api token and project id"
+ when 'redmine'
+ "You must specify your Redmine url, api token and project id"
+ when 'pivotal'
+ "You must specify your Pivotal Tracker api token and project id"
+ end
+ errors.add(:base, message)
+ end
+ end
+
+ class << self
+ def lighthouseapp_body_template
+ @@lighthouseapp_body_template ||= ERB.new(File.read(Rails.root + "app/views/errs/lighthouseapp_body.txt.erb").gsub(/^\s*/, ''))
+ end
+
+ def redmine_body_template
+ @@redmine_body_template ||= ERB.new(File.read(Rails.root + "app/views/errs/redmine_body.txt.erb"))
+ end
+
+ def pivotal_body_template
+ @@pivotal_body_template ||= ERB.new(File.read(Rails.root + "app/views/errs/pivotal_body.txt.erb"))
+ end
+ end
+end
diff --git a/app/models/notice.rb b/app/models/notice.rb
index 95568f0a3c..4b2b56dda7 100644
--- a/app/models/notice.rb
+++ b/app/models/notice.rb
@@ -1,31 +1,37 @@
require 'hoptoad'
+require 'recurse'
class Notice
include Mongoid::Document
include Mongoid::Timestamps
-
+
field :message
field :backtrace, :type => Array
field :server_environment, :type => Hash
field :request, :type => Hash
field :notifier, :type => Hash
-
- embedded_in :err, :inverse_of => :notices
-
+
+ referenced_in :err
+ index :err_id
+
after_create :cache_last_notice_at
after_create :deliver_notification, :if => :should_notify?
-
+ before_create :increase_counter_cache, :cache_message
+ before_save :sanitize
+ before_destroy :decrease_counter_cache
+
validates_presence_of :backtrace, :server_environment, :notifier
-
+
scope :ordered, order_by(:created_at.asc)
-
+
def self.from_xml(hoptoad_xml)
hoptoad_notice = Hoptoad::V2.parse_xml(hoptoad_xml)
app = App.find_by_api_key!(hoptoad_notice['api-key'])
-
+
+ hoptoad_notice['request'] ||= {}
hoptoad_notice['request']['component'] = 'unknown' if hoptoad_notice['request']['component'].blank?
hoptoad_notice['request']['action'] = nil if hoptoad_notice['request']['action'].blank?
-
+
err = Err.for({
:app => app,
:klass => hoptoad_notice['error']['class'],
@@ -35,7 +41,7 @@ def self.from_xml(hoptoad_xml)
:fingerprint => hoptoad_notice['fingerprint']
})
err.update_attributes(:resolved => false) if err.resolved?
-
+
err.notices.create!({
:message => hoptoad_notice['error']['message'],
:backtrace => hoptoad_notice['error']['backtrace']['line'],
@@ -44,35 +50,77 @@ def self.from_xml(hoptoad_xml)
:notifier => hoptoad_notice['notifier']
})
end
-
+
+ def user_agent
+ agent_string = env_vars['HTTP_USER_AGENT']
+ agent_string.blank? ? nil : UserAgent.parse(agent_string)
+ end
+
def request
read_attribute(:request) || {}
end
-
+
def env_vars
request['cgi-data'] || {}
end
-
+
def params
request['params'] || {}
end
-
+
def session
request['session'] || {}
end
-
+
def deliver_notification
+ puts "Deliver notification!"
Mailer.err_notification(self).deliver
end
-
+
def cache_last_notice_at
err.update_attributes(:last_notice_at => created_at)
end
-
+
protected
-
- def should_notify?
- Errbit::Config.email_at_notices.include?(err.notices.count) && err.app.watchers.any?
+
+ def should_notify?
+ puts "notify_on_errs: #{err.app.notify_on_errs?}"
+ puts "email_at_notices: #{Errbit::Config.email_at_notices.to_json}"
+ puts "notices_count: #{err.notices.count}"
+ puts "watchers: #{err.app.watchers.count}"
+ err.app.notify_on_errs? && Errbit::Config.email_at_notices.include?(err.notices.count) && err.app.watchers.any?
+ end
+
+
+ def increase_counter_cache
+ err.inc(:notices_count,1)
+ end
+
+ def decrease_counter_cache
+ err.inc(:notices_count,-1)
+ end
+
+ def cache_message
+ err.update_attribute(:message, message) if err.notices_count == 1
+ end
+
+ def sanitize
+ [:server_environment, :request, :notifier].each do |h|
+ send("#{h}=",sanitize_hash(send(h)))
+ end
+ end
+
+ def sanitize_hash(h)
+ h.recurse do
+ |h| h.inject({}) do |h,(k,v)|
+ if k.is_a?(String)
+ h[k.gsub(/\./,'.').gsub(/^\$/,'$')] = v
+ else
+ h[k] = v
+ end
+ h
+ end
end
-
-end
\ No newline at end of file
+ end
+end
+
diff --git a/app/models/user.rb b/app/models/user.rb
index 603d1d1a29..61146f6c22 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -1,4 +1,5 @@
class User
+ PER_PAGE = 30
include Mongoid::Document
include Mongoid::Timestamps
@@ -8,8 +9,10 @@ class User
field :name
field :admin, :type => Boolean, :default => false
-
+ field :per_page, :type => Fixnum, :default => PER_PAGE
+
after_destroy :destroy_watchers
+ before_save :ensure_authentication_token
validates_presence_of :name
@@ -20,6 +23,10 @@ class User
def watchers
App.all.map(&:watchers).flatten.select {|w| w.user_id.to_s == id.to_s}
end
+
+ def per_page
+ self[:per_page] || PER_PAGE
+ end
def apps
# This is completely wasteful but became necessary
diff --git a/app/views/apps/_configuration_instructions.html.haml b/app/views/apps/_configuration_instructions.html.haml
index b210cc6127..c951c4366c 100644
--- a/app/views/apps/_configuration_instructions.html.haml
+++ b/app/views/apps/_configuration_instructions.html.haml
@@ -1,7 +1,7 @@
%pre
%code
:preserve
-
+
# Require the hoptoad_notifier gem in you App.
# --------------------------------------------
#
@@ -14,9 +14,10 @@
# Then add the following to config/initializers/errbit.rb
# -------------------------------------------------------
HoptoadNotifier.configure do |config|
- config.api_key = '#{app.api_key}'
- config.host = '#{request.host}'
- config.port = #{request.port} # Note: Deployment notifications only work on port 80
+ config.api_key = '#{app.api_key}'
+ config.host = '#{request.host}'
+ config.port = #{request.port}
+ config.secure = config.port == 443
end
#
# Testing
@@ -28,5 +29,4 @@
# Run:
# rake hoptoad:test
# refresh this page
-
-
\ No newline at end of file
+
diff --git a/app/views/apps/_fields.html.haml b/app/views/apps/_fields.html.haml
index 0a2c82031e..43a2267382 100644
--- a/app/views/apps/_fields.html.haml
+++ b/app/views/apps/_fields.html.haml
@@ -3,14 +3,22 @@
%div.required
= f.label :name
= f.text_field :name
-
+
+%div.checkbox
+ = f.check_box :notify_on_errs
+ = f.label :notify_on_errs, 'Notify on errors'
+
%div.checkbox
= f.check_box :resolve_errs_on_deploy
= f.label :resolve_errs_on_deploy, 'Resolve errs on deploy'
-
+
+%div.checkbox
+ = f.check_box :notify_on_deploys
+ = f.label :notify_on_deploys, 'Notify on deploys'
+
%fieldset.nested-wrapper
%legend Watchers
- - f.fields_for :watchers do |w|
+ = f.fields_for :watchers do |w|
%div.watcher.nested
%div.choose
= w.radio_button :watcher_type, :user
@@ -20,4 +28,35 @@
%div.user{:class => w.object.email.blank? ? 'choosen' : nil}
= w.select :user_id, User.all.map{|u| [u.name,u.id.to_s]}, :include_blank => '-- Select a User --'
%div.email{:class => w.object.email.present? ? 'choosen' : nil}
- = w.text_field :email
\ No newline at end of file
+ = w.text_field :email
+
+%fieldset
+ %legend Issue tracker
+ = f.fields_for :issue_tracker do |w|
+ %div.issue_tracker.nested
+ %div.choose
+ = w.radio_button :issue_tracker_type, :lighthouseapp
+ = label_tag :issue_tracker_type_lighthouseapp, 'Lighthouse', :for => label_for_attr(w, 'issue_tracker_type_lighthouseapp')
+ = w.radio_button :issue_tracker_type, :redmine
+ = label_tag :issue_tracker_type_redmine, 'Redmine', :for => label_for_attr(w, 'issue_tracker_type_redmine')
+ = w.radio_button :issue_tracker_type, :pivotal
+ = label_tag :issue_tracker_type_pivotal, 'Pivotal Tracker', :for => label_for_attr(w, 'issue_tracker_type_pivotal')
+ %div.tracker_params.lighthouseapp{:class => lighthouse_tracker?(w.object) ? 'chosen' : nil}
+ = w.label :account, "Account"
+ = w.text_field :account, :placeholder => "abc from abc.lighthouseapp.com"
+ = w.label :api_token, "API token"
+ = w.text_field :api_token, :placeholder => "API Token for your account"
+ = w.label :project_id, "Project ID"
+ = w.text_field :project_id, :placeholder => "123 from abc from abc.lighthouseapp.com/projects/123"
+ %div.tracker_params.redmine{:class => redmine_tracker?(w.object) ? 'chosen' : nil}
+ = w.label :account, "Redmine URL"
+ = w.text_field :account, :placeholder => "like http://www.redmine.org/"
+ = w.label :api_token, "API token"
+ = w.text_field :api_token, :placeholder => "API Token for your account"
+ = w.label :project_id, "Project ID"
+ = w.text_field :project_id
+ %div.tracker_params.pivotal{:class => pivotal_tracker?(w.object) ? 'chosen' : nil}
+ = w.label :project_id, "Project ID"
+ = w.text_field :project_id
+ = w.label :api_token, "API token"
+ = w.text_field :api_token, :placeholder => "API Token for your account"
diff --git a/app/views/apps/index.html.haml b/app/views/apps/index.html.haml
index 3916553af4..4519184029 100644
--- a/app/views/apps/index.html.haml
+++ b/app/views/apps/index.html.haml
@@ -12,9 +12,9 @@
- @apps.each do |app|
%tr
%td.name= link_to app.name, app_path(app)
- %td.deploy= app.last_deploy_at ? app.last_deploy_at.to_s(:micro) : 'n/a'
+ %td.deploy= app.last_deploy_at ? link_to( app.last_deploy_at.to_s(:micro), app_deploys_path(app)) : 'n/a'
%td.count
- - if app.errs.any?
+ - if app.errs.count > 0
= link_to app.errs.unresolved.count, app_errs_path(app)
- else
\-
@@ -23,4 +23,4 @@
%td{:colspan => 3}
%em
No apps here.
- = link_to 'Click here to create your first one', new_app_path
\ No newline at end of file
+ = link_to 'Click here to create your first one', new_app_path
diff --git a/app/views/apps/show.atom.builder b/app/views/apps/show.atom.builder
new file mode 100644
index 0000000000..424a97b89c
--- /dev/null
+++ b/app/views/apps/show.atom.builder
@@ -0,0 +1,4 @@
+atom_feed do |feed|
+ feed.title("Errbit notices for #{h @app.name} at #{root_url}")
+ render :partial => "errs/list", :locals => {:feed => feed}
+end
diff --git a/app/views/apps/show.html.haml b/app/views/apps/show.html.haml
index 57c6a813ad..200ff75cb1 100644
--- a/app/views/apps/show.html.haml
+++ b/app/views/apps/show.html.haml
@@ -1,7 +1,11 @@
- content_for :title, @app.name
+- content_for :head do
+ = auto_discovery_link_tag :atom, app_url(@app, User.token_authentication_key => current_user.authentication_token, :format => "atom"), :title => "Errbit notices for #{@app.name} at #{root_url}"
- content_for :meta do
%strong Errs Caught:
= @app.errs.count
+ %strong Deploy Count:
+ = @app.deploys.count
%strong API Key:
= @app.api_key
- content_for :action_bar do
@@ -23,9 +27,32 @@
%td
%em Sadly, no one is watching this app
-- if @app.errs.any?
- %h3 Errs
+%h3 Latest Deploys
+- if @deploys.any?
+ %table.deploys
+ %thead
+ %tr
+ %th When
+ %th Who
+ %th Message
+ %th Repository
+ %th Revision
+
+ %tbody
+ - @deploys.each do |deploy|
+ %tr
+ %td.when #{deploy.created_at.to_s(:micro)}
+ %td.who #{deploy.username}
+ %td.message #{deploy.message}
+ %td.repository #{deploy.repository}
+ %td.revision #{deploy.revision}
+ = link_to "All Deploys (#{@app.deploys.count})", app_deploys_path(@app), :class => 'button'
+- else
+ %h3 No deploys
+
+- if @app.errs.count > 0
+ %h3.clear Errs
= render 'errs/table', :errs => @errs
- else
- %h3 No errs have been caught yet, make sure you setup your app
- = render 'configuration_instructions', :app => @app
\ No newline at end of file
+ %h3.clear No errs have been caught yet, make sure you setup your app
+ = render 'configuration_instructions', :app => @app
diff --git a/app/views/deploys/_table.html.haml b/app/views/deploys/_table.html.haml
new file mode 100644
index 0000000000..6a70badb9c
--- /dev/null
+++ b/app/views/deploys/_table.html.haml
@@ -0,0 +1,20 @@
+%table.errs
+ %thead
+ %tr
+ %th App
+ %th When
+ %th Who
+ %th Message
+ %th Repository
+ %th Revision
+ %tbody
+ - deploys.each do |deploy|
+ %tr
+ %td.app
+ = deploy.app.name
+ %span.environment= deploy.environment
+ %td.latest #{time_ago_in_words(deploy.created_at)} ago
+ %td.who #{deploy.username}
+ %td.message #{deploy.message}
+ %td.repository #{deploy.repository}
+ %td.revision #{deploy.revision}
diff --git a/app/views/deploys/index.html.haml b/app/views/deploys/index.html.haml
new file mode 100644
index 0000000000..8d99fa4dfd
--- /dev/null
+++ b/app/views/deploys/index.html.haml
@@ -0,0 +1,3 @@
+- content_for :title, 'Deploys'
+= render 'table', :deploys => @deploys
+= will_paginate @deploys, :previous_label => '« Previous', :next_label => 'Next »'
diff --git a/app/views/errs/_list.atom.builder b/app/views/errs/_list.atom.builder
new file mode 100644
index 0000000000..f9d8ef06e5
--- /dev/null
+++ b/app/views/errs/_list.atom.builder
@@ -0,0 +1,15 @@
+feed.updated(@errs.first.created_at)
+
+for err in @errs
+ notice = err.notices.first
+
+ feed.entry(err, :url => app_err_url(err.app, err)) do |entry|
+ entry.title "[#{ err.where }] #{err.message.to_s.truncate(27)}"
+ entry.author do |author|
+ author.name "#{ err.app.name } [#{ err.environment }]"
+ end
+ if notice
+ entry.summary(notice_atom_summary(notice), :type => "html")
+ end
+ end
+end
diff --git a/app/views/errs/_table.html.haml b/app/views/errs/_table.html.haml
index 649175a806..96c269e1e5 100644
--- a/app/views/errs/_table.html.haml
+++ b/app/views/errs/_table.html.haml
@@ -6,20 +6,22 @@
%th Latest
%th Deploy
%th Count
+ %th Resolve
%tbody
- errs.each do |err|
%tr{:class => err.resolved? ? 'resolved' : 'unresolved'}
%td.app
- = err.app.name
+ = link_to err.app.name, app_path(err.app)
%span.environment= err.environment
%td.message
= link_to err.message, app_err_path(err.app, err)
%em= err.where
- %td.latest #{time_ago_in_words(err.last_notice_at)} ago
+ %td.latest #{time_ago_in_words(last_notice_at err)} ago
%td.deploy= err.app.last_deploy_at ? err.app.last_deploy_at.to_s(:micro) : 'n/a'
- %td.count= link_to err.notices.count, app_err_path(err.app, err)
+ %td.count= link_to err.notices_count, app_err_path(err.app, err)
+ %td.resolve= link_to image_tag("thumbs-up.png"), resolve_app_err_path(err.app, err), :title => "Resolve", :method => :put, :confirm => err_confirm, :class => 'resolve' if err.unresolved?
- if errs.none?
%tr
%td{:colspan => (@app ? 5 : 6)}
%em No errs here
-= will_paginate @errs, :previous_label => '« Previous', :next_label => 'Next »'
\ No newline at end of file
+= will_paginate @errs, :previous_label => '« Previous', :next_label => 'Next »'
diff --git a/app/views/errs/_tally_table.html.haml b/app/views/errs/_tally_table.html.haml
new file mode 100644
index 0000000000..bf54ce587d
--- /dev/null
+++ b/app/views/errs/_tally_table.html.haml
@@ -0,0 +1,5 @@
+%table.tally
+ - rows.each do |row|
+ %tr
+ %td.percent= number_to_percentage(row[0], :precision => 1)
+ %th.value= row[1]
diff --git a/app/views/errs/index.atom.builder b/app/views/errs/index.atom.builder
new file mode 100644
index 0000000000..b0a77d5d5c
--- /dev/null
+++ b/app/views/errs/index.atom.builder
@@ -0,0 +1,4 @@
+atom_feed do |feed|
+ feed.title("Errbit notices at #{root_url}")
+ render :partial => "errs/list", :locals => {:feed => feed}
+end
diff --git a/app/views/errs/index.html.haml b/app/views/errs/index.html.haml
index 40b02480cb..75315bdb4c 100644
--- a/app/views/errs/index.html.haml
+++ b/app/views/errs/index.html.haml
@@ -1,4 +1,6 @@
- content_for :title, 'Unresolved Errs'
+- content_for :head do
+ = auto_discovery_link_tag :atom, errs_url(User.token_authentication_key => current_user.authentication_token, :format => "atom"), :title => "Errbit notices at #{root_url}"
- content_for :action_bar do
= link_to 'show resolved', all_errs_path, :class => 'button'
= render 'table', :errs => @errs
\ No newline at end of file
diff --git a/app/views/errs/lighthouseapp_body.txt.erb b/app/views/errs/lighthouseapp_body.txt.erb
new file mode 100644
index 0000000000..709d194f5f
--- /dev/null
+++ b/app/views/errs/lighthouseapp_body.txt.erb
@@ -0,0 +1,34 @@
+[See this exception on Errbit](<%= app_err_url err.app, err %> "See this exception on Errbit")
+<% if notice = err.notices.first %>
+ # <%= notice.message %> #
+ ## Summary ##
+ <% if notice.request['url'].present? %>
+ ### URL ###
+ [<%= notice.request['url'] %>](<%= notice.request['url'] %>)"
+ <% end %>
+ ### Where ###
+ <%= notice.err.where %>
+
+ ### Occured ###
+ <%= notice.created_at.to_s(:micro) %>
+
+ ### Similar ###
+ <%= (notice.err.notices_count - 1).to_s %>
+
+ ## Params ##
+ <%= pretty_hash(notice.params) %>
+
+ ## Session ##
+ <%= pretty_hash(notice.session) %>
+
+ ## Backtrace ##
+
+ <% for line in notice.backtrace %><%= line['number'] %>: <%= line['file'].sub(/^\[PROJECT_ROOT\]/, '') %> -> **<%= line['method'] %>**
+ <% end %>
+
+
+ ## Environment ##
+ <% for key, val in notice.env_vars %>
+ <%= key %>: <%= val %>
+ <% end %>
+<% end %>
diff --git a/app/views/errs/pivotal_body.txt.erb b/app/views/errs/pivotal_body.txt.erb
new file mode 100644
index 0000000000..7a5362d516
--- /dev/null
+++ b/app/views/errs/pivotal_body.txt.erb
@@ -0,0 +1,16 @@
+See this exception on Errbit: <%= app_err_url err.app, err %>
+<% if notice = err.notices.first %>
+ <% if notice.request['url'].present? %>URL: <%= notice.request['url'] %><% end %>
+ Where: <%= notice.err.where %>
+ Occurred: <%= notice.created_at.to_s :micro %>
+ Similar: <%= (notice.err.notices.count - 1).to_s %>
+
+ Params:
+ <%= pretty_hash notice.params %>
+
+ Session:
+ <%= pretty_hash notice.session %>
+
+ Backtrace:
+ <%= notice.backtrace[0..4].map { |line| "#{line['number']}: #{line['file'].sub(/^\[PROJECT_ROOT\]/, '')} -> *#{line['method']}*" }.join "\n" %>
+<% end %>
diff --git a/app/views/errs/redmine_body.txt.erb b/app/views/errs/redmine_body.txt.erb
new file mode 100644
index 0000000000..2a7e975ec4
--- /dev/null
+++ b/app/views/errs/redmine_body.txt.erb
@@ -0,0 +1,45 @@
+"See this exception on Errbit":<%= app_err_url err.app, err %>
+<% if notice = err.notices.first %>
+h1. <%= notice.message %>
+
+h2. Summary
+<% if notice.request['url'].present? %>
+h3. URL
+
+"<%= notice.request['url'] %>":<%= notice.request['url'] %>
+<% end %>
+h3. Where
+
+<%= notice.err.where %>
+
+h3. Occured
+
+<%= notice.created_at.to_s(:micro) %>
+
+h3. Similar
+
+<%= (notice.err.notices_count - 1).to_s %>
+
+h2. Params
+
+
<%= pretty_hash(notice.params) %>
+
+h2. Session
+
+<%= pretty_hash(notice.session) %>
+
+h2. Backtrace
+
+
+<% for line in notice.backtrace %><%= line['number'] %>: <%= line['file'].sub(/^\[PROJECT_ROOT\]/, '') %> -> *<%= line['method'] %>*
+<% end %>
+
+
+h2. Environment
+
+
+<% for key, val in notice.env_vars %>
+<%= key %>: <%= val %>
+<% end %>
+
+<% end %>
diff --git a/app/views/errs/show.html.haml b/app/views/errs/show.html.haml
index 99b47cc5f0..3f975797bc 100644
--- a/app/views/errs/show.html.haml
+++ b/app/views/errs/show.html.haml
@@ -1,17 +1,26 @@
- content_for :page_title, @err.message
- content_for :title, @err.klass
- content_for :meta do
+ %strong App:
+ = @app.name
%strong Where:
= @err.where
%strong Environment:
= @err.environment
%strong Last Notice:
- = @err.last_notice_at.to_s(:micro)
+ = last_notice_at(@err).to_s(:micro)
- content_for :action_bar do
- %span= link_to 'resolve', resolve_app_err_path(@app, @err), :method => :put, :confirm => 'Seriously?', :class => 'resolve' if @err.unresolved?
+ - if @err.app.issue_tracker
+ - if @err.issue_link.blank?
+ %span= link_to 'create issue', create_issue_app_err_path(@app, @err), :method => :post, :class => "#{@app.issue_tracker.issue_tracker_type}_create create-issue"
+ - else
+ %span= link_to 'go to issue', @err.issue_link, :class => "#{@app.issue_tracker.issue_tracker_type}_goto goto-issue"
+ = link_to 'clear issue', clear_issue_app_err_path(@app, @err), :method => :delete, :confirm => "Clear err issues?", :class => "clear-issue"
+ - if @err.unresolved?
+ %span= link_to 'resolve', resolve_app_err_path(@app, @err), :method => :put, :confirm => err_confirm, :class => 'resolve'
+
+%h4= @notice.try(:message)
-%h4= @notice.message
-
= will_paginate @notices, :param_name => :notice, :page_links => false, :class => 'notice-pagination'
viewing occurrence #{@notices.current_page} of #{@notices.total_pages}
@@ -23,22 +32,23 @@ viewing occurrence #{@notices.current_page} of #{@notices.total_pages}
%li= link_to 'Parameters', '#params', :rel => 'params', :class => 'button'
%li= link_to 'Session', '#session', :rel => 'session', :class => 'button'
-#summary
- %h3 Summary
- = render 'notices/summary', :notice => @notice
-
-#backtrace
- %h3 Backtrace
- = render 'notices/backtrace', :lines => @notice.backtrace
-
-#environment
- %h3 Environment
- = render 'notices/environment', :notice => @notice
-
-#params
- %h3 Parameters
- = render 'notices/params', :notice => @notice
-
-#session
- %h3 Session
- = render 'notices/session', :notice => @notice
\ No newline at end of file
+- if @notice
+ #summary
+ %h3 Summary
+ = render 'notices/summary', :notice => @notice
+
+ #backtrace
+ %h3 Backtrace
+ = render 'notices/backtrace', :lines => @notice.backtrace
+
+ #environment
+ %h3 Environment
+ = render 'notices/environment', :notice => @notice
+
+ #params
+ %h3 Parameters
+ = render 'notices/params', :notice => @notice
+
+ #session
+ %h3 Session
+ = render 'notices/session', :notice => @notice
diff --git a/app/views/mailer/err_notification.text.erb b/app/views/mailer/err_notification.text.erb
index 3d46554f67..dfd8a31597 100644
--- a/app/views/mailer/err_notification.text.erb
+++ b/app/views/mailer/err_notification.text.erb
@@ -1,7 +1,7 @@
An err has just occurred in <%= @notice.err.environment %>: <%= @notice.err.message %>
-This err has occurred <%= pluralize @notice.err.notices.count, 'time' %>. You should really look into it here:
+This err has occurred <%= pluralize @notice.err.notices_count, 'time' %>. You should really look into it here:
<%= app_err_url(@app, @notice.err) %>
-
-<%= render :partial => 'signature' %>
\ No newline at end of file
+
+<%= render :partial => 'signature' %>
diff --git a/app/views/notices/_atom_entry.html.haml b/app/views/notices/_atom_entry.html.haml
new file mode 100644
index 0000000000..b11e19859d
--- /dev/null
+++ b/app/views/notices/_atom_entry.html.haml
@@ -0,0 +1,41 @@
+%h2= notice.message
+%h3 Summary
+- if notice.request['url'].present?
+ %p
+ %strong URL:
+ = link_to(notice.request['url'], notice.request['url'])
+%p
+ %strong Where:
+ = notice.err.where
+%p
+ %strong Occured:
+ = notice.created_at.to_s(:micro)
+%p
+ %strong Similar:
+ = notice.err.notices_count - 1
+
+%h3 Params
+%p= pretty_hash(notice.params)
+
+%h3 Session
+%p= pretty_hash(notice.session)
+
+%h3 Backtrace
+%table
+ - for line in notice.backtrace
+ %tr
+ %td
+ = "#{line['number']}:"
+
+ %td
+ = raw "#{h line['file'].sub(/^\[PROJECT_ROOT\]/, '')} -> #{content_tag :strong, h(line['method'])}"
+
+%h3 Environment
+%table
+ - for key, val in notice.env_vars
+ %tr
+ %td
+ = h key
+ %td
+ = h val
+
diff --git a/app/views/notices/_environment.html.haml b/app/views/notices/_environment.html.haml
index ebf533ef8b..a68535f0e2 100644
--- a/app/views/notices/_environment.html.haml
+++ b/app/views/notices/_environment.html.haml
@@ -1,6 +1,6 @@
.window
%table.environment
- - notice.env_vars.each do |key,val|
+ - notice.env_vars.sort_by {|pair| pair[0]}.each do |pair|
%tr
- %th= key
- %td.main= val
\ No newline at end of file
+ %th= pair[0]
+ %td.main= pair[1]
diff --git a/app/views/notices/_summary.html.haml b/app/views/notices/_summary.html.haml
index 06889e6912..904b48650f 100644
--- a/app/views/notices/_summary.html.haml
+++ b/app/views/notices/_summary.html.haml
@@ -15,4 +15,7 @@
%td= notice.created_at.to_s(:micro)
%tr
%th Similar
- %td= notice.err.notices.count - 1
\ No newline at end of file
+ %td= notice.err.notices.count - 1
+ %tr
+ %th Browser
+ %td= user_agent_graph(notice.err)
diff --git a/app/views/users/_fields.html.haml b/app/views/users/_fields.html.haml
index f116059bf2..b6c6b47747 100644
--- a/app/views/users/_fields.html.haml
+++ b/app/views/users/_fields.html.haml
@@ -7,6 +7,10 @@
.required
= f.label :email
= f.text_field :email
+
+.required
+ = f.label 'Entries per page'
+ = f.select :per_page, [10, 20, 30, 50, 75, 100]
.required
= f.label :password
diff --git a/app/views/users/edit.html.haml b/app/views/users/edit.html.haml
index 93b75cbf54..c0eb807de9 100644
--- a/app/views/users/edit.html.haml
+++ b/app/views/users/edit.html.haml
@@ -1,7 +1,7 @@
- content_for :title, "Edit #{@user.name}"
- content_for :action_bar, link_to('cancel', user_path(@user), :class => 'button')
-= form_for @user do |f|
+= form_for @user, :html => {:autocomplete => "off"} do |f|
= @user.errors.full_messages.to_sentence
= render 'fields', :f => f
diff --git a/config/config.example.yml b/config/config.example.yml
index a2a4e46d46..c9b42cbc9b 100644
--- a/config/config.example.yml
+++ b/config/config.example.yml
@@ -17,4 +17,8 @@ email_from: errbit@example.com
# Configure when emails are sent for an error.
# [1,3,7] = 1st, 3rd, and 7th occurence triggers
# an email notification.
-email_at_notices: [1, 10, 100]
\ No newline at end of file
+email_at_notices: [1, 10, 100]
+
+# Set to false to suppress confirmation when
+# resolving errors.
+confirm_resolve_err: true
diff --git a/config/deploy.example.rb b/config/deploy.example.rb
index ae5e2b7289..5a3203e4e1 100644
--- a/config/deploy.example.rb
+++ b/config/deploy.example.rb
@@ -6,6 +6,8 @@
# `cap deploy` whenever you would like to deploy Errbit. Refer
# to the Readme for more information.
+require 'bundler/capistrano'
+
set :application, "errbit"
set :repository, "http://github.com/jdpace/errbit.git"
@@ -29,7 +31,7 @@
set(:current_branch) { `git branch`.match(/\* (\S+)\s/m)[1] || raise("Couldn't determine current branch") }
set :branch, defer { current_branch }
-after 'deploy:update_code', 'errbit:symlink_configs', 'bundler:install'
+after 'deploy:update_code', 'errbit:symlink_configs'
namespace :deploy do
task :start do ; end
@@ -39,19 +41,6 @@
end
end
-namespace :bundler do
- task :symlink_vendor, :roles => :app, :except => { :no_release => true } do
- shared_gems = File.join(shared_path,'vendor','bundler_gems')
- release_gems = "#{latest_release}/vendor/"
- run("mkdir -p #{shared_gems} && ln -nfs #{shared_gems} #{release_gems}")
- end
-
- task :install, :rolse => :app do
- bundler.symlink_vendor
- run("cd #{release_path} && bundle install vendor/bundler_gems --without development test")
- end
-end
-
namespace :errbit do
task :setup_configs do
shared_configs = File.join(shared_path,'config')
diff --git a/config/environments/development.rb b/config/environments/development.rb
index 666269148c..4a01584d4b 100644
--- a/config/environments/development.rb
+++ b/config/environments/development.rb
@@ -16,6 +16,7 @@
# Don't care if the mailer can't send
config.action_mailer.raise_delivery_errors = false
+ config.action_mailer.default_url_options = { :host => 'localhost:3000' }
# Print deprecation notices to the Rails logger
config.active_support.deprecation = :log
diff --git a/config/environments/production.rb b/config/environments/production.rb
index 6c1ea4ffb5..6a540aff6d 100644
--- a/config/environments/production.rb
+++ b/config/environments/production.rb
@@ -46,4 +46,5 @@
# Send deprecation notices to registered listeners
config.active_support.deprecation = :notify
+ config.action_mailer.default_url_options = { :host => 'errbit.welaika.com' }
end
diff --git a/config/environments/test.rb b/config/environments/test.rb
index 9dfc650c05..1922d219a8 100644
--- a/config/environments/test.rb
+++ b/config/environments/test.rb
@@ -24,6 +24,7 @@
# The :test delivery method accumulates sent emails in the
# ActionMailer::Base.deliveries array.
config.action_mailer.delivery_method = :test
+ config.action_mailer.default_url_options = { :host => 'test.host' }
# 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,
diff --git a/config/initializers/_load_config.rb b/config/initializers/_load_config.rb
index e52b66113b..3806c23220 100644
--- a/config/initializers/_load_config.rb
+++ b/config/initializers/_load_config.rb
@@ -15,4 +15,6 @@
end
# Set config specific values
-ActionMailer::Base.default_url_options[:host] = Errbit::Config.host
\ No newline at end of file
+(Errbit::Application.config.action_mailer.default_url_options ||= {}).tap do |default|
+ default.merge! :host => Errbit::Config.host if default[:host].blank?
+end
\ No newline at end of file
diff --git a/config/initializers/xml_backend.rb b/config/initializers/xml_backend.rb
index fe1e9883da..3bc16acbdd 100644
--- a/config/initializers/xml_backend.rb
+++ b/config/initializers/xml_backend.rb
@@ -1 +1 @@
-ActiveSupport::XmlMini.backend = 'LibXML'
\ No newline at end of file
+ActiveSupport::XmlMini.backend = 'Nokogiri'
\ No newline at end of file
diff --git a/config/routes.rb b/config/routes.rb
index 9f4cd9aacd..6d9ad1e813 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -1,11 +1,11 @@
Errbit::Application.routes.draw do
-
+
devise_for :users
# Hoptoad Notifier Routes
match '/notifier_api/v2/notices' => 'notices#create'
- match '/deploys.txt' => 'deploys#create'
-
+ match '/deploys.txt' => 'deploys#create', :via => [:post]
+
resources :notices, :only => [:show]
resources :deploys, :only => [:show]
resources :users
@@ -14,18 +14,22 @@
get :all
end
end
-
+
resources :apps do
resources :errs do
resources :notices
member do
put :resolve
+ post :create_issue
+ delete :clear_issue
end
end
+
+ resources :deploys, :only => [:index]
end
-
+
devise_for :users
-
+
root :to => 'apps#index'
-
+
end
diff --git a/db/migrate/20110422152027_move_notices_to_separate_collection.rb b/db/migrate/20110422152027_move_notices_to_separate_collection.rb
new file mode 100644
index 0000000000..32e914c985
--- /dev/null
+++ b/db/migrate/20110422152027_move_notices_to_separate_collection.rb
@@ -0,0 +1,26 @@
+class MoveNoticesToSeparateCollection < Mongoid::Migration
+ def self.up
+ # copy embedded Notices into a separate collection
+ mongo_db = Err.db
+ errs = mongo_db.collection("errs").find({ }, :fields => ["notices"])
+ errs.each do |err|
+ next unless err['notices']
+ e = Err.find(err['_id'])
+ # disable email notifications
+ old_notify = e.app.notify_on_errs?
+ e.app.update_attribute(:notify_on_errs, false)
+ puts "Copying notices for Err #{err['_id']}"
+ err['notices'].each do |notice|
+ e.notices.create!(notice)
+ end
+ e.app.update_attribute(:notify_on_errs, old_notify)
+ mongo_db.collection("errs").update({ "_id" => err['_id']}, { "$unset" => { "notices" => 1}})
+ end
+ Rake::Task["errbit:db:update_notices_count"].invoke
+ Rake::Task["errbit:db:update_err_message"].invoke
+ end
+
+ def self.down
+ end
+
+end
diff --git a/db/seeds.rb b/db/seeds.rb
index 880432a26a..87fca02850 100644
--- a/db/seeds.rb
+++ b/db/seeds.rb
@@ -10,13 +10,12 @@
puts "-- password: #{admin_pass}"
puts ""
puts "Be sure to change these credentials ASAP!"
-u = User.create!({
+user = User.where(:email => admin_email).first || User.new({
:name => 'Errbit Admin',
:email => admin_email,
:password => admin_pass,
:password_confirmation => admin_pass
})
-#Admin is protected
-u.admin=true
-u.save
\ No newline at end of file
+user.admin = true
+user.save!
diff --git a/lib/hoptoad.rb b/lib/hoptoad.rb
index ee6d799022..1db916c905 100644
--- a/lib/hoptoad.rb
+++ b/lib/hoptoad.rb
@@ -1,23 +1,23 @@
module Hoptoad
module V2
require 'digest/md5'
-
+
class ApiVersionError < StandardError
def initialize
- super "Wrong API Version: Expecting v2.0"
+ super "Wrong API Version: Expecting v2.0 or v2.1"
end
end
-
+
def self.parse_xml(xml)
parsed = ActiveSupport::XmlMini.backend.parse(xml)['notice']
- raise ApiVersionError unless parsed && parsed['version'] == '2.0'
+ raise ApiVersionError unless parsed && (parsed['version'] == '2.0' || parsed['version'] == '2.1')
rekeyed = rekey(parsed)
rekeyed['fingerprint'] = Digest::MD5.hexdigest(rekeyed['error']['backtrace'].to_s)
rekeyed
end
-
+
private
-
+
def self.rekey(node)
if node.is_a?(Hash) && node.has_key?('var') && node.has_key?('key')
{node['key'] => rekey(node['var'])}
@@ -42,4 +42,4 @@ def self.rekey(node)
end
end
end
-end
\ No newline at end of file
+end
diff --git a/lib/recurse.rb b/lib/recurse.rb
new file mode 100644
index 0000000000..7f5a4ee9a4
--- /dev/null
+++ b/lib/recurse.rb
@@ -0,0 +1,24 @@
+class Hash
+
+ # Apply a block to hash, and recursively apply that block
+ # to each sub-hash or +types+.
+ #
+ # h = {:a=>1, :b=>{:b1=>1, :b2=>2}}
+ # g = h.recurse{|h| h.inject({}){|h,(k,v)| h[k.to_s] = v; h} }
+ # g #=> {"a"=>1, "b"=>{"b1"=>1, "b2"=>2}}
+ #
+ def recurse(*types, &block)
+ types = [self.class] if types.empty?
+ h = inject({}) do |hash, (key, value)|
+ case value
+ when *types
+ hash[key] = value.recurse(*types, &block)
+ else
+ hash[key] = value
+ end
+ hash
+ end
+ yield h
+ end
+
+end
diff --git a/lib/tasks/errbit/bootstrap.rake b/lib/tasks/errbit/bootstrap.rake
index 714c09872b..5c9470b02b 100644
--- a/lib/tasks/errbit/bootstrap.rake
+++ b/lib/tasks/errbit/bootstrap.rake
@@ -26,6 +26,8 @@ namespace :errbit do
Rake::Task['errbit:copy_configs'].execute
puts "\n"
Rake::Task['db:seed'].invoke
+ puts "\n"
+ Rake::Task['db:mongoid:create_indexes'].invoke
end
end
\ No newline at end of file
diff --git a/lib/tasks/errbit/err_message.rake b/lib/tasks/errbit/err_message.rake
new file mode 100644
index 0000000000..6f9e8c17f7
--- /dev/null
+++ b/lib/tasks/errbit/err_message.rake
@@ -0,0 +1,12 @@
+namespace :errbit do
+
+ namespace :db do
+ desc "Updates Err#notices_count"
+ task :update_err_message => :environment do
+ puts "Updating err.message"
+ Err.all.each do |e|
+ e.update_attributes(:message => e.notices.first.message) if e.notices.first
+ end
+ end
+ end
+end
diff --git a/lib/tasks/errbit/notices_counter.rake b/lib/tasks/errbit/notices_counter.rake
new file mode 100644
index 0000000000..617ea447d3
--- /dev/null
+++ b/lib/tasks/errbit/notices_counter.rake
@@ -0,0 +1,12 @@
+namespace :errbit do
+
+ namespace :db do
+ desc "Updates Err#notices_count"
+ task :update_notices_count => :environment do
+ puts "Updating err.notices_count"
+ Err.all.each do |e|
+ e.update_attributes(:notices_count => e.notices.count)
+ end
+ end
+ end
+end
diff --git a/public/images/lighthouseapp_create.png b/public/images/lighthouseapp_create.png
new file mode 100644
index 0000000000..a28b9a0c33
Binary files /dev/null and b/public/images/lighthouseapp_create.png differ
diff --git a/public/images/lighthousehouseapp_goto.png b/public/images/lighthousehouseapp_goto.png
new file mode 100644
index 0000000000..d7e468b94b
Binary files /dev/null and b/public/images/lighthousehouseapp_goto.png differ
diff --git a/public/images/pivotal_create.png b/public/images/pivotal_create.png
new file mode 100644
index 0000000000..83e4f49ba5
Binary files /dev/null and b/public/images/pivotal_create.png differ
diff --git a/public/images/pivotal_goto.png b/public/images/pivotal_goto.png
new file mode 100644
index 0000000000..b338690aae
Binary files /dev/null and b/public/images/pivotal_goto.png differ
diff --git a/public/images/redmine_create.png b/public/images/redmine_create.png
new file mode 100644
index 0000000000..a7f8c63a68
Binary files /dev/null and b/public/images/redmine_create.png differ
diff --git a/public/images/redmine_goto.png b/public/images/redmine_goto.png
new file mode 100644
index 0000000000..39bd0ae2c5
Binary files /dev/null and b/public/images/redmine_goto.png differ
diff --git a/public/images/thumbs-up.png b/public/images/thumbs-up.png
new file mode 100644
index 0000000000..03dad8404c
Binary files /dev/null and b/public/images/thumbs-up.png differ
diff --git a/public/javascripts/form.js b/public/javascripts/form.js
index a7b6aeb89e..b0f6c64dea 100644
--- a/public/javascripts/form.js
+++ b/public/javascripts/form.js
@@ -1,16 +1,19 @@
$(function(){
activateNestedForms();
-
+
if($('div.watcher.nested').length)
activateWatcherTypeSelector();
+
+ if($('div.issue_tracker.nested').length)
+ activateIssueTrackerTypeSelector();
});
function activateNestedForms() {
$('.nested-wrapper').each(function(){
var wrapper = $(this);
-
+
makeNestedItemsDestroyable(wrapper);
-
+
var addLink = $('').text('add another').addClass('add-nested');
addLink.click(appendNestedItem);
wrapper.append(addLink);
@@ -32,7 +35,7 @@ function appendNestedItem() {
var nestedItem = addLink.parent().find('.nested').first().clone().show();
var timestamp = new Date();
timestamp = timestamp.valueOf();
-
+
nestedItem.find('input, select').each(function(){
var input = $(this);
input.attr('id', input.attr('id').replace(/([_\[])\d+([\]_])/,'$1'+timestamp+'$2'));
@@ -67,4 +70,13 @@ function activateWatcherTypeSelector() {
wrapper.find('div.choosen').removeClass('choosen');
wrapper.find('div.'+choosen).addClass('choosen');
});
+}
+
+function activateIssueTrackerTypeSelector() {
+ $('div.issue_tracker input[name*=issue_tracker_type]').live('click', function(){
+ var chosen = $(this).val();
+ var wrapper = $(this).closest('.nested');
+ wrapper.find('div.chosen').removeClass('chosen');
+ wrapper.find('div.'+chosen).addClass('chosen');
+ });
}
\ No newline at end of file
diff --git a/public/javascripts/jquery.js b/public/javascripts/jquery.js
index 48a88b8f48..6437874c69 100644
--- a/public/javascripts/jquery.js
+++ b/public/javascripts/jquery.js
@@ -1,154 +1,16 @@
/*!
- * jQuery JavaScript Library v1.4.2
+ * jQuery JavaScript Library v1.5.1
* http://jquery.com/
*
- * Copyright 2010, John Resig
+ * Copyright 2011, John Resig
* Dual licensed under the MIT or GPL Version 2 licenses.
* http://jquery.org/license
*
* Includes Sizzle.js
* http://sizzlejs.com/
- * Copyright 2010, The Dojo Foundation
+ * Copyright 2011, The Dojo Foundation
* Released under the MIT, BSD, and GPL Licenses.
*
- * Date: Sat Feb 13 22:33:48 2010 -0500
+ * Date: Wed Feb 23 13:55:29 2011 -0500
*/
-(function(A,w){function ma(){if(!c.isReady){try{s.documentElement.doScroll("left")}catch(a){setTimeout(ma,1);return}c.ready()}}function Qa(a,b){b.src?c.ajax({url:b.src,async:false,dataType:"script"}):c.globalEval(b.text||b.textContent||b.innerHTML||"");b.parentNode&&b.parentNode.removeChild(b)}function X(a,b,d,f,e,j){var i=a.length;if(typeof b==="object"){for(var o in b)X(a,o,b[o],f,e,d);return a}if(d!==w){f=!j&&f&&c.isFunction(d);for(o=0;o)[^>]*$|^#([\w-]+)$/,Ua=/^.[^:#\[\.,]*$/,Va=/\S/,
-Wa=/^(\s|\u00A0)+|(\s|\u00A0)+$/g,Xa=/^<(\w+)\s*\/?>(?:<\/\1>)?$/,P=navigator.userAgent,xa=false,Q=[],L,$=Object.prototype.toString,aa=Object.prototype.hasOwnProperty,ba=Array.prototype.push,R=Array.prototype.slice,ya=Array.prototype.indexOf;c.fn=c.prototype={init:function(a,b){var d,f;if(!a)return this;if(a.nodeType){this.context=this[0]=a;this.length=1;return this}if(a==="body"&&!b){this.context=s;this[0]=s.body;this.selector="body";this.length=1;return this}if(typeof a==="string")if((d=Ta.exec(a))&&
-(d[1]||!b))if(d[1]){f=b?b.ownerDocument||b:s;if(a=Xa.exec(a))if(c.isPlainObject(b)){a=[s.createElement(a[1])];c.fn.attr.call(a,b,true)}else a=[f.createElement(a[1])];else{a=sa([d[1]],[f]);a=(a.cacheable?a.fragment.cloneNode(true):a.fragment).childNodes}return c.merge(this,a)}else{if(b=s.getElementById(d[2])){if(b.id!==d[2])return T.find(a);this.length=1;this[0]=b}this.context=s;this.selector=a;return this}else if(!b&&/^\w+$/.test(a)){this.selector=a;this.context=s;a=s.getElementsByTagName(a);return c.merge(this,
-a)}else return!b||b.jquery?(b||T).find(a):c(b).find(a);else if(c.isFunction(a))return T.ready(a);if(a.selector!==w){this.selector=a.selector;this.context=a.context}return c.makeArray(a,this)},selector:"",jquery:"1.4.2",length:0,size:function(){return this.length},toArray:function(){return R.call(this,0)},get:function(a){return a==null?this.toArray():a<0?this.slice(a)[0]:this[a]},pushStack:function(a,b,d){var f=c();c.isArray(a)?ba.apply(f,a):c.merge(f,a);f.prevObject=this;f.context=this.context;if(b===
-"find")f.selector=this.selector+(this.selector?" ":"")+d;else if(b)f.selector=this.selector+"."+b+"("+d+")";return f},each:function(a,b){return c.each(this,a,b)},ready:function(a){c.bindReady();if(c.isReady)a.call(s,c);else Q&&Q.push(a);return this},eq:function(a){return a===-1?this.slice(a):this.slice(a,+a+1)},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},slice:function(){return this.pushStack(R.apply(this,arguments),"slice",R.call(arguments).join(","))},map:function(a){return this.pushStack(c.map(this,
-function(b,d){return a.call(b,d,b)}))},end:function(){return this.prevObject||c(null)},push:ba,sort:[].sort,splice:[].splice};c.fn.init.prototype=c.fn;c.extend=c.fn.extend=function(){var a=arguments[0]||{},b=1,d=arguments.length,f=false,e,j,i,o;if(typeof a==="boolean"){f=a;a=arguments[1]||{};b=2}if(typeof a!=="object"&&!c.isFunction(a))a={};if(d===b){a=this;--b}for(;ba";
-var e=d.getElementsByTagName("*"),j=d.getElementsByTagName("a")[0];if(!(!e||!e.length||!j)){c.support={leadingWhitespace:d.firstChild.nodeType===3,tbody:!d.getElementsByTagName("tbody").length,htmlSerialize:!!d.getElementsByTagName("link").length,style:/red/.test(j.getAttribute("style")),hrefNormalized:j.getAttribute("href")==="/a",opacity:/^0.55$/.test(j.style.opacity),cssFloat:!!j.style.cssFloat,checkOn:d.getElementsByTagName("input")[0].value==="on",optSelected:s.createElement("select").appendChild(s.createElement("option")).selected,
-parentNode:d.removeChild(d.appendChild(s.createElement("div"))).parentNode===null,deleteExpando:true,checkClone:false,scriptEval:false,noCloneEvent:true,boxModel:null};b.type="text/javascript";try{b.appendChild(s.createTextNode("window."+f+"=1;"))}catch(i){}a.insertBefore(b,a.firstChild);if(A[f]){c.support.scriptEval=true;delete A[f]}try{delete b.test}catch(o){c.support.deleteExpando=false}a.removeChild(b);if(d.attachEvent&&d.fireEvent){d.attachEvent("onclick",function k(){c.support.noCloneEvent=
-false;d.detachEvent("onclick",k)});d.cloneNode(true).fireEvent("onclick")}d=s.createElement("div");d.innerHTML="";a=s.createDocumentFragment();a.appendChild(d.firstChild);c.support.checkClone=a.cloneNode(true).cloneNode(true).lastChild.checked;c(function(){var k=s.createElement("div");k.style.width=k.style.paddingLeft="1px";s.body.appendChild(k);c.boxModel=c.support.boxModel=k.offsetWidth===2;s.body.removeChild(k).style.display="none"});a=function(k){var n=
-s.createElement("div");k="on"+k;var r=k in n;if(!r){n.setAttribute(k,"return;");r=typeof n[k]==="function"}return r};c.support.submitBubbles=a("submit");c.support.changeBubbles=a("change");a=b=d=e=j=null}})();c.props={"for":"htmlFor","class":"className",readonly:"readOnly",maxlength:"maxLength",cellspacing:"cellSpacing",rowspan:"rowSpan",colspan:"colSpan",tabindex:"tabIndex",usemap:"useMap",frameborder:"frameBorder"};var G="jQuery"+J(),Ya=0,za={};c.extend({cache:{},expando:G,noData:{embed:true,object:true,
-applet:true},data:function(a,b,d){if(!(a.nodeName&&c.noData[a.nodeName.toLowerCase()])){a=a==A?za:a;var f=a[G],e=c.cache;if(!f&&typeof b==="string"&&d===w)return null;f||(f=++Ya);if(typeof b==="object"){a[G]=f;e[f]=c.extend(true,{},b)}else if(!e[f]){a[G]=f;e[f]={}}a=e[f];if(d!==w)a[b]=d;return typeof b==="string"?a[b]:a}},removeData:function(a,b){if(!(a.nodeName&&c.noData[a.nodeName.toLowerCase()])){a=a==A?za:a;var d=a[G],f=c.cache,e=f[d];if(b){if(e){delete e[b];c.isEmptyObject(e)&&c.removeData(a)}}else{if(c.support.deleteExpando)delete a[c.expando];
-else a.removeAttribute&&a.removeAttribute(c.expando);delete f[d]}}}});c.fn.extend({data:function(a,b){if(typeof a==="undefined"&&this.length)return c.data(this[0]);else if(typeof a==="object")return this.each(function(){c.data(this,a)});var d=a.split(".");d[1]=d[1]?"."+d[1]:"";if(b===w){var f=this.triggerHandler("getData"+d[1]+"!",[d[0]]);if(f===w&&this.length)f=c.data(this[0],a);return f===w&&d[1]?this.data(d[0]):f}else return this.trigger("setData"+d[1]+"!",[d[0],b]).each(function(){c.data(this,
-a,b)})},removeData:function(a){return this.each(function(){c.removeData(this,a)})}});c.extend({queue:function(a,b,d){if(a){b=(b||"fx")+"queue";var f=c.data(a,b);if(!d)return f||[];if(!f||c.isArray(d))f=c.data(a,b,c.makeArray(d));else f.push(d);return f}},dequeue:function(a,b){b=b||"fx";var d=c.queue(a,b),f=d.shift();if(f==="inprogress")f=d.shift();if(f){b==="fx"&&d.unshift("inprogress");f.call(a,function(){c.dequeue(a,b)})}}});c.fn.extend({queue:function(a,b){if(typeof a!=="string"){b=a;a="fx"}if(b===
-w)return c.queue(this[0],a);return this.each(function(){var d=c.queue(this,a,b);a==="fx"&&d[0]!=="inprogress"&&c.dequeue(this,a)})},dequeue:function(a){return this.each(function(){c.dequeue(this,a)})},delay:function(a,b){a=c.fx?c.fx.speeds[a]||a:a;b=b||"fx";return this.queue(b,function(){var d=this;setTimeout(function(){c.dequeue(d,b)},a)})},clearQueue:function(a){return this.queue(a||"fx",[])}});var Aa=/[\n\t]/g,ca=/\s+/,Za=/\r/g,$a=/href|src|style/,ab=/(button|input)/i,bb=/(button|input|object|select|textarea)/i,
-cb=/^(a|area)$/i,Ba=/radio|checkbox/;c.fn.extend({attr:function(a,b){return X(this,a,b,true,c.attr)},removeAttr:function(a){return this.each(function(){c.attr(this,a,"");this.nodeType===1&&this.removeAttribute(a)})},addClass:function(a){if(c.isFunction(a))return this.each(function(n){var r=c(this);r.addClass(a.call(this,n,r.attr("class")))});if(a&&typeof a==="string")for(var b=(a||"").split(ca),d=0,f=this.length;d-1)return true;return false},val:function(a){if(a===w){var b=this[0];if(b){if(c.nodeName(b,"option"))return(b.attributes.value||{}).specified?b.value:b.text;if(c.nodeName(b,"select")){var d=b.selectedIndex,f=[],e=b.options;b=b.type==="select-one";if(d<0)return null;var j=b?d:0;for(d=b?d+1:e.length;j=0;else if(c.nodeName(this,"select")){var u=c.makeArray(r);c("option",this).each(function(){this.selected=
-c.inArray(c(this).val(),u)>=0});if(!u.length)this.selectedIndex=-1}else this.value=r}})}});c.extend({attrFn:{val:true,css:true,html:true,text:true,data:true,width:true,height:true,offset:true},attr:function(a,b,d,f){if(!a||a.nodeType===3||a.nodeType===8)return w;if(f&&b in c.attrFn)return c(a)[b](d);f=a.nodeType!==1||!c.isXMLDoc(a);var e=d!==w;b=f&&c.props[b]||b;if(a.nodeType===1){var j=$a.test(b);if(b in a&&f&&!j){if(e){b==="type"&&ab.test(a.nodeName)&&a.parentNode&&c.error("type property can't be changed");
-a[b]=d}if(c.nodeName(a,"form")&&a.getAttributeNode(b))return a.getAttributeNode(b).nodeValue;if(b==="tabIndex")return(b=a.getAttributeNode("tabIndex"))&&b.specified?b.value:bb.test(a.nodeName)||cb.test(a.nodeName)&&a.href?0:w;return a[b]}if(!c.support.style&&f&&b==="style"){if(e)a.style.cssText=""+d;return a.style.cssText}e&&a.setAttribute(b,""+d);a=!c.support.hrefNormalized&&f&&j?a.getAttribute(b,2):a.getAttribute(b);return a===null?w:a}return c.style(a,b,d)}});var O=/\.(.*)$/,db=function(a){return a.replace(/[^\w\s\.\|`]/g,
-function(b){return"\\"+b})};c.event={add:function(a,b,d,f){if(!(a.nodeType===3||a.nodeType===8)){if(a.setInterval&&a!==A&&!a.frameElement)a=A;var e,j;if(d.handler){e=d;d=e.handler}if(!d.guid)d.guid=c.guid++;if(j=c.data(a)){var i=j.events=j.events||{},o=j.handle;if(!o)j.handle=o=function(){return typeof c!=="undefined"&&!c.event.triggered?c.event.handle.apply(o.elem,arguments):w};o.elem=a;b=b.split(" ");for(var k,n=0,r;k=b[n++];){j=e?c.extend({},e):{handler:d,data:f};if(k.indexOf(".")>-1){r=k.split(".");
-k=r.shift();j.namespace=r.slice(0).sort().join(".")}else{r=[];j.namespace=""}j.type=k;j.guid=d.guid;var u=i[k],z=c.event.special[k]||{};if(!u){u=i[k]=[];if(!z.setup||z.setup.call(a,f,r,o)===false)if(a.addEventListener)a.addEventListener(k,o,false);else a.attachEvent&&a.attachEvent("on"+k,o)}if(z.add){z.add.call(a,j);if(!j.handler.guid)j.handler.guid=d.guid}u.push(j);c.event.global[k]=true}a=null}}},global:{},remove:function(a,b,d,f){if(!(a.nodeType===3||a.nodeType===8)){var e,j=0,i,o,k,n,r,u,z=c.data(a),
-C=z&&z.events;if(z&&C){if(b&&b.type){d=b.handler;b=b.type}if(!b||typeof b==="string"&&b.charAt(0)==="."){b=b||"";for(e in C)c.event.remove(a,e+b)}else{for(b=b.split(" ");e=b[j++];){n=e;i=e.indexOf(".")<0;o=[];if(!i){o=e.split(".");e=o.shift();k=new RegExp("(^|\\.)"+c.map(o.slice(0).sort(),db).join("\\.(?:.*\\.)?")+"(\\.|$)")}if(r=C[e])if(d){n=c.event.special[e]||{};for(B=f||0;B=0){a.type=
-e=e.slice(0,-1);a.exclusive=true}if(!d){a.stopPropagation();c.event.global[e]&&c.each(c.cache,function(){this.events&&this.events[e]&&c.event.trigger(a,b,this.handle.elem)})}if(!d||d.nodeType===3||d.nodeType===8)return w;a.result=w;a.target=d;b=c.makeArray(b);b.unshift(a)}a.currentTarget=d;(f=c.data(d,"handle"))&&f.apply(d,b);f=d.parentNode||d.ownerDocument;try{if(!(d&&d.nodeName&&c.noData[d.nodeName.toLowerCase()]))if(d["on"+e]&&d["on"+e].apply(d,b)===false)a.result=false}catch(j){}if(!a.isPropagationStopped()&&
-f)c.event.trigger(a,b,f,true);else if(!a.isDefaultPrevented()){f=a.target;var i,o=c.nodeName(f,"a")&&e==="click",k=c.event.special[e]||{};if((!k._default||k._default.call(d,a)===false)&&!o&&!(f&&f.nodeName&&c.noData[f.nodeName.toLowerCase()])){try{if(f[e]){if(i=f["on"+e])f["on"+e]=null;c.event.triggered=true;f[e]()}}catch(n){}if(i)f["on"+e]=i;c.event.triggered=false}}},handle:function(a){var b,d,f,e;a=arguments[0]=c.event.fix(a||A.event);a.currentTarget=this;b=a.type.indexOf(".")<0&&!a.exclusive;
-if(!b){d=a.type.split(".");a.type=d.shift();f=new RegExp("(^|\\.)"+d.slice(0).sort().join("\\.(?:.*\\.)?")+"(\\.|$)")}e=c.data(this,"events");d=e[a.type];if(e&&d){d=d.slice(0);e=0;for(var j=d.length;e-1?c.map(a.options,function(f){return f.selected}).join("-"):"";else if(a.nodeName.toLowerCase()==="select")d=a.selectedIndex;return d},fa=function(a,b){var d=a.target,f,e;if(!(!da.test(d.nodeName)||d.readOnly)){f=c.data(d,"_change_data");e=Fa(d);if(a.type!=="focusout"||d.type!=="radio")c.data(d,"_change_data",
-e);if(!(f===w||e===f))if(f!=null||e){a.type="change";return c.event.trigger(a,b,d)}}};c.event.special.change={filters:{focusout:fa,click:function(a){var b=a.target,d=b.type;if(d==="radio"||d==="checkbox"||b.nodeName.toLowerCase()==="select")return fa.call(this,a)},keydown:function(a){var b=a.target,d=b.type;if(a.keyCode===13&&b.nodeName.toLowerCase()!=="textarea"||a.keyCode===32&&(d==="checkbox"||d==="radio")||d==="select-multiple")return fa.call(this,a)},beforeactivate:function(a){a=a.target;c.data(a,
-"_change_data",Fa(a))}},setup:function(){if(this.type==="file")return false;for(var a in ea)c.event.add(this,a+".specialChange",ea[a]);return da.test(this.nodeName)},teardown:function(){c.event.remove(this,".specialChange");return da.test(this.nodeName)}};ea=c.event.special.change.filters}s.addEventListener&&c.each({focus:"focusin",blur:"focusout"},function(a,b){function d(f){f=c.event.fix(f);f.type=b;return c.event.handle.call(this,f)}c.event.special[b]={setup:function(){this.addEventListener(a,
-d,true)},teardown:function(){this.removeEventListener(a,d,true)}}});c.each(["bind","one"],function(a,b){c.fn[b]=function(d,f,e){if(typeof d==="object"){for(var j in d)this[b](j,f,d[j],e);return this}if(c.isFunction(f)){e=f;f=w}var i=b==="one"?c.proxy(e,function(k){c(this).unbind(k,i);return e.apply(this,arguments)}):e;if(d==="unload"&&b!=="one")this.one(d,f,e);else{j=0;for(var o=this.length;j0){y=t;break}}t=t[g]}m[q]=y}}}var f=/((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^[\]]*\]|['"][^'"]*['"]|[^[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g,
-e=0,j=Object.prototype.toString,i=false,o=true;[0,0].sort(function(){o=false;return 0});var k=function(g,h,l,m){l=l||[];var q=h=h||s;if(h.nodeType!==1&&h.nodeType!==9)return[];if(!g||typeof g!=="string")return l;for(var p=[],v,t,y,S,H=true,M=x(h),I=g;(f.exec(""),v=f.exec(I))!==null;){I=v[3];p.push(v[1]);if(v[2]){S=v[3];break}}if(p.length>1&&r.exec(g))if(p.length===2&&n.relative[p[0]])t=ga(p[0]+p[1],h);else for(t=n.relative[p[0]]?[h]:k(p.shift(),h);p.length;){g=p.shift();if(n.relative[g])g+=p.shift();
-t=ga(g,t)}else{if(!m&&p.length>1&&h.nodeType===9&&!M&&n.match.ID.test(p[0])&&!n.match.ID.test(p[p.length-1])){v=k.find(p.shift(),h,M);h=v.expr?k.filter(v.expr,v.set)[0]:v.set[0]}if(h){v=m?{expr:p.pop(),set:z(m)}:k.find(p.pop(),p.length===1&&(p[0]==="~"||p[0]==="+")&&h.parentNode?h.parentNode:h,M);t=v.expr?k.filter(v.expr,v.set):v.set;if(p.length>0)y=z(t);else H=false;for(;p.length;){var D=p.pop();v=D;if(n.relative[D])v=p.pop();else D="";if(v==null)v=h;n.relative[D](y,v,M)}}else y=[]}y||(y=t);y||k.error(D||
-g);if(j.call(y)==="[object Array]")if(H)if(h&&h.nodeType===1)for(g=0;y[g]!=null;g++){if(y[g]&&(y[g]===true||y[g].nodeType===1&&E(h,y[g])))l.push(t[g])}else for(g=0;y[g]!=null;g++)y[g]&&y[g].nodeType===1&&l.push(t[g]);else l.push.apply(l,y);else z(y,l);if(S){k(S,q,l,m);k.uniqueSort(l)}return l};k.uniqueSort=function(g){if(B){i=o;g.sort(B);if(i)for(var h=1;h":function(g,h){var l=typeof h==="string";if(l&&!/\W/.test(h)){h=h.toLowerCase();for(var m=0,q=g.length;m=0))l||m.push(v);else if(l)h[p]=false;return false},ID:function(g){return g[1].replace(/\\/g,"")},TAG:function(g){return g[1].toLowerCase()},
-CHILD:function(g){if(g[1]==="nth"){var h=/(-?)(\d*)n((?:\+|-)?\d*)/.exec(g[2]==="even"&&"2n"||g[2]==="odd"&&"2n+1"||!/\D/.test(g[2])&&"0n+"+g[2]||g[2]);g[2]=h[1]+(h[2]||1)-0;g[3]=h[3]-0}g[0]=e++;return g},ATTR:function(g,h,l,m,q,p){h=g[1].replace(/\\/g,"");if(!p&&n.attrMap[h])g[1]=n.attrMap[h];if(g[2]==="~=")g[4]=" "+g[4]+" ";return g},PSEUDO:function(g,h,l,m,q){if(g[1]==="not")if((f.exec(g[3])||"").length>1||/^\w/.test(g[3]))g[3]=k(g[3],null,null,h);else{g=k.filter(g[3],h,l,true^q);l||m.push.apply(m,
-g);return false}else if(n.match.POS.test(g[0])||n.match.CHILD.test(g[0]))return true;return g},POS:function(g){g.unshift(true);return g}},filters:{enabled:function(g){return g.disabled===false&&g.type!=="hidden"},disabled:function(g){return g.disabled===true},checked:function(g){return g.checked===true},selected:function(g){return g.selected===true},parent:function(g){return!!g.firstChild},empty:function(g){return!g.firstChild},has:function(g,h,l){return!!k(l[3],g).length},header:function(g){return/h\d/i.test(g.nodeName)},
-text:function(g){return"text"===g.type},radio:function(g){return"radio"===g.type},checkbox:function(g){return"checkbox"===g.type},file:function(g){return"file"===g.type},password:function(g){return"password"===g.type},submit:function(g){return"submit"===g.type},image:function(g){return"image"===g.type},reset:function(g){return"reset"===g.type},button:function(g){return"button"===g.type||g.nodeName.toLowerCase()==="button"},input:function(g){return/input|select|textarea|button/i.test(g.nodeName)}},
-setFilters:{first:function(g,h){return h===0},last:function(g,h,l,m){return h===m.length-1},even:function(g,h){return h%2===0},odd:function(g,h){return h%2===1},lt:function(g,h,l){return hl[3]-0},nth:function(g,h,l){return l[3]-0===h},eq:function(g,h,l){return l[3]-0===h}},filter:{PSEUDO:function(g,h,l,m){var q=h[1],p=n.filters[q];if(p)return p(g,l,h,m);else if(q==="contains")return(g.textContent||g.innerText||a([g])||"").indexOf(h[3])>=0;else if(q==="not"){h=
-h[3];l=0;for(m=h.length;l=0}},ID:function(g,h){return g.nodeType===1&&g.getAttribute("id")===h},TAG:function(g,h){return h==="*"&&g.nodeType===1||g.nodeName.toLowerCase()===h},CLASS:function(g,h){return(" "+(g.className||g.getAttribute("class"))+" ").indexOf(h)>-1},ATTR:function(g,h){var l=h[1];g=n.attrHandle[l]?n.attrHandle[l](g):g[l]!=null?g[l]:g.getAttribute(l);l=g+"";var m=h[2];h=h[4];return g==null?m==="!=":m===
-"="?l===h:m==="*="?l.indexOf(h)>=0:m==="~="?(" "+l+" ").indexOf(h)>=0:!h?l&&g!==false:m==="!="?l!==h:m==="^="?l.indexOf(h)===0:m==="$="?l.substr(l.length-h.length)===h:m==="|="?l===h||l.substr(0,h.length+1)===h+"-":false},POS:function(g,h,l,m){var q=n.setFilters[h[2]];if(q)return q(g,l,h,m)}}},r=n.match.POS;for(var u in n.match){n.match[u]=new RegExp(n.match[u].source+/(?![^\[]*\])(?![^\(]*\))/.source);n.leftMatch[u]=new RegExp(/(^(?:.|\r|\n)*?)/.source+n.match[u].source.replace(/\\(\d+)/g,function(g,
-h){return"\\"+(h-0+1)}))}var z=function(g,h){g=Array.prototype.slice.call(g,0);if(h){h.push.apply(h,g);return h}return g};try{Array.prototype.slice.call(s.documentElement.childNodes,0)}catch(C){z=function(g,h){h=h||[];if(j.call(g)==="[object Array]")Array.prototype.push.apply(h,g);else if(typeof g.length==="number")for(var l=0,m=g.length;l";var l=s.documentElement;l.insertBefore(g,l.firstChild);if(s.getElementById(h)){n.find.ID=function(m,q,p){if(typeof q.getElementById!=="undefined"&&!p)return(q=q.getElementById(m[1]))?q.id===m[1]||typeof q.getAttributeNode!=="undefined"&&
-q.getAttributeNode("id").nodeValue===m[1]?[q]:w:[]};n.filter.ID=function(m,q){var p=typeof m.getAttributeNode!=="undefined"&&m.getAttributeNode("id");return m.nodeType===1&&p&&p.nodeValue===q}}l.removeChild(g);l=g=null})();(function(){var g=s.createElement("div");g.appendChild(s.createComment(""));if(g.getElementsByTagName("*").length>0)n.find.TAG=function(h,l){l=l.getElementsByTagName(h[1]);if(h[1]==="*"){h=[];for(var m=0;l[m];m++)l[m].nodeType===1&&h.push(l[m]);l=h}return l};g.innerHTML="";
-if(g.firstChild&&typeof g.firstChild.getAttribute!=="undefined"&&g.firstChild.getAttribute("href")!=="#")n.attrHandle.href=function(h){return h.getAttribute("href",2)};g=null})();s.querySelectorAll&&function(){var g=k,h=s.createElement("div");h.innerHTML="";if(!(h.querySelectorAll&&h.querySelectorAll(".TEST").length===0)){k=function(m,q,p,v){q=q||s;if(!v&&q.nodeType===9&&!x(q))try{return z(q.querySelectorAll(m),p)}catch(t){}return g(m,q,p,v)};for(var l in g)k[l]=g[l];h=null}}();
-(function(){var g=s.createElement("div");g.innerHTML="";if(!(!g.getElementsByClassName||g.getElementsByClassName("e").length===0)){g.lastChild.className="e";if(g.getElementsByClassName("e").length!==1){n.order.splice(1,0,"CLASS");n.find.CLASS=function(h,l,m){if(typeof l.getElementsByClassName!=="undefined"&&!m)return l.getElementsByClassName(h[1])};g=null}}})();var E=s.compareDocumentPosition?function(g,h){return!!(g.compareDocumentPosition(h)&16)}:
-function(g,h){return g!==h&&(g.contains?g.contains(h):true)},x=function(g){return(g=(g?g.ownerDocument||g:0).documentElement)?g.nodeName!=="HTML":false},ga=function(g,h){var l=[],m="",q;for(h=h.nodeType?[h]:h;q=n.match.PSEUDO.exec(g);){m+=q[0];g=g.replace(n.match.PSEUDO,"")}g=n.relative[g]?g+"*":g;q=0;for(var p=h.length;q=0===d})};c.fn.extend({find:function(a){for(var b=this.pushStack("","find",a),d=0,f=0,e=this.length;f0)for(var j=d;j0},closest:function(a,b){if(c.isArray(a)){var d=[],f=this[0],e,j=
-{},i;if(f&&a.length){e=0;for(var o=a.length;e-1:c(f).is(e)){d.push({selector:i,elem:f});delete j[i]}}f=f.parentNode}}return d}var k=c.expr.match.POS.test(a)?c(a,b||this.context):null;return this.map(function(n,r){for(;r&&r.ownerDocument&&r!==b;){if(k?k.index(r)>-1:c(r).is(a))return r;r=r.parentNode}return null})},index:function(a){if(!a||typeof a===
-"string")return c.inArray(this[0],a?c(a):this.parent().children());return c.inArray(a.jquery?a[0]:a,this)},add:function(a,b){a=typeof a==="string"?c(a,b||this.context):c.makeArray(a);b=c.merge(this.get(),a);return this.pushStack(qa(a[0])||qa(b[0])?b:c.unique(b))},andSelf:function(){return this.add(this.prevObject)}});c.each({parent:function(a){return(a=a.parentNode)&&a.nodeType!==11?a:null},parents:function(a){return c.dir(a,"parentNode")},parentsUntil:function(a,b,d){return c.dir(a,"parentNode",
-d)},next:function(a){return c.nth(a,2,"nextSibling")},prev:function(a){return c.nth(a,2,"previousSibling")},nextAll:function(a){return c.dir(a,"nextSibling")},prevAll:function(a){return c.dir(a,"previousSibling")},nextUntil:function(a,b,d){return c.dir(a,"nextSibling",d)},prevUntil:function(a,b,d){return c.dir(a,"previousSibling",d)},siblings:function(a){return c.sibling(a.parentNode.firstChild,a)},children:function(a){return c.sibling(a.firstChild)},contents:function(a){return c.nodeName(a,"iframe")?
-a.contentDocument||a.contentWindow.document:c.makeArray(a.childNodes)}},function(a,b){c.fn[a]=function(d,f){var e=c.map(this,b,d);eb.test(a)||(f=d);if(f&&typeof f==="string")e=c.filter(f,e);e=this.length>1?c.unique(e):e;if((this.length>1||gb.test(f))&&fb.test(a))e=e.reverse();return this.pushStack(e,a,R.call(arguments).join(","))}});c.extend({filter:function(a,b,d){if(d)a=":not("+a+")";return c.find.matches(a,b)},dir:function(a,b,d){var f=[];for(a=a[b];a&&a.nodeType!==9&&(d===w||a.nodeType!==1||!c(a).is(d));){a.nodeType===
-1&&f.push(a);a=a[b]}return f},nth:function(a,b,d){b=b||1;for(var f=0;a;a=a[d])if(a.nodeType===1&&++f===b)break;return a},sibling:function(a,b){for(var d=[];a;a=a.nextSibling)a.nodeType===1&&a!==b&&d.push(a);return d}});var Ja=/ jQuery\d+="(?:\d+|null)"/g,V=/^\s+/,Ka=/(<([\w:]+)[^>]*?)\/>/g,hb=/^(?:area|br|col|embed|hr|img|input|link|meta|param)$/i,La=/<([\w:]+)/,ib=/"+d+">"},F={option:[1,""],legend:[1,""],thead:[1,""],tr:[2,""],td:[3,""],col:[2,""],area:[1,""],_default:[0,"",""]};F.optgroup=F.option;F.tbody=F.tfoot=F.colgroup=F.caption=F.thead;F.th=F.td;if(!c.support.htmlSerialize)F._default=[1,"div","
"];c.fn.extend({text:function(a){if(c.isFunction(a))return this.each(function(b){var d=
-c(this);d.text(a.call(this,b,d.text()))});if(typeof a!=="object"&&a!==w)return this.empty().append((this[0]&&this[0].ownerDocument||s).createTextNode(a));return c.text(this)},wrapAll:function(a){if(c.isFunction(a))return this.each(function(d){c(this).wrapAll(a.call(this,d))});if(this[0]){var b=c(a,this[0].ownerDocument).eq(0).clone(true);this[0].parentNode&&b.insertBefore(this[0]);b.map(function(){for(var d=this;d.firstChild&&d.firstChild.nodeType===1;)d=d.firstChild;return d}).append(this)}return this},
-wrapInner:function(a){if(c.isFunction(a))return this.each(function(b){c(this).wrapInner(a.call(this,b))});return this.each(function(){var b=c(this),d=b.contents();d.length?d.wrapAll(a):b.append(a)})},wrap:function(a){return this.each(function(){c(this).wrapAll(a)})},unwrap:function(){return this.parent().each(function(){c.nodeName(this,"body")||c(this).replaceWith(this.childNodes)}).end()},append:function(){return this.domManip(arguments,true,function(a){this.nodeType===1&&this.appendChild(a)})},
-prepend:function(){return this.domManip(arguments,true,function(a){this.nodeType===1&&this.insertBefore(a,this.firstChild)})},before:function(){if(this[0]&&this[0].parentNode)return this.domManip(arguments,false,function(b){this.parentNode.insertBefore(b,this)});else if(arguments.length){var a=c(arguments[0]);a.push.apply(a,this.toArray());return this.pushStack(a,"before",arguments)}},after:function(){if(this[0]&&this[0].parentNode)return this.domManip(arguments,false,function(b){this.parentNode.insertBefore(b,
-this.nextSibling)});else if(arguments.length){var a=this.pushStack(this,"after",arguments);a.push.apply(a,c(arguments[0]).toArray());return a}},remove:function(a,b){for(var d=0,f;(f=this[d])!=null;d++)if(!a||c.filter(a,[f]).length){if(!b&&f.nodeType===1){c.cleanData(f.getElementsByTagName("*"));c.cleanData([f])}f.parentNode&&f.parentNode.removeChild(f)}return this},empty:function(){for(var a=0,b;(b=this[a])!=null;a++)for(b.nodeType===1&&c.cleanData(b.getElementsByTagName("*"));b.firstChild;)b.removeChild(b.firstChild);
-return this},clone:function(a){var b=this.map(function(){if(!c.support.noCloneEvent&&!c.isXMLDoc(this)){var d=this.outerHTML,f=this.ownerDocument;if(!d){d=f.createElement("div");d.appendChild(this.cloneNode(true));d=d.innerHTML}return c.clean([d.replace(Ja,"").replace(/=([^="'>\s]+\/)>/g,'="$1">').replace(V,"")],f)[0]}else return this.cloneNode(true)});if(a===true){ra(this,b);ra(this.find("*"),b.find("*"))}return b},html:function(a){if(a===w)return this[0]&&this[0].nodeType===1?this[0].innerHTML.replace(Ja,
-""):null;else if(typeof a==="string"&&!ta.test(a)&&(c.support.leadingWhitespace||!V.test(a))&&!F[(La.exec(a)||["",""])[1].toLowerCase()]){a=a.replace(Ka,Ma);try{for(var b=0,d=this.length;b0||e.cacheable||this.length>1?k.cloneNode(true):k)}o.length&&c.each(o,Qa)}return this}});c.fragments={};c.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(a,b){c.fn[a]=function(d){var f=[];d=c(d);var e=this.length===1&&this[0].parentNode;if(e&&e.nodeType===11&&e.childNodes.length===1&&d.length===1){d[b](this[0]);
-return this}else{e=0;for(var j=d.length;e0?this.clone(true):this).get();c.fn[b].apply(c(d[e]),i);f=f.concat(i)}return this.pushStack(f,a,d.selector)}}});c.extend({clean:function(a,b,d,f){b=b||s;if(typeof b.createElement==="undefined")b=b.ownerDocument||b[0]&&b[0].ownerDocument||s;for(var e=[],j=0,i;(i=a[j])!=null;j++){if(typeof i==="number")i+="";if(i){if(typeof i==="string"&&!jb.test(i))i=b.createTextNode(i);else if(typeof i==="string"){i=i.replace(Ka,Ma);var o=(La.exec(i)||["",
-""])[1].toLowerCase(),k=F[o]||F._default,n=k[0],r=b.createElement("div");for(r.innerHTML=k[1]+i+k[2];n--;)r=r.lastChild;if(!c.support.tbody){n=ib.test(i);o=o==="table"&&!n?r.firstChild&&r.firstChild.childNodes:k[1]===""&&!n?r.childNodes:[];for(k=o.length-1;k>=0;--k)c.nodeName(o[k],"tbody")&&!o[k].childNodes.length&&o[k].parentNode.removeChild(o[k])}!c.support.leadingWhitespace&&V.test(i)&&r.insertBefore(b.createTextNode(V.exec(i)[0]),r.firstChild);i=r.childNodes}if(i.nodeType)e.push(i);else e=
-c.merge(e,i)}}if(d)for(j=0;e[j];j++)if(f&&c.nodeName(e[j],"script")&&(!e[j].type||e[j].type.toLowerCase()==="text/javascript"))f.push(e[j].parentNode?e[j].parentNode.removeChild(e[j]):e[j]);else{e[j].nodeType===1&&e.splice.apply(e,[j+1,0].concat(c.makeArray(e[j].getElementsByTagName("script"))));d.appendChild(e[j])}return e},cleanData:function(a){for(var b,d,f=c.cache,e=c.event.special,j=c.support.deleteExpando,i=0,o;(o=a[i])!=null;i++)if(d=o[c.expando]){b=f[d];if(b.events)for(var k in b.events)e[k]?
-c.event.remove(o,k):Ca(o,k,b.handle);if(j)delete o[c.expando];else o.removeAttribute&&o.removeAttribute(c.expando);delete f[d]}}});var kb=/z-?index|font-?weight|opacity|zoom|line-?height/i,Na=/alpha\([^)]*\)/,Oa=/opacity=([^)]*)/,ha=/float/i,ia=/-([a-z])/ig,lb=/([A-Z])/g,mb=/^-?\d+(?:px)?$/i,nb=/^-?\d/,ob={position:"absolute",visibility:"hidden",display:"block"},pb=["Left","Right"],qb=["Top","Bottom"],rb=s.defaultView&&s.defaultView.getComputedStyle,Pa=c.support.cssFloat?"cssFloat":"styleFloat",ja=
-function(a,b){return b.toUpperCase()};c.fn.css=function(a,b){return X(this,a,b,true,function(d,f,e){if(e===w)return c.curCSS(d,f);if(typeof e==="number"&&!kb.test(f))e+="px";c.style(d,f,e)})};c.extend({style:function(a,b,d){if(!a||a.nodeType===3||a.nodeType===8)return w;if((b==="width"||b==="height")&&parseFloat(d)<0)d=w;var f=a.style||a,e=d!==w;if(!c.support.opacity&&b==="opacity"){if(e){f.zoom=1;b=parseInt(d,10)+""==="NaN"?"":"alpha(opacity="+d*100+")";a=f.filter||c.curCSS(a,"filter")||"";f.filter=
-Na.test(a)?a.replace(Na,b):b}return f.filter&&f.filter.indexOf("opacity=")>=0?parseFloat(Oa.exec(f.filter)[1])/100+"":""}if(ha.test(b))b=Pa;b=b.replace(ia,ja);if(e)f[b]=d;return f[b]},css:function(a,b,d,f){if(b==="width"||b==="height"){var e,j=b==="width"?pb:qb;function i(){e=b==="width"?a.offsetWidth:a.offsetHeight;f!=="border"&&c.each(j,function(){f||(e-=parseFloat(c.curCSS(a,"padding"+this,true))||0);if(f==="margin")e+=parseFloat(c.curCSS(a,"margin"+this,true))||0;else e-=parseFloat(c.curCSS(a,
-"border"+this+"Width",true))||0})}a.offsetWidth!==0?i():c.swap(a,ob,i);return Math.max(0,Math.round(e))}return c.curCSS(a,b,d)},curCSS:function(a,b,d){var f,e=a.style;if(!c.support.opacity&&b==="opacity"&&a.currentStyle){f=Oa.test(a.currentStyle.filter||"")?parseFloat(RegExp.$1)/100+"":"";return f===""?"1":f}if(ha.test(b))b=Pa;if(!d&&e&&e[b])f=e[b];else if(rb){if(ha.test(b))b="float";b=b.replace(lb,"-$1").toLowerCase();e=a.ownerDocument.defaultView;if(!e)return null;if(a=e.getComputedStyle(a,null))f=
-a.getPropertyValue(b);if(b==="opacity"&&f==="")f="1"}else if(a.currentStyle){d=b.replace(ia,ja);f=a.currentStyle[b]||a.currentStyle[d];if(!mb.test(f)&&nb.test(f)){b=e.left;var j=a.runtimeStyle.left;a.runtimeStyle.left=a.currentStyle.left;e.left=d==="fontSize"?"1em":f||0;f=e.pixelLeft+"px";e.left=b;a.runtimeStyle.left=j}}return f},swap:function(a,b,d){var f={};for(var e in b){f[e]=a.style[e];a.style[e]=b[e]}d.call(a);for(e in b)a.style[e]=f[e]}});if(c.expr&&c.expr.filters){c.expr.filters.hidden=function(a){var b=
-a.offsetWidth,d=a.offsetHeight,f=a.nodeName.toLowerCase()==="tr";return b===0&&d===0&&!f?true:b>0&&d>0&&!f?false:c.curCSS(a,"display")==="none"};c.expr.filters.visible=function(a){return!c.expr.filters.hidden(a)}}var sb=J(),tb=/