diff --git a/Contents/Scripts/bundle.min.js b/Contents/Scripts/bundle.min.js index c29d170..9dfaeec 100644 --- a/Contents/Scripts/bundle.min.js +++ b/Contents/Scripts/bundle.min.js @@ -1,4 +1,4 @@ -'use strict';var _createClass=function(){function defineProperties(target,props){for(var i=0;i0){var matchedDefaultMenuItems=this.matchingDefaultMenuItems(input);if(matchedDefaultMenuItems.length>0){return matchedDefaultMenuItems.concat(this.conflictingHandleMenuItem(input));}else{return this.displayMenuItemFor(input);}}else{return this.defaultMenuItems;}}},{key:'matchingDefaultMenuItems',value:function matchingDefaultMenuItems(input){return this.defaultMenuItems.filter(function(item){var regex=new RegExp(input,'i');return item.title.match(regex);});}},{key:'conflictingHandleMenuItem',value:function conflictingHandleMenuItem(handle){return[{title:'@'+handle,subtitle:'Looking for the user @'+handle+'?',alwaysShowsSubtitle:true,icon:'personTemplate.png',action:'openAccountMenu',actionArgument:handle}];}},{key:'displayMenuItemFor',value:function displayMenuItemFor(input){var GITHUB_LINK_FORMAT=/^https?:\/\/((www|gist|raw)\.)?github\.(io|com)/;var ISSUE_OR_PR_FORMAT=/^(\w+)\/(\w+)#(\d+)?\s*(\w+)?$/;var REPOSITORY_FORMAT=/^(\w+)\/(.*)?\s*(\w+)?$/;var COMMIT_SHA_FORMAT=/^\b[0-9a-f]{5,40}\b$/;var ACCOUNT_FORMAT=/^(\w+)?\s*(\w+)?$/;var match=void 0;// Matching: +'use strict';var _createClass=function(){function defineProperties(target,props){for(var i=0;i0){var matchedDefaultMenuItems=this.matchingDefaultMenuItems(input);if(matchedDefaultMenuItems.length>0){return matchedDefaultMenuItems.concat(this.conflictingHandleMenuItem(input));}else{return this.displayMenuItemFor(input);}}else{return this.defaultMenuItems;}}},{key:'matchingDefaultMenuItems',value:function matchingDefaultMenuItems(input){return this.defaultMenuItems.filter(function(item){var regex=new RegExp(input,'i');return item.title.match(regex);});}},{key:'conflictingHandleMenuItem',value:function conflictingHandleMenuItem(handle){return[{title:'@'+handle,subtitle:'Looking for the user @'+handle+'?',alwaysShowsSubtitle:true,icon:'personTemplate.png',action:'openAccountMenu',actionArgument:handle}];}},{key:'displayMenuItemFor',value:function displayMenuItemFor(input){var GITHUB_LINK_FORMAT=/^https?:\/\/((www|gist|raw)\.)?github\.(io|com)/;var ISSUE_OR_PR_FORMAT=/^(\w+)\/(\w+)#(\d+)?\s*(\w+)?$/;var REPOSITORY_FORMAT=/^(\w+)\/(.*)?\s*(\w+)?$/;var COMMIT_SHA_FORMAT=/^\b[0-9a-f]{5,40}\b$/;var ACCOUNT_FORMAT=/^(\w+)?\s*(\w+)?$/;var match=void 0;// Matching: // https://github.com/bswinnerton/dotfiles/blob/master/ack/ackrc.symlink#L6 if(input.match(GITHUB_LINK_FORMAT)){return this.openLinkShortnerMenu(input);}// Matching: // rails/rails#123 @@ -21,7 +21,7 @@ function openAccountRepositories(string){return app.openAccountRepositoriesMenu( if(owner.login===this.login){var repository=new Repository(owner,repo.name,repo.description);repositories.push(repository);}return repositories;}.bind(this),[]);}},{key:'_fetchRepositories',value:function _fetchRepositories(cursor,allEdges){allEdges=allEdges||[];var query='\n query($login: String!, $cursor: String) {\n repositoryOwner(login: $login) {\n repositories(first: 30, after: $cursor, orderBy: {field: PUSHED_AT, direction: DESC}) {\n edges {\n cursor\n node {\n name\n description\n owner {\n login\n }\n }\n }\n }\n }\n }\n ';var variables={login:this.login,cursor:cursor};var result=GraphQL.execute(query,variables);if(result){var repositoryEdges=result.data.repositoryOwner.repositories.edges;if(repositoryEdges.length>0){allEdges=allEdges.concat(repositoryEdges);var lastEdge=repositoryEdges[repositoryEdges.length-1];return this._fetchRepositories(lastEdge.cursor,allEdges);}}else{return[];}return allEdges;}},{key:'handle',get:function get(){return'@'+this.login;}},{key:'profileURL',get:function get(){return'https://github.com/'+this.login;}},{key:'repositoriesURL',get:function get(){return'https://github.com/'+this.login+'?tab=repositories';}},{key:'issuesURL',get:function get(){return'https://github.com/search?utf8=%E2%9C%93&q=author%3A'+this.login+'+is%3Aissue&ref=simplesearch';}},{key:'pullRequestsURL',get:function get(){return'https://github.com/search?utf8=%E2%9C%93&q=author%3A'+this.login+'+is%3Apr&ref=simplesearch';}},{key:'gistsURL',get:function get(){return'https://gist.github.com/'+this.login;}}]);return Account;}();if(typeof module!=='undefined'){module.exports.Account=Account;} 'use strict';function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function");}}var Cache=function Cache(){_classCallCheck(this,Cache);};Cache.fetch=function(key,ttl,func){var results=Cache.read(key);if(results){return results;}else{return Cache.write(key,ttl,func);}};Cache.read=function(key){var path=Cache.filePath(key);if(File.exists(path)){var cacheData=File.readJSON(path);var currentTime=Math.floor(new Date()/1000);if(currentTime0){var cacheData={expiresAt:expiresAt,results:results};File.writeJSON(cacheData,path,{'prettyPrint':Action.debugLogEnabled});}return results;};Cache.filePath=function(key){return Action.cachePath+'/'+'v2-'+key+'.json';};if(typeof module!=='undefined'){module.exports.Cache=Cache;} 'use strict';var _createClass=function(){function defineProperties(target,props){for(var i=0;i0){var matchedDefaultMenuItems=this.matchingDefaultMenuItems(input);if(matchedDefaultMenuItems.length>0){return matchedDefaultMenuItems.concat(this.conflictingHandleMenuItem(input));}else{return this.displayMenuItemFor(input);}}else{return this.defaultMenuItems;}}},{key:'matchingDefaultMenuItems',value:function matchingDefaultMenuItems(input){return this.defaultMenuItems.filter(function(item){var regex=new RegExp(input,'i');return item.title.match(regex);});}},{key:'conflictingHandleMenuItem',value:function conflictingHandleMenuItem(handle){return[{title:'@'+handle,subtitle:'Looking for the user @'+handle+'?',alwaysShowsSubtitle:true,icon:'personTemplate.png',action:'openAccountMenu',actionArgument:handle}];}},{key:'displayMenuItemFor',value:function displayMenuItemFor(input){var GITHUB_LINK_FORMAT=/^https?:\/\/((www|gist|raw)\.)?github\.(io|com)/;var ISSUE_OR_PR_FORMAT=/^(\w+)\/(\w+)#(\d+)?\s*(\w+)?$/;var REPOSITORY_FORMAT=/^(\w+)\/(.*)?\s*(\w+)?$/;var COMMIT_SHA_FORMAT=/^\b[0-9a-f]{5,40}\b$/;var ACCOUNT_FORMAT=/^(\w+)?\s*(\w+)?$/;var match=void 0;// Matching: +'use strict';var _createClass=function(){function defineProperties(target,props){for(var i=0;i0){var matchedDefaultMenuItems=this.matchingDefaultMenuItems(input);if(matchedDefaultMenuItems.length>0){return matchedDefaultMenuItems.concat(this.conflictingHandleMenuItem(input));}else{return this.displayMenuItemFor(input);}}else{return this.defaultMenuItems;}}},{key:'matchingDefaultMenuItems',value:function matchingDefaultMenuItems(input){return this.defaultMenuItems.filter(function(item){var regex=new RegExp(input,'i');return item.title.match(regex);});}},{key:'conflictingHandleMenuItem',value:function conflictingHandleMenuItem(handle){return[{title:'@'+handle,subtitle:'Looking for the user @'+handle+'?',alwaysShowsSubtitle:true,icon:'personTemplate.png',action:'openAccountMenu',actionArgument:handle}];}},{key:'displayMenuItemFor',value:function displayMenuItemFor(input){var GITHUB_LINK_FORMAT=/^https?:\/\/((www|gist|raw)\.)?github\.(io|com)/;var ISSUE_OR_PR_FORMAT=/^(\w+)\/(\w+)#(\d+)?\s*(\w+)?$/;var REPOSITORY_FORMAT=/^(\w+)\/(.*)?\s*(\w+)?$/;var COMMIT_SHA_FORMAT=/^\b[0-9a-f]{5,40}\b$/;var ACCOUNT_FORMAT=/^(\w+)?\s*(\w+)?$/;var match=void 0;// Matching: // https://github.com/bswinnerton/dotfiles/blob/master/ack/ackrc.symlink#L6 if(input.match(GITHUB_LINK_FORMAT)){return this.openLinkShortnerMenu(input);}// Matching: // rails/rails#123 diff --git a/Contents/Scripts/default.js b/Contents/Scripts/default.js index a997d73..c0836c3 100644 --- a/Contents/Scripts/default.js +++ b/Contents/Scripts/default.js @@ -1,9 +1,11 @@ class GitHubLB { constructor() { + let handle = Action.preferences.viewerHandle || ''; + this.defaultMenuItems = [ { title: 'My Repositories', - url: 'https://github.com/' + Action.preferences.viewerHandle, + url: 'https://github.com/' + handle + '?tab=repositories', icon: 'repoTemplate.png', }, {