Improve README auto-generation

Now screenshots are automatically embedded into the README
This commit is contained in:
Maddison Hellstrom 2017-11-17 06:31:29 -08:00
parent d8e8c0ab25
commit 5a718243d3
16 changed files with 85 additions and 96 deletions

111
README.md
View File

@ -18,50 +18,52 @@ This is my personal configuration for the wonderful [SurfingKeys](https://github
#### Bundled Search Engine Completions
There are currently 36 Search Engine auto-completions.
There are currently 38 Search Engine auto-completions.
You can access a Search Engine auto-completion by pressing the search leader key, which is `a` by default, followed by the search engine alias.
For example, to open the Wikipedia completion, you would type `awp` while in normal mode.
| Alias | Name | Domain |
| ---- | ------ | ----- |
| `al` | `archlinux` | `www.archlinux.org` |
| `au` | `AUR` | `aur.archlinux.org` |
| `aw` | `archwiki` | `wiki.archlinux.org` |
| `az` | `amazon` | `smile.amazon.com` |
| `cl` | `craigslist` | `craigslist.org` |
| `co` | `crunchbase-orgs` | `www.crunchbase.com` |
| `cp` | `crunchbase-people` | `www.crunchbase.com` |
| `cs` | `chromestore` | `chrome.google.com` |
| `de` | `define` | `onelook.com` |
| `dg` | `duckduckgo` | `duckduckgo.com` |
| `dh` | `dockerhub` | `hub.docker.com` |
| `do` | `domainr` | `domainr.com` |
| `ex` | `exdocs` | `hex.pm` |
| `gd` | `godoc` | `godoc.org` |
| `gh` | `github` | `github.com` |
| `gl` | `google-lucky` | `www.google.com` |
| `go` | `google` | `www.google.com` |
| `gs` | `go-search` | `go-search.org` |
| `ha` | `hackage` | `hackage.haskell.org` |
| `hd` | `hexdocs` | `hex.pm` |
| `hn` | `hackernews` | `hn.algolia.com` |
| `ho` | `hoogle` | `www.haskell.org` |
| `hw` | `haskellwiki` | `wiki.haskell.org` |
| `hx` | `hex` | `hex.pm` |
| `hy` | `hayoo` | `hayoo.fh-wedel.de` |
| `md` | `mdn` | `developer.mozilla.org` |
| `np` | `npm` | `www.npmjs.com` |
| `ow` | `owasp` | `www.owasp.org` |
| `re` | `reddit` | `www.reddit.com` |
| `so` | `stackoverflow` | `stackoverflow.com` |
| `th` | `thesaurus` | `www.onelook.com` |
| `vw` | `vimwikia` | `vim.wikia.com` |
| `wa` | `wolframalpha` | `www.wolframalpha.com` |
| `wp` | `wikipedia` | `en.wikipedia.org` |
| `yp` | `yelp` | `www.yelp.com` |
| `yt` | `youtube` | `www.youtube.com` |
| Alias | Name | Domain | Screenshots |
| ---- | ------ | ----- | ----- |
| `af` | `archforums` | `Google Custom Search` | |
| `al` | `archlinux` | `www.archlinux.org` | |
| `au` | `AUR` | `aur.archlinux.org` | |
| `aw` | `archwiki` | `wiki.archlinux.org` | |
| `az` | `amazon` | `smile.amazon.com` | |
| `cl` | `craigslist` | `craigslist.org` | |
| `co` | `crunchbase-orgs` | `www.crunchbase.com` | |
| `cp` | `crunchbase-people` | `www.crunchbase.com` | [\[1\]](#crunchbase-people) |
| `cs` | `chromestore` | `chrome.google.com` | |
| `de` | `define` | `onelook.com` | [\[1\]](#define) |
| `dg` | `duckduckgo` | `duckduckgo.com` | |
| `dh` | `dockerhub` | `hub.docker.com` | [\[1\]](#dockerhub) |
| `do` | `domainr` | `domainr.com` | [\[1\]](#domainr) |
| `ex` | `exdocs` | `hex.pm` | |
| `gd` | `godoc` | `godoc.org` | |
| `gh` | `github` | `github.com` | [\[1\]](#github) |
| `gl` | `google-lucky` | `www.google.com` | |
| `go` | `google` | `www.google.com` | |
| `gs` | `go-search` | `go-search.org` | |
| `ha` | `hackage` | `hackage.haskell.org` | |
| `hd` | `hexdocs` | `hex.pm` | |
| `hn` | `hackernews` | `hn.algolia.com` | [\[1\]](#hackernews) |
| `ho` | `hoogle` | `www.haskell.org` | [\[1\]](#hoogle) |
| `hw` | `haskellwiki` | `wiki.haskell.org` | |
| `hx` | `hex` | `hex.pm` | |
| `hy` | `hayoo` | `hayoo.fh-wedel.de` | |
| `md` | `mdn` | `developer.mozilla.org` | [\[1\]](#mdn) |
| `no` | `node` | `Google Custom Search` | |
| `np` | `npm` | `www.npmjs.com` | [\[1\]](#npm) |
| `ow` | `owasp` | `www.owasp.org` | |
| `re` | `reddit` | `www.reddit.com` | |
| `so` | `stackoverflow` | `stackoverflow.com` | |
| `th` | `thesaurus` | `www.onelook.com` | [\[1\]](#thesaurus) |
| `vw` | `vimwikia` | `vim.wikia.com` | |
| `wa` | `wolframalpha` | `www.wolframalpha.com` | [\[1\]](#wolframalpha) [\[2\]](#wolframalpha-2) |
| `wp` | `wikipedia` | `en.wikipedia.org` | |
| `yp` | `yelp` | `www.yelp.com` | |
| `yt` | `youtube` | `www.youtube.com` | [\[1\]](#youtube) |
#### Installation
@ -125,45 +127,46 @@ The final step is to tell SurfingKeys where to find your configuration file:
If you ever make a change to any of your configuration files in the future, simply run `gulp install` again and your settings will be immediately updated.
#### Screenshots
##### crunchbase-people
![crunchbase-people](./assets/crunchbase-people.png)
![crunchbase-people screenshot](./assets/screenshots/cp.png)
##### define
![define](./assets/define.png)
![define screenshot](./assets/screenshots/de.png)
##### dockerhub
![dockerhub](./assets/dockerhub.png)
![dockerhub screenshot](./assets/screenshots/dh.png)
##### domainr
![domainr](./assets/domainr.png)
![domainr screenshot](./assets/screenshots/do.png)
##### github
![github](./assets/github.png)
![github screenshot](./assets/screenshots/gh.png)
##### hackernews
![hackernews](./assets/hackernews.png)
![hackernews screenshot](./assets/screenshots/hn.png)
##### hoogle
![hoogle](./assets/hoogle.png)
![hoogle screenshot](./assets/screenshots/ho.png)
##### mdn
![mdn](./assets/mdn.png)
![mdn screenshot](./assets/screenshots/md.png)
##### npm
![npm](./assets/npm.png)
![npm screenshot](./assets/screenshots/np.png)
##### thesaurus
![thesaurus](./assets/thesaurus.png)
![thesaurus screenshot](./assets/screenshots/th.png)
##### wolframalpha
![wolframalpha-01](./assets/wolframalpha-01.png)
![wolframalpha screenshot](./assets/screenshots/wa-01.png)
##### wolframalpha
![wolframalpha-02](./assets/wolframalpha-02.png)
##### wolframalpha 2
![wolframalpha screenshot](./assets/screenshots/wa-02.png)
##### youtube
![youtube](./assets/youtube.png)
![youtube screenshot](./assets/screenshots/yt.png)
### License
©2017 Maddison Hellstrom - MIT License

View File

@ -18,8 +18,8 @@ You can access a Search Engine auto-completion by pressing the search leader key
For example, to open the Wikipedia completion, you would type `awp` while in normal mode.
| Alias | Name | Domain |
| ---- | ------ | ----- |
| Alias | Name | Domain | Screenshots |
| ---- | ------ | ----- | ----- |
<!--COMPL_TABLE-->
#### Installation
@ -83,45 +83,7 @@ The final step is to tell SurfingKeys where to find your configuration file:
If you ever make a change to any of your configuration files in the future, simply run `gulp install` again and your settings will be immediately updated.
#### Screenshots
##### crunchbase-people
![crunchbase-people](./assets/crunchbase-people.png)
##### define
![define](./assets/define.png)
##### dockerhub
![dockerhub](./assets/dockerhub.png)
##### domainr
![domainr](./assets/domainr.png)
##### github
![github](./assets/github.png)
##### hackernews
![hackernews](./assets/hackernews.png)
##### hoogle
![hoogle](./assets/hoogle.png)
##### mdn
![mdn](./assets/mdn.png)
##### npm
![npm](./assets/npm.png)
##### thesaurus
![thesaurus](./assets/thesaurus.png)
##### wolframalpha
![wolframalpha-01](./assets/wolframalpha-01.png)
##### wolframalpha
![wolframalpha-02](./assets/wolframalpha-02.png)
##### youtube
![youtube](./assets/youtube.png)
<!--SCREENSHOTS-->
### License
&copy;2017 Maddison Hellstrom - MIT License

View File

Before

Width:  |  Height:  |  Size: 146 KiB

After

Width:  |  Height:  |  Size: 146 KiB

View File

Before

Width:  |  Height:  |  Size: 50 KiB

After

Width:  |  Height:  |  Size: 50 KiB

View File

Before

Width:  |  Height:  |  Size: 122 KiB

After

Width:  |  Height:  |  Size: 122 KiB

View File

Before

Width:  |  Height:  |  Size: 72 KiB

After

Width:  |  Height:  |  Size: 72 KiB

View File

Before

Width:  |  Height:  |  Size: 152 KiB

After

Width:  |  Height:  |  Size: 152 KiB

View File

Before

Width:  |  Height:  |  Size: 154 KiB

After

Width:  |  Height:  |  Size: 154 KiB

View File

Before

Width:  |  Height:  |  Size: 168 KiB

After

Width:  |  Height:  |  Size: 168 KiB

View File

Before

Width:  |  Height:  |  Size: 157 KiB

After

Width:  |  Height:  |  Size: 157 KiB

View File

Before

Width:  |  Height:  |  Size: 94 KiB

After

Width:  |  Height:  |  Size: 94 KiB

View File

Before

Width:  |  Height:  |  Size: 121 KiB

After

Width:  |  Height:  |  Size: 121 KiB

View File

Before

Width:  |  Height:  |  Size: 162 KiB

After

Width:  |  Height:  |  Size: 162 KiB

View File

Before

Width:  |  Height:  |  Size: 85 KiB

After

Width:  |  Height:  |  Size: 85 KiB

View File

Before

Width:  |  Height:  |  Size: 135 KiB

After

Width:  |  Height:  |  Size: 135 KiB

View File

@ -3,8 +3,10 @@ const concat = require('gulp-concat');
const replace = require('gulp-replace');
const rename = require('gulp-rename');
const jshint = require('gulp-jshint');
const path = require('path');
const del = require('del');
const os = require('os');
const fs = require('fs');
const spawn = require('child_process').spawn;
const { URL } = require('url');
const compl = require('./completions');
@ -13,6 +15,7 @@ var paths = {
scripts: ['conf.priv.js', 'completions.js', 'conf.js'],
gulpfile: ['gulpfile.js'],
readme: ['README.tmpl.md'],
screenshots: 'assets/screenshots',
};
// This notice will be injected into the generated README.md file
@ -73,6 +76,16 @@ gulp.task('watch-nogulpfile', function() {
});
gulp.task('readme', function() {
var screens = {};
var screenshotList = "";
fs.readdirSync(path.join(__dirname, paths.screenshots)).forEach(function(s) {
var file = path.basename(s, '.png').split('-');
var alias = file[0];
if (!screens[alias]) {
screens[alias] = [];
}
screens[alias].push(path.join(paths.screenshots, path.basename(s)));
});
var table = Object.keys(compl).sort(function(a, b) {
if (a < b) return -1;
if (a > b) return 1;
@ -80,12 +93,23 @@ gulp.task('readme', function() {
}).reduce(function(a, k) {
var c = compl[k];
var u = new URL(c.search);
return a + `| \`${c.alias}\` | \`${c.name}\` | \`${u.hostname}\` |\n`;
var domain = (u.hostname === "cse.google.com") ? "Google Custom Search" : u.hostname;
var s = "";
if (screens[c.alias]) {
screens[c.alias].forEach(function(url, i) {
var num = (i > 0) ? ` ${i+1}` : "";
s += `[\\[${i+1}\\]](#${c.name}${num.replace(' ', '-')}) `;
screenshotList += `##### ${c.name}${num}\n`;
screenshotList += `![${c.name} screenshot](./${url})\n\n`;
});
}
return a + `| \`${c.alias}\` | \`${c.name}\` | \`${domain}\` | ${s} |\n`;
}, "");
return gulp.src(['./README.tmpl.md'])
.pipe(replace("<!--DISCLAIMER-->", disclaimer))
.pipe(replace("<!--COMPL_COUNT-->", Object.keys(compl).length))
.pipe(replace("<!--COMPL_TABLE-->", table))
.pipe(replace("<!--SCREENSHOTS-->", screenshotList))
.pipe(rename('README.md'))
.pipe(gulp.dest('.'));
});