2 changed files with 41 additions and 2 deletions
@ -0,0 +1,40 @@ |
|||||
|
#! /usr/bin/env tclsh |
||||
|
|
||||
|
package require fileutil |
||||
|
|
||||
|
proc screenshot {name css github demo} { |
||||
|
set src screenshot-page.html |
||||
|
set dest temp.html |
||||
|
|
||||
|
set filename [slugify $name].png |
||||
|
|
||||
|
fileutil::writeFile $dest [regsub %CSS_HERE% [fileutil::cat $src] $css] |
||||
|
run wkhtmltoimage $dest screenshot/$filename |
||||
|
run convert \ |
||||
|
-resize 25% \ |
||||
|
-adaptive-sharpen 10 \ |
||||
|
screenshot/$filename \ |
||||
|
thumbnail/$filename |
||||
|
run optipng -o5 -strip all screenshot/$filename thumbnail/$filename |
||||
|
|
||||
|
puts ------\n[markup $name $github $demo $filename] |
||||
|
} |
||||
|
|
||||
|
proc slugify text { |
||||
|
string trim [regsub -all {[^[:alnum:]]+} [string tolower $text] -] - |
||||
|
} |
||||
|
|
||||
|
proc run args { |
||||
|
exec {*}$args >@ stdout 2>@ stderr |
||||
|
} |
||||
|
|
||||
|
proc markup {name github demo filename} { |
||||
|
subst -nocommands {### $name |
||||
|
|
||||
|
* [Repository](https://github.com/$github)      |
||||
|
* [Demo]($demo) |
||||
|
|
||||
|
[](screenshot/$filename)} |
||||
|
} |
||||
|
|
||||
|
screenshot {*}$argv |
||||
Loading…
Reference in new issue