Skip to content

Commit 7a5251b

Browse files
committed
add highlight css
1 parent b13460e commit 7a5251b

File tree

7 files changed

+78
-70
lines changed

7 files changed

+78
-70
lines changed

docs/branding/footer.html.in

+2-46
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,7 @@
11
</div><!-- end #content -->
22

3-
<script type="text/javascript" charset="utf-8">
4-
$(function() {
5-
var headerHeight = $("#header").height();
6-
var offsets = [];
7-
var current = -1;
8-
9-
function endpoint(scrollDistance) {
10-
if (scrollDistance < offsets[0]) {
11-
return -1;
12-
} else {
13-
for (var id = offsets.length; id > 0; id--) {
14-
if (scrollDistance > offsets[id - 1]) {
15-
return id - 1;
16-
break;
17-
}
18-
}
19-
}
20-
}
21-
22-
$("h2").each(function(i) {
23-
offsets.push($(this).offset().top - headerHeight)
24-
});
25-
26-
$("#content").append('<h2 class="fixed" style="display: none"><span>&nbsp;</span></h2>');
27-
var fixed_h2 = $("h2.fixed");
28-
var fixed_span = $("h2.fixed span");
29-
30-
$("#content").scroll(function() {
31-
var scrollDistance = $("#content").attr('scrollTop');
32-
var now = endpoint(scrollDistance);
33-
34-
if (now !== current) {
35-
$("#sidebar li").removeClass("current");
36-
current = now;
37-
if (current < 0) {
38-
fixed_h2.hide();
39-
} else if (current >= 0) {
40-
var heading = $($("h2 span")[current]).text();
41-
$("#sidebar a[href|=#" + heading.replace(' ', '-') + "]").parent().addClass("current");
42-
fixed_span.text(heading);
43-
fixed_h2.show();
44-
}
45-
}
46-
});
47-
});
48-
</script>
3+
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
4+
<script type="text/javascript" src="media/js/script.js"></script>
495

506
</body>
517
</html>

docs/branding/header.html.in

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<title>%(title)s</title>
55
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
66
<link rel="stylesheet" type="text/css" href="media/css/style.css">
7-
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
7+
<link rel="stylesheet" type="text/css" href="media/css/highlight.css">
88
</head>
99
<body>
1010
<div id="header">

docs/branding/media/js/script.js

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
2+
/* eslint-disable */
3+
4+
$(function() {
5+
var headerHeight = $("#header").height();
6+
var offsets = [];
7+
var current = -1;
8+
9+
function endpoint(scrollDistance) {
10+
if (scrollDistance < offsets[0]) {
11+
return -1;
12+
} else {
13+
for (var id = offsets.length; id > 0; id--) {
14+
if (scrollDistance > offsets[id - 1]) {
15+
return id - 1;
16+
break;
17+
}
18+
}
19+
}
20+
}
21+
22+
$("h2").each(function(i) {
23+
offsets.push($(this).offset().top - headerHeight)
24+
});
25+
26+
$("#content").append('<h2 class="fixed" style="display: none"><span>&nbsp;</span></h2>');
27+
var fixed_h2 = $("h2.fixed");
28+
var fixed_span = $("h2.fixed span");
29+
30+
$("#content").scroll(function() {
31+
var scrollDistance = $("#content").attr('scrollTop');
32+
var now = endpoint(scrollDistance);
33+
34+
if (now !== current) {
35+
$("#sidebar li").removeClass("current");
36+
current = now;
37+
if (current < 0) {
38+
fixed_h2.hide();
39+
} else if (current >= 0) {
40+
var heading = $($("h2 span")[current]).text();
41+
$("#sidebar a[href|=#" + heading.replace(' ', '-') + "]").parent().addClass("current");
42+
fixed_span.text(heading);
43+
fixed_h2.show();
44+
}
45+
}
46+
});
47+
});

