From bc08c2fd254fcec74d8ee980bdfb739f83c30e0b Mon Sep 17 00:00:00 2001 From: pointbar Date: Tue, 10 May 2016 21:56:21 +0200 Subject: [PATCH 1/5] Try simple SPA approach --- src/init.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/init.js b/src/init.js index df4fc58..95b5b86 100644 --- a/src/init.js +++ b/src/init.js @@ -1,9 +1,14 @@ -window.addEventListener('hashchange', () => window.location.reload(true)) +window.addEventListener('hashchange', () => { + const ghUrl = window.location.toString().split('#')[1] + router.go(ghUrl) +}) + window.addEventListener('load', () => { const ghUrl = window.location.toString().split('#')[1] router.go(ghUrl) if (router.isNoRoute()) { window.location = './404.html' + window.location.reload(true) } }) const template = new Template() From 488586c814e81302fd4d481c01f2742dc74e7109 Mon Sep 17 00:00:00 2001 From: pointbar Date: Tue, 10 May 2016 21:57:41 +0200 Subject: [PATCH 2/5] Load organizations by github repo --- src/config.js | 28 ------------------------ src/layout-home.js | 4 +++- src/tpl-crews.js | 54 ++++++++++++++++++++++++++++++---------------- 3 files changed, 38 insertions(+), 48 deletions(-) diff --git a/src/config.js b/src/config.js index 94bda91..27aa41e 100644 --- a/src/config.js +++ b/src/config.js @@ -1,30 +1,2 @@ const GH_SECRET = 'M2NmYjI1YmNlOWE4MGFjN2E2NzIxZTg5YzkwMGVhZjM5NzEwN2Y2MA==' const GH_ID = 'NGEzOWM4YzE4NjA3NDkxNWU1NDY=' - -const CREWS = {crews: - [ - { title: 'Bienvenue sur multiBàO', - label: 'Accueil Multibao', - owner: 'multibao' - }, { - title: 'Réseau Transition BE', - label: 'association Réseau Transition Wallonie Bruxelles', - owner: 'reseautransitionwb' - }, { - title: 'Réseau Coop-tic', - label: 'associations Outils Réseaux (FR) et CRIE Mouscron (BE); établissement SupAgro Florac (FR)', - owner: 'supagroflorac' - }, { - title: 'Captain Berrotte', - label: 'stagiaires travaillant sur multiBàO', - owner: 'captain-berrotte' - }, { - title: 'Traducteurs agiles', - label: 'Les Traducteurs Agiles sont une communauté d’Agilistes et de … Traducteurs.', - owner: 'les-traducteurs-agiles' - }, { - title: 'Onpassealacte', - label: 'Media web citoyen montrant des initiatives positives en vidéos', - owner: 'onpassealacte' - } - ]} diff --git a/src/layout-home.js b/src/layout-home.js index 418abba..4afbd2b 100644 --- a/src/layout-home.js +++ b/src/layout-home.js @@ -10,7 +10,9 @@ Commencer ici Guide d'utilisation -
+
+
    +
`) } diff --git a/src/tpl-crews.js b/src/tpl-crews.js index 02083b5..331722c 100644 --- a/src/tpl-crews.js +++ b/src/tpl-crews.js @@ -4,23 +4,39 @@ * @param {String} An HTML string representing a github Url contribution. * @result {Array} A array with each crew Object. */ -const crewsWithSelectedClass = (owner, crews) => { - return crews.map(elt => { - if (elt.owner === owner) { - elt.classAttr = 'selected' - } - return elt - }) -} -template.create('crews') -template.crews.data = () => { - const ownerRoute = router.params.owner - const {crews} = {crews: crewsWithSelectedClass(ownerRoute, CREWS.crews)} - template.crews.html( - `
    ` + - crews.map(({title, repo, label, link, owner, classAttr}) => - `
  • ${label}

    ${title}

  • ` - ).join('\n') + - `
