From 32e9bbfc47a9b5101794683a2dc7e387e15057df Mon Sep 17 00:00:00 2001 From: Nathan Broadbent Date: Tue, 5 Mar 2013 19:48:36 +1300 Subject: [PATCH] Added asset_host to generate JavaScript links in backtraces --- app/helpers/backtrace_line_helper.rb | 13 ++++++++++++- app/models/app.rb | 1 + app/views/apps/_fields.html.haml | 4 ++++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/app/helpers/backtrace_line_helper.rb b/app/helpers/backtrace_line_helper.rb index 34e508f..3219009 100644 --- a/app/helpers/backtrace_line_helper.rb +++ b/app/helpers/backtrace_line_helper.rb @@ -7,13 +7,24 @@ module BacktraceLineHelper private def link_to_in_app_source_file(line, text) return unless line.in_app? - link_to_repo_source_file(line, text) || link_to_issue_tracker_file(line, text) + if line.file_name =~ /\.js$/ + link_to_hosted_javascript(line, text) + else + link_to_repo_source_file(line, text) || + link_to_issue_tracker_file(line, text) + end end def link_to_repo_source_file(line, text) link_to_github(line, text) || link_to_bitbucket(line, text) end + def link_to_hosted_javascript(line, text) + if line.app.asset_host? + link_to(text, "#{line.app.asset_host}/#{line.file_relative}", :target => '_blank') + end + end + def link_to_external_source_file(text) text end diff --git a/app/models/app.rb b/app/models/app.rb index 2f9fb2a..0ab65f5 100644 --- a/app/models/app.rb +++ b/app/models/app.rb @@ -7,6 +7,7 @@ class App field :api_key field :github_repo field :bitbucket_repo + field :asset_host field :repository_branch field :resolve_errs_on_deploy, :type => Boolean, :default => false field :notify_all_users, :type => Boolean, :default => false diff --git a/app/views/apps/_fields.html.haml b/app/views/apps/_fields.html.haml index 80dafb2..5bb0dbc 100644 --- a/app/views/apps/_fields.html.haml +++ b/app/views/apps/_fields.html.haml @@ -13,6 +13,10 @@ %div = f.label :bitbucket_repo = f.text_field :bitbucket_repo, :placeholder => "errbit/errbit from https://bitbucket.org/errbit/errbit" +%div + = f.label :asset_host + %em Used to generate links for JavaScript errors + = f.text_field :asset_host, :placeholder => "e.g. https://assets.example.com" %fieldset %legend Notifications -- libgit2 0.21.2