<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <div markdown-here-wrapper-content-modified="true" style=""
data-md-original="Thanks%2C%20I%20didn%E2%80%99t%20know%20about%20%60TextMate.system(%E2%80%A6)%60%20%E2%80%93%20that%E2%80%99s%20exactly%20what%20I%20was%20looking%20for.%20%F0%9F%91%8D%3Cbr%3E%3Cbr%3EIt%20took%20a%20while%20until%20I%20got%20the%20escaping%20right%2C%20here%E2%80%99s%20what%20I%20ended%20up%20with%3A%3Cbr%3E%3Cbr%3E%60%60%60ruby%3Cbr%3Edef%20link_to(title%2C%20local_path)%3Cbr%3E%C2%A0%20url%20%3D%20URI.escape(%22file%3A%2F%2F%23%7Blocal_path%7D%22)%3Cbr%3E%C2%A0%20title%20%3D%20CGI.escape_html(title)%3Cbr%3E%C2%A0%20%25%7B%26lt%3Ba%20onclick%3D'TextMate.system(%22open%20%23%7BShellwords.escape(url)%7D%22)%3B%20return%20false%3B'%20href%3D'%23%7Burl%7D'%26gt%3B%23%7Btitle%7D%26lt%3B%2Fa%26gt%3B%7D%3Cbr%3Eend%3Cbr%3E%60%60%60%3Cbr%3E%3Cbr%3EGist%20with%20the%20complete%20setup%3A%20https%3A%2F%2Fgist.github.com%2Fnoniq%2F9289157%3Cbr%3E%3Cbr%3EStefan%3Cbr%3E%3Cbr%3E%3Cdiv%20class%3D%22moz-cite-prefix%22%3EAm%2001.03.14%2007%3A15%2C%20schrieb%20Allan%20Odgaard%3A%3Cb
 r
%3E%3C%2Fdiv%3E%3Cblockquote%20cite%3D%22mid%3AFA394127-14F1-4F16-B3FA-5A9F7A81CDEB%40textmate.org%22%20type%3D%22cite%22%3E%3Cdiv%20class%3D%22markdown%22%3E%0A%3Cp%20dir%3D%22auto%22%3EOn%201%20Mar%202014%2C%20at%209%3A20%2C%20Stefan%20Daschek%20wrote%3A%3C%2Fp%3E%0A%0A%3Cblockquote%3E%0A%3Cp%20dir%3D%22auto%22%3EIs%20it%20possible%20to%20force%20specific%20links%20in%20the%20HTML%20output%20window%20to%20open%20in%20the%20default%20browser%20%5B%E2%80%A6%5D%20I%20have%20a%20Rails%20project%20where%20the%20testsuite%20already%20creates%20a%20dump%20of%20the%20HTML%20page%20for%20each%20failed%20feature%20spec.%20Now%20I%E2%80%99m%20trying%20to%20extend%20RSpec%E2%80%99s%20TextMateFormatter%20to%20include%20links%20to%20these%20files.%20Works%20so%20far%2C%20but%20I%20need%20to%20open%20the%20saved%20HTML%20pages%20in%20my%20default%20browser%20so%20that%20I%20have%20my%20usual%20developer%20tools%20around%20for%20debugging.%3C%2Fp%3E%0A%3C%2Fblockquote%3E%0A%0A%3Cp%20dir%3D%22auto%
 2