docs/examples.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,7 @@ db.query("SELECT c.*,u.username,u.password " +
546546

547547
To test out this example, try:
548548

549-
```sh
549+
```shell
550550
$ ldapsearch -H ldap://localhost:389 -x -D cn=demo,dc=example,dc=com \
551551
-w demo -b "dc=example,dc=com" objectclass=*
552552
```

docs/guide.md

+16-16
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ keyid=foo
4343

4444
Let's say we wanted to look at the record cn=john:
4545

46-
```sh
46+
```shell
4747
dn: cn=john, ou=users, o=example
4848
cn: john
4949
sn: smith
@@ -114,7 +114,7 @@ If you don't already have node.js and npm, clearly you need those, so follow
114114
the steps at [nodejs.org](http://nodejs.org) and [npmjs.org](http://npmjs.org),
115115
respectively. After that, run:
116116

117-
```sh
117+
```shell
118118
$ npm install ldapjs
119119
```
120120

@@ -139,7 +139,7 @@ server.listen(1389, () => {
139139
And run that. Doing anything will give you errors (LDAP "No Such Object")
140140
since we haven't added any support in yet, but go ahead and try it anyway:
141141

142-
```sh
142+
```shell
143143
$ ldapsearch -H ldap://localhost:1389 -x -b "o=myhost" objectclass=*
144144
```
145145

@@ -205,7 +205,7 @@ add another handler in later you won't get bit by it not being invoked.
205205

206206
Blah blah, let's try running the ldap client again, first with a bad password:
207207

208-
```sh
208+
```shell
209209
$ ldapsearch -H ldap://localhost:1389 -x -D cn=root -w foo -b "o=myhost" objectclass=*
210210

211211
ldap_bind: Invalid credentials (49)
@@ -215,7 +215,7 @@ ldap_bind: Invalid credentials (49)
215215

216216
And again with the correct one:
217217

218-
```sh
218+
```shell
219219
$ ldapsearch -H ldap://localhost:1389 -x -D cn=root -w secret -LLL -b "o=myhost" objectclass=*
220220

221221
No such object (32)
@@ -252,7 +252,7 @@ oriented, so we check that the connection remote user was indeed our `cn=root`
252252
We said we wanted to allow LDAP operations over /etc/passwd, so let's detour
253253
for a moment to explain an /etc/passwd record.
254254

255-
```sh
255+
```shell
256256
jsmith:x:1001:1000:Joe Smith,Room 1007,(234)555-8910,(234)555-0044,email:/home/jsmith:/bin/sh
257257
```
258258

@@ -331,7 +331,7 @@ server.search('o=myhost', pre, (req, res, next) => {
331331

332332
And try running:
333333

334-
```sh
334+
```shell
335335
$ ldapsearch -H ldap://localhost:1389 -x -D cn=root -w secret -LLL -b "o=myhost" cn=root
336336
dn: cn=root, ou=users, o=myhost
337337
cn: root
@@ -345,7 +345,7 @@ objectclass: unixUser
345345

346346
Sweet! Try this out too:
347347

348-
```sh
348+
```shell
349349
$ ldapsearch -H ldap://localhost:1389 -x -D cn=root -w secret -LLL -b "o=myhost" objectclass=*
350350
...
351351
```
@@ -357,7 +357,7 @@ What all did we do here? A lot. Let's break this down...
357357

358358
Let's start with looking at what you even asked for:
359359

360-
```sh
360+
```shell
361361
$ ldapsearch -H ldap://localhost:1389 -x -D cn=root -w secret -LLL -b "o=myhost" cn=root
362362
```
363363

@@ -420,7 +420,7 @@ shell set to `/bin/false` and whose name starts with `p` (I'm doing this
420420
on Ubuntu). Then, let's say we only care about their login name and primary
421421
group id. We'd do this:
422422

423-
```sh
423+
```shell
424424
$ ldapsearch -H ldap://localhost:1389 -x -D cn=root -w secret -LLL -b "o=myhost" "(&(shell=/bin/false)(cn=p*))" cn gid
425425
dn: cn=proxy, ou=users, o=myhost
426426
cn: proxy
@@ -502,7 +502,7 @@ Then, you'll need to be root to have this running, so start your server with
502502
`sudo` (or be root, whatever). Now, go ahead and create a file called
503503
`user.ldif` with the following contents:
504504

505-
```sh
505+
```shell
506506
dn: cn=ldapjs, ou=users, o=myhost
507507
objectClass: unixUser
508508
cn: ldapjs
@@ -512,14 +512,14 @@ description: Created via ldapadd
512512

513513
Now go ahead and invoke with:
514514

515-
```sh
515+
```shell
516516
$ ldapadd -H ldap://localhost:1389 -x -D cn=root -w secret -f ./user.ldif
517517
adding new entry "cn=ldapjs, ou=users, o=myhost"
518518
```
519519

520520
Let's confirm he got added with an ldapsearch:
521521

522-
```sh
522+
```shell
523523
$ ldapsearch -H ldap://localhost:1389 -LLL -x -D cn=root -w secret -b "ou=users, o=myhost" cn=ldapjs
524524
dn: cn=ldapjs, ou=users, o=myhost
525525
cn: ldapjs
@@ -626,7 +626,7 @@ is the 'standard' LDAP attribute for passwords; if you think it's easier to use
626626
command (which lets you change a user's password over stdin). Next, go ahead
627627
and create a `passwd.ldif` file:
628628

629-
```sh
629+
```shell
630630
dn: cn=ldapjs, ou=users, o=myhost
631631
changetype: modify
632632
replace: userPassword
@@ -636,7 +636,7 @@ userPassword: secret
636636

637637
And then run the OpenLDAP CLI:
638638

639-
```sh
639+
```shell
640640
$ ldapmodify -H ldap://localhost:1389 -x -D cn=root -w secret -f ./passwd.ldif
641641
```
642642

@@ -679,7 +679,7 @@ server.del('ou=users, o=myhost', pre, (req, res, next) => {
679679

680680
And then run the following command:
681681

682-
```sh
682+
```shell
683683
$ ldapdelete -H ldap://localhost:1389 -x -D cn=root -w secret "cn=ldapjs, ou=users, o=myhost"
684684
```
685685

docs/index.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ server.listen(1389, () => {
4444

4545
Try hitting that with:
4646

47-
```sh
47+
```shell
4848
$ ldapsearch -H ldap://localhost:1389 -x -b o=example objectclass=*
4949
```
5050

@@ -59,7 +59,7 @@ that you can build LDAP over anything you want, not just traditional databases.
5959

6060
# Getting started
6161

62-
```sh
62+
```shell
6363
$ npm install ldapjs
6464
```
6565

scripts/build-docs.js

+9-4
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@ const fs = require('fs/promises')
22
const path = require('path')
33
const marked = require('marked')
44
const fm = require('front-matter')
5-
const { highlight, highlightAuto } = require('highlight.js')
5+
const { highlight } = require('highlight.js')
66

77
marked.use({
88
highlight: (code, lang) => {
9-
if (!lang) {
10-
return highlightAuto(code).value
9+
if (lang) {
10+
return highlight(lang, code).value
1111
}
12-
return highlight(lang, code).value
12+
13+
return code
1314
}
1415
})
1516

@@ -102,10 +103,14 @@ async function createDocs () {
102103

103104
const dest = path.join(dist, 'media')
104105
const src = path.join(branding, 'media')
106+
const highlightjsStyles = path.resolve(__dirname, '..', 'node_modules', 'highlight.js', 'styles')
105107
await fs.mkdir(dest)
106108
await fs.mkdir(path.join(dest, 'css'))
109+
await fs.mkdir(path.join(dest, 'js'))
107110
await fs.mkdir(path.join(dest, 'img'))
108111
await fs.copyFile(path.join(src, 'css', 'style.css'), path.join(dest, 'css', 'style.css'))
112+
await fs.copyFile(path.join(highlightjsStyles, 'default.css'), path.join(dest, 'css', 'highlight.css'))
113+
await fs.copyFile(path.join(src, 'js', 'script.js'), path.join(dest, 'js', 'script.js'))
109114
await fs.copyFile(path.join(src, 'img', 'logo.svg'), path.join(dest, 'img', 'logo.svg'))
110115
await fs.copyFile(path.join(branding, 'CNAME'), path.join(dist, 'CNAME'))
111116
}

0 commit comments

Comments
 (0)