-
Notifications
You must be signed in to change notification settings - Fork 595
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #734 from callmehiphop/common-docs
Migrating to gcloud-common docs
- Loading branch information
Showing
18 changed files
with
177 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<script id="contributing-header.html" type="text/ng-template"> | ||
<header header title="Contributing"> | ||
<div class="row row--right"> | ||
<div class="col margin-vertical"> | ||
<a href="https://github.com/GoogleCloudPlatform/gcloud-common/edit/master/contributing/readme.md" | ||
class="v-btn"> | ||
<img src="site/img/icon-link-github.svg" /> | ||
Edit on GitHub | ||
</a> | ||
</div> | ||
</div> | ||
</header> | ||
</script> | ||
|
||
<div subpage | ||
header-templateUrl="contributing-header.html" | ||
title="Contributing"> | ||
<div | ||
gcloud-markdown="https://raw.githubusercontent.com/GoogleCloudPlatform/gcloud-common/master/contributing/readme.md"> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
angular | ||
.module('gcloud.contributing', ['ngRoute', 'gcloud.subpage', 'gcloud.markdown']) | ||
.config(function($routeProvider) { | ||
'use strict'; | ||
|
||
$routeProvider.when('/contributing', { | ||
controller: 'ContributingCtrl', | ||
templateUrl: 'site/components/contributing/contributing.html', | ||
reloadOnSearch: false | ||
}); | ||
}) | ||
|
||
.controller('ContributingCtrl', function($scope) { | ||
'use strict'; | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
angular | ||
.module('gcloud.markdown') | ||
.directive('gcloudMarkdown', function (mdConverter, mdDeeplink, $http, $sce, $compile, $location, $window, $timeout) { | ||
return { | ||
retstrict: 'A', | ||
link: function (scope, element, attrs) { | ||
// could be cross domain, but that's ok! | ||
var markdown = $sce.trustAsResourceUrl(attrs.gcloudMarkdown); | ||
|
||
// fetch markdown | ||
$http.get(markdown).then(function (resp) { | ||
var html, blocks; | ||
|
||
// make it pretty! | ||
html = mdConverter.makeHtml(resp.data); | ||
element.html(html); | ||
blocks = element.find('pre').find('code'); | ||
angular.forEach(blocks, hljs.highlightBlock); | ||
|
||
// this will trigger any directives inside the markdown | ||
// e.g. "hljs-class" | ||
$compile(element.contents())(scope); | ||
|
||
// wrapping in timeout to get around paint lag | ||
$timeout(function () { | ||
mdDeeplink($location.search().section) | ||
}, 50); | ||
}); | ||
} | ||
}; | ||
}) | ||
.directive('gcloudScroll', function (mdDeeplink, $location) { | ||
return { | ||
restrict: 'A', | ||
link: function (scope, elem, attrs) { | ||
elem.on('click', function (e) { | ||
mdDeeplink(attrs.gcloudScroll); | ||
}); | ||
} | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
angular | ||
.module('gcloud.markdown', []) | ||
.config(function ($anchorScrollProvider) { | ||
$anchorScrollProvider.disableAutoScrolling(); | ||
}) | ||
.factory('mdConverter', function ($location, $interpolate) { | ||
var template = '<a gcloud-scroll="{{id}}" href="#{{href}}">{{text}}</a>'; | ||
var anchor = $interpolate(template); | ||
|
||
return new showdown.Converter({ | ||
extensions: [function () { | ||
return [{ | ||
type: 'lang', | ||
// unescaped version \[([^\]]+)\]\(([\/|\#][^)]+)\) | ||
regex: '\\[([^\\]]+)\\]\\(([\\/|\\#][^)]+)\\)', | ||
replace: function (match, text, href) { | ||
var isDeeplink = /^\#/.test(href); | ||
var data = { text: text }; | ||
|
||
if (isDeeplink) { | ||
data.id = href.replace('#', ''); | ||
data.href = $location.path() + '?section=' + data.id; | ||
} else { | ||
data.href = href.replace('readme.md', ''); | ||
} | ||
|
||
return anchor(data); | ||
} | ||
}]; | ||
}] | ||
}); | ||
}) | ||
.factory('mdDeeplink', function ($window, $location) { | ||
// retrieve amount to offset the scroll by (height of the page header) | ||
function offset () { | ||
if (!offset._value) { | ||
var el = document.getElementsByClassName('page-header')[0]; | ||
offset._value = el ? el.offsetHeight : 0; | ||
} | ||
|
||
return offset._value; | ||
} | ||
|
||
return function deeplink (section) { | ||
if (!section) return; | ||
// showdown doesn't insert hyphens like ghfm does | ||
var id = section.split('-').join(''); | ||
var el = document.getElementById(id); | ||
|
||
if (!el) return; | ||
|
||
$window.scrollTo(0, el.offsetTop - offset()); | ||
}; | ||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.