Skip to content

Commit dd5de38

Browse files
authored
Merge branch 'master' into fix/212/bit-docs-html-canjs
2 parents d5758f3 + 39a4238 commit dd5de38

30 files changed

+28737
-21523
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ temp/
33
index.html
44
.vscode
55
*.log
6+
.DS_Store

bit-docs.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
var path = require("path");
2+
var tags = require('./tags/tags');
23

34
module.exports = function(bitDocs){
45
var pkg = require("./package.json");
@@ -9,4 +10,6 @@ module.exports = function(bitDocs){
910
templates: path.join(__dirname, "templates"),
1011
dependencies: dependencies
1112
});
12-
}
13+
14+
bitDocs.register("tags", tags);
15+
}

docMap.json

Lines changed: 27439 additions & 21300 deletions
Large diffs are not rendered by default.

make-example.js

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,25 @@
11
var generate = require("bit-docs-generate-html/generate");
2+
var generateSearchMap = require("bit-docs-generate-searchmap/generate");
23
var Q = require("q");
34
var fs = require("fs");
45
var readFile = Q.denodeify(fs.readFile);
56
var path = require("path");
67

8+
var forceBuild = process.argv.indexOf("-f") !== -1;
9+
710
var docMap = readFile(__dirname+"/docMap.json").then(function(source){
811
return JSON.parse(""+source);
912
});
10-
11-
var forceBuild = process.argv.indexOf("-f") !== -1;
12-
13-
generate(docMap,{
13+
var siteConfig = {
1414
html: {
1515
templates: path.join(__dirname, "templates"),
1616
dependencies: {
1717
"bit-docs-html-canjs": __dirname,
1818
"bit-docs-prettify": "^0.1.0",
19-
"bit-docs-html-highlight-line": "^0.2.2"
19+
"bit-docs-html-highlight-line": "^0.2.2",
20+
//TODO: This should not be include here and should only be included in package.json.
21+
// we get an error without this, here, though
22+
"steal-stache": "^3.0.1"
2023
}
2124
},
2225
dest: path.join(__dirname, "temp"),
@@ -27,4 +30,8 @@ generate(docMap,{
2730
"2.3.27": "https://v2.canjs.com"
2831
},
2932
debug: true
33+
};
34+
35+
generate(docMap,siteConfig).then(function(){
36+
return generateSearchMap(docMap, siteConfig);
3037
}).done();

package.json

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "bit-docs-html-canjs",
3-
"version": "0.4.14",
3+
"version": "0.6.0",
44
"description": "The plugins to produce the CanJS site",
55
"main": "static/canjs",
66
"scripts": {
@@ -27,13 +27,18 @@
2727
"homepage": "https://github.com/canjs/bit-docs-html-canjs#readme",
2828
"system": {},
2929
"dependencies": {
30+
"can-control": "^3.0.3",
31+
"can-util": "^3.0.10",
3032
"escape-html": "^1.0.3",
3133
"jquery": "^2.2.4",
3234
"lodash": "^4.17.4",
35+
"lunr": "^2.0.3",
36+
"steal-stache": "^3.0.1",
3337
"unescape-html": "^1.0.0"
3438
},
3539
"devDependencies": {
36-
"bit-docs-generate-html": "^0.3.0",
40+
"bit-docs-generate-html": "^0.5.0",
41+
"bit-docs-generate-searchmap": "^0.0.1-0",
3742
"q": "^1.4.1",
3843
"connect": "^2.14.4",
3944
"normalize.css": "^4.1.1",

static/article-title.less

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,14 @@ ul.title-links {
3232
.page-type{
3333
h1{
3434
display: inline-block;
35+
float: left;
36+
}
37+
.title-social {
38+
float: right;
39+
margin-top: 15px;
40+
li{
41+
margin: 0 0 0 15px;
42+
}
3543
}
3644
div{
3745
display: inline-block;
@@ -50,8 +58,8 @@ ul.title-links {
5058
display: block;
5159
color: @link-color;
5260
line-height: 1.7em;
53-
cursor: pointer;
5461
a:hover{
62+
cursor: pointer;
5563
text-decoration: underline;
5664
}
5765
}
@@ -65,3 +73,16 @@ ul.title-links {
6573
.description{
6674
margin: @gutter 0;
6775
}
76+
77+
/* Homepage hero images*/
78+
.hero-images {
79+
border: 1px solid #EEE;
80+
padding: 30px;
81+
.tortoise {
82+
float: right;
83+
padding-right: 40px;
84+
}
85+
.hare {
86+
padding-left: 40px;
87+
}
88+
}

static/canjs.js

Lines changed: 53 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ var LoadingBar = require('./loading-bar.js');
33
$ = require("jquery");
44
var debounce = require("lodash/debounce");
55
var loader = new LoadingBar('blue');
6+
var SearchControl = require('./search');
67

78
// state
89
var $articleContainer,
@@ -12,22 +13,31 @@ var $articleContainer,
1213
$everything,
1314
$headers,
1415
$nav,
16+
$pathPrefix,
1517
headerHidden,
1618
animating,
1719
navigating,
1820
scrollPositionInterval,
19-
currentHref;
21+
currentHref,
22+
searchControl,
23+
hasShownSearch;
2024

2125
(function() {
26+
//flag that determines whether or not the search has already been shown
27+
//(used for fading in or not)
28+
hasShownSearch = false;
2229
init();
2330

2431
// prevent sidebar from changing width when header hides
2532
$('#left').css('min-width', $('.top-left').width());
2633

2734
// Override link behavior
2835
$(document.body).on("click", "a", function(ev) {
29-
var noModifierKeys = !ev.altKey && !ev.ctrlKey && !ev.metaKey && !ev.shiftKey;
30-
if (noModifierKeys && this.hostname === window.location.hostname) {
36+
var noModifierKeys = !ev.altKey && !ev.ctrlKey && !ev.metaKey && !ev.shiftKey,
37+
sameHostname = this.hostname === window.location.hostname,
38+
sameProtocol = this.protocol === window.location.protocol;
39+
40+
if (noModifierKeys && sameHostname && sameProtocol) {
3141
ev.preventDefault();
3242
var href = this.href;
3343
window.history.pushState(null, null, href);
@@ -69,13 +79,35 @@ function init() {
6979
$everything = $('#everything');
7080
$headers = getHeaders();
7181
$nav = $('.top-left > .brand, .top-right-top');
82+
$pathPrefix = $("[path-prefix]").first();
7283
headerHidden = undefined;
7384
currentHref = window.location.href;
7485

86+
setPathPrefix();
7587
setOnThisPageContent();
7688
buildTOC();
7789
setNavToggleListener();
7890
setScrollPosition();
91+
searchControl = new SearchControl(".search-bar", {
92+
navigate: function(href){
93+
window.history.pushState(null, null, href);
94+
navigate(href);
95+
},
96+
pathPrefix: window.pathPrefix,
97+
animateInOnStart: !hasShownSearch
98+
});
99+
100+
hasShownSearch = true;
101+
}
102+
103+
function setPathPrefix(){
104+
var pathPrefix;
105+
if($pathPrefix && $pathPrefix.length){
106+
pathPrefix = $pathPrefix.attr("path-prefix");
107+
if(pathPrefix && pathPrefix.length){
108+
window.pathPrefix = pathPrefix;
109+
}
110+
}
79111
}
80112

81113
function setDocTitle() {
@@ -163,14 +195,27 @@ function navigate(href) {
163195
if (!$content.length) {
164196
window.location.reload();
165197
}
166-
var $nav = $content.find(".bottom-left > ul");
167-
var $article = $content.find("article");
168-
var $breadcrumb = $content.find(".breadcrumb");
169-
var homeLink = $content.find(".logo > a").attr('href');
170-
$(".bottom-left>ul").replaceWith($nav);
198+
var $nav = $content.find(".bottom-left > ul"),
199+
$article = $content.find("article"),
200+
$breadcrumb = $content.find(".breadcrumb"),
201+
homeLink = $content.find(".logo > a").attr('href'),
202+
$navReplace = $(".bottom-left>ul"),
203+
204+
//root elements - use .filter; not .find
205+
$pathPrefixDiv = $content.filter("[path-prefix]");
206+
207+
208+
//if any page doesn't have a nav, replacing it won't work,
209+
//and the nav will be gone for any subsequent page visits
210+
if($navReplace && $navReplace.length){
211+
$navReplace.replaceWith($nav);
212+
}else{
213+
$(".bottom-left").append($nav);
214+
}
171215
$("article").replaceWith($article);
172216
$(".breadcrumb").replaceWith($breadcrumb);
173217
$(".logo > a").attr('href', homeLink);
218+
$("[path-prefix]").replaceWith($pathPrefixDiv);
174219

175220
// Initialize jsbin scripts
176221
delete window.jsbinified;

static/canjs.less

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,4 @@
2020
@import "breadcrumb.less";
2121
@import "screenshots.less";
2222
@import "loading-bar.less";
23+
@import "search.less";

static/header.less

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,6 @@
66
justify-content: space-between;
77
}
88

9-
.top-left {
10-
display: none;
11-
}
12-
139
.brand {
1410
height: 53px;
1511
padding-top: @gutter;
@@ -41,10 +37,6 @@
4137

4238
// ----- CANJS LOGO AND VERSION DESKTOP -----
4339
@media screen and (min-width: @breakpoint) {
44-
.top-left {
45-
display: block;
46-
}
47-
4840
.brand {
4941
.dropdown {
5042
position: absolute;
@@ -132,16 +124,7 @@
132124
font-size: 14px;
133125
margin-right: @gutter;
134126
> a {
135-
font-weight: 700;
136-
font-size: 12px;
137-
padding: 2px 10px;
138-
line-height: 20px;
139-
.border-radius;
140-
.border;
141-
&:hover {
142-
text-decoration: none;
143-
background: @border-color;
144-
}
127+
.button-link
145128
}
146129
}
147130
}

static/img/icon-search-white.svg

Lines changed: 6 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)