add highlight css

This commit is contained in:
Tony Brix 2021-02-24 17:02:30 -06:00
parent b13460e4a9
commit 7a5251b47a
7 changed files with 78 additions and 70 deletions

View File

@ -1,51 +1,7 @@
</div><!-- end #content --> </div><!-- end #content -->
<script type="text/javascript" charset="utf-8"> <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
$(function() { <script type="text/javascript" src="media/js/script.js"></script>
var headerHeight = $("#header").height();
var offsets = [];
var current = -1;
function endpoint(scrollDistance) {
if (scrollDistance < offsets[0]) {
return -1;
} else {
for (var id = offsets.length; id > 0; id--) {
if (scrollDistance > offsets[id - 1]) {
return id - 1;
break;
}
}
}
}
$("h2").each(function(i) {
offsets.push($(this).offset().top - headerHeight)
});
$("#content").append('<h2 class="fixed" style="display: none"><span>&nbsp;</span></h2>');
var fixed_h2 = $("h2.fixed");
var fixed_span = $("h2.fixed span");
$("#content").scroll(function() {
var scrollDistance = $("#content").attr('scrollTop');
var now = endpoint(scrollDistance);
if (now !== current) {
$("#sidebar li").removeClass("current");
current = now;
if (current < 0) {
fixed_h2.hide();
} else if (current >= 0) {
var heading = $($("h2 span")[current]).text();
$("#sidebar a[href|=#" + heading.replace(' ', '-') + "]").parent().addClass("current");
fixed_span.text(heading);
fixed_h2.show();
}
}
});
});
</script>
</body> </body>
</html> </html>

View File

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

View File

@ -0,0 +1,47 @@
/* eslint-disable */
$(function() {
var headerHeight = $("#header").height();
var offsets = [];
var current = -1;
function endpoint(scrollDistance) {
if (scrollDistance < offsets[0]) {
return -1;
} else {
for (var id = offsets.length; id > 0; id--) {
if (scrollDistance > offsets[id - 1]) {
return id - 1;
break;
}
}
}
}
$("h2").each(function(i) {
offsets.push($(this).offset().top - headerHeight)
});
$("#content").append('<h2 class="fixed" style="display: none"><span>&nbsp;</span></h2>');
var fixed_h2 = $("h2.fixed");
var fixed_span = $("h2.fixed span");
$("#content").scroll(function() {
var scrollDistance = $("#content").attr('scrollTop');
var now = endpoint(scrollDistance);
if (now !== current) {
$("#sidebar li").removeClass("current");
current = now;
if (current < 0) {
fixed_h2.hide();
} else if (current >= 0) {
var heading = $($("h2 span")[current]).text();
$("#sidebar a[href|=#" + heading.replace(' ', '-') + "]").parent().addClass("current");
fixed_span.text(heading);
fixed_h2.show();
}
}
});
});

View File

