From ea01136482149d37673ef6da332aeb09c5337c26 Mon Sep 17 00:00:00 2001 From: jrtechs Date: Sat, 16 Jun 2018 19:04:33 -0400 Subject: [PATCH] Added RepoJs to website for an embedded git hub viewer --- website/src/RepoJS/README.md | 37 ++++ website/src/RepoJS/bower.json | 5 + website/src/RepoJS/fonts/repo.eot | Bin 0 -> 1704 bytes website/src/RepoJS/fonts/repo.svg | 18 ++ website/src/RepoJS/fonts/repo.ttf | Bin 0 -> 1540 bytes website/src/RepoJS/fonts/repo.woff | Bin 0 -> 1272 bytes website/src/RepoJS/repo.js | 296 +++++++++++++++++++++++++++++ website/src/RepoJS/repo.min.js | 29 +++ 8 files changed, 385 insertions(+) create mode 100755 website/src/RepoJS/README.md create mode 100755 website/src/RepoJS/bower.json create mode 100755 website/src/RepoJS/fonts/repo.eot create mode 100755 website/src/RepoJS/fonts/repo.svg create mode 100755 website/src/RepoJS/fonts/repo.ttf create mode 100755 website/src/RepoJS/fonts/repo.woff create mode 100755 website/src/RepoJS/repo.js create mode 100755 website/src/RepoJS/repo.min.js diff --git a/website/src/RepoJS/README.md b/website/src/RepoJS/README.md new file mode 100755 index 0000000..8b91d20 --- /dev/null +++ b/website/src/RepoJS/README.md @@ -0,0 +1,37 @@ +Repo.js +======= + +[![Build Status](http://img.shields.io/travis/darcyclarke/Repo.js.svg?style=flat-square)](https://travis-ci.org/darcyclarke/Repo.js) +[![Dependency Status](https://david-dm.org/darcyclarke/repo.js/badges.svg?style=flat-square)](https://david-dm.org/darcyclarke/repo.js/badges) +[![devDependency Status](https://david-dm.org/darcyclarke/repo.js/badges/dev-status.svg?style=flat-square)](https://david-dm.org/darcyclarke/repo.js/badges#info=devDependencies) +[![Code Climate](http://img.shields.io/codeclimate/github/darcyclarke/Repo.js.svg?style=flat-square)](https://codeclimate.com/github/darcyclarke/Repo.js) +[![npm](https://img.shields.io/npm/v/repo.js.svg?maxAge=2592000&style=flat-square)](https://www.npmjs.com/package/repo.js) +[![npm](https://img.shields.io/npm/dt/repo.js.svg?maxAge=2592000&style=flat-square)](https://www.npmjs.com/package/repo.js) +[![License](http://img.shields.io/:license-mit-blue.svg?style=flat-square)](http://darcyclarke.mit-license.org) +[![Join the chat at https://gitter.im/darcyclarke/Repo.js](http://img.shields.io/:Gitter-Join Chat-orange.svg?style=flat-square)](https://gitter.im/darcyclarke/Repo.js) + +Repo.js is a jQuery plugin that lets you easily embed a Github repo onto your site. This is great for other plugin or library authors that want to showcase the contents of a repo on their project pages. + +Repo.js uses [Markus Ekwall](https://twitter.com/#!/mekwall)'s [jQuery Vangogh](https://github.com/mekwall/jquery-vangogh) plugin for styling of file contents. Vangogh, subsequently, utilizes [highlight.js](https://github.com/isagalaev/highlight.js), written by [Ivan Sagalaev](https://github.com/isagalaev) for syntax highlighting. + +##Example Usage + +```javascript +$('body').repo({ user: 'darcyclarke', name: 'Repo.js' }); +```` + +You can also reference a specific branch if you want: + +```javascript +$('body').repo({ user: 'jquery', name: 'jquery', branch: 'strip_iife' }); +```` + +##License + +Copyright (c) 2016 Darcy Clarke + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/website/src/RepoJS/bower.json b/website/src/RepoJS/bower.json new file mode 100755 index 0000000..c9b7f01 --- /dev/null +++ b/website/src/RepoJS/bower.json @@ -0,0 +1,5 @@ +{ + "name": "Repo.js", + "version": "1.0", + "main": "repo.js" +} diff --git a/website/src/RepoJS/fonts/repo.eot b/website/src/RepoJS/fonts/repo.eot new file mode 100755 index 0000000000000000000000000000000000000000..2d33e2e0c597ce185e10b71b46f38e6ca81457d6 GIT binary patch literal 1704 zcmd5+J#SM<6g~4koVOT)y@?%zf_M%HvdhNn4~Y0GTm%DJ5LSq?t56Wjv7M}9Kg)4e zK_G#E0y!B0SgY#K~m0WvKi(Yd_pfRM*aU)+$`*%Rq>xi5V$=1_!#DnAD`4)kIiB~-A8 zc@)qf6U8K%1{UZmeQczVKvMZ`o=s8)u!DQ*$mens=ZjBE6M*?Y*}>Cer*g=ECoo^r zwl7@#HJy*Y-^)pV(4H(-3-x~+u|H{ZTufC83w77!N-$q=+^Wo9DgW|nX$8;^(|$W! zD$INu8~um)J-^Xe5=O}Vk8}HJ@1LzUmjX{1FvK(3v3aLhz)ehX{(joM)xuI8zws~- zM`_!&LbX(zc(=wZ8{}@)orUJZkLQ^;^A5*H)!BHyPGpaBdFRPB1id=E`SEI)FEE-Oto!Btx@VTp61O#8IouVEK% zZ@dfAcfI^H^5s)A$fCUJ$H3U^8|x9sjZ}N$ZA#nr85xQE22~uu1T7i&APmTSZBr+d z3zX4Z1uG@nI(8qpt&r)@RYTmAweKFC2lBS`$5huH+{k?s_R`p$%5r{>Z8z`YECW+T zV11XF;cY;?FRu6L;mklLB9^B+)6>~(EBjW!g|Itqv7F6vjt<*x3;xiD-T0Y#J(v)O z#84m-?vG~T>Cq$M!v}hz1N)9d2m1Q=#fNC05b1$PCK?eh&jf!8t%hQ;kf?`Z;UP^Q z*Yzo@)3U5p!?-TQwKKtREY!&>mt=T2sMAC1T(T_j%o5l6K3FOLrZf7mh-=0A^hcIgZyJ3n+RgX#{u#mZ)i)@KCD=$S>9cX1_-pa= zxMLWhJdV&W$v(qHoLV#IG%6)Kok-fpZGTsyVr@}Xx8HrWs-`P< Los@LgsDYmWN5|CV literal 0 HcmV?d00001 diff --git a/website/src/RepoJS/fonts/repo.svg b/website/src/RepoJS/fonts/repo.svg new file mode 100755 index 0000000..b67e13b --- /dev/null +++ b/website/src/RepoJS/fonts/repo.svg @@ -0,0 +1,18 @@ + + + + +This is a custom SVG font generated by IcoMoon. + + + + + + + + + + \ No newline at end of file diff --git a/website/src/RepoJS/fonts/repo.ttf b/website/src/RepoJS/fonts/repo.ttf new file mode 100755 index 0000000000000000000000000000000000000000..ce2fa8f921ba21451e882f4e071c8b00a7ef65bc GIT binary patch literal 1540 zcmd5+%WD%s9R6l^ldi_c#x`k`iknt^H|C+m*CB@*6%~t?D)nGPOwvk|4QVPB1w}pR zttY{Q*sC5y{{s(#_8{oNn_xghFG4Rp30c3HjBN$IcyhvIzVG`z<~Of}0I(LfU}7kj z8$MllRvZQb->CK+8$6mr20`*SB(fltIA*$2icSdRadv0da_$19DQ;8VEd&&gwx zULlX$7-jrc@^zK`ObsWIp#1>3Tg_LB)#3MxfMrp;Q}d=8kH4R8asGR>4?wPsy%pK) zU0Q!+5g~&D@OH!X@bc(44TvVWjka0Eh^F5}LJBP@%SzQpL#3makws~NRmmDyn|o`i0y&XtPur7{yIPU? zWbaXR0K;Um?jBf>`?XrFP$np$u>hWwY)jaG7lxP2I>0D5IN^MiaFXKw> zpYZZ#$Z#I#|JXM1E{?M>bqGA)IqvXkAl?}_JI!#WI};IeW392VY<4#LPQZt7TTL;S z%`(P>>o)~|=)@-M;=XQAh~1($7zuYpGx7Am{_wtS9ntQ-{n75uuD*CL`C*anj%1<{ z@#=VJr?cS1VveXev2d?po;A%;yESXu3zl_Lh#SX4;h57JQZC8xj*v+Yqjk}?#dBNS z6^~#!y<0*Vv8oc)bt0EcGM`lWl6e`4Gg1r13lJKVAP!%tfTDsV zh>Q-EA|gU1h+xGENVEkn1!JpIC?F09PC!Tmixd!xL`}L>rvLPvdFJ-{-R`^Z?#+8? zB7s08k%$05-U14MfsO#e{PX|87YJAY5Xex!0YG#te^lZn5J+~x@nbmK32IgJ4Vfe; zAW#6=B=ig@7T^Fxw8zaI01^%Q5GYK{AMlM#f0hY+$}=$TNi2+eAgE0UFvy@h^0Ck=)BD5Of54}tXoXrT}>NRTRIkj>BOhkKk% zkaWIDJd~6S**IiWC>9_Apezk6*d@2$O?&V{5t-T~6~>RFls~Jm9Dg_7c*WH+v-BFd zi|!VPc=zTBLw-{1ao((uFBQGddc_$nij>fHsJaTVgyUs9RE`@|tiQ!Ki-Xd-4|mN( zFKInw@_Bt(iu2g|8FhM2P>w&dm`F8iG`~Kw`$kQ1ai%6bC{Nm?_AfnNq0a3ptlv#B zeYzaCp)i}m&)!;Al)bZ?pNmuuyl)e)E97x}n*BJ`rrzz7rgCD~7iF8C$(P6Fzpd>&p=dX zBmc(T`+1j(NG1EPy-jVtZYJsyLM@De9fl`%?p_R)#o}f^)qPr+J(R)CQ%dMTSVxm; zOYrw!53A19oeroqB)6sQD!kZVx3w$8n;iU?Q|II5W9jBOZr}Q2vqPPxSB(0|o>3dw zw1;zx!Nn|ITe2p}7^F@ux))9k2|HGkTwR+FMAdzCp6gw|)m-l0Z05JZ#gVxxX~AXJ zjom|8PhRpzBuLrt?U9$92J;UAvh7<&HZAoYi#t4)LQb-1k`L4{qWf$^1Q*#+Rzk(g z88!T%%F<{I!(zaR!b@|fSmx{EMpixwcwZq8Kfa5>ut8GPB9w+jVTgY$E0*w@4v>R@ zyRbGk3M<9&hq!LEwOEhigG)5`+;_S+u-RDc< zFbT~;%bm1D8&(VgKnJC2p^n%rYy~PnX=K7QU6-*OrLca#kLz$Gn@WwNu3b&HSZ!-h z)LT0&hV?kLhhmc-Ppu|yB~{;Mcis>|}LkwGD zeqBm|-vOc@EzmG3r|}aVZpBB)JX&XBGzX`^KCNTiDMDjK&#JY9b`d5z&$r-g`iR$) zb(EEPN8h{)`+zd%T!)XiGmGi7ZFTz0sto#zE;l_%pRsbO#`^Gr(Pe|^+2ix+&mD(9 zqih_GF!w2OkNtZ7m`_8zYFu*8yWyht^zO;f@}agOPoY8{+TV!v%@sVmG(z5XAXvjQ z)mYypJk2N8)flILjuQ^7{*L3R>ya5v?VktM|KgZpG~Sv0@w~IWZL@)x;n=>hl3(l4 Xa($xRLclzEk^kOFEDnEinE?3*wNUel literal 0 HcmV?d00001 diff --git a/website/src/RepoJS/repo.js b/website/src/RepoJS/repo.js new file mode 100755 index 0000000..ec6a720 --- /dev/null +++ b/website/src/RepoJS/repo.js @@ -0,0 +1,296 @@ +/*! + * @mekwall's .vangogh() for Syntax Highlighting + * + * All code is open source and dual licensed under GPL and MIT. + * Check the individual licenses for more information. + * https://github.com/mekwall/jquery-vangogh/blob/master/GPL-LICENSE.txt + * https://github.com/mekwall/jquery-vangogh/blob/master/MIT-LICENSE.txt + */ +(function($,a,b){var c=1,d=!1,e=!1,f={get:function(b){var c=a.location.hash;if(c.length>0){var d=c.match(new RegExp(b+":{([a-zA-Z0-9,-]*)}"));if(d)return d[1].split(",")}return[]},set:function(b,c){var d=a.location.hash,e,f=b+":{"+c.join(",")+"}",g=d.indexOf(b+":{");if(c.length===0)return this.remove(b);g!==-1?e=d.replace(new RegExp("("+b+":{[a-zA-Z0-9,-]*})"),f):e=d.length>0?d+","+f:f,a.location.hash=e},remove:function(b){a.location.hash=a.location.hash.replace(new RegExp("([,]?"+b+":{[a-zA-Z0-9,-]*}[,]?)"),"")}},g={numberRange:/^([0-9]+)-([0-9]+)$/,pageNumber:/-([0-9]+)$/,multilineBegin:/(?:.[^<]*(?!<\/span>)|)$/ig,multilineEnd:/()?(?:.[^<]*)?(<\/span>)/ig};$.fn.vanGogh=function(h){function n(){if(d||e)setTimeout(n,100);else{k++;if(k>=10)return;if(h.source&&!l){e=!0,$.ajax({url:h.source,crossDomain:!0,dataType:"text",success:function(a){l=a},error:function(a,b){l="ERROR: "+b},complete:function(){e=!1,n()}});return}b=b||a.hljs;if(!b){d=!0,$.getScript(h.autoload,function(){d=!1,n()});return}j.filter("pre,code").each(function(){function r(b,c,e){var h=!1,i=a.find(".vg-line");c&&(a.find(".vg-highlight").removeClass("vg-highlight"),f.remove(d),k=[]),b=$.type(b)==="array"?b:[b],$.each(b,function(b,c){if(k.indexOf(c)<=-1){!isNaN(parseFloat(c,10))&&isFinite(c)&&(c=parseInt(c,10));if($.type(c)==="string"){var e=g.numberRange.exec(c);if(e){var f=e[1],h=e[2],j="";for(var b=f;b<=h;b++)j+=",#"+d+"-"+b,k.push(b);i.filter(j.substring(1)).addClass("vg-highlight")}else a.find(".vg-line:contains("+c+")").each(function(){var a=$(this).addClass("vg-highlight");a.html(a.html().replace(c,''+c+""))}),k.push(c)}else{var l=d+"-"+this,m=i.filter("#"+l);m.length&&(m.addClass("vg-highlight"),k.push(c))}}}),!e&&f.set(d,k)}var a=$(this).addClass("vg-container").attr("id",this.id||"vg-"+c++),d=this.id,e=a.find("code"),i=!1,j=!1,k=[];e.length||(e=a,i=!0),h.source&&l&&e.text(l);var n=e.text();b.highlightBlock(e[0],h.tab);var o=e.html().split("\n"),p="",q="";if(!i){var s={},t=0;$.each(o,function(a,b){var c=a+h.firstLine,e=d+"-"+c,f=b;h.numbers&&(p+=''+c+"");if(s[t]){var i=g.multilineEnd.exec(b);i&&!i[1]?(f=''+f,delete s[t],t--):f=''+f+""}var j=g.multilineBegin.exec(b);j&&(t++,s[t]=j[1]),q+='
'+f+"
"}),q=''+q+"",h.numbers&&(q='
'+p+"
"+q),a.html(q),e=a.find("code"),a.find(".vg-number").click(function(b){var c=$(this),e=c.attr("rel"),h=a.find(e);if(h.hasClass("vg-highlight")){h.removeClass("vg-highlight"),k.splice(k.indexOf(c.text()),1),f.set(d,k),j=!1;return!1}var i=j;j=parseInt(g.pageNumber.exec(e)[1],10),b.shiftKey&&j?r(iv){if(this.scrollLeft0){var y=a.find(".vg-line").height(),z=parseInt(e.css("paddingTop")),A=y*(h.maxLines+1)+z;a.css({minHeight:y+z,maxHeight:A})}h.highlight&&r(h.highlight,!0,!0);var B=f.get(d);B.length&&r(B,!1,!0)})}}function m(b){var c=a,d=a.document;if(d.body.createTextRange){var e=d.body.createTextRange();e.moveToElementText(b),e.select()}else if(d.createRange){var f=c.getSelection(),e=d.createRange();e.selectNodeContents(b),f.removeAllRanges(),f.addRange(e)}}var i={language:"auto",firstLine:1,maxLines:0,numbers:!0,highlight:null,animateGutter:!0,autoload:"http://softwaremaniacs.org/media/soft/highlight/highlight.pack.js",tab:" "};h=$.extend({},i,h);var j=this,k=0,l;n();return j}})(jQuery,this,typeof this.hljs!="undefined"?this.hljs:!1); + +/*! + * Repo.js + * @author Darcy Clarke + * + * Copyright (c) 2012 Darcy Clarke + * Dual licensed under the MIT and GPL licenses. + * http://darcyclarke.me/ + */ + (function($){ + + // Github repo + $.fn.repo = function( options ){ + + // Context and Base64 methods + var _this = this, + keyStr64 = "ABCDEFGHIJKLMNOP" + "QRSTUVWXYZabcdef" + "ghijklmnopqrstuv" + "wxyz0123456789+/" + "=", + encode64 = function(a){a=escape(a);var b="";var c,d,e="";var f,g,h,i="";var j=0;do{c=a.charCodeAt(j++);d=a.charCodeAt(j++);e=a.charCodeAt(j++);f=c>>2;g=(c&3)<<4|d>>4;h=(d&15)<<2|e>>6;i=e&63;if(isNaN(d)){h=i=64}else if(isNaN(e)){i=64}b=b+keyStr64.charAt(f)+keyStr64.charAt(g)+keyStr64.charAt(h)+keyStr64.charAt(i);c=d=e="";f=g=h=i=""}while(j>4;d=(g&15)<<4|h>>2;e=(h&3)<<6|i;b=b+String.fromCharCode(c);if(h!=64){b=b+String.fromCharCode(d)}if(i!=64){b=b+String.fromCharCode(e)}c=d=e="";f=g=h=i=""}while(j').html(_this.settings.css)); + + // Query Github Tree API + $.ajax({ + url: 'https://api.github.com/repos/' + _this.settings.user + '/' + _this.settings.name + '/git/trees/' + _this.settings.branch + '?recursive=1', + type: 'GET', + data: {}, + dataType: 'jsonp', + success: function(response){ + + var treeLength = response.data.tree.length; + $.each(response.data.tree, function(i){ + + // Setup if last element + if(!--treeLength){ + _this.container.addClass('loaded'); + // Add 10ms timeout here as some browsers require a bit of time before calculating height. + setTimeout( function(){ + transition(_this.container.find('.page').first(), 'left', true); + }, 10 ); + } + + // Return if data is not a file + if(this.type != 'blob') + return; + + // Setup defaults + var first = _this.container.find('.page').first() + ctx = _this.repo, + output = first, + path = this.path, + arr = path.split('/'), + file = arr[(arr.length - 1)], + id = ''; + + // Remove file from array + arr = arr.slice(0,-1); + id = _this.namespace; + + // Loop through folders + $.each(arr, function(i){ + + var name = String(this), + index = 0, + exists = false; + + id = id + '_split_' + name.replace('.','_dot_'); + + // Loop through folders and check names + $.each(ctx.folders, function(i){ + if(this.name == name){ + index = i; + exists = true; + } + }); + + // Create folder if it doesn't exist + if(!exists){ + + // Append folder to DOM + if(output !== first){ + output.find('ul li.back').after($('
  • ' + name +'
  • ')); + } else { + output.find('ul li').first().after($('
  • ' + name +'
  • ')); + } + + // Add folder to repo object + ctx.folders.push({ + name : name, + folders : [], + files : [], + element : $('
    ').appendTo(_this.container)[0] + }); + index = ctx.folders.length-1; + + } + + // Change context & output to the proper folder + output = $(ctx.folders[index].element); + ctx = ctx.folders[index]; + + }); + + // Append file to DOM + output.find('ul').append($('
  • ' + file +'
  • ')); + + // Add file to the repo object + ctx.files.push(file); + + }); + + // Bind to page links + _this.container.on('click', 'a', function(e){ + + e.preventDefault(); + + var link = $(this), + parent = link.parents('li'), + page = link.parents('.page'), + repo = link.parents('.repo'), + el = $('#' + link.data('id')); + + // Is link a file + if(parent.hasClass('file')){ + + el = $('#' + link.data('id')); + + if(el.legnth > 0){ + el.addClass('active'); + } else { + $.ajax({ + url: 'https://api.github.com/repos/' + _this.settings.user + '/' + _this.settings.name + '/contents/' + link.data('path') + '?ref=' + _this.settings.branch, + type: 'GET', + data: {}, + dataType: 'jsonp', + success: function(response){ + var fileContainer = $('
    '), + extension = response.data.name.split('.').pop().toLowerCase(), + mimeType = getMimeTypeByExtension(extension); + + if('image' === mimeType.split('/').shift()){ + el = fileContainer.append($('
    ')).appendTo(repo); + el.find('img') + .attr('src', 'data:' + mimeType + ';base64,' + response.data.content) + .attr('alt', response.data.name); + } + else { + el = fileContainer.append($('
    ')).appendTo(repo); + if(typeof _this.extensions[extension] != 'undefined') + el.find('code').addClass(_this.extensions[extension]); + el.find('code').html(String(decode64(response.data.content)).replace(/&/g, '&').replace(//g, '>').replace(/"/g, '"')); + el.find('pre').vanGogh(); + } + + transition(el, 'left'); + }, + error: function(response){ + if(console && console.log) + console.log('Request Error:', e); + } + }); + } + + // Is link a folder + } else if(parent.hasClass('dir')) { + + _this.container + .find('h1') + .find('.active') + .removeClass('active') + .end() + .append('' + link.text() + ''); + transition(el, 'left'); + + // Is link a back link + } else if(parent.hasClass('back')){ + + _this.container.find('h1 a').last().remove(); + el = page[0].id.split('_split_').slice(0,-1).join('_split_'); + el = (el == _this.namespace) ? _this.container.find('.page').first() : $('#' + el); + transition(el, 'right'); + + // Is nav link + } else { + el = el.length ? el : _this.container.find('.page').eq(link.index()); + + if(link[0] !== _this.container.find('h1 a')[0]) + link.addClass('active'); + _this.container.find('h1 a').slice((link.index()+1),_this.container.find('h1 a').length).remove(); + transition(el, 'right'); + } + }); + }, + error : function(response){ + if(console && console.log) + console.log('Request Error:', response); + } + }); + + // Setup repo container + return this.each(function(){ + _this.container = $('').appendTo($(this)); + }); + }; + +})(jQuery); + diff --git a/website/src/RepoJS/repo.min.js b/website/src/RepoJS/repo.min.js new file mode 100755 index 0000000..5a3beb9 --- /dev/null +++ b/website/src/RepoJS/repo.min.js @@ -0,0 +1,29 @@ +/*! + * @mekwall's .vangogh() for Syntax Highlighting + * + * All code is open source and dual licensed under GPL and MIT. + * Check the individual licenses for more information. + * https://github.com/mekwall/jquery-vangogh/blob/master/GPL-LICENSE.txt + * https://github.com/mekwall/jquery-vangogh/blob/master/MIT-LICENSE.txt + */ +(function($,a,b){var c=1,d=!1,e=!1,f={get:function(b){var c=a.location.hash;if(c.length>0){var d=c.match(new RegExp(b+":{([a-zA-Z0-9,-]*)}"));if(d)return d[1].split(",")}return[]},set:function(b,c){var d=a.location.hash,e,f=b+":{"+c.join(",")+"}",g=d.indexOf(b+":{");if(c.length===0)return this.remove(b);g!==-1?e=d.replace(new RegExp("("+b+":{[a-zA-Z0-9,-]*})"),f):e=d.length>0?d+","+f:f,a.location.hash=e},remove:function(b){a.location.hash=a.location.hash.replace(new RegExp("([,]?"+b+":{[a-zA-Z0-9,-]*}[,]?)"),"")}},g={numberRange:/^([0-9]+)-([0-9]+)$/,pageNumber:/-([0-9]+)$/,multilineBegin:/(?:.[^<]*(?!<\/span>)|)$/ig,multilineEnd:/()?(?:.[^<]*)?(<\/span>)/ig};$.fn.vanGogh=function(h){function n(){if(d||e)setTimeout(n,100);else{k++;if(k>=10)return;if(h.source&&!l){e=!0,$.ajax({url:h.source,crossDomain:!0,dataType:"text",success:function(a){l=a},error:function(a,b){l="ERROR: "+b},complete:function(){e=!1,n()}});return}b=b||a.hljs;if(!b){d=!0,$.getScript(h.autoload,function(){d=!1,n()});return}j.filter("pre,code").each(function(){function r(b,c,e){var h=!1,i=a.find(".vg-line");c&&(a.find(".vg-highlight").removeClass("vg-highlight"),f.remove(d),k=[]),b=$.type(b)==="array"?b:[b],$.each(b,function(b,c){if(k.indexOf(c)<=-1){!isNaN(parseFloat(c,10))&&isFinite(c)&&(c=parseInt(c,10));if($.type(c)==="string"){var e=g.numberRange.exec(c);if(e){var f=e[1],h=e[2],j="";for(var b=f;b<=h;b++)j+=",#"+d+"-"+b,k.push(b);i.filter(j.substring(1)).addClass("vg-highlight")}else a.find(".vg-line:contains("+c+")").each(function(){var a=$(this).addClass("vg-highlight");a.html(a.html().replace(c,''+c+""))}),k.push(c)}else{var l=d+"-"+this,m=i.filter("#"+l);m.length&&(m.addClass("vg-highlight"),k.push(c))}}}),!e&&f.set(d,k)}var a=$(this).addClass("vg-container").attr("id",this.id||"vg-"+c++),d=this.id,e=a.find("code"),i=!1,j=!1,k=[];e.length||(e=a,i=!0),h.source&&l&&e.text(l);var n=e.text();b.highlightBlock(e[0],h.tab);var o=e.html().split("\n"),p="",q="";if(!i){var s={},t=0;$.each(o,function(a,b){var c=a+h.firstLine,e=d+"-"+c,f=b;h.numbers&&(p+=''+c+"");if(s[t]){var i=g.multilineEnd.exec(b);i&&!i[1]?(f=''+f,delete s[t],t--):f=''+f+""}var j=g.multilineBegin.exec(b);j&&(t++,s[t]=j[1]),q+='
    '+f+"
    "}),q=''+q+"",h.numbers&&(q='
    '+p+"
    "+q),a.html(q),e=a.find("code"),a.find(".vg-number").click(function(b){var c=$(this),e=c.attr("rel"),h=a.find(e);if(h.hasClass("vg-highlight")){h.removeClass("vg-highlight"),k.splice(k.indexOf(c.text()),1),f.set(d,k),j=!1;return!1}var i=j;j=parseInt(g.pageNumber.exec(e)[1],10),b.shiftKey&&j?r(iv){if(this.scrollLeft0){var y=a.find(".vg-line").height(),z=parseInt(e.css("paddingTop")),A=y*(h.maxLines+1)+z;a.css({minHeight:y+z,maxHeight:A})}h.highlight&&r(h.highlight,!0,!0);var B=f.get(d);B.length&&r(B,!1,!0)})}}function m(b){var c=a,d=a.document;if(d.body.createTextRange){var e=d.body.createTextRange();e.moveToElementText(b),e.select()}else if(d.createRange){var f=c.getSelection(),e=d.createRange();e.selectNodeContents(b),f.removeAllRanges(),f.addRange(e)}}var i={language:"auto",firstLine:1,maxLines:0,numbers:!0,highlight:null,animateGutter:!0,autoload:"http://softwaremaniacs.org/media/soft/highlight/highlight.pack.js",tab:" "};h=$.extend({},i,h);var j=this,k=0,l;n();return j}})(jQuery,this,typeof this.hljs!="undefined"?this.hljs:!1); + +/*! + * Repo.js + * @author Darcy Clarke + * + * Copyright (c) 2012 Darcy Clarke + * Dual licensed under the MIT and GPL licenses. + * http://darcyclarke.me/ + */ +(function(a){a.fn.repo=function(j){var g=this,b="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",i=function(t){t=escape(t);var s="";var r,q,p="";var o,n,m,l="";var k=0;do{r=t.charCodeAt(k++);q=t.charCodeAt(k++);p=t.charCodeAt(k++);o=r>>2;n=(r&3)<<4|q>>4;m=(q&15)<<2|p>>6;l=p&63;if(isNaN(q)){m=l=64}else{if(isNaN(p)){l=64}}s=s+b.charAt(o)+b.charAt(n)+b.charAt(m)+b.charAt(l);r=q=p="";o=n=m=l=""}while(k>4;s=(p&15)<<4|o>>2;r=(o&3)<<6|n;u=u+String.fromCharCode(t);if(o!=64){u=u+String.fromCharCode(s)}if(n!=64){u=u+String.fromCharCode(r)}t=s=r="";q=p=o=n=""}while(m').html(g.settings.css))}a.ajax({url:"https://api.github.com/repos/"+g.settings.user+"/"+g.settings.name+"/git/trees/"+g.settings.branch+"?recursive=1",type:"GET",data:{},dataType:"jsonp",success:function(k){var l=k.data.tree.length; +a.each(k.data.tree,function(m){if(!--l){g.container.addClass("loaded");setTimeout(function(){h(g.container.find(".page").first(),"left",true)},10)}if(this.type!="blob"){return}var n=g.container.find(".page").first();ctx=g.repo,output=n,path=this.path,arr=path.split("/"),file=arr[(arr.length-1)],id="";arr=arr.slice(0,-1);id=g.namespace;a.each(arr,function(q){var p=String(this),o=0,r=false;id=id+"_split_"+p.replace(".","_dot_");a.each(ctx.folders,function(s){if(this.name==p){o=s;r=true}});if(!r){if(output!==n){output.find("ul li.back").after(a('
  • '+p+"
  • ")) +}else{output.find("ul li").first().after(a('
  • '+p+"
  • "))}ctx.folders.push({name:p,folders:[],files:[],element:a('
    ').appendTo(g.container)[0]});o=ctx.folders.length-1}output=a(ctx.folders[o].element);ctx=ctx.folders[o]});output.find("ul").append(a('
  • '+file+"
  • ")); +ctx.files.push(file)});g.container.on("click","a",function(r){r.preventDefault();var p=a(this),o=p.parents("li"),q=p.parents(".page"),m=p.parents(".repo"),n=a("#"+p.data("id"));if(o.hasClass("file")){n=a("#"+p.data("id"));if(n.legnth>0){n.addClass("active")}else{a.ajax({url:"https://api.github.com/repos/"+g.settings.user+"/"+g.settings.name+"/contents/"+p.data("path")+"?ref="+g.settings.branch,type:"GET",data:{},dataType:"jsonp",success:function(t){var s=a('
    '),v=t.data.name.split(".").pop().toLowerCase(),u=e(v); +if("image"===u.split("/").shift()){n=s.append(a('
    ')).appendTo(m);n.find("img").attr("src","data:"+u+";base64,"+t.data.content).attr("alt",t.data.name)}else{n=s.append(a("
    ")).appendTo(m);if(typeof g.extensions[v]!="undefined"){n.find("code").addClass(g.extensions[v])}n.find("code").html(String(c(t.data.content)).replace(/&/g,"&").replace(//g,">").replace(/"/g,"""));n.find("pre").vanGogh() +}h(n,"left")},error:function(s){if(console&&console.log){console.log("Request Error:",r)}}})}}else{if(o.hasClass("dir")){g.container.find("h1").find(".active").removeClass("active").end().append(''+p.text()+"");h(n,"left")}else{if(o.hasClass("back")){g.container.find("h1 a").last().remove();n=q[0].id.split("_split_").slice(0,-1).join("_split_");n=(n==g.namespace)?g.container.find(".page").first():a("#"+n);h(n,"right")}else{n=n.length?n:g.container.find(".page").eq(p.index()); +if(p[0]!==g.container.find("h1 a")[0]){p.addClass("active")}g.container.find("h1 a").slice((p.index()+1),g.container.find("h1 a").length).remove();h(n,"right")}}}})},error:function(k){if(console&&console.log){console.log("Request Error:",k)}}});return this.each(function(){g.container=a('').appendTo(a(this)) +})}})(jQuery);