Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 28ed5ba

Browse files
dandoyonIgorMinar
authored andcommitted
feat(docs): disqus integration
- add style for disqus threads in css - add loadDisqus method to be called afterPartialLoaded - add div container for disqus threads
1 parent 02dc81b commit 28ed5ba

File tree

3 files changed

+40
-7
lines changed

3 files changed

+40
-7
lines changed

docs/src/templates/docs.css

+7-4
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ li {
268268

269269
/*----- content styles -----*/
270270

271-
#content-panel {
271+
.content-panel {
272272
float: left;
273273
margin-top: 4em;
274274
margin-left: 3em;
@@ -286,16 +286,15 @@ li {
286286
border-radius: 15px;
287287
}
288288

289-
#content-panel > h2 {
289+
.content-panel > h2 {
290290
font-size: 2em;
291291
font-weight: normal;
292292
color: #fff;
293293
margin: 0 4em 0 0;
294294
height: 1em;
295295
}
296296

297-
298-
#content {
297+
.content-panel-content {
299298
background-color: #fff;
300299
display: block;
301300
margin: 0.7em -1em -1em;
@@ -354,6 +353,10 @@ li {
354353
padding-left: 0;
355354
}
356355

356+
#disqus #disqus_thread {
357+
margin: 0.7em -1em -1em;
358+
}
359+
357360
/* subpages */
358361

359362
#fader {

docs/src/templates/docs.js

+23-1
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,13 @@ function DocsController($location, $window, $cookies) {
7171
};
7272

7373
scope.afterPartialLoaded = function() {
74+
var currentPageId = $location.path();
7475
scope.loading--;
7576
scope.partialTitle = scope.futurePartialTitle;
7677
SyntaxHighlighter.highlight();
7778
$window.scrollTo(0,0);
78-
$window._gaq.push(['_trackPageview', $location.path()]);
79+
$window._gaq.push(['_trackPageview', currentPageId]);
80+
loadDisqus(currentPageId);
7981
};
8082

8183
scope.getFeedbackUrl = function() {
@@ -105,6 +107,26 @@ function DocsController($location, $window, $cookies) {
105107
});
106108
}
107109
});
110+
111+
function loadDisqus(currentPageId) {
112+
// http://docs.disqus.com/help/2/
113+
window.disqus_shortname = 'angularjs';
114+
window.disqus_identifier = currentPageId;
115+
116+
if ($location.host() == 'localhost') {
117+
window.disqus_developer = 1;
118+
}
119+
120+
// http://docs.disqus.com/developers/universal/
121+
(function() {
122+
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
123+
dsq.src = 'http://angularjs.disqus.com/embed.js';
124+
(document.getElementsByTagName('head')[0] ||
125+
document.getElementsByTagName('body')[0]).appendChild(dsq);
126+
})();
127+
128+
angular.element(document.getElementById('disqus_thread')).html('');
129+
}
108130
}
109131

110132
// prevent compilation of code

docs/src/templates/index.html

+10-2
Original file line numberDiff line numberDiff line change
@@ -114,10 +114,18 @@
114114
<div id="loading" ng:show="loading">Loading...</div>
115115

116116

117-
<div id="content-panel">
117+
<div class="content-panel">
118118
<h2 ng:bind="partialTitle"></h2>
119119
<a id="feedback" ng:href="{{getFeedbackUrl()}}">Report an Issue or Ask a Question</a>
120-
<ng:include id="content" src="getCurrentPartial()" onload="afterPartialLoaded()"></ng:include>
120+
<ng:include id="content"
121+
class="content-panel-content"
122+
src="getCurrentPartial()"
123+
onload="afterPartialLoaded()"></ng:include>
124+
</div>
125+
126+
<div id="disqus" class="content-panel">
127+
<h2>Discussion</h2>
128+
<div id="disqus_thread" class="content-panel-content"></div>
121129
</div>
122130

123131
<div id="footer" ng:cloak>

0 commit comments

Comments
 (0)