@ -546,7 +546,7 @@ db.query("SELECT c.*,u.username,u.password " +
To test out this example, try: To test out this example, try:
```sh ```shell
$ ldapsearch -H ldap://localhost:389 -x -D cn=demo,dc=example,dc=com \ $ ldapsearch -H ldap://localhost:389 -x -D cn=demo,dc=example,dc=com \
-w demo -b "dc=example,dc=com" objectclass=* -w demo -b "dc=example,dc=com" objectclass=*
``` ```

View File

@ -43,7 +43,7 @@ keyid=foo
Let's say we wanted to look at the record cn=john: Let's say we wanted to look at the record cn=john:
```sh ```shell
dn: cn=john, ou=users, o=example dn: cn=john, ou=users, o=example
cn: john cn: john
sn: smith sn: smith
@ -114,7 +114,7 @@ If you don't already have node.js and npm, clearly you need those, so follow
the steps at [nodejs.org](http://nodejs.org) and [npmjs.org](http://npmjs.org), the steps at [nodejs.org](http://nodejs.org) and [npmjs.org](http://npmjs.org),
respectively. After that, run: respectively. After that, run:
```sh ```shell
$ npm install ldapjs $ npm install ldapjs
``` ```
@ -139,7 +139,7 @@ server.listen(1389, () => {
And run that. Doing anything will give you errors (LDAP "No Such Object") And run that. Doing anything will give you errors (LDAP "No Such Object")
since we haven't added any support in yet, but go ahead and try it anyway: since we haven't added any support in yet, but go ahead and try it anyway:
```sh ```shell
$ ldapsearch -H ldap://localhost:1389 -x -b "o=myhost" objectclass=* $ ldapsearch -H ldap://localhost:1389 -x -b "o=myhost" objectclass=*
``` ```
@ -205,7 +205,7 @@ add another handler in later you won't get bit by it not being invoked.
Blah blah, let's try running the ldap client again, first with a bad password: Blah blah, let's try running the ldap client again, first with a bad password:
```sh ```shell
$ ldapsearch -H ldap://localhost:1389 -x -D cn=root -w foo -b "o=myhost" objectclass=* $ ldapsearch -H ldap://localhost:1389 -x -D cn=root -w foo -b "o=myhost" objectclass=*
ldap_bind: Invalid credentials (49) ldap_bind: Invalid credentials (49)
@ -215,7 +215,7 @@ ldap_bind: Invalid credentials (49)
And again with the correct one: And again with the correct one:
```sh ```shell
$ ldapsearch -H ldap://localhost:1389 -x -D cn=root -w secret -LLL -b "o=myhost" objectclass=* $ ldapsearch -H ldap://localhost:1389 -x -D cn=root -w secret -LLL -b "o=myhost" objectclass=*
No such object (32) No such object (32)
@ -252,7 +252,7 @@ oriented, so we check that the connection remote user was indeed our `cn=root`
We said we wanted to allow LDAP operations over /etc/passwd, so let's detour We said we wanted to allow LDAP operations over /etc/passwd, so let's detour
for a moment to explain an /etc/passwd record. for a moment to explain an /etc/passwd record.
```sh ```shell
jsmith:x:1001:1000:Joe Smith,Room 1007,(234)555-8910,(234)555-0044,email:/home/jsmith:/bin/sh jsmith:x:1001:1000:Joe Smith,Room 1007,(234)555-8910,(234)555-0044,email:/home/jsmith:/bin/sh
``` ```
@ -331,7 +331,7 @@ server.search('o=myhost', pre, (req, res, next) => {
And try running: And try running:
```sh ```shell
$ ldapsearch -H ldap://localhost:1389 -x -D cn=root -w secret -LLL -b "o=myhost" cn=root $ ldapsearch -H ldap://localhost:1389 -x -D cn=root -w secret -LLL -b "o=myhost" cn=root
dn: cn=root, ou=users, o=myhost dn: cn=root, ou=users, o=myhost
cn: root cn: root
@ -345,7 +345,7 @@ objectclass: unixUser
Sweet! Try this out too: Sweet! Try this out too:
```sh ```shell
$ ldapsearch -H ldap://localhost:1389 -x -D cn=root -w secret -LLL -b "o=myhost" objectclass=* $ ldapsearch -H ldap://localhost:1389 -x -D cn=root -w secret -LLL -b "o=myhost" objectclass=*
... ...
``` ```
@ -357,7 +357,7 @@ What all did we do here? A lot. Let's break this down...
Let's start with looking at what you even asked for: Let's start with looking at what you even asked for:
```sh ```shell
$ ldapsearch -H ldap://localhost:1389 -x -D cn=root -w secret -LLL -b "o=myhost" cn=root $ ldapsearch -H ldap://localhost:1389 -x -D cn=root -w secret -LLL -b "o=myhost" cn=root
``` ```
@ -420,7 +420,7 @@ shell set to `/bin/false` and whose name starts with `p` (I'm doing this
on Ubuntu). Then, let's say we only care about their login name and primary on Ubuntu). Then, let's say we only care about their login name and primary
group id. We'd do this: group id. We'd do this:
```sh ```shell
$ ldapsearch -H ldap://localhost:1389 -x -D cn=root -w secret -LLL -b "o=myhost" "(&(shell=/bin/false)(cn=p*))" cn gid $ ldapsearch -H ldap://localhost:1389 -x -D cn=root -w secret -LLL -b "o=myhost" "(&(shell=/bin/false)(cn=p*))" cn gid
dn: cn=proxy, ou=users, o=myhost dn: cn=proxy, ou=users, o=myhost
cn: proxy cn: proxy
@ -502,7 +502,7 @@ Then, you'll need to be root to have this running, so start your server with
`sudo` (or be root, whatever). Now, go ahead and create a file called `sudo` (or be root, whatever). Now, go ahead and create a file called
`user.ldif` with the following contents: `user.ldif` with the following contents:
```sh ```shell
dn: cn=ldapjs, ou=users, o=myhost dn: cn=ldapjs, ou=users, o=myhost
objectClass: unixUser objectClass: unixUser
cn: ldapjs cn: ldapjs
@ -512,14 +512,14 @@ description: Created via ldapadd
Now go ahead and invoke with: Now go ahead and invoke with:
```sh ```shell
$ ldapadd -H ldap://localhost:1389 -x -D cn=root -w secret -f ./user.ldif $ ldapadd -H ldap://localhost:1389 -x -D cn=root -w secret -f ./user.ldif
adding new entry "cn=ldapjs, ou=users, o=myhost" adding new entry "cn=ldapjs, ou=users, o=myhost"
``` ```
Let's confirm he got added with an ldapsearch: Let's confirm he got added with an ldapsearch:
```sh ```shell
$ ldapsearch -H ldap://localhost:1389 -LLL -x -D cn=root -w secret -b "ou=users, o=myhost" cn=ldapjs $ ldapsearch -H ldap://localhost:1389 -LLL -x -D cn=root -w secret -b "ou=users, o=myhost" cn=ldapjs
dn: cn=ldapjs, ou=users, o=myhost dn: cn=ldapjs, ou=users, o=myhost
cn: ldapjs cn: ldapjs
@ -626,7 +626,7 @@ is the 'standard' LDAP attribute for passwords; if you think it's easier to use
command (which lets you change a user's password over stdin). Next, go ahead command (which lets you change a user's password over stdin). Next, go ahead
and create a `passwd.ldif` file: and create a `passwd.ldif` file:
```sh ```shell
dn: cn=ldapjs, ou=users, o=myhost dn: cn=ldapjs, ou=users, o=myhost
changetype: modify changetype: modify
replace: userPassword replace: userPassword
@ -636,7 +636,7 @@ userPassword: secret
And then run the OpenLDAP CLI: And then run the OpenLDAP CLI:
```sh ```shell
$ ldapmodify -H ldap://localhost:1389 -x -D cn=root -w secret -f ./passwd.ldif $ ldapmodify -H ldap://localhost:1389 -x -D cn=root -w secret -f ./passwd.ldif
``` ```
@ -679,7 +679,7 @@ server.del('ou=users, o=myhost', pre, (req, res, next) => {
And then run the following command: And then run the following command:
```sh ```shell
$ ldapdelete -H ldap://localhost:1389 -x -D cn=root -w secret "cn=ldapjs, ou=users, o=myhost" $ ldapdelete -H ldap://localhost:1389 -x -D cn=root -w secret "cn=ldapjs, ou=users, o=myhost"
``` ```

View File

@ -44,7 +44,7 @@ server.listen(1389, () => {
Try hitting that with: Try hitting that with:
```sh ```shell
$ ldapsearch -H ldap://localhost:1389 -x -b o=example objectclass=* $ ldapsearch -H ldap://localhost:1389 -x -b o=example objectclass=*
``` ```
@ -59,7 +59,7 @@ that you can build LDAP over anything you want, not just traditional databases.
# Getting started # Getting started
```sh ```shell
$ npm install ldapjs $ npm install ldapjs
``` ```

View File

@ -2,14 +2,15 @@ const fs = require('fs/promises')
const path = require('path') const path = require('path')
const marked = require('marked') const marked = require('marked')
const fm = require('front-matter') const fm = require('front-matter')
const { highlight, highlightAuto } = require('highlight.js') const { highlight } = require('highlight.js')
marked.use({ marked.use({
highlight: (code, lang) => { highlight: (code, lang) => {
if (!lang) { if (lang) {
return highlightAuto(code).value return highlight(lang, code).value
} }
return highlight(lang, code).value
return code
} }
}) })
@ -102,10 +103,14 @@ async function createDocs () {
const dest = path.join(dist, 'media') const dest = path.join(dist, 'media')
const src = path.join(branding, 'media') const src = path.join(branding, 'media')
const highlightjsStyles = path.resolve(__dirname, '..', 'node_modules', 'highlight.js', 'styles')
await fs.mkdir(dest) await fs.mkdir(dest)
await fs.mkdir(path.join(dest, 'css')) await fs.mkdir(path.join(dest, 'css'))
await fs.mkdir(path.join(dest, 'js'))
await fs.mkdir(path.join(dest, 'img')) await fs.mkdir(path.join(dest, 'img'))
await fs.copyFile(path.join(src, 'css', 'style.css'), path.join(dest, 'css', 'style.css')) await fs.copyFile(path.join(src, 'css', 'style.css'), path.join(dest, 'css', 'style.css'))
await fs.copyFile(path.join(highlightjsStyles, 'default.css'), path.join(dest, 'css', 'highlight.css'))
await fs.copyFile(path.join(src, 'js', 'script.js'), path.join(dest, 'js', 'script.js'))
await fs.copyFile(path.join(src, 'img', 'logo.svg'), path.join(dest, 'img', 'logo.svg')) await fs.copyFile(path.join(src, 'img', 'logo.svg'), path.join(dest, 'img', 'logo.svg'))
await fs.copyFile(path.join(branding, 'CNAME'), path.join(dist, 'CNAME')) await fs.copyFile(path.join(branding, 'CNAME'), path.join(dist, 'CNAME'))
} }