Update readme, switch to using electroshot to generate the screenshots

This commit is contained in:
Mikito Takada 2015-10-29 13:31:11 -07:00
parent ba2bf2a339
commit 8a85d72cb4
42 changed files with 29 additions and 322 deletions

View File

@ -14,38 +14,20 @@ ifeq ($(UNAME), Darwin)
open output/index.html
endif
# Note: for fonts to render you need to download them first
screenshots: build
rm -f ./screenshots/*.png
# Note: on OSX, run brew install ghostscript as well to get the fonts needed for montage
screenshots:
rm -f ./screenshots/*.jpg
for name in `find ./output -mindepth 1 -maxdepth 1 -type d | sed -e 's/.\/output\///'` ; do \
cutycapt --url=file://$(CURDIR)/output/$$name/index.html --out=./screenshots/$$name.png ; \
convert ./screenshots/$$name.png -resize "800x" -crop 800x600+0+0 +repage ./screenshots/$$name-cropped.png ; \
rm ./screenshots/$$name.png ; \
mv ./screenshots/$$name-cropped.png ./screenshots/$$name.png ; \
./node_modules/.bin/electroshot $(CURDIR)/output/$$name/index.html 800x600 --format jpg --quality 60 --force-device-scale-factor 1 --filename ./screenshots/$$name.jpg; \
done
rm ./screenshots/montage.png || true
montage -tile 4x -label '%t' -geometry 120x120\>+20+5 ./screenshots/*.png ./screenshots/montage.png
phantomjs:
rm -f ./screenshots/*.png
for name in `find ./output -mindepth 1 -maxdepth 1 -type d | sed -e 's/.\/output\///'` ; do \
phantomjs ./screenshots/screenshot.js --url=file://$(CURDIR)/output/$$name/index.html --out=./screenshots/$$name.png ; \
convert ./screenshots/$$name.png -resize "800x" -crop 800x600+0+0 +repage ./screenshots/$$name-cropped.png ; \
rm ./screenshots/$$name.png ; \
mv ./screenshots/$$name-cropped.png ./screenshots/$$name.png ; \
done
rm ./screenshots/montage.png || true
montage -tile 4x -label '%t' -geometry 120x120\>+20+5 ./screenshots/*.png ./screenshots/montage.png
rm ./screenshots/montage.jpg || true
montage -tile 4x -label '%t' -geometry 120x120\>+20+5 ./screenshots/*.jpg ./screenshots/montage.jpg
montage:
rm ./screenshots/montage.png || true
montage -tile 4x -label '%t' -geometry 120x120\>+20+5 ./screenshots/*.png ./screenshots/montage.png
rm ./screenshots/montage.jpg || true
montage -tile 4x -label '%t' -geometry 120x120\>+20+5 ./screenshots/*.jpg ./screenshots/montage.jpg
# Download google fonts for cutycapt
get-fonts:
node screenshots/font-download.js
.PHONY: build screenshots get-fonts montage
.PHONY: build screenshots montage
lint:
fixjsstyle $(GJSLINT) -r .

View File

@ -39,6 +39,7 @@
"yargs": "~3.27.0"
},
"devDependencies": {
"electroshot": "~1.0.0",
"file-fixture": "0.0.2",
"mds-csv": "0.0.0"
}

View File

@ -48,7 +48,7 @@ Create a markdown file and then convert it to html:
Try out different layouts by changing the `--layout` parameter; screenshots are at the bottom of this page.
![montage](https://github.com/mixu/markdown-styles/raw/master/screenshots/montage.png)
![montage](https://github.com/mixu/markdown-styles/raw/master/screenshots/montage.jpg)
## generate-md CLI options
@ -386,75 +386,75 @@ I'd like to thank the following people for making CSS stylesheets available with
## Screenshots of the layouts
Note: these screenshots are generated via phantomjs, so they look worse than they do in a real browser because the font rendering is just bad and lacks webfont support. For example, WiTeX actually uses the Latin Modern Roman font from TeX but the screenshots show the fallback font.
Thanks to [electroshot](https://github.com/mixu/electroshot), the screenshots now look about right (e.g. web fonts render correctly).
### github
![github](https://github.com/mixu/markdown-styles/raw/master/screenshots/github.png)
![github](https://github.com/mixu/markdown-styles/raw/master/screenshots/github.jpg)
### witex
![witex](https://github.com/mixu/markdown-styles/raw/master/screenshots/witex.png)
![witex](https://github.com/mixu/markdown-styles/raw/master/screenshots/witex.jpg)
### roryg-ghostwriter
![roryg-ghostwriter](https://github.com/mixu/markdown-styles/raw/master/screenshots/roryg-ghostwriter.png)
![roryg-ghostwriter](https://github.com/mixu/markdown-styles/raw/master/screenshots/roryg-ghostwriter.jpg)
### mixu-bootstrap
![mixu-bootstrap](https://github.com/mixu/markdown-styles/raw/master/screenshots/mixu-bootstrap.png)
![mixu-bootstrap](https://github.com/mixu/markdown-styles/raw/master/screenshots/mixu-bootstrap.jpg)
### mixu-bootstrap-2col
![mixu-bootstrap-2col](https://github.com/mixu/markdown-styles/raw/master/screenshots/mixu-bootstrap-2col.png)
![mixu-bootstrap-2col](https://github.com/mixu/markdown-styles/raw/master/screenshots/mixu-bootstrap-2col.jpg)
### mixu-gray
![mixu-gray](https://github.com/mixu/markdown-styles/raw/master/screenshots/mixu-gray.png)
![mixu-gray](https://github.com/mixu/markdown-styles/raw/master/screenshots/mixu-gray.jpg)
### jasonm23-dark
![jasonm23-dark](https://github.com/mixu/markdown-styles/raw/master/screenshots/jasonm23-dark.png)
![jasonm23-dark](https://github.com/mixu/markdown-styles/raw/master/screenshots/jasonm23-dark.jpg)
### jasonm23-foghorn
![jasonm23-foghorn](https://github.com/mixu/markdown-styles/raw/master/screenshots/jasonm23-foghorn.png)
![jasonm23-foghorn](https://github.com/mixu/markdown-styles/raw/master/screenshots/jasonm23-foghorn.jpg)
### jasonm23-markdown
![jasonm23-markdown](https://github.com/mixu/markdown-styles/raw/master/screenshots/jasonm23-markdown.png)
![jasonm23-markdown](https://github.com/mixu/markdown-styles/raw/master/screenshots/jasonm23-markdown.jpg)
### jasonm23-swiss
![jasonm23-swiss](https://github.com/mixu/markdown-styles/raw/master/screenshots/jasonm23-swiss.png)
![jasonm23-swiss](https://github.com/mixu/markdown-styles/raw/master/screenshots/jasonm23-swiss.jpg)
### markedapp-byword
![markedapp-byword](https://github.com/mixu/markdown-styles/raw/master/screenshots/markedapp-byword.png)
![markedapp-byword](https://github.com/mixu/markdown-styles/raw/master/screenshots/markedapp-byword.jpg)
### mixu-book
![mixu-book](https://github.com/mixu/markdown-styles/raw/master/screenshots/mixu-book.png)
![mixu-book](https://github.com/mixu/markdown-styles/raw/master/screenshots/mixu-book.jpg)
### mixu-page
![mixu-page](https://github.com/mixu/markdown-styles/raw/master/screenshots/mixu-page.png)
![mixu-page](https://github.com/mixu/markdown-styles/raw/master/screenshots/mixu-page.jpg)
### mixu-radar
![mixu-radar](https://github.com/mixu/markdown-styles/raw/master/screenshots/mixu-radar.png)
![mixu-radar](https://github.com/mixu/markdown-styles/raw/master/screenshots/mixu-radar.jpg)
### thomasf-solarizedcssdark
![thomasf-solarizedcssdark](https://github.com/mixu/markdown-styles/raw/master/screenshots/thomasf-solarizedcssdark.png)
![thomasf-solarizedcssdark](https://github.com/mixu/markdown-styles/raw/master/screenshots/thomasf-solarizedcssdark.jpg)
### thomasf-solarizedcsslight
![thomasf-solarizedcsslight](https://github.com/mixu/markdown-styles/raw/master/screenshots/thomasf-solarizedcsslight.png)
![thomasf-solarizedcsslight](https://github.com/mixu/markdown-styles/raw/master/screenshots/thomasf-solarizedcsslight.jpg)
### bootstrap3
![bootstrap3](https://github.com/mixu/markdown-styles/raw/master/screenshots/bootstrap3.png)
![bootstrap3](https://github.com/mixu/markdown-styles/raw/master/screenshots/bootstrap3.jpg)
## Contributing new styles to markdown-styles

BIN
screenshots/bootstrap3.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 77 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 84 KiB

View File

@ -1,34 +0,0 @@
var https = require('https'),
child_process = require('child_process');
https.get({
hostname: 'api.github.com',
port: 443,
path: '/repos/w0ng/googlefontdirectory/contents/fonts',
headers: { 'user-agent': 'nodejs'}
}, function(res) {
console.log('Got response: ' + res.statusCode);
console.log(res.headers);
var data = '';
res.setEncoding('utf8');
res.on('data', function(chunk) {
data += chunk;
});
res.on('end', function() {
var content = JSON.parse(data);
['Andika', 'Cantarell', 'DroidSansMono', 'Vollkorn', 'PT_Sans', 'Inconsolata'].forEach(function(font) {
var items = content.filter(function(item) {
return item.name.match(font);
});
console.log('# Run the following commands to get the fonts: ');
items.forEach(function(item) {
console.log('cd ~/.fonts && wget -N https://github.com/w0ng/googlefontdirectory/raw/master/' + item.path);
});
console.log('fc-cache -fv');
});
});
}).on('error', function(e) {
console.log('Got error: ' + e.message);
});

BIN
screenshots/github.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 70 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 81 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 67 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 68 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 64 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 86 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 72 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 80 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 94 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 95 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 78 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 105 KiB

BIN
screenshots/mixu-book.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 57 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 173 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 66 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 110 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 81 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 85 KiB

BIN
screenshots/mixu-gray.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 87 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 488 KiB

BIN
screenshots/mixu-page.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 65 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 230 KiB

BIN
screenshots/mixu-radar.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 71 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 90 KiB

BIN
screenshots/montage.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 112 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 623 KiB

BIN
screenshots/plain.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 60 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 50 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 54 KiB

View File

@ -1,242 +0,0 @@
var system = require('system');
/**
* Checks if value is a javascript String
*
* @param mixed value
* @return Boolean
*/
function isString(value) {
'use strict';
return isType(value, 'string');
}
/**
* Checks if value is a javascript Number
*
* @param mixed value
* @return Boolean
*/
function isNumber(value) {
'use strict';
return isType(value, 'number');
}
/**
* Shorthands for checking if a value is of the given type. Can check for
* arrays.
*
* @param mixed what The value to check
* @param String typeName The type name ("string", "number", "function", etc.)
* @return Boolean
*/
function isType(what, typeName) {
'use strict';
if (typeof typeName !== 'string' || !typeName) {
throw new Error('You must pass isType() a typeName string');
}
return betterTypeOf(what).toLowerCase() === typeName.toLowerCase();
}
/**
* Object recursive merging utility.
*
* @param Object origin the origin object
* @param Object add the object to merge data into origin
* @param Object opts optional options to be passed in
* @return Object
*/
function mergeObjects(origin, add, opts) {
'use strict';
var options = opts || {},
keepReferences = options.keepReferences;
if (phantom.casperEngine === 'slimerjs') {
// Because of an issue in the module system of slimerjs (security membranes?)
// constructor is undefined.
// let's use an other algorithm
return mergeObjectsInGecko(origin, add, options);
}
for (var p in add) {
if (add[p] && add[p].constructor === Object) {
if (origin[p] && origin[p].constructor === Object) {
origin[p] = mergeObjects(origin[p], add[p]);
} else {
origin[p] = keepReferences ? add[p] : clone(add[p]);
}
} else {
origin[p] = add[p];
}
}
return origin;
}
/**
* Provides a better typeof operator equivalent, able to retrieve the array
* type.
*
* CAVEAT: this function does not necessarilly map to classical js "type" names,
* notably a `null` will map to "null" instead of "object".
*
* @param mixed input
* @return String
* @see http://javascriptweblog.wordpress.com/2011/08/08/fixing-the-javascript-typeof-operator/
*/
function betterTypeOf(input) {
'use strict';
switch (input) {
case undefined:
return 'undefined';
case null:
return 'null';
default:
try {
var type = Object.prototype.toString.call(input).match(/^\[object\s(.*)\]$/)[1].toLowerCase();
if (type === 'object' &&
phantom.casperEngine !== 'phantomjs' &&
'__type' in input) {
type = input.__type;
}
// gecko returns window instead of domwindow
else if (type === 'window') {
return 'domwindow';
}
return type;
} catch (e) {
return typeof input;
}
}
}
/**
* Extracts, normalize and organize PhantomJS CLI arguments in a dedicated
* Object.
*
* @param array phantomArgs system.args value
* @return Object
*/
function parse(phantomArgs) {
'use strict';
var extract = {
args: [],
options: {},
raw: {
args: [],
options: {}
},
drop: function drop(what) {
if (isNumber(what)) {
// deleting an arg by its position
this.args = this.args.filter(function _filter(arg, index) {
return index !== what;
});
// raw
if ('raw' in this) {
this.raw.args = this.raw.args.filter(function _filter(arg, index) {
return index !== what;
});
}
} else if (isString(what)) {
// deleting an arg by its value
this.args = this.args.filter(function _filter(arg) {
return arg !== what;
});
// deleting an option by its name (key)
delete this.options[what];
// raw
if ('raw' in this) {
this.raw.args = this.raw.args.filter(function _filter(arg) {
return arg !== what;
});
delete this.raw.options[what];
}
} else {
throw new Error('Cannot drop argument of type ' + typeof what);
}
},
has: function has(what) {
if (isNumber(what)) {
return what in this.args;
}
if (isString(what)) {
return what in this.options;
}
throw new Error('Unsupported cli arg tester ' + typeof what);
},
get: function get(what, def) {
if (isNumber(what)) {
return what in this.args ? this.args[what] : def;
}
if (isString(what)) {
return what in this.options ? this.options[what] : def;
}
throw new Error('Unsupported cli arg getter ' + typeof what);
}
};
phantomArgs.forEach(function _forEach(arg) {
if (arg.indexOf('--') === 0) {
// named option
var optionMatch = arg.match(/^--(.*?)=(.*)/i);
if (optionMatch) {
extract.options[optionMatch[1]] = castArgument(optionMatch[2]);
extract.raw.options[optionMatch[1]] = optionMatch[2];
} else {
// flag
var flagMatch = arg.match(/^--(.*)/);
if (flagMatch) {
extract.options[flagMatch[1]] = extract.raw.options[flagMatch[1]] = true;
}
}
} else {
// positional arg
extract.args.push(castArgument(arg));
extract.raw.args.push(arg);
}
});
extract.raw = mergeObjects(extract.raw, {
drop: function() {
return extract.drop.apply(extract, arguments);
},
has: extract.has,
get: extract.get
});
return extract;
}
/**
* Cast a string argument to its typed equivalent.
*
* @param String arg
* @return Mixed
*/
function castArgument(arg) {
'use strict';
if (arg.match(/^-?\d+$/)) {
return parseInt(arg, 10);
} else if (arg.match(/^-?\d+\.\d+$/)) {
return parseFloat(arg);
} else if (arg.match(/^(true|false)$/i)) {
return arg.trim().toLowerCase() === 'true' ? true : false;
} else {
return arg;
}
}
var args = parse(system.args);
// console.log(args.get('url'), args.get('out'));
var page = require('webpage').create();
page.viewportSize = { width: 800, height: 600 };
page.evaluate(function() {
document.body.bgColor = 'white';
});
page.open(args.get('url'), function() {
page.render(args.get('out'));
phantom.exit();
});

Binary file not shown.

After

Width:  |  Height:  |  Size: 62 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 94 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 62 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 95 KiB

BIN
screenshots/witex.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 82 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 73 KiB