`) +{ + const htmlWithMetas = ({title, label, owner, classAttr}) => + `
  • +

    ${label}

    ${title}

    +
  • ` + + template.create('crews') + template.crews.data = () => { + const ghApi = new GithubUrl({owner: 'multibao', repo: 'organisations' }) + const html = [] + ghApi.getJsonFolders() + .then(jsonResponse => { + jsonResponse.map((elt) => { + if (elt.name === 'README.md') { + return + } + const readmeUrl = {owner: 'multibao', repo: 'organisations', branch: 'master', path: elt.name} + const ghApiBlob = new GithubUrl(readmeUrl) + ghApiBlob.getMdBlob() + .then(mdResponse => { + const contribution = new Markdown(mdResponse) + if (contribution.isMetas()) { + const metas = { + label: contribution.metas.label, + title: contribution.metas.title, + owner: contribution.metas.owner + } + html.push(htmlWithMetas(metas)) + } + template.crews.html(html.join('\n')) + template.crews.renderAsync(template.crews._htmlTpl) + }) + }) + }) + } } From 51a923b33889fb72b4224c23cf9fa8ef6644ee45 Mon Sep 17 00:00:00 2001 From: pointbar Date: Tue, 10 May 2016 21:58:24 +0200 Subject: [PATCH 3/5] Remove console --- src/lib/dk-markdown.js | 4 ---- src/tpl-repos.js | 1 - 2 files changed, 5 deletions(-) diff --git a/src/lib/dk-markdown.js b/src/lib/dk-markdown.js index 39cccaf..a1e3d7c 100644 --- a/src/lib/dk-markdown.js +++ b/src/lib/dk-markdown.js @@ -14,15 +14,11 @@ class Markdown { this.content.match(/---([\s\S]*?)---/)[1].split('\n') .map(elt => { if (!! elt.match(/^\w+:$/)) { - console.log('elt ul', elt) - console.log('labelList ul', labelList) const [, label] = elt.match(/^(\w+):$/) this.metas[label] = [] labelList = label } if (elt.match(/^ - [\s\S]*?$/)) { - console.log('elt', elt) - console.log('labelList', labelList) const [, content] = elt.match(/^ - ([\s\S]*?)$/) this.metas[labelList].push(content) } diff --git a/src/tpl-repos.js b/src/tpl-repos.js index a4f7fc6..1c51c83 100644 --- a/src/tpl-repos.js +++ b/src/tpl-repos.js @@ -46,7 +46,6 @@ folders: contribution.metas.folders, files: contribution.metas.files } - console.log('metas', contribution.metas) html.push(htmlWithMetas(metas)) } else { const noMetas = { From 0b5bfaccf488e937d328b7f3412baacaecf4828f Mon Sep 17 00:00:00 2001 From: pointbar Date: Tue, 10 May 2016 21:59:46 +0200 Subject: [PATCH 4/5] Optimize --- dist/dk.js | 102 +++++++++++++++++++++---------------------------- dist/dk.min.js | 2 +- 2 files changed, 45 insertions(+), 59 deletions(-) diff --git a/dist/dk.js b/dist/dk.js index dc524ac..e5d5cff 100644 --- a/dist/dk.js +++ b/dist/dk.js @@ -245,9 +245,6 @@ var Markdown = (function () { var labelList = ''; this.content.match(/---([\s\S]*?)---/)[1].split('\n').map(function (elt) { if (!!elt.match(/^\w+:$/)) { - console.log('elt ul', elt); - console.log('labelList ul', labelList); - var _elt$match = elt.match(/^(\w+):$/); var _elt$match2 = _slicedToArray(_elt$match, 2); @@ -258,9 +255,6 @@ var Markdown = (function () { labelList = label; } if (elt.match(/^ - [\s\S]*?$/)) { - console.log('elt', elt); - console.log('labelList', labelList); - var _elt$match3 = elt.match(/^ - ([\s\S]*?)$/); var _elt$match32 = _slicedToArray(_elt$match3, 2); @@ -542,41 +536,19 @@ var Template = (function () { var GH_SECRET = 'M2NmYjI1YmNlOWE4MGFjN2E2NzIxZTg5YzkwMGVhZjM5NzEwN2Y2MA=='; var GH_ID = 'NGEzOWM4YzE4NjA3NDkxNWU1NDY='; - -var CREWS = { crews: [{ title: 'Bienvenue sur multiBàO', - label: 'Accueil Multibao', - owner: 'multibao' - }, { - title: 'Réseau Transition BE', - label: 'association Réseau Transition Wallonie Bruxelles', - owner: 'reseautransitionwb' - }, { - title: 'Réseau Coop-tic', - label: 'associations Outils Réseaux (FR) et CRIE Mouscron (BE); établissement SupAgro Florac (FR)', - owner: 'supagroflorac' - }, { - title: 'Captain Berrotte', - label: 'stagiaires travaillant sur multiBàO', - owner: 'captain-berrotte' - }, { - title: 'Traducteurs agiles', - label: 'Les Traducteurs Agiles sont une communauté d’Agilistes et de … Traducteurs.', - owner: 'les-traducteurs-agiles' - }, { - title: 'Onpassealacte', - label: 'Media web citoyen montrant des initiatives positives en vidéos', - owner: 'onpassealacte' - }] }; 'use strict'; window.addEventListener('hashchange', function () { - return window.location.reload(true); + var ghUrl = window.location.toString().split('#')[1]; + router.go(ghUrl); }); + window.addEventListener('load', function () { var ghUrl = window.location.toString().split('#')[1]; router.go(ghUrl); if (router.isNoRoute()) { window.location = './404.html'; + window.location.reload(true); } }); var template = new Template(); @@ -595,7 +567,7 @@ var layout = new Layout(); { layout.create('home'); - layout.home.html('\n
    \n

    multiBàO

    \n
    \n
    \n
    \n

    Partager en équipe et au monde ses apprentissages sur le faire ensemble

    \n Commencer ici\n Guide d\'utilisation\n
    \n
    \n
    \n
    '); + layout.home.html('\n
    \n

    multiBàO

    \n
    \n
    \n
    \n

    Partager en équipe et au monde ses apprentissages sur le faire ensemble

    \n Commencer ici\n Guide d\'utilisation\n
    \n
    \n
      \n
    \n
    \n
    '); } /** * Layout for manage and display Github repositories. @@ -741,30 +713,45 @@ router.route(':owner', function () { */ 'use strict'; -var crewsWithSelectedClass = function crewsWithSelectedClass(owner, crews) { - return crews.map(function (elt) { - if (elt.owner === owner) { - elt.classAttr = 'selected'; - } - return elt; - }); -}; -template.create('crews'); -template.crews.data = function () { - var ownerRoute = router.params.owner; - var _crews = { crews: crewsWithSelectedClass(ownerRoute, CREWS.crews) }; - var crews = _crews.crews; - - template.crews.html('
      ' + crews.map(function (_ref) { - var title = _ref.title; - var repo = _ref.repo; - var label = _ref.label; - var link = _ref.link; - var owner = _ref.owner; - var classAttr = _ref.classAttr; - return '
    • ' + label + '

      ' + title + '

    • '); - }).join('\n') + '
    '); -}; +{ + (function () { + var htmlWithMetas = function htmlWithMetas(_ref) { + var title = _ref.title; + var label = _ref.label; + var owner = _ref.owner; + var classAttr = _ref.classAttr; + return '
  • \n

    ' + label + '

    ' + title + '

    \n
  • '; + }; + + template.create('crews'); + template.crews.data = function () { + var ghApi = new GithubUrl({ owner: 'multibao', repo: 'organisations' }); + var html = []; + ghApi.getJsonFolders().then(function (jsonResponse) { + jsonResponse.map(function (elt) { + if (elt.name === 'README.md') { + return; + } + var readmeUrl = { owner: 'multibao', repo: 'organisations', branch: 'master', path: elt.name }; + var ghApiBlob = new GithubUrl(readmeUrl); + ghApiBlob.getMdBlob().then(function (mdResponse) { + var contribution = new Markdown(mdResponse); + if (contribution.isMetas()) { + var metas = { + label: contribution.metas.label, + title: contribution.metas.title, + owner: contribution.metas.owner + }; + html.push(htmlWithMetas(metas)); + } + template.crews.html(html.join('\n')); + template.crews.renderAsync(template.crews._htmlTpl); + }); + }); + }); + }; + })(); +} 'use strict'; { @@ -924,7 +911,6 @@ template.crews.data = function () { folders: contribution.metas.folders, files: contribution.metas.files }; - console.log('metas', contribution.metas); html.push(htmlWithMetas(metas)); } else { var noMetas = { diff --git a/dist/dk.min.js b/dist/dk.min.js index 8955bf7..f356474 100644 --- a/dist/dk.min.js +++ b/dist/dk.min.js @@ -1 +1 @@ -"use strict";function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor))throw new TypeError("Cannot call a class as a function")}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor))throw new TypeError("Cannot call a class as a function")}function _slicedToArray(arr,i){if(Array.isArray(arr))return arr;if(Symbol.iterator in Object(arr)){var _arr=[],_n=!0,_d=!1,_e=void 0;try{for(var _s,_i=arr[Symbol.iterator]();!(_n=(_s=_i.next()).done)&&(_arr.push(_s.value),!i||_arr.length!==i);_n=!0);}catch(err){_d=!0,_e=err}finally{try{!_n&&_i["return"]&&_i["return"]()}finally{if(_d)throw _e}}return _arr}throw new TypeError("Invalid attempt to destructure non-iterable instance")}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor))throw new TypeError("Cannot call a class as a function")}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor))throw new TypeError("Cannot call a class as a function")}function _slicedToArray(arr,i){if(Array.isArray(arr))return arr;if(Symbol.iterator in Object(arr)){var _arr=[],_n=!0,_d=!1,_e=void 0;try{for(var _s,_i=arr[Symbol.iterator]();!(_n=(_s=_i.next()).done)&&(_arr.push(_s.value),!i||_arr.length!==i);_n=!0);}catch(err){_d=!0,_e=err}finally{try{!_n&&_i["return"]&&_i["return"]()}finally{if(_d)throw _e}}return _arr}throw new TypeError("Invalid attempt to destructure non-iterable instance")}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor))throw new TypeError("Cannot call a class as a function")}function _slicedToArray(arr,i){if(Array.isArray(arr))return arr;if(Symbol.iterator in Object(arr)){var _arr=[],_n=!0,_d=!1,_e=void 0;try{for(var _s,_i=arr[Symbol.iterator]();!(_n=(_s=_i.next()).done)&&(_arr.push(_s.value),!i||_arr.length!==i);_n=!0);}catch(err){_d=!0,_e=err}finally{try{!_n&&_i["return"]&&_i["return"]()}finally{if(_d)throw _e}}return _arr}throw new TypeError("Invalid attempt to destructure non-iterable instance")}var _createClass=function(){function defineProperties(target,props){for(var i=0;i\n

    multiBàO

    \n
    \n
    \n \n
    \n \n
    \n
    \n
    '),layout.create("home"),layout.home.html('\n
    \n

    multiBàO

    \n
    \n
    \n
    \n

    Partager en équipe et au monde ses apprentissages sur le faire ensemble

    \n Commencer ici\n Guide d\'utilisation\n
    \n
    \n
    \n
    '),layout.create("repos"),layout.repos.html('\n
    \n

    multiBàO

    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    '),layout.create("searchList"),layout.searchList.html('\n
    \n

    multiBàO

    \n
    \n
    \n
    \n
    \n
    \n
    \n
    '),layout.create("viewer"),layout.viewer.html('\n
    \n
    \n ');var router=new Router;router.route("/",function(){this.currentRoute="home",layout.home.render()}),router.route("search/code",function(){this.currentRoute="search",layout.searchList.render()}),router.route(":owner/:repo/blob/:branch/:path(.*)",function(){this.currentRoute="blob",layout.viewer.render()}),router.route(":owner/:repo/tree/:branch/:path(.*)?",function(){this.currentRoute="tree",layout.folders.render()}),router.route(":owner/:repo",function(){this.currentRoute="list",layout.folders.render()}),router.route(":owner",function(){this.currentRoute="repos",layout.repos.render()}),template.create("breadcrumb"),template.breadcrumb.data=function(){var _router$params=router.params,owner=_router$params.owner,repo=_router$params.repo,branch=_router$params.branch,path=_router$params.path,folders=[];path&&!function(){var pathByFolder=[];path.split("/").map(function(elt){pathByFolder.push("/"+elt),folders.push({link:"#"+owner+"/"+repo+"/tree/"+branch+pathByFolder.join(""),label:elt})})}();var _ownerTpl$repoTpl$foldersTpl={ownerTpl:{label:owner,link:"#"+owner},repoTpl:{label:repo,link:"#"+owner+"/"+repo+"/tree/"+branch},foldersTpl:folders},ownerTpl=_ownerTpl$repoTpl$foldersTpl.ownerTpl,repoTpl=_ownerTpl$repoTpl$foldersTpl.repoTpl,foldersTpl=_ownerTpl$repoTpl$foldersTpl.foldersTpl;template.breadcrumb.html('")},!function(){var html=function(_ref){var link=_ref.link,label=_ref.label,_html=_ref.html;return'\n \n
    \n '+_html+"\n
    \n "};template.create("contribution"),template.contribution.data=function(){var ghApi=new GithubUrl(router.params);ghApi.getHtmlBlob().then(function(htmlResponse){var _router$params=router.params,owner=_router$params.owner,repo=_router$params.repo,branch=_router$params.branch,path=_router$params.path,data={html:htmlResponse,link:"#"+owner+"/"+repo+"/tree/"+branch+"/"+path.replace(/(\/|)[0-9A-Za-z\u00C0-\u017F\-\_\.]*$/,""),label:""+owner+" - "+repo};template.contribution.html(html(data)),template.contribution.renderAsync()})}}();var crewsWithSelectedClass=function(owner,crews){return crews.map(function(elt){return elt.owner===owner&&(elt.classAttr="selected"),elt})};template.create("crews"),template.crews.data=function(){var ownerRoute=router.params.owner,_crews={crews:crewsWithSelectedClass(ownerRoute,CREWS.crews)},crews=_crews.crews;template.crews.html("
      "+crews.map(function(_ref){var title=_ref.title,label=(_ref.repo,_ref.label),owner=(_ref.link,_ref.owner),classAttr=_ref.classAttr;return'
    • '+label+"

      "+title+"

    • ")}).join("\n")+"
    ")},!function(){var htmlContribWithMetas=function(_ref){var url=_ref.url,title=_ref.title,authors=_ref.authors,git_url=_ref.git_url,prose_url=_ref.prose_url,image_url=_ref.image_url,description=_ref.description;return''},htmlContribNoMetas=function(_ref2){var url=_ref2.url,title=_ref2.title;return'"},htmlFolderWithMetas=function(_ref3){var url=_ref3.url,title=_ref3.title,folders=_ref3.folders,files=_ref3.files,contributors=_ref3.contributors,git_url=_ref3.git_url,image_url=_ref3.image_url,description=_ref3.description;return''},htmlFolderNoMetas=function(_ref4){var url=_ref4.url,title=_ref4.title;return'"};template.create("folders"),template.folders.data=function(){var ghApi=new GithubUrl(router.params),html=[];ghApi.getJsonFolders().then(function(jsonResponse){jsonResponse.map(function(_ref5){var name=_ref5.name,type=_ref5.type,html_url=_ref5.html_url;if("file"===type){var readmeUrl={owner:router.params.owner,repo:router.params.repo,branch:"master",path:""+(router.params.path?""+router.params.path+"/"+name:name)},ghApiBlob=new GithubUrl(readmeUrl);ghApiBlob.getMdBlob().then(function(mdResponse){var contribution=new Markdown(mdResponse);if(contribution.isMetas()){var metas={prose_url:("http://prose.io/#"+html_url.match(/^https:\/\/github.com\/(.*)/)[1]).replace("blob","edit"),git_url:html_url,url:""+html_url.match(/^https:\/\/github.com\/(.*)/)[1],description:contribution.metas.description,title:contribution.metas.title||name,authors:contribution.metas.authors,image_url:contribution.metas.image_url||"http://lorempixel.com/g/350/150/"};html.push(htmlContribWithMetas(metas))}else{var noMetas={title:name,url:""+html_url.match(/^https:\/\/github.com\/(.*)/)[1]};html.push(htmlContribNoMetas(noMetas))}template.folders.html(html.join("\n")),template.folders.renderAsync(template.folders._htmlTpl)})}else{var readmeUrl={owner:router.params.owner,repo:name,branch:"master",path:""+(router.params.path?""+router.params.path+"/README.md":"README.md")},ghApiBlob=new GithubUrl(readmeUrl);ghApiBlob.getMdBlob().then(function(mdResponse){var contribution=new Markdown(mdResponse);if(contribution.isMetas()){var metas={url:""+html_url.match(/^https:\/\/github.com\/(.*)/)[1],title:contribution.metas.title||name,git_url:html_url,folders:12,files:5,contributors:contribution.metas.contributors,description:"Lorem ipsum",image_url:"http://lorempixel.com/g/350/150/"};html.push(htmlFolderWithMetas(metas))}else{var noMetas={title:name,url:""+html_url.match(/^https:\/\/github.com\/(.*)/)[1]};html.push(htmlFolderNoMetas(noMetas))}template.folders.html(html.join("\n")),template.folders.renderAsync(template.folders._htmlTpl)})}})})}}(),!function(){var htmlWithMetas=function(_ref){var url=_ref.url,title=_ref.title,folders=_ref.folders,files=_ref.files,contributors=_ref.contributors,git_url=_ref.git_url,image_url=_ref.image_url,description=_ref.description,readme_url=_ref.readme_url;return''},htmlNoMetas=function(_ref2){var url=_ref2.url,title=_ref2.title;return'"};template.create("repos"),template.repos.data=function(){var ghApi=new GithubUrl(router.params),html=[];ghApi.getJsonRepo().then(function(jsonResponse){jsonResponse.map(function(_ref3){var name=_ref3.name,html_url=(_ref3.type,_ref3.html_url),readmeUrl=(_ref3.url,{owner:router.params.owner,repo:name,branch:"master",path:"README.md"}),ghApiBlob=new GithubUrl(readmeUrl);ghApiBlob.getMdBlob().then(function(mdResponse){var contribution=new Markdown(mdResponse);if(contribution.isMetas()){var metas={url:html_url.replace("https://github.com/",""),git_url:html_url,readme_url:html_url.replace("https://github.com/","")+"/blob/master/README.md",title:contribution.metas.title,image_url:contribution.metas.image_url||"http://lorempixel.com/g/350/150/",description:contribution.metas.description,contributors:contribution.metas.contributors,folders:contribution.metas.folders,files:contribution.metas.files};console.log("metas",contribution.metas),html.push(htmlWithMetas(metas))}else{var noMetas={url:html_url.replace("https://github.com/",""),title:name};html.push(htmlNoMetas(noMetas))}template.repos.html(html.join("\n")),template.repos.renderAsync(template.repos._htmlTpl)})})})}}(),template.create("search"),template.search.data=function(){template.search.html('\n
    \n
    \n \n \n
    \n
    \n '),template.search.events({"click #button-gh-search":function(){if(document.querySelector("#gh-search").value.length>2){var userQuery=document.querySelector("#gh-search").value,apiUrl=new GithubUrl(router.params).toGhApiSearch(userQuery);router.go(apiUrl.replace("https://api.github.com/",""))}},"keypress #gh-search":function(evt){if("Enter"===evt.key&&evt.target.value.length>2){var userQuery=evt.target.value,apiUrl=new GithubUrl(router.params).toGhApiSearch(userQuery);router.go(apiUrl.replace("https://api.github.com/",""))}}})},!function(){var htmlWithMetas=function(_ref){var url=_ref.url,title=_ref.title,authors=_ref.authors,prose_url=_ref.prose_url,git_url=_ref.git_url,image_url=_ref.image_url,description=_ref.description;return''},htmlNoMetas=function(_ref2){var url=_ref2.url,title=_ref2.title;return'"};template.create("searchList"),template.searchList.data=function(){var _router$queries$q$match=router.queries.q.match(/(.*)\+language:Markdown\+user:([0-9A-Za-z\u00C0-\u017F\-\_\.]*)/),_router$queries$q$match2=_slicedToArray(_router$queries$q$match,3),query=(_router$queries$q$match2[0],_router$queries$q$match2[1]),user=_router$queries$q$match2[2];router.params.owner=user;var ghApi=new GithubUrl(router.params),html=[];ghApi.getJsonSearch(query).then(function(jsonResponse){jsonResponse.items.map(function(_ref3){var name=_ref3.name,path=_ref3.path,html_url=_ref3.html_url,repository=_ref3.repository,readmeUrl={owner:router.params.owner,repo:repository.name,branch:"master",path:path},ghApiBlob=new GithubUrl(readmeUrl);ghApiBlob.getMdBlob().then(function(mdResponse){var contribution=new Markdown(mdResponse);if(contribution.isMetas()){var metas={prose_url:("http://prose.io/#"+html_url.match(/^https:\/\/github.com\/(.*)/)[1]).replace("blob","edit"),git_url:html_url,url:""+repository.full_name+"/blob/master/"+path,description:contribution.metas.description,title:contribution.metas.title,authors:contribution.metas.contributors,image_url:contribution.metas.image_url||"http://lorempixel.com/g/350/150/"};html.push(htmlWithMetas(metas))}else{var noMetas={title:name,url:""+repository.full_name+"/blob/master/"+path};html.push(htmlNoMetas(noMetas))}template.searchList.html(html.join("\n")),template.searchList.renderAsync(template.searchList._htmlTpl)})})})}}(); \ No newline at end of file +"use strict";function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor))throw new TypeError("Cannot call a class as a function")}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor))throw new TypeError("Cannot call a class as a function")}function _slicedToArray(arr,i){if(Array.isArray(arr))return arr;if(Symbol.iterator in Object(arr)){var _arr=[],_n=!0,_d=!1,_e=void 0;try{for(var _s,_i=arr[Symbol.iterator]();!(_n=(_s=_i.next()).done)&&(_arr.push(_s.value),!i||_arr.length!==i);_n=!0);}catch(err){_d=!0,_e=err}finally{try{!_n&&_i["return"]&&_i["return"]()}finally{if(_d)throw _e}}return _arr}throw new TypeError("Invalid attempt to destructure non-iterable instance")}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor))throw new TypeError("Cannot call a class as a function")}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor))throw new TypeError("Cannot call a class as a function")}function _slicedToArray(arr,i){if(Array.isArray(arr))return arr;if(Symbol.iterator in Object(arr)){var _arr=[],_n=!0,_d=!1,_e=void 0;try{for(var _s,_i=arr[Symbol.iterator]();!(_n=(_s=_i.next()).done)&&(_arr.push(_s.value),!i||_arr.length!==i);_n=!0);}catch(err){_d=!0,_e=err}finally{try{!_n&&_i["return"]&&_i["return"]()}finally{if(_d)throw _e}}return _arr}throw new TypeError("Invalid attempt to destructure non-iterable instance")}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor))throw new TypeError("Cannot call a class as a function")}function _slicedToArray(arr,i){if(Array.isArray(arr))return arr;if(Symbol.iterator in Object(arr)){var _arr=[],_n=!0,_d=!1,_e=void 0;try{for(var _s,_i=arr[Symbol.iterator]();!(_n=(_s=_i.next()).done)&&(_arr.push(_s.value),!i||_arr.length!==i);_n=!0);}catch(err){_d=!0,_e=err}finally{try{!_n&&_i["return"]&&_i["return"]()}finally{if(_d)throw _e}}return _arr}throw new TypeError("Invalid attempt to destructure non-iterable instance")}var _createClass=function(){function defineProperties(target,props){for(var i=0;i\n

    multiBàO

    \n
    \n
    \n \n
    \n \n
    \n
    \n
    '),layout.create("home"),layout.home.html('\n
    \n

    multiBàO

    \n
    \n
    \n
    \n

    Partager en équipe et au monde ses apprentissages sur le faire ensemble

    \n Commencer ici\n Guide d\'utilisation\n
    \n
    \n
      \n
    \n
    \n
    '),layout.create("repos"),layout.repos.html('\n
    \n

    multiBàO

    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    '),layout.create("searchList"),layout.searchList.html('\n
    \n

    multiBàO

    \n
    \n
    \n
    \n
    \n
    \n
    \n
    '),layout.create("viewer"),layout.viewer.html('\n
    \n
    \n ');var router=new Router;router.route("/",function(){this.currentRoute="home",layout.home.render()}),router.route("search/code",function(){this.currentRoute="search",layout.searchList.render()}),router.route(":owner/:repo/blob/:branch/:path(.*)",function(){this.currentRoute="blob",layout.viewer.render()}),router.route(":owner/:repo/tree/:branch/:path(.*)?",function(){this.currentRoute="tree",layout.folders.render()}),router.route(":owner/:repo",function(){this.currentRoute="list",layout.folders.render()}),router.route(":owner",function(){this.currentRoute="repos",layout.repos.render()}),template.create("breadcrumb"),template.breadcrumb.data=function(){var _router$params=router.params,owner=_router$params.owner,repo=_router$params.repo,branch=_router$params.branch,path=_router$params.path,folders=[];path&&!function(){var pathByFolder=[];path.split("/").map(function(elt){pathByFolder.push("/"+elt),folders.push({link:"#"+owner+"/"+repo+"/tree/"+branch+pathByFolder.join(""),label:elt})})}();var _ownerTpl$repoTpl$foldersTpl={ownerTpl:{label:owner,link:"#"+owner},repoTpl:{label:repo,link:"#"+owner+"/"+repo+"/tree/"+branch},foldersTpl:folders},ownerTpl=_ownerTpl$repoTpl$foldersTpl.ownerTpl,repoTpl=_ownerTpl$repoTpl$foldersTpl.repoTpl,foldersTpl=_ownerTpl$repoTpl$foldersTpl.foldersTpl;template.breadcrumb.html('")},!function(){var html=function(_ref){var link=_ref.link,label=_ref.label,_html=_ref.html;return'\n \n
    \n '+_html+"\n
    \n "};template.create("contribution"),template.contribution.data=function(){var ghApi=new GithubUrl(router.params);ghApi.getHtmlBlob().then(function(htmlResponse){var _router$params=router.params,owner=_router$params.owner,repo=_router$params.repo,branch=_router$params.branch,path=_router$params.path,data={html:htmlResponse,link:"#"+owner+"/"+repo+"/tree/"+branch+"/"+path.replace(/(\/|)[0-9A-Za-z\u00C0-\u017F\-\_\.]*$/,""),label:""+owner+" - "+repo};template.contribution.html(html(data)),template.contribution.renderAsync()})}}(),!function(){var htmlWithMetas=function(_ref){var title=_ref.title,label=_ref.label,owner=_ref.owner;_ref.classAttr;return'
  • \n

    '+label+"

    "+title+"

    \n
  • "};template.create("crews"),template.crews.data=function(){var ghApi=new GithubUrl({owner:"multibao",repo:"organisations"}),html=[];ghApi.getJsonFolders().then(function(jsonResponse){jsonResponse.map(function(elt){if("README.md"!==elt.name){var readmeUrl={owner:"multibao",repo:"organisations",branch:"master",path:elt.name},ghApiBlob=new GithubUrl(readmeUrl);ghApiBlob.getMdBlob().then(function(mdResponse){var contribution=new Markdown(mdResponse);if(contribution.isMetas()){var metas={label:contribution.metas.label,title:contribution.metas.title,owner:contribution.metas.owner};html.push(htmlWithMetas(metas))}template.crews.html(html.join("\n")),template.crews.renderAsync(template.crews._htmlTpl)})}})})}}(),!function(){var htmlContribWithMetas=function(_ref){var url=_ref.url,title=_ref.title,authors=_ref.authors,git_url=_ref.git_url,prose_url=_ref.prose_url,image_url=_ref.image_url,description=_ref.description;return''},htmlContribNoMetas=function(_ref2){var url=_ref2.url,title=_ref2.title;return'"},htmlFolderWithMetas=function(_ref3){var url=_ref3.url,title=_ref3.title,folders=_ref3.folders,files=_ref3.files,contributors=_ref3.contributors,git_url=_ref3.git_url,image_url=_ref3.image_url,description=_ref3.description;return''},htmlFolderNoMetas=function(_ref4){var url=_ref4.url,title=_ref4.title;return'"};template.create("folders"),template.folders.data=function(){var ghApi=new GithubUrl(router.params),html=[];ghApi.getJsonFolders().then(function(jsonResponse){jsonResponse.map(function(_ref5){var name=_ref5.name,type=_ref5.type,html_url=_ref5.html_url;if("file"===type){var readmeUrl={owner:router.params.owner,repo:router.params.repo,branch:"master",path:""+(router.params.path?""+router.params.path+"/"+name:name)},ghApiBlob=new GithubUrl(readmeUrl);ghApiBlob.getMdBlob().then(function(mdResponse){var contribution=new Markdown(mdResponse);if(contribution.isMetas()){var metas={prose_url:("http://prose.io/#"+html_url.match(/^https:\/\/github.com\/(.*)/)[1]).replace("blob","edit"),git_url:html_url,url:""+html_url.match(/^https:\/\/github.com\/(.*)/)[1],description:contribution.metas.description,title:contribution.metas.title||name,authors:contribution.metas.authors,image_url:contribution.metas.image_url||"http://lorempixel.com/g/350/150/"};html.push(htmlContribWithMetas(metas))}else{var noMetas={title:name,url:""+html_url.match(/^https:\/\/github.com\/(.*)/)[1]};html.push(htmlContribNoMetas(noMetas))}template.folders.html(html.join("\n")),template.folders.renderAsync(template.folders._htmlTpl)})}else{var readmeUrl={owner:router.params.owner,repo:name,branch:"master",path:""+(router.params.path?""+router.params.path+"/README.md":"README.md")},ghApiBlob=new GithubUrl(readmeUrl);ghApiBlob.getMdBlob().then(function(mdResponse){var contribution=new Markdown(mdResponse);if(contribution.isMetas()){var metas={url:""+html_url.match(/^https:\/\/github.com\/(.*)/)[1],title:contribution.metas.title||name,git_url:html_url,folders:12,files:5,contributors:contribution.metas.contributors,description:"Lorem ipsum",image_url:"http://lorempixel.com/g/350/150/"};html.push(htmlFolderWithMetas(metas))}else{var noMetas={title:name,url:""+html_url.match(/^https:\/\/github.com\/(.*)/)[1]};html.push(htmlFolderNoMetas(noMetas))}template.folders.html(html.join("\n")),template.folders.renderAsync(template.folders._htmlTpl)})}})})}}(),!function(){var htmlWithMetas=function(_ref){var url=_ref.url,title=_ref.title,folders=_ref.folders,files=_ref.files,contributors=_ref.contributors,git_url=_ref.git_url,image_url=_ref.image_url,description=_ref.description,readme_url=_ref.readme_url;return''},htmlNoMetas=function(_ref2){var url=_ref2.url,title=_ref2.title;return'"};template.create("repos"),template.repos.data=function(){var ghApi=new GithubUrl(router.params),html=[];ghApi.getJsonRepo().then(function(jsonResponse){jsonResponse.map(function(_ref3){var name=_ref3.name,html_url=(_ref3.type,_ref3.html_url),readmeUrl=(_ref3.url,{owner:router.params.owner,repo:name,branch:"master",path:"README.md"}),ghApiBlob=new GithubUrl(readmeUrl);ghApiBlob.getMdBlob().then(function(mdResponse){var contribution=new Markdown(mdResponse);if(contribution.isMetas()){var metas={url:html_url.replace("https://github.com/",""),git_url:html_url,readme_url:html_url.replace("https://github.com/","")+"/blob/master/README.md",title:contribution.metas.title,image_url:contribution.metas.image_url||"http://lorempixel.com/g/350/150/",description:contribution.metas.description,contributors:contribution.metas.contributors,folders:contribution.metas.folders,files:contribution.metas.files};html.push(htmlWithMetas(metas))}else{var noMetas={url:html_url.replace("https://github.com/",""),title:name};html.push(htmlNoMetas(noMetas))}template.repos.html(html.join("\n")),template.repos.renderAsync(template.repos._htmlTpl)})})})}}(),template.create("search"),template.search.data=function(){template.search.html('\n
    \n
    \n \n \n
    \n
    \n '),template.search.events({"click #button-gh-search":function(){if(document.querySelector("#gh-search").value.length>2){var userQuery=document.querySelector("#gh-search").value,apiUrl=new GithubUrl(router.params).toGhApiSearch(userQuery);router.go(apiUrl.replace("https://api.github.com/",""))}},"keypress #gh-search":function(evt){if("Enter"===evt.key&&evt.target.value.length>2){var userQuery=evt.target.value,apiUrl=new GithubUrl(router.params).toGhApiSearch(userQuery);router.go(apiUrl.replace("https://api.github.com/",""))}}})},!function(){var htmlWithMetas=function(_ref){var url=_ref.url,title=_ref.title,authors=_ref.authors,prose_url=_ref.prose_url,git_url=_ref.git_url,image_url=_ref.image_url,description=_ref.description;return''},htmlNoMetas=function(_ref2){var url=_ref2.url,title=_ref2.title;return'"};template.create("searchList"),template.searchList.data=function(){var _router$queries$q$match=router.queries.q.match(/(.*)\+language:Markdown\+user:([0-9A-Za-z\u00C0-\u017F\-\_\.]*)/),_router$queries$q$match2=_slicedToArray(_router$queries$q$match,3),query=(_router$queries$q$match2[0],_router$queries$q$match2[1]),user=_router$queries$q$match2[2];router.params.owner=user;var ghApi=new GithubUrl(router.params),html=[];ghApi.getJsonSearch(query).then(function(jsonResponse){jsonResponse.items.map(function(_ref3){var name=_ref3.name,path=_ref3.path,html_url=_ref3.html_url,repository=_ref3.repository,readmeUrl={owner:router.params.owner,repo:repository.name,branch:"master",path:path},ghApiBlob=new GithubUrl(readmeUrl);ghApiBlob.getMdBlob().then(function(mdResponse){var contribution=new Markdown(mdResponse);if(contribution.isMetas()){var metas={prose_url:("http://prose.io/#"+html_url.match(/^https:\/\/github.com\/(.*)/)[1]).replace("blob","edit"),git_url:html_url,url:""+repository.full_name+"/blob/master/"+path,description:contribution.metas.description,title:contribution.metas.title,authors:contribution.metas.contributors,image_url:contribution.metas.image_url||"http://lorempixel.com/g/350/150/"};html.push(htmlWithMetas(metas))}else{var noMetas={title:name,url:""+repository.full_name+"/blob/master/"+path};html.push(htmlNoMetas(noMetas))}template.searchList.html(html.join("\n")),template.searchList.renderAsync(template.searchList._htmlTpl)})})})}}(); \ No newline at end of file From 149bb57a7689432b6bea87478a5701ed7c5d4a7e Mon Sep 17 00:00:00 2001 From: pointbar Date: Tue, 10 May 2016 22:02:19 +0200 Subject: [PATCH 5/5] Remove crews test --- tests/index.html | 2 -- tests/test.tpl-crews.js | 16 ---------------- 2 files changed, 18 deletions(-) delete mode 100644 tests/test.tpl-crews.js diff --git a/tests/index.html b/tests/index.html index efd5467..73c4d79 100644 --- a/tests/index.html +++ b/tests/index.html @@ -24,8 +24,6 @@ - - diff --git a/tests/test.tpl-crews.js b/tests/test.tpl-crews.js deleted file mode 100644 index b597f93..0000000 --- a/tests/test.tpl-crews.js +++ /dev/null @@ -1,16 +0,0 @@ -describe('#Crews', () => { - it('should selected an an option on select html menu.', () => { - const owner = 'stack' - const crews = [ - { title: 'E-COMMERCE Threat', - label: 'Info disclosure', - owner: 'stack' - }, { - title: 'Easy to reproduce', - label: 'Elevation of privilege', - owner: 'continuity' - }] - expect(crewsWithSelectedClass(owner, crews)[0].classAttr) - .to.be('selected') - }) -})