2%3EGiven%20that%20you%20are%20modifying%20the%20generated%20output%2C%20you%20can%20change%20the%20link%20to%20use%20JavaScript%20and%20TextMate.system()%2C%20example%3A%3C%2Fp%3E%0A%0A%3Cpre%3E%3Ccode%3E%26lt%3Bscript%26gt%3B%0Afunction%20open_url(url)%20%7B%0A%20%20TextMate.system(%22open%20'%22%20%2B%20url%20%2B%20%22'%22)%3B%0A%7D%0A%26lt%3B%2Fscript%26gt%3B%0A%0A%26lt%3Ba%20href%3D%22%23%22%20onClick%3D%22open_url('http%3A%2F%2Fmacromates.com%2F')%3B%20return%20true%3B%22%26gt%3BOpen%20Website%26lt%3B%2Fa%26gt%3B%0A%3C%2Fcode%3E%3C%2Fpre%3E%0A%0A%3C%2Fdiv%3E%0A%3Cbr%3E%3Cfieldset%20class%3D%22mimeAttachmentHeader%22%3E%3C%2Ffieldset%3E%3Cbr%3E%3Cpre%20wrap%3D%22%22%3E_______________________________________________%0Atextmate%20mailing%20list%0Atextmate%40lists.macromates.com%0Ahttp%3A%2F%2Flists.macromates.com%2Flistinfo%2Ftextmate%3C%2Fpre%3E%0A%0A%3C%2Fblockquote%3E%3Cbr%3E"
      class="markdown-here-wrapper" data-md-url="Thunderbird"
      id="markdown-here-wrapper-866045">
      <p style="margin: 1.2em 0px ! important;">Thanks, I didn’t know
        about <code style="font-size: 0.85em; font-family:
          Consolas,Inconsolata,Courier,monospace;margin: 0px 0.15em;
          padding: 0px 0.3em; white-space: pre-wrap; border: 1px solid
          rgb(234, 234, 234); background-color: rgb(248, 248, 248);
          border-radius: 3px 3px 3px 3px; display: inline;">TextMate.system(…)</code>
        – that’s exactly what I was looking for. �</p>
      <p style="margin: 1.2em 0px ! important;">It took a while until I
        got the escaping right, here’s what I ended up with:</p>
      <pre style="font-size: 0.85em; font-family: Consolas,Inconsolata,Courier,monospace;font-size: 1em; line-height: 1.2em;margin: 1.2em 0px;"><code style="font-size: 0.85em; font-family: Consolas,Inconsolata,Courier,monospace;margin: 0px 0.15em; padding: 0px 0.3em; white-space: pre-wrap; border: 1px solid rgb(234, 234, 234); background-color: rgb(248, 248, 248); border-radius: 3px 3px 3px 3px; display: inline;white-space: pre; overflow: auto; border-radius: 3px 3px 3px 3px; border: 1px solid rgb(204, 204, 204); padding: 0.5em 0.7em; display: block ! important;display: block; padding: 0.5em; color: rgb(51, 51, 51); background: none repeat scroll 0% 0% rgb(248, 248, 255);" class="language-ruby"><span class="function"><span style="color: rgb(51, 51, 51); font-weight: bold;" class="keyword">def</span> <span style="color: rgb(153, 0, 0); font-weight: bold;" class="title">link_to</span><span class="params">(title, local_path)</span></span>
  url = <span class="constant">URI</span>.escape(<span style="color: rgb(221, 17, 68);" class="string">"<a class="moz-txt-link-freetext" href="file://">file://</a><span style="color: rgb(51, 51, 51); font-weight: bold;font-weight: normal;" class="subst">#{local_path}</span>"</span>)
  title = <span class="constant">CGI</span>.escape_html(title)
  <span style="color: rgb(221, 17, 68);" class="string">%{<a onclick='TextMate.system("open <span style="color: rgb(51, 51, 51); font-weight: bold;font-weight: normal;" class="subst">#{<span class="constant">Shellwords</span>.escape(url)}</span>"); return false;' href='<span style="color: rgb(51, 51, 51); font-weight: bold;font-weight: normal;" class="subst">#{url}</span>'><span style="color: rgb(51, 51, 51); font-weight: bold;font-weight: normal;" class="subst">#{title}</span></a>}</span>
<span style="color: rgb(51, 51, 51); font-weight: bold;" class="keyword">end</span>
</code></pre>
      <p style="margin: 1.2em 0px ! important;">Gist with the complete
        setup: <a href="https://gist.github.com/noniq/9289157">https://gist.github.com/noniq/9289157</a></p>
      <p style="margin: 1.2em 0px ! important;">Stefan</p>
      <p style="margin: 1.2em 0px ! important;">Am 01.03.14 07:15,
        schrieb Allan Odgaard:</p>
      <p style="margin: 1.2em 0px ! important;"></p>
      <div class="markdown-here-exclude">
        <p></p>
        <blockquote
          cite="mid:FA394127-14F1-4F16-B3FA-5A9F7A81CDEB@textmate.org"
          type="cite">
          <div class="markdown">
            <p dir="auto">On 1 Mar 2014, at 9:20, Stefan Daschek wrote:</p>
            <blockquote>
              <p dir="auto">Is it possible to force specific links in
                the HTML output window to open in the default browser
                […] I have a Rails project where the testsuite already
                creates a dump of the HTML page for each failed feature
                spec. Now I’m trying to extend RSpec’s TextMateFormatter
                to include links to these files. Works so far, but I
                need to open the saved HTML pages in my default browser
                so that I have my usual developer tools around for
                debugging.</p>
            </blockquote>
            <p dir="auto">Given that you are modifying the generated
              output, you can change the link to use JavaScript and
              TextMate.system(), example:</p>
            <pre><code><script>
function open_url(url) {
  TextMate.system("open '" + url + "'");
}
</script>

<a href="#" onClick="open_url('<a class="moz-txt-link-freetext" href="http://macromates.com/">http://macromates.com/</a>'); return true;">Open Website</a>
</code></pre>
          </div>
          <br>
          <fieldset class="mimeAttachmentHeader"></fieldset>
          <br>
          <pre wrap="">_______________________________________________
textmate mailing list
<a class="moz-txt-link-abbreviated" href="mailto:textmate@lists.macromates.com">textmate@lists.macromates.com</a>
<a class="moz-txt-link-freetext" href="http://lists.macromates.com/listinfo/textmate">http://lists.macromates.com/listinfo/textmate</a></pre>
        </blockquote>
        <p></p>
      </div>
      <p style="margin: 1.2em 0px ! important;"></p>
    </div>
  </body>
</html>