From f68c7cba9ad837c2fc759311061ccd78f6a88811 Mon Sep 17 00:00:00 2001 From: Matthew Russell Date: Fri, 5 Feb 2016 17:14:29 -0800 Subject: [PATCH 1/2] Create a git branch option --- lib/cli.coffee | 5 +++++ lib/styles/default/behavior.coffee | 3 ++- lib/styles/default/docPage.jade | 3 ++- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/cli.coffee b/lib/cli.coffee index 7b9d25b..2bf6753 100755 --- a/lib/cli.coffee +++ b/lib/cli.coffee @@ -79,6 +79,10 @@ module.exports = CLI = (inputArgs, callback) -> describe: "Supply your GitHub repository URL (if groc fails to guess it)." type: 'string' + 'repository-branch': + describe: "Supply your git branch" + type: 'string' + 'only-render-newer': describe: "Only render files if the source is newer than the output." default: true @@ -235,6 +239,7 @@ module.exports = CLI = (inputArgs, callback) -> # Good to go! unless argv.github project.githubURL = argv['repository-url'] + project.gitBranch = argv['repository-branch'] project.generate options, (error) -> callback error diff --git a/lib/styles/default/behavior.coffee b/lib/styles/default/behavior.coffee index 74ffcfa..5a37082 100755 --- a/lib/styles/default/behavior.coffee +++ b/lib/styles/default/behavior.coffee @@ -191,7 +191,7 @@ buildNav = (metaInfo) -> if metaInfo.documentPath == 'index' sourceURL = metaInfo.githubURL else - sourceURL = "#{metaInfo.githubURL}/blob/master/#{metaInfo.projectPath}" + sourceURL = "#{metaInfo.githubURL}/blob/#{metaInfo.gitBranch}/#{metaInfo.projectPath}" nav$.find('.tools').prepend """
  • @@ -255,6 +255,7 @@ $ -> metaInfo = relativeRoot: $('meta[name="groc-relative-root"]').attr('content') githubURL: $('meta[name="groc-github-url"]').attr('content') + gitBranch: $('meta[name="groc-git-branch"]').attr('content') documentPath: $('meta[name="groc-document-path"]').attr('content') projectPath: $('meta[name="groc-project-path"]').attr('content') diff --git a/lib/styles/default/docPage.jade b/lib/styles/default/docPage.jade index ccbc9b8..c5ad0b7 100755 --- a/lib/styles/default/docPage.jade +++ b/lib/styles/default/docPage.jade @@ -8,6 +8,7 @@ html(lang="en") meta(name="groc-document-path", content=targetPath) meta(name="groc-project-path", content=projectPath) - if (project.githubURL) + meta(name="groc-git-branch", content=project.gitBranch) meta(name="groc-github-url", content=project.githubURL) link(rel="stylesheet", type="text/css", media="all", href=relativeRoot + "assets/style.css") script(type="text/javascript", src=relativeRoot + "assets/behavior.js") @@ -16,7 +17,7 @@ html(lang="en") #meta - if (project.githubURL) .file-path - a(href=project.githubURL + '/blob/master/' + projectPath)= projectPath + a(href=project.githubURL + '/blob/' + project.gitBranch + '/' + projectPath)= projectPath - else .file-path= projectPath #document From 05d43d34e27ea2b896c141029eb711c184ba30d9 Mon Sep 17 00:00:00 2001 From: Matthew Russell Date: Fri, 5 Feb 2016 17:26:16 -0800 Subject: [PATCH 2/2] Add default to branch option and move out of if block --- lib/cli.coffee | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/cli.coffee b/lib/cli.coffee index 2bf6753..74b1c5a 100755 --- a/lib/cli.coffee +++ b/lib/cli.coffee @@ -82,6 +82,7 @@ module.exports = CLI = (inputArgs, callback) -> 'repository-branch': describe: "Supply your git branch" type: 'string' + default: 'master' 'only-render-newer': describe: "Only render files if the source is newer than the output." @@ -236,10 +237,10 @@ module.exports = CLI = (inputArgs, callback) -> onlyRenderNewer: argv['only-render-newer'] style: style + project.gitBranch = argv['repository-branch'] # Good to go! unless argv.github project.githubURL = argv['repository-url'] - project.gitBranch = argv['repository-branch'] project.generate options, (error) -> callback error