Skip to content

Commit

Permalink
feat: command-line interface for generating presentations from markdown
Browse files Browse the repository at this point in the history
* add script to package.json

* README-driven development

* saner expectation

* use node gitignore

* update user guide

* add templates for biggie integration

* add biggie as big-presentation-compose

* use original index.html

* remove minimist

* remove .gitignore
  • Loading branch information
Bill Morris authored and tmcw committed Aug 4, 2017
1 parent 30ce3be commit c5e3aa7
Show file tree
Hide file tree
Showing 6 changed files with 88 additions and 3 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,14 @@ $ cd all-about-cats
$ big-presentation-serve
```

Convert a presentation composed in markdown into serve-able html.

```sh
$ cd all-about-cats
$ big-presentation-compose
```
_(This will convert an `index.md` file in that presentation directory into an `index.html`)_

:tada: :tada: :tada: :tada: :tada:

* [Demo](http://macwright.org/big/demo.html)
Expand Down
24 changes: 24 additions & 0 deletions bin/big-presentation-compose.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env node

// Pulled from https://github.com/tmcw/biggie/blob/gh-pages/cli.js
var concat = require('concat-stream');
var fs = require('fs');
var marked = require('marked');
var mustache = require('mustache');

fs.createReadStream('index.md').pipe(concat(convert));

function convert(data) {
var divs = data.toString().split('---').filter(function(v) {
return v.replace(/\s/g, '');
}).map(function(v) {
return '<div>' + marked(v) + '</div>';
}).join('\n');

fs.writeFileSync('index.html', mustache.render(
fs.readFileSync('template.hbs', 'utf8'), {
//TODO parameterize title?
title: 'big',
slides: divs
}), null, 2)
}
5 changes: 4 additions & 1 deletion docs/user-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ which helps create and serve presentations. Install it globally with `npm` or

`big-presentation` is the tool you use to create, manage and give big presentations.

When you install it with npm or yarn, you get these three utilities:
When you install it with npm or yarn, you get these four utilities:

* `big-presentation-init`
* Initializes presentations. Run it just like that to dump the necessary
Expand All @@ -22,6 +22,9 @@ When you install it with npm or yarn, you get these three utilities:
* `big-presentation-offline`
* Creates an `index.offline.html` file with everything that can be included,
included inline in the HTML, so you don't have to trust wifi
* `big-presentation-compose`
* Writes from a file you've composed in [Markdown](https://help.ghost.org/hc/en-us/articles/224410728-Markdown-Guide)
into html suitable for a big presentation. (Writes from `index.md` to `index.html`)

## Writing a presentation

Expand Down
27 changes: 27 additions & 0 deletions lib/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
## Write a big presentation in Markdown

---

It's _big_, but a little more eazy

---

Put dashes between slides to separate them.

---

Supports lists

* Like
* This
* One

---

Run

```sh
big-presentation-compose
```

to publish your presentation.
19 changes: 19 additions & 0 deletions lib/template.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8'>
<meta name='viewport' content='width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0' />
<title>{{{ title }}}</title>
<link href='big.css' rel='stylesheet' type='text/css' />
<link href='highlight.css' rel='stylesheet' type='text/css' />
<style>
.new-shiny { background: #aaaaaa; }
</style>
<script src='big.js'></script>
<script src='highlight.js'></script>
<script>hljs.initHighlightingOnLoad();</script>
</head>
<body class='light'>
{{{ slides }}}
</body>
</html>
8 changes: 6 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "big-presentation",
"version": "3.1.0",
"version": "3.2.0",
"description": "a presentation system for busy messy hackers",
"main": "big.js",
"scripts": {
Expand All @@ -11,7 +11,8 @@
"bin": {
"big-presentation-init": "./bin/big-presentation-init.js",
"big-presentation-serve": "./bin/big-presentation-serve.js",
"big-presentation-offline": "./bin/big-presentation-offline.js"
"big-presentation-offline": "./bin/big-presentation-offline.js",
"big-presentation-compose": "./bin/big-presentation-compose.js"
},
"repository": {
"type": "git",
Expand Down Expand Up @@ -75,10 +76,13 @@
"extends": "eslint:recommended"
},
"dependencies": {
"concat-stream": "^1.6.0",
"ecstatic": "^2.1.0",
"get-port": "^3.1.0",
"inliner": "^1.12.1",
"ip": "^1.1.5",
"marked": "^0.3.6",
"mustache": "^2.3.0",
"shelljs": "^0.7.7"
}
}

0 comments on commit c5e3aa7

Please sign in to comment.