spec/fixtures/githubblob.response in onebox-1.1.0 vs spec/fixtures/githubblob.response in onebox-1.2.0

- old
+ new

@@ -1,922 +1,50 @@ +require_dependency 'oneboxer/handlebars_onebox' +module Oneboxer + class GithubBlobOnebox < HandlebarsOnebox + matcher /^https?:\/\/(?:www\.)?github\.com\/[^\/]+\/[^\/]+\/blob\/.*/ + favicon 'github.png' -<!DOCTYPE html> -<html> - <head prefix="og: http://ogp.me/ns# fb: http://ogp.me/ns/fb# githubog: http://ogp.me/ns/fb/githubog#"> - <meta charset='utf-8'> - <meta http-equiv="X-UA-Compatible" content="IE=edge"> - <title>discourse/lib/oneboxer/github_blob_onebox.rb at master · discourse/discourse · GitHub</title> - <link rel="search" type="application/opensearchdescription+xml" href="/opensearch.xml" title="GitHub" /> - <link rel="fluid-icon" href="https://github.com/fluidicon.png" title="GitHub" /> - <link rel="apple-touch-icon" sizes="57x57" href="/apple-touch-icon-114.png" /> - <link rel="apple-touch-icon" sizes="114x114" href="/apple-touch-icon-114.png" /> - <link rel="apple-touch-icon" sizes="72x72" href="/apple-touch-icon-144.png" /> - <link rel="apple-touch-icon" sizes="144x144" href="/apple-touch-icon-144.png" /> - <link rel="logo" type="image/svg" href="https://github-media-downloads.s3.amazonaws.com/github-logo.svg" /> - <meta property="og:image" content="https://github.global.ssl.fastly.net/images/modules/logos_page/Octocat.png"> - <meta name="hostname" content="github-fe121-cp1-prd.iad.github.net"> - <meta name="ruby" content="ruby 1.9.3p194-tcs-github-tcmalloc (2012-05-25, TCS patched 2012-05-27, GitHub v1.0.36) [x86_64-linux]"> - <link rel="assets" href="https://github.global.ssl.fastly.net/"> - <link rel="conduit-xhr" href="https://ghconduit.com:25035/"> - <link rel="xhr-socket" href="/_sockets" /> - + def translate_url + m = @url.match(/github\.com\/(?<user>[^\/]+)\/(?<repo>[^\/]+)\/blob\/(?<sha1>[^\/]+)\/(?<file>[^#]+)(#(L(?<from>[^-]*)(-L(?<to>.*))?))?/mi) + if m + @from = (m[:from] || -1).to_i + @to = (m[:to] || -1).to_i + @file = m[:file] + return "https://raw.github.com/#{m[:user]}/#{m[:repo]}/#{m[:sha1]}/#{m[:file]}" + end + nil + end + def parse(data) - <meta name="msapplication-TileImage" content="/windows-tile.png" /> - <meta name="msapplication-TileColor" content="#ffffff" /> - <meta name="selected-link" value="repo_source" data-pjax-transient /> - <meta content="collector.githubapp.com" name="octolytics-host" /><meta content="github" name="octolytics-app-id" /><meta content="4C576AE2:34F1:250FD3C:524BA190" name="octolytics-dimension-request_id" /> - + if @from > 0 + if @to < 0 + @from = @from - 10 + @to = @from + 20 + end + if @to > @from + data = data.split("\n")[@from..@to].join("\n") + end + end - - - <link rel="icon" type="image/x-icon" href="/favicon.ico" /> + extension = @file.split(".")[-1] + @lang = case extension + when "rb" then "ruby" + when "js" then "javascript" + else extension + end - <meta content="authenticity_token" name="csrf-param" /> -<meta content="JdJTjxytA2XtJT0oxb+vwcdzMb0csOQRNtwyfZ2++0M=" name="csrf-token" /> + truncated = false + if data.length > SiteSetting.onebox_max_chars + data = data[0..SiteSetting.onebox_max_chars-1] + truncated = true + end - <link href="https://github.global.ssl.fastly.net/assets/github-33cf54e1c25c41c1bb09506a6e93ef032819ce2c.css" media="all" rel="stylesheet" type="text/css" /> - <link href="https://github.global.ssl.fastly.net/assets/github2-4e9347ae8f53d7710a27ba7dfdfb83229471a306.css" media="all" rel="stylesheet" type="text/css" /> - + {content: data, truncated: truncated} + end - - - <script src="https://github.global.ssl.fastly.net/assets/frameworks-4e5aeedcc7a86dcff8294cb84644a333b46202a2.js" type="text/javascript"></script> - <script src="https://github.global.ssl.fastly.net/assets/github-d7ac31eea49e88b740350eb21b88f43c6d4762e4.js" type="text/javascript"></script> - - <meta http-equiv="x-pjax-version" content="e2af00064d49e9cdb439af3ae2437345"> - - <link data-pjax-transient rel='permalink' href='/discourse/discourse/blob/af467a16755d9d0b5cea325fd4503a5648ca5f8c/lib/oneboxer/github_blob_onebox.rb'> - <meta property="og:title" content="discourse"/> - <meta property="og:type" content="githubog:gitrepository"/> - <meta property="og:url" content="https://github.com/discourse/discourse"/> - <meta property="og:image" content="https://github.global.ssl.fastly.net/images/gravatars/gravatar-user-420.png"/> - <meta property="og:site_name" content="GitHub"/> - <meta property="og:description" content="discourse - A platform for community discussion. Free, open, simple."/> - - <meta name="description" content="discourse - A platform for community discussion. Free, open, simple." /> - - <meta content="3220138" name="octolytics-dimension-user_id" /><meta content="discourse" name="octolytics-dimension-user_login" /><meta content="7569578" name="octolytics-dimension-repository_id" /><meta content="discourse/discourse" name="octolytics-dimension-repository_nwo" /><meta content="true" name="octolytics-dimension-repository_public" /><meta content="false" name="octolytics-dimension-repository_is_fork" /><meta content="7569578" name="octolytics-dimension-repository_network_root_id" /><meta content="discourse/discourse" name="octolytics-dimension-repository_network_root_nwo" /> - <link href="https://github.com/discourse/discourse/commits/master.atom" rel="alternate" title="Recent Commits to discourse:master" type="application/atom+xml" /> - - </head> - - - <body class="logged_out env-production vis-public page-blob"> - <div class="wrapper"> - - - - - - - <div class="header header-logged-out"> - <div class="container clearfix"> - - <a class="header-logo-wordmark" href="https://github.com/"> - <span class="mega-octicon octicon-logo-github"></span> - </a> - - <div class="header-actions"> - <a class="button primary" href="/signup">Sign up</a> - <a class="button signin" href="/login?return_to=%2Fdiscourse%2Fdiscourse%2Fblob%2Fmaster%2Flib%2Foneboxer%2Fgithub_blob_onebox.rb">Sign in</a> - </div> - - <div class="command-bar js-command-bar in-repository"> - - <ul class="top-nav"> - <li class="explore"><a href="/explore">Explore</a></li> - <li class="features"><a href="/features">Features</a></li> - <li class="enterprise"><a href="https://enterprise.github.com/">Enterprise</a></li> - <li class="blog"><a href="/blog">Blog</a></li> - </ul> - <form accept-charset="UTF-8" action="/search" class="command-bar-form" id="top_search_form" method="get"> - -<input type="text" data-hotkey="/ s" name="q" id="js-command-bar-field" placeholder="Search or type a command" tabindex="1" autocapitalize="off" - - - data-repo="discourse/discourse" - data-branch="master" - data-sha="9e03da6523981fcfd64e0864e61f25713b2e1af7" - > - - <input type="hidden" name="nwo" value="discourse/discourse" /> - - <div class="select-menu js-menu-container js-select-menu search-context-select-menu"> - <span class="minibutton select-menu-button js-menu-target"> - <span class="js-select-button">This repository</span> - </span> - - <div class="select-menu-modal-holder js-menu-content js-navigation-container"> - <div class="select-menu-modal"> - - <div class="select-menu-item js-navigation-item js-this-repository-navigation-item selected"> - <span class="select-menu-item-icon octicon octicon-check"></span> - <input type="radio" class="js-search-this-repository" name="search_target" value="repository" checked="checked" /> - <div class="select-menu-item-text js-select-button-text">This repository</div> - </div> <!-- /.select-menu-item --> - - <div class="select-menu-item js-navigation-item js-all-repositories-navigation-item"> - <span class="select-menu-item-icon octicon octicon-check"></span> - <input type="radio" name="search_target" value="global" /> - <div class="select-menu-item-text js-select-button-text">All repositories</div> - </div> <!-- /.select-menu-item --> - - </div> - </div> - </div> - - <span class="octicon help tooltipped downwards" title="Show command bar help"> - <span class="octicon octicon-question"></span> - </span> - - - <input type="hidden" name="ref" value="cmdform"> - -</form> - </div> - - </div> -</div> - - - - - - <div class="site" itemscope itemtype="http://schema.org/WebPage"> - - <div class="pagehead repohead instapaper_ignore readability-menu"> - <div class="container"> - - -<ul class="pagehead-actions"> - - - <li> - <a href="/login?return_to=%2Fdiscourse%2Fdiscourse" - class="minibutton with-count js-toggler-target star-button entice tooltipped upwards" - title="You must be signed in to use this feature" rel="nofollow"> - <span class="octicon octicon-star"></span>Star -</a> -<a class="social-count js-social-count" href="/discourse/discourse/stargazers"> - 7,869 -</a> - - </li> - - <li> - <a href="/login?return_to=%2Fdiscourse%2Fdiscourse" - class="minibutton with-count js-toggler-target fork-button entice tooltipped upwards" - title="You must be signed in to fork a repository" rel="nofollow"> - <span class="octicon octicon-git-branch"></span>Fork - </a> - <a href="/discourse/discourse/network" class="social-count"> - 1,882 - </a> - </li> -</ul> - - <h1 itemscope itemtype="http://data-vocabulary.org/Breadcrumb" class="entry-title public"> - <span class="repo-label"><span>public</span></span> - <span class="mega-octicon octicon-repo"></span> - <span class="author"> - <a href="/discourse" class="url fn" itemprop="url" rel="author"><span itemprop="title">discourse</span></a></span - ><span class="repohead-name-divider">/</span><strong - ><a href="/discourse/discourse" class="js-current-repository js-repo-home-link">discourse</a></strong> - - <span class="page-context-loader"> - <img alt="Octocat-spinner-32" height="16" src="https://github.global.ssl.fastly.net/images/spinners/octocat-spinner-32.gif" width="16" /> - </span> - - </h1> - </div><!-- /.container --> - </div><!-- /.repohead --> - - <div class="container"> - - <div class="repository-with-sidebar repo-container "> - - <div class="repository-sidebar"> - - -<div class="repo-nav repo-nav-full js-repository-container-pjax js-octicon-loaders"> - <div class="repo-nav-contents"> - <ul class="repo-menu"> - <li class="tooltipped leftwards" title="Code"> - <a href="/discourse/discourse" aria-label="Code" class="js-selected-navigation-item selected" data-gotokey="c" data-pjax="true" data-selected-links="repo_source repo_downloads repo_commits repo_tags repo_branches /discourse/discourse"> - <span class="octicon octicon-code"></span> <span class="full-word">Code</span> - <img alt="Octocat-spinner-32" class="mini-loader" height="16" src="https://github.global.ssl.fastly.net/images/spinners/octocat-spinner-32.gif" width="16" /> -</a> </li> - - <li class="tooltipped leftwards" title="Issues"> - <a href="/discourse/discourse/issues" aria-label="Issues" class="js-selected-navigation-item js-disable-pjax" data-gotokey="i" data-selected-links="repo_issues /discourse/discourse/issues"> - <span class="octicon octicon-issue-opened"></span> <span class="full-word">Issues</span> - <span class='counter'>40</span> - <img alt="Octocat-spinner-32" class="mini-loader" height="16" src="https://github.global.ssl.fastly.net/images/spinners/octocat-spinner-32.gif" width="16" /> -</a> </li> - - <li class="tooltipped leftwards" title="Pull Requests"><a href="/discourse/discourse/pulls" aria-label="Pull Requests" class="js-selected-navigation-item js-disable-pjax" data-gotokey="p" data-selected-links="repo_pulls /discourse/discourse/pulls"> - <span class="octicon octicon-git-pull-request"></span> <span class="full-word">Pull Requests</span> - <span class='counter'>10</span> - <img alt="Octocat-spinner-32" class="mini-loader" height="16" src="https://github.global.ssl.fastly.net/images/spinners/octocat-spinner-32.gif" width="16" /> -</a> </li> - - - <li class="tooltipped leftwards" title="Wiki"> - <a href="/discourse/discourse/wiki" aria-label="Wiki" class="js-selected-navigation-item " data-pjax="true" data-selected-links="repo_wiki /discourse/discourse/wiki"> - <span class="octicon octicon-book"></span> <span class="full-word">Wiki</span> - <img alt="Octocat-spinner-32" class="mini-loader" height="16" src="https://github.global.ssl.fastly.net/images/spinners/octocat-spinner-32.gif" width="16" /> -</a> </li> - </ul> - <div class="repo-menu-separator"></div> - <ul class="repo-menu"> - - <li class="tooltipped leftwards" title="Pulse"> - <a href="/discourse/discourse/pulse" aria-label="Pulse" class="js-selected-navigation-item " data-pjax="true" data-selected-links="pulse /discourse/discourse/pulse"> - <span class="octicon octicon-pulse"></span> <span class="full-word">Pulse</span> - <img alt="Octocat-spinner-32" class="mini-loader" height="16" src="https://github.global.ssl.fastly.net/images/spinners/octocat-spinner-32.gif" width="16" /> -</a> </li> - - <li class="tooltipped leftwards" title="Graphs"> - <a href="/discourse/discourse/graphs" aria-label="Graphs" class="js-selected-navigation-item " data-pjax="true" data-selected-links="repo_graphs repo_contributors /discourse/discourse/graphs"> - <span class="octicon octicon-graph"></span> <span class="full-word">Graphs</span> - <img alt="Octocat-spinner-32" class="mini-loader" height="16" src="https://github.global.ssl.fastly.net/images/spinners/octocat-spinner-32.gif" width="16" /> -</a> </li> - - <li class="tooltipped leftwards" title="Network"> - <a href="/discourse/discourse/network" aria-label="Network" class="js-selected-navigation-item js-disable-pjax" data-selected-links="repo_network /discourse/discourse/network"> - <span class="octicon octicon-git-branch"></span> <span class="full-word">Network</span> - <img alt="Octocat-spinner-32" class="mini-loader" height="16" src="https://github.global.ssl.fastly.net/images/spinners/octocat-spinner-32.gif" width="16" /> -</a> </li> - </ul> - - - </div> -</div> - - <div class="only-with-full-nav"> - - - - -<div class="clone-url open" - data-protocol-type="http" - data-url="/users/set_protocol?protocol_selector=http&amp;protocol_type=clone"> - <h3><strong>HTTPS</strong> clone URL</h3> - <div class="clone-url-box"> - <input type="text" class="clone js-url-field" - value="https://github.com/discourse/discourse.git" readonly="readonly"> - - <span class="js-zeroclipboard url-box-clippy minibutton zeroclipboard-button" data-clipboard-text="https://github.com/discourse/discourse.git" data-copied-hint="copied!" title="copy to clipboard"><span class="octicon octicon-clippy"></span></span> - </div> -</div> - - - -<div class="clone-url " - data-protocol-type="subversion" - data-url="/users/set_protocol?protocol_selector=subversion&amp;protocol_type=clone"> - <h3><strong>Subversion</strong> checkout URL</h3> - <div class="clone-url-box"> - <input type="text" class="clone js-url-field" - value="https://github.com/discourse/discourse" readonly="readonly"> - - <span class="js-zeroclipboard url-box-clippy minibutton zeroclipboard-button" data-clipboard-text="https://github.com/discourse/discourse" data-copied-hint="copied!" title="copy to clipboard"><span class="octicon octicon-clippy"></span></span> - </div> -</div> - - -<p class="clone-options">You can clone with - <a href="#" class="js-clone-selector" data-protocol="http">HTTPS</a>, - or <a href="#" class="js-clone-selector" data-protocol="subversion">Subversion</a>. - <span class="octicon help tooltipped upwards" title="Get help on which URL is right for you."> - <a href="https://help.github.com/articles/which-remote-url-should-i-use"> - <span class="octicon octicon-question"></span> - </a> - </span> -</p> - - - - <a href="/discourse/discourse/archive/master.zip" - class="minibutton sidebar-button" - title="Download this repository as a zip file" - rel="nofollow"> - <span class="octicon octicon-cloud-download"></span> - Download ZIP - </a> - </div> - </div><!-- /.repository-sidebar --> - - <div id="js-repo-pjax-container" class="repository-content context-loader-container" data-pjax-container> - - - -<!-- blob contrib key: blob_contributors:v21:6d5b6c2c96d010ae9f2e5c516e200612 --> - -<p title="This is a placeholder element" class="js-history-link-replace hidden"></p> - -<a href="/discourse/discourse/find/master" data-pjax data-hotkey="t" class="js-show-file-finder" style="display:none">Show File Finder</a> - -<div class="file-navigation"> - - - -<div class="select-menu js-menu-container js-select-menu" > - <span class="minibutton select-menu-button js-menu-target" data-hotkey="w" - data-master-branch="master" - data-ref="master" - role="button" aria-label="Switch branches or tags" tabindex="0"> - <span class="octicon octicon-git-branch"></span> - <i>branch:</i> - <span class="js-select-button">master</span> - </span> - - <div class="select-menu-modal-holder js-menu-content js-navigation-container" data-pjax> - - <div class="select-menu-modal"> - <div class="select-menu-header"> - <span class="select-menu-title">Switch branches/tags</span> - <span class="octicon octicon-remove-close js-menu-close"></span> - </div> <!-- /.select-menu-header --> - - <div class="select-menu-filters"> - <div class="select-menu-text-filter"> - <input type="text" aria-label="Filter branches/tags" id="context-commitish-filter-field" class="js-filterable-field js-navigation-enable" placeholder="Filter branches/tags"> - </div> - <div class="select-menu-tabs"> - <ul> - <li class="select-menu-tab"> - <a href="#" data-tab-filter="branches" class="js-select-menu-tab">Branches</a> - </li> - <li class="select-menu-tab"> - <a href="#" data-tab-filter="tags" class="js-select-menu-tab">Tags</a> - </li> - </ul> - </div><!-- /.select-menu-tabs --> - </div><!-- /.select-menu-filters --> - - <div class="select-menu-list select-menu-tab-bucket js-select-menu-tab-bucket" data-tab-filter="branches"> - - <div data-filterable-for="context-commitish-filter-field" data-filterable-type="substring"> - - - <div class="select-menu-item js-navigation-item "> - <span class="select-menu-item-icon octicon octicon-check"></span> - <a href="/discourse/discourse/blob/auth_work/lib/oneboxer/github_blob_onebox.rb" - data-name="auth_work" - data-skip-pjax="true" - rel="nofollow" - class="js-navigation-open select-menu-item-text js-select-button-text css-truncate-target" - title="auth_work">auth_work</a> - </div> <!-- /.select-menu-item --> - <div class="select-menu-item js-navigation-item "> - <span class="select-menu-item-icon octicon octicon-check"></span> - <a href="/discourse/discourse/blob/bus/lib/oneboxer/github_blob_onebox.rb" - data-name="bus" - data-skip-pjax="true" - rel="nofollow" - class="js-navigation-open select-menu-item-text js-select-button-text css-truncate-target" - title="bus">bus</a> - </div> <!-- /.select-menu-item --> - <div class="select-menu-item js-navigation-item "> - <span class="select-menu-item-icon octicon octicon-check"></span> - <a href="/discourse/discourse/blob/ember-1.0/lib/oneboxer/github_blob_onebox.rb" - data-name="ember-1.0" - data-skip-pjax="true" - rel="nofollow" - class="js-navigation-open select-menu-item-text js-select-button-text css-truncate-target" - title="ember-1.0">ember-1.0</a> - </div> <!-- /.select-menu-item --> - <div class="select-menu-item js-navigation-item "> - <span class="select-menu-item-icon octicon octicon-check"></span> - <a href="/discourse/discourse/blob/listview/lib/oneboxer/github_blob_onebox.rb" - data-name="listview" - data-skip-pjax="true" - rel="nofollow" - class="js-navigation-open select-menu-item-text js-select-button-text css-truncate-target" - title="listview">listview</a> - </div> <!-- /.select-menu-item --> - <div class="select-menu-item js-navigation-item "> - <span class="select-menu-item-icon octicon octicon-check"></span> - <a href="/discourse/discourse/blob/markdown.js/lib/oneboxer/github_blob_onebox.rb" - data-name="markdown.js" - data-skip-pjax="true" - rel="nofollow" - class="js-navigation-open select-menu-item-text js-select-button-text css-truncate-target" - title="markdown.js">markdown.js</a> - </div> <!-- /.select-menu-item --> - <div class="select-menu-item js-navigation-item selected"> - <span class="select-menu-item-icon octicon octicon-check"></span> - <a href="/discourse/discourse/blob/master/lib/oneboxer/github_blob_onebox.rb" - data-name="master" - data-skip-pjax="true" - rel="nofollow" - class="js-navigation-open select-menu-item-text js-select-button-text css-truncate-target" - title="master">master</a> - </div> <!-- /.select-menu-item --> - <div class="select-menu-item js-navigation-item "> - <span class="select-menu-item-icon octicon octicon-check"></span> - <a href="/discourse/discourse/blob/mdtest/lib/oneboxer/github_blob_onebox.rb" - data-name="mdtest" - data-skip-pjax="true" - rel="nofollow" - class="js-navigation-open select-menu-item-text js-select-button-text css-truncate-target" - title="mdtest">mdtest</a> - </div> <!-- /.select-menu-item --> - <div class="select-menu-item js-navigation-item "> - <span class="select-menu-item-icon octicon octicon-check"></span> - <a href="/discourse/discourse/blob/mobile/lib/oneboxer/github_blob_onebox.rb" - data-name="mobile" - data-skip-pjax="true" - rel="nofollow" - class="js-navigation-open select-menu-item-text js-select-button-text css-truncate-target" - title="mobile">mobile</a> - </div> <!-- /.select-menu-item --> - <div class="select-menu-item js-navigation-item "> - <span class="select-menu-item-icon octicon octicon-check"></span> - <a href="/discourse/discourse/blob/rails4/lib/oneboxer/github_blob_onebox.rb" - data-name="rails4" - data-skip-pjax="true" - rel="nofollow" - class="js-navigation-open select-menu-item-text js-select-button-text css-truncate-target" - title="rails4">rails4</a> - </div> <!-- /.select-menu-item --> - <div class="select-menu-item js-navigation-item "> - <span class="select-menu-item-icon octicon octicon-check"></span> - <a href="/discourse/discourse/blob/security_changes/lib/oneboxer/github_blob_onebox.rb" - data-name="security_changes" - data-skip-pjax="true" - rel="nofollow" - class="js-navigation-open select-menu-item-text js-select-button-text css-truncate-target" - title="security_changes">security_changes</a> - </div> <!-- /.select-menu-item --> - </div> - - <div class="select-menu-no-results">Nothing to show</div> - </div> <!-- /.select-menu-list --> - - <div class="select-menu-list select-menu-tab-bucket js-select-menu-tab-bucket" data-tab-filter="tags"> - <div data-filterable-for="context-commitish-filter-field" data-filterable-type="substring"> - - - <div class="select-menu-item js-navigation-item "> - <span class="select-menu-item-icon octicon octicon-check"></span> - <a href="/discourse/discourse/tree/v0.9.6.3/lib/oneboxer/github_blob_onebox.rb" - data-name="v0.9.6.3" - data-skip-pjax="true" - rel="nofollow" - class="js-navigation-open select-menu-item-text js-select-button-text css-truncate-target" - title="v0.9.6.3">v0.9.6.3</a> - </div> <!-- /.select-menu-item --> - <div class="select-menu-item js-navigation-item "> - <span class="select-menu-item-icon octicon octicon-check"></span> - <a href="/discourse/discourse/tree/v0.9.6.2/lib/oneboxer/github_blob_onebox.rb" - data-name="v0.9.6.2" - data-skip-pjax="true" - rel="nofollow" - class="js-navigation-open select-menu-item-text js-select-button-text css-truncate-target" - title="v0.9.6.2">v0.9.6.2</a> - </div> <!-- /.select-menu-item --> - <div class="select-menu-item js-navigation-item "> - <span class="select-menu-item-icon octicon octicon-check"></span> - <a href="/discourse/discourse/tree/v0.9.6.1/lib/oneboxer/github_blob_onebox.rb" - data-name="v0.9.6.1" - data-skip-pjax="true" - rel="nofollow" - class="js-navigation-open select-menu-item-text js-select-button-text css-truncate-target" - title="v0.9.6.1">v0.9.6.1</a> - </div> <!-- /.select-menu-item --> - <div class="select-menu-item js-navigation-item "> - <span class="select-menu-item-icon octicon octicon-check"></span> - <a href="/discourse/discourse/tree/v0.9.6/lib/oneboxer/github_blob_onebox.rb" - data-name="v0.9.6" - data-skip-pjax="true" - rel="nofollow" - class="js-navigation-open select-menu-item-text js-select-button-text css-truncate-target" - title="v0.9.6">v0.9.6</a> - </div> <!-- /.select-menu-item --> - <div class="select-menu-item js-navigation-item "> - <span class="select-menu-item-icon octicon octicon-check"></span> - <a href="/discourse/discourse/tree/v0.9.5.2/lib/oneboxer/github_blob_onebox.rb" - data-name="v0.9.5.2" - data-skip-pjax="true" - rel="nofollow" - class="js-navigation-open select-menu-item-text js-select-button-text css-truncate-target" - title="v0.9.5.2">v0.9.5.2</a> - </div> <!-- /.select-menu-item --> - <div class="select-menu-item js-navigation-item "> - <span class="select-menu-item-icon octicon octicon-check"></span> - <a href="/discourse/discourse/tree/v0.9.5.1/lib/oneboxer/github_blob_onebox.rb" - data-name="v0.9.5.1" - data-skip-pjax="true" - rel="nofollow" - class="js-navigation-open select-menu-item-text js-select-button-text css-truncate-target" - title="v0.9.5.1">v0.9.5.1</a> - </div> <!-- /.select-menu-item --> - <div class="select-menu-item js-navigation-item "> - <span class="select-menu-item-icon octicon octicon-check"></span> - <a href="/discourse/discourse/tree/v0.9.5/lib/oneboxer/github_blob_onebox.rb" - data-name="v0.9.5" - data-skip-pjax="true" - rel="nofollow" - class="js-navigation-open select-menu-item-text js-select-button-text css-truncate-target" - title="v0.9.5">v0.9.5</a> - </div> <!-- /.select-menu-item --> - <div class="select-menu-item js-navigation-item "> - <span class="select-menu-item-icon octicon octicon-check"></span> - <a href="/discourse/discourse/tree/v0.9.4/lib/oneboxer/github_blob_onebox.rb" - data-name="v0.9.4" - data-skip-pjax="true" - rel="nofollow" - class="js-navigation-open select-menu-item-text js-select-button-text css-truncate-target" - title="v0.9.4">v0.9.4</a> - </div> <!-- /.select-menu-item --> - <div class="select-menu-item js-navigation-item "> - <span class="select-menu-item-icon octicon octicon-check"></span> - <a href="/discourse/discourse/tree/v0.9.3.5/lib/oneboxer/github_blob_onebox.rb" - data-name="v0.9.3.5" - data-skip-pjax="true" - rel="nofollow" - class="js-navigation-open select-menu-item-text js-select-button-text css-truncate-target" - title="v0.9.3.5">v0.9.3.5</a> - </div> <!-- /.select-menu-item --> - <div class="select-menu-item js-navigation-item "> - <span class="select-menu-item-icon octicon octicon-check"></span> - <a href="/discourse/discourse/tree/v0.9.3/lib/oneboxer/github_blob_onebox.rb" - data-name="v0.9.3" - data-skip-pjax="true" - rel="nofollow" - class="js-navigation-open select-menu-item-text js-select-button-text css-truncate-target" - title="v0.9.3">v0.9.3</a> - </div> <!-- /.select-menu-item --> - <div class="select-menu-item js-navigation-item "> - <span class="select-menu-item-icon octicon octicon-check"></span> - <a href="/discourse/discourse/tree/v0.9.2.6/lib/oneboxer/github_blob_onebox.rb" - data-name="v0.9.2.6" - data-skip-pjax="true" - rel="nofollow" - class="js-navigation-open select-menu-item-text js-select-button-text css-truncate-target" - title="v0.9.2.6">v0.9.2.6</a> - </div> <!-- /.select-menu-item --> - <div class="select-menu-item js-navigation-item "> - <span class="select-menu-item-icon octicon octicon-check"></span> - <a href="/discourse/discourse/tree/v0.9.2.5/lib/oneboxer/github_blob_onebox.rb" - data-name="v0.9.2.5" - data-skip-pjax="true" - rel="nofollow" - class="js-navigation-open select-menu-item-text js-select-button-text css-truncate-target" - title="v0.9.2.5">v0.9.2.5</a> - </div> <!-- /.select-menu-item --> - <div class="select-menu-item js-navigation-item "> - <span class="select-menu-item-icon octicon octicon-check"></span> - <a href="/discourse/discourse/tree/v0.9.2/lib/oneboxer/github_blob_onebox.rb" - data-name="v0.9.2" - data-skip-pjax="true" - rel="nofollow" - class="js-navigation-open select-menu-item-text js-select-button-text css-truncate-target" - title="v0.9.2">v0.9.2</a> - </div> <!-- /.select-menu-item --> - <div class="select-menu-item js-navigation-item "> - <span class="select-menu-item-icon octicon octicon-check"></span> - <a href="/discourse/discourse/tree/v0.9.1/lib/oneboxer/github_blob_onebox.rb" - data-name="v0.9.1" - data-skip-pjax="true" - rel="nofollow" - class="js-navigation-open select-menu-item-text js-select-button-text css-truncate-target" - title="v0.9.1">v0.9.1</a> - </div> <!-- /.select-menu-item --> - <div class="select-menu-item js-navigation-item "> - <span class="select-menu-item-icon octicon octicon-check"></span> - <a href="/discourse/discourse/tree/v0.9.0/lib/oneboxer/github_blob_onebox.rb" - data-name="v0.9.0" - data-skip-pjax="true" - rel="nofollow" - class="js-navigation-open select-menu-item-text js-select-button-text css-truncate-target" - title="v0.9.0">v0.9.0</a> - </div> <!-- /.select-menu-item --> - <div class="select-menu-item js-navigation-item "> - <span class="select-menu-item-icon octicon octicon-check"></span> - <a href="/discourse/discourse/tree/v0.8.9/lib/oneboxer/github_blob_onebox.rb" - data-name="v0.8.9" - data-skip-pjax="true" - rel="nofollow" - class="js-navigation-open select-menu-item-text js-select-button-text css-truncate-target" - title="v0.8.9">v0.8.9</a> - </div> <!-- /.select-menu-item --> - <div class="select-menu-item js-navigation-item "> - <span class="select-menu-item-icon octicon octicon-check"></span> - <a href="/discourse/discourse/tree/v0.8.8/lib/oneboxer/github_blob_onebox.rb" - data-name="v0.8.8" - data-skip-pjax="true" - rel="nofollow" - class="js-navigation-open select-menu-item-text js-select-button-text css-truncate-target" - title="v0.8.8">v0.8.8</a> - </div> <!-- /.select-menu-item --> - <div class="select-menu-item js-navigation-item "> - <span class="select-menu-item-icon octicon octicon-check"></span> - <a href="/discourse/discourse/tree/v0.8.7/lib/oneboxer/github_blob_onebox.rb" - data-name="v0.8.7" - data-skip-pjax="true" - rel="nofollow" - class="js-navigation-open select-menu-item-text js-select-button-text css-truncate-target" - title="v0.8.7">v0.8.7</a> - </div> <!-- /.select-menu-item --> - <div class="select-menu-item js-navigation-item "> - <span class="select-menu-item-icon octicon octicon-check"></span> - <a href="/discourse/discourse/tree/v0.8.6/lib/oneboxer/github_blob_onebox.rb" - data-name="v0.8.6" - data-skip-pjax="true" - rel="nofollow" - class="js-navigation-open select-menu-item-text js-select-button-text css-truncate-target" - title="v0.8.6">v0.8.6</a> - </div> <!-- /.select-menu-item --> - <div class="select-menu-item js-navigation-item "> - <span class="select-menu-item-icon octicon octicon-check"></span> - <a href="/discourse/discourse/tree/v0.8.5/lib/oneboxer/github_blob_onebox.rb" - data-name="v0.8.5" - data-skip-pjax="true" - rel="nofollow" - class="js-navigation-open select-menu-item-text js-select-button-text css-truncate-target" - title="v0.8.5">v0.8.5</a> - </div> <!-- /.select-menu-item --> - <div class="select-menu-item js-navigation-item "> - <span class="select-menu-item-icon octicon octicon-check"></span> - <a href="/discourse/discourse/tree/v0.8.4/lib/oneboxer/github_blob_onebox.rb" - data-name="v0.8.4" - data-skip-pjax="true" - rel="nofollow" - class="js-navigation-open select-menu-item-text js-select-button-text css-truncate-target" - title="v0.8.4">v0.8.4</a> - </div> <!-- /.select-menu-item --> - <div class="select-menu-item js-navigation-item "> - <span class="select-menu-item-icon octicon octicon-check"></span> - <a href="/discourse/discourse/tree/v0.8.3/lib/oneboxer/github_blob_onebox.rb" - data-name="v0.8.3" - data-skip-pjax="true" - rel="nofollow" - class="js-navigation-open select-menu-item-text js-select-button-text css-truncate-target" - title="v0.8.3">v0.8.3</a> - </div> <!-- /.select-menu-item --> - <div class="select-menu-item js-navigation-item "> - <span class="select-menu-item-icon octicon octicon-check"></span> - <a href="/discourse/discourse/tree/v0.8.2/lib/oneboxer/github_blob_onebox.rb" - data-name="v0.8.2" - data-skip-pjax="true" - rel="nofollow" - class="js-navigation-open select-menu-item-text js-select-button-text css-truncate-target" - title="v0.8.2">v0.8.2</a> - </div> <!-- /.select-menu-item --> - <div class="select-menu-item js-navigation-item "> - <span class="select-menu-item-icon octicon octicon-check"></span> - <a href="/discourse/discourse/tree/v0.8.1/lib/oneboxer/github_blob_onebox.rb" - data-name="v0.8.1" - data-skip-pjax="true" - rel="nofollow" - class="js-navigation-open select-menu-item-text js-select-button-text css-truncate-target" - title="v0.8.1">v0.8.1</a> - </div> <!-- /.select-menu-item --> - <div class="select-menu-item js-navigation-item "> - <span class="select-menu-item-icon octicon octicon-check"></span> - <a href="/discourse/discourse/tree/v0.8.0/lib/oneboxer/github_blob_onebox.rb" - data-name="v0.8.0" - data-skip-pjax="true" - rel="nofollow" - class="js-navigation-open select-menu-item-text js-select-button-text css-truncate-target" - title="v0.8.0">v0.8.0</a> - </div> <!-- /.select-menu-item --> - <div class="select-menu-item js-navigation-item "> - <span class="select-menu-item-icon octicon octicon-check"></span> - <a href="/discourse/discourse/tree/latest-release/lib/oneboxer/github_blob_onebox.rb" - data-name="latest-release" - data-skip-pjax="true" - rel="nofollow" - class="js-navigation-open select-menu-item-text js-select-button-text css-truncate-target" - title="latest-release">latest-release</a> - </div> <!-- /.select-menu-item --> - </div> - - <div class="select-menu-no-results">Nothing to show</div> - </div> <!-- /.select-menu-list --> - - </div> <!-- /.select-menu-modal --> - </div> <!-- /.select-menu-modal-holder --> -</div> <!-- /.select-menu --> - - <div class="breadcrumb"> - <span class='repo-root js-repo-root'><span itemscope="" itemtype="http://data-vocabulary.org/Breadcrumb"><a href="/discourse/discourse" data-branch="master" data-direction="back" data-pjax="true" itemscope="url"><span itemprop="title">discourse</span></a></span></span><span class="separator"> / </span><span itemscope="" itemtype="http://data-vocabulary.org/Breadcrumb"><a href="/discourse/discourse/tree/master/lib" data-branch="master" data-direction="back" data-pjax="true" itemscope="url"><span itemprop="title">lib</span></a></span><span class="separator"> / </span><span itemscope="" itemtype="http://data-vocabulary.org/Breadcrumb"><a href="/discourse/discourse/tree/master/lib/oneboxer" data-branch="master" data-direction="back" data-pjax="true" itemscope="url"><span itemprop="title">oneboxer</span></a></span><span class="separator"> / </span><strong class="final-path">github_blob_onebox.rb</strong> <span class="js-zeroclipboard minibutton zeroclipboard-button" data-clipboard-text="lib/oneboxer/github_blob_onebox.rb" data-copied-hint="copied!" title="copy to clipboard"><span class="octicon octicon-clippy"></span></span> - </div> -</div> - - - - <div class="commit file-history-tease"> - <img class="main-avatar" height="24" src="https://2.gravatar.com/avatar/c6e17f2ae2a215e87ff9e878a4e63cd9?d=https%3A%2F%2Fidenticons.github.com%2Fba01baa4856d494a66a0d5eca39f5418.png&amp;s=140" width="24" /> - <span class="author"><a href="/eviltrout" rel="author">eviltrout</a></span> - <time class="js-relative-date" datetime="2013-02-26T07:42:49-08:00" title="2013-02-26 07:42:49">February 26, 2013</time> - <div class="commit-title"> - <a href="/discourse/discourse/commit/1221c393a37177658b8103699cc71e05bd5345a1" class="message" data-pjax="true" title="Merge branch &#39;whitespace-cleanese&#39; of git://github.com/goshakkk/discours... - -...e - -Conflicts: - lib/oneboxer.rb - lib/oneboxer/whitelist.rb - spec/controllers/robots_txt_controller_spec.rb">Merge branch 'whitespace-cleanese' of git://github.com/goshakkk/disco…</a> - </div> - - <div class="participation"> - <p class="quickstat"><a href="#blob_contributors_box" rel="facebox"><strong>3</strong> contributors</a></p> - <a class="avatar tooltipped downwards" title="eviltrout" href="/discourse/discourse/commits/master/lib/oneboxer/github_blob_onebox.rb?author=eviltrout"><img height="20" src="https://2.gravatar.com/avatar/c6e17f2ae2a215e87ff9e878a4e63cd9?d=https%3A%2F%2Fidenticons.github.com%2Fba01baa4856d494a66a0d5eca39f5418.png&amp;s=140" width="20" /></a> - <a class="avatar tooltipped downwards" title="jeremybanks" href="/discourse/discourse/commits/master/lib/oneboxer/github_blob_onebox.rb?author=jeremybanks"><img height="20" src="https://0.gravatar.com/avatar/bd192f0a40308fe9ecb9aa2a72ee8d81?d=https%3A%2F%2Fidenticons.github.com%2F540cfc2804c3f507c28c8942f1e90343.png&amp;s=140" width="20" /></a> - <a class="avatar tooltipped downwards" title="goshakkk" href="/discourse/discourse/commits/master/lib/oneboxer/github_blob_onebox.rb?author=goshakkk"><img height="20" src="https://0.gravatar.com/avatar/477dc65c2083c0aea87485b399372db0?d=https%3A%2F%2Fidenticons.github.com%2F8e6fe8f267d3b31fe2e5b5da1787a120.png&amp;s=140" width="20" /></a> - - - </div> - <div id="blob_contributors_box" style="display:none"> - <h2 class="facebox-header">Users who have contributed to this file</h2> - <ul class="facebox-user-list"> - <li class="facebox-user-list-item"> - <img height="24" src="https://2.gravatar.com/avatar/c6e17f2ae2a215e87ff9e878a4e63cd9?d=https%3A%2F%2Fidenticons.github.com%2Fba01baa4856d494a66a0d5eca39f5418.png&amp;s=140" width="24" /> - <a href="/eviltrout">eviltrout</a> - </li> - <li class="facebox-user-list-item"> - <img height="24" src="https://0.gravatar.com/avatar/bd192f0a40308fe9ecb9aa2a72ee8d81?d=https%3A%2F%2Fidenticons.github.com%2F540cfc2804c3f507c28c8942f1e90343.png&amp;s=140" width="24" /> - <a href="/jeremybanks">jeremybanks</a> - </li> - <li class="facebox-user-list-item"> - <img height="24" src="https://0.gravatar.com/avatar/477dc65c2083c0aea87485b399372db0?d=https%3A%2F%2Fidenticons.github.com%2F8e6fe8f267d3b31fe2e5b5da1787a120.png&amp;s=140" width="24" /> - <a href="/goshakkk">goshakkk</a> - </li> - </ul> - </div> - </div> - -<div id="files" class="bubble"> - <div class="file"> - <div class="meta"> - <div class="info"> - <span class="icon"><b class="octicon octicon-file-text"></b></span> - <span class="mode" title="File Mode">file</span> - <span>50 lines (40 sloc)</span> - <span>1.262 kb</span> - </div> - <div class="actions"> - <div class="button-group"> - <a class="minibutton disabled js-entice" href="" - data-entice="You must be signed in to make or propose changes">Edit</a> - <a href="/discourse/discourse/raw/master/lib/oneboxer/github_blob_onebox.rb" class="button minibutton " id="raw-url">Raw</a> - <a href="/discourse/discourse/blame/master/lib/oneboxer/github_blob_onebox.rb" class="button minibutton ">Blame</a> - <a href="/discourse/discourse/commits/master/lib/oneboxer/github_blob_onebox.rb" class="button minibutton " rel="nofollow">History</a> - </div><!-- /.button-group --> - <a class="minibutton danger empty-icon js-entice" href="" - data-entice="You must be signed in and on a branch to make or propose changes"> - Delete - </a> - </div><!-- /.actions --> - - </div> - <div class="blob-wrapper data type-ruby js-blob-data"> - <table class="file-code file-diff"> - <tr class="file-code-line"> - <td class="blob-line-nums"> - <span id="L1" rel="#L1">1</span> -<span id="L2" rel="#L2">2</span> -<span id="L3" rel="#L3">3</span> -<span id="L4" rel="#L4">4</span> -<span id="L5" rel="#L5">5</span> -<span id="L6" rel="#L6">6</span> -<span id="L7" rel="#L7">7</span> -<span id="L8" rel="#L8">8</span> -<span id="L9" rel="#L9">9</span> -<span id="L10" rel="#L10">10</span> -<span id="L11" rel="#L11">11</span> -<span id="L12" rel="#L12">12</span> -<span id="L13" rel="#L13">13</span> -<span id="L14" rel="#L14">14</span> -<span id="L15" rel="#L15">15</span> -<span id="L16" rel="#L16">16</span> -<span id="L17" rel="#L17">17</span> -<span id="L18" rel="#L18">18</span> -<span id="L19" rel="#L19">19</span> -<span id="L20" rel="#L20">20</span> -<span id="L21" rel="#L21">21</span> -<span id="L22" rel="#L22">22</span> -<span id="L23" rel="#L23">23</span> -<span id="L24" rel="#L24">24</span> -<span id="L25" rel="#L25">25</span> -<span id="L26" rel="#L26">26</span> -<span id="L27" rel="#L27">27</span> -<span id="L28" rel="#L28">28</span> -<span id="L29" rel="#L29">29</span> -<span id="L30" rel="#L30">30</span> -<span id="L31" rel="#L31">31</span> -<span id="L32" rel="#L32">32</span> -<span id="L33" rel="#L33">33</span> -<span id="L34" rel="#L34">34</span> -<span id="L35" rel="#L35">35</span> -<span id="L36" rel="#L36">36</span> -<span id="L37" rel="#L37">37</span> -<span id="L38" rel="#L38">38</span> -<span id="L39" rel="#L39">39</span> -<span id="L40" rel="#L40">40</span> -<span id="L41" rel="#L41">41</span> -<span id="L42" rel="#L42">42</span> -<span id="L43" rel="#L43">43</span> -<span id="L44" rel="#L44">44</span> -<span id="L45" rel="#L45">45</span> -<span id="L46" rel="#L46">46</span> -<span id="L47" rel="#L47">47</span> -<span id="L48" rel="#L48">48</span> -<span id="L49" rel="#L49">49</span> - - </td> - <td class="blob-line-code"> - <div class="highlight"><pre><div class='line' id='LC1'><span class="n">require_dependency</span> <span class="s1">&#39;oneboxer/handlebars_onebox&#39;</span></div><div class='line' id='LC2'><br/></div><div class='line' id='LC3'><span class="k">module</span> <span class="nn">Oneboxer</span></div><div class='line' id='LC4'>&nbsp;&nbsp;<span class="k">class</span> <span class="nc">GithubBlobOnebox</span> <span class="o">&lt;</span> <span class="no">HandlebarsOnebox</span></div><div class='line' id='LC5'><br/></div><div class='line' id='LC6'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">matcher</span> <span class="sr">/^https?:\/\/(?:www\.)?github\.com\/[^\/]+\/[^\/]+\/blob\/.*/</span></div><div class='line' id='LC7'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">favicon</span> <span class="s1">&#39;github.png&#39;</span></div><div class='line' id='LC8'><br/></div><div class='line' id='LC9'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">def</span> <span class="nf">translate_url</span></div><div class='line' id='LC10'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">m</span> <span class="o">=</span> <span class="vi">@url</span><span class="o">.</span><span class="n">match</span><span class="p">(</span><span class="sr">/github\.com\/(?&lt;user&gt;[^\/]+)\/(?&lt;repo&gt;[^\/]+)\/blob\/(?&lt;sha1&gt;[^\/]+)\/(?&lt;file&gt;[^#]+)(#(L(?&lt;from&gt;[^-]*)(-L(?&lt;to&gt;.*))?))?/mi</span><span class="p">)</span></div><div class='line' id='LC11'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">if</span> <span class="n">m</span></div><div class='line' id='LC12'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="vi">@from</span> <span class="o">=</span> <span class="p">(</span><span class="n">m</span><span class="o">[</span><span class="ss">:from</span><span class="o">]</span> <span class="o">||</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span><span class="o">.</span><span class="n">to_i</span></div><div class='line' id='LC13'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="vi">@to</span> <span class="o">=</span> <span class="p">(</span><span class="n">m</span><span class="o">[</span><span class="ss">:to</span><span class="o">]</span> <span class="o">||</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span><span class="o">.</span><span class="n">to_i</span></div><div class='line' id='LC14'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="vi">@file</span> <span class="o">=</span> <span class="n">m</span><span class="o">[</span><span class="ss">:file</span><span class="o">]</span></div><div class='line' id='LC15'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">return</span> <span class="s2">&quot;https://raw.github.com/</span><span class="si">#{</span><span class="n">m</span><span class="o">[</span><span class="ss">:user</span><span class="o">]</span><span class="si">}</span><span class="s2">/</span><span class="si">#{</span><span class="n">m</span><span class="o">[</span><span class="ss">:repo</span><span class="o">]</span><span class="si">}</span><span class="s2">/</span><span class="si">#{</span><span class="n">m</span><span class="o">[</span><span class="ss">:sha1</span><span class="o">]</span><span class="si">}</span><span class="s2">/</span><span class="si">#{</span><span class="n">m</span><span class="o">[</span><span class="ss">:file</span><span class="o">]</span><span class="si">}</span><span class="s2">&quot;</span></div><div class='line' id='LC16'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">end</span></div><div class='line' id='LC17'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="kp">nil</span></div><div class='line' id='LC18'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">end</span></div><div class='line' id='LC19'><br/></div><div class='line' id='LC20'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">def</span> <span class="nf">parse</span><span class="p">(</span><span class="n">data</span><span class="p">)</span></div><div class='line' id='LC21'><br/></div><div class='line' id='LC22'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">if</span> <span class="vi">@from</span> <span class="o">&gt;</span> <span class="mi">0</span></div><div class='line' id='LC23'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">if</span> <span class="vi">@to</span> <span class="o">&lt;</span> <span class="mi">0</span></div><div class='line' id='LC24'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="vi">@from</span> <span class="o">=</span> <span class="vi">@from</span> <span class="o">-</span> <span class="mi">10</span></div><div class='line' id='LC25'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="vi">@to</span> <span class="o">=</span> <span class="vi">@from</span> <span class="o">+</span> <span class="mi">20</span></div><div class='line' id='LC26'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">end</span></div><div class='line' id='LC27'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">if</span> <span class="vi">@to</span> <span class="o">&gt;</span> <span class="vi">@from</span></div><div class='line' id='LC28'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">data</span> <span class="o">=</span> <span class="n">data</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">&quot;</span><span class="se">\n</span><span class="s2">&quot;</span><span class="p">)</span><span class="o">[</span><span class="vi">@from</span><span class="o">.</span><span class="n">.</span><span class="vi">@to</span><span class="o">].</span><span class="n">join</span><span class="p">(</span><span class="s2">&quot;</span><span class="se">\n</span><span class="s2">&quot;</span><span class="p">)</span></div><div class='line' id='LC29'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">end</span></div><div class='line' id='LC30'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">end</span></div><div class='line' id='LC31'><br/></div><div class='line' id='LC32'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">extension</span> <span class="o">=</span> <span class="vi">@file</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">&quot;.&quot;</span><span class="p">)</span><span class="o">[-</span><span class="mi">1</span><span class="o">]</span></div><div class='line' id='LC33'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="vi">@lang</span> <span class="o">=</span> <span class="k">case</span> <span class="n">extension</span></div><div class='line' id='LC34'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">when</span> <span class="s2">&quot;rb&quot;</span> <span class="k">then</span> <span class="s2">&quot;ruby&quot;</span></div><div class='line' id='LC35'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">when</span> <span class="s2">&quot;js&quot;</span> <span class="k">then</span> <span class="s2">&quot;javascript&quot;</span></div><div class='line' id='LC36'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">else</span> <span class="n">extension</span></div><div class='line' id='LC37'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">end</span></div><div class='line' id='LC38'><br/></div><div class='line' id='LC39'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">truncated</span> <span class="o">=</span> <span class="kp">false</span></div><div class='line' id='LC40'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">if</span> <span class="n">data</span><span class="o">.</span><span class="n">length</span> <span class="o">&gt;</span> <span class="no">SiteSetting</span><span class="o">.</span><span class="n">onebox_max_chars</span></div><div class='line' id='LC41'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">data</span> <span class="o">=</span> <span class="n">data</span><span class="o">[</span><span class="mi">0</span><span class="o">.</span><span class="n">.</span><span class="no">SiteSetting</span><span class="o">.</span><span class="n">onebox_max_chars</span><span class="o">-</span><span class="mi">1</span><span class="o">]</span></div><div class='line' id='LC42'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">truncated</span> <span class="o">=</span> <span class="kp">true</span></div><div class='line' id='LC43'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">end</span></div><div class='line' id='LC44'><br/></div><div class='line' id='LC45'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="p">{</span><span class="ss">content</span><span class="p">:</span> <span class="n">data</span><span class="p">,</span> <span class="ss">truncated</span><span class="p">:</span> <span class="n">truncated</span><span class="p">}</span></div><div class='line' id='LC46'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">end</span></div><div class='line' id='LC47'><br/></div><div class='line' id='LC48'>&nbsp;&nbsp;<span class="k">end</span></div><div class='line' id='LC49'><span class="k">end</span></div></pre></div> - </td> - </tr> - </table> - </div> - - </div> -</div> - -<a href="#jump-to-line" rel="facebox[.linejump]" data-hotkey="l" class="js-jump-to-line" style="display:none">Jump to Line</a> -<div id="jump-to-line" style="display:none"> - <form accept-charset="UTF-8" class="js-jump-to-line-form"> - <input class="linejump-input js-jump-to-line-field" type="text" placeholder="Jump to line&hellip;" autofocus> - <button type="submit" class="button">Go</button> - </form> -</div> - - </div> - - </div><!-- /.repo-container --> - <div class="modal-backdrop"></div> - </div><!-- /.container --> - </div><!-- /.site --> - - - </div><!-- /.wrapper --> - - <div class="container"> - <div class="site-footer"> - <ul class="site-footer-links right"> - <li><a href="https://status.github.com/">Status</a></li> - <li><a href="http://developer.github.com">API</a></li> - <li><a href="http://training.github.com">Training</a></li> - <li><a href="http://shop.github.com">Shop</a></li> - <li><a href="/blog">Blog</a></li> - <li><a href="/about">About</a></li> - - </ul> - - <a href="/"> - <span class="mega-octicon octicon-mark-github"></span> - </a> - - <ul class="site-footer-links"> - <li>&copy; 2013 <span title="0.02166s from github-fe121-cp1-prd.iad.github.net">GitHub</span>, Inc.</li> - <li><a href="/site/terms">Terms</a></li> - <li><a href="/site/privacy">Privacy</a></li> - <li><a href="/security">Security</a></li> - <li><a href="/contact">Contact</a></li> - </ul> - </div><!-- /.site-footer --> -</div><!-- /.container --> - - - <div class="fullscreen-overlay js-fullscreen-overlay" id="fullscreen_overlay"> - <div class="fullscreen-container js-fullscreen-container"> - <div class="textarea-wrap"> - <textarea name="fullscreen-contents" id="fullscreen-contents" class="js-fullscreen-contents" placeholder="" data-suggester="fullscreen_suggester"></textarea> - <div class="suggester-container"> - <div class="suggester fullscreen-suggester js-navigation-container" id="fullscreen_suggester" - data-url="/discourse/discourse/suggestions/commit"> - </div> - </div> - </div> - </div> - <div class="fullscreen-sidebar"> - <a href="#" class="exit-fullscreen js-exit-fullscreen tooltipped leftwards" title="Exit Zen Mode"> - <span class="mega-octicon octicon-screen-normal"></span> - </a> - <a href="#" class="theme-switcher js-theme-switcher tooltipped leftwards" - title="Switch themes"> - <span class="octicon octicon-color-mode"></span> - </a> - </div> -</div> - - - - <div id="ajax-error-message" class="flash flash-error"> - <span class="octicon octicon-alert"></span> - <a href="#" class="octicon octicon-remove-close close ajax-error-dismiss"></a> - Something went wrong with that request. Please try again. - </div> - - </body> -</html> + end +end