This repository has been archived by the owner on Sep 7, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 248
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Docs: showcases now have screenshots!
- Loading branch information
Showing
9 changed files
with
202 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,56 @@ | ||
--- | ||
title: "See who's using Phenomic" | ||
layout: "Showcase" | ||
|
||
# To add you website to the showcase, just add an entry like you can see below | ||
# Eg: | ||
#- name: My super title | ||
# url: http://url-of-the-website/app | ||
# source: https://github.com/url/of-the-source-(optional-if-relevant) | ||
|
||
list: | ||
- name: Phenomic docs | ||
url: https://phenomic.io/ | ||
source: https://github.com/MoOx/phenomic/tree/master/docs | ||
- name: Putain de code ! | ||
url: http://putaindecode.io/ | ||
source: https://github.com/putaindecode/putaindecode.io | ||
|
||
- name: PostCSS | ||
url: http://postcss.org/ | ||
source: https://github.com/postcss/postcss.org | ||
|
||
- name: cssnano | ||
url: http://cssnano.co/ | ||
source: https://github.com/ben-eb/cssnano/tree/master/docs | ||
- name: Stylelint | ||
url: http://stylelint.io/ | ||
source: https://github.com/stylelint/stylelint.io | ||
|
||
- name: ReactClass | ||
url: http://reactclass.com | ||
source: https://github.com/DavidWells/react-class/ | ||
|
||
- name: Bluejay Wireless | ||
url: https://www.bluejaywireless.com/ | ||
- name: Khoa Nguyen's Blog | ||
url: https://khoanguyen.me | ||
source: https://github.com/thangngoc89/blog | ||
|
||
- name: SEAADE 2016 website | ||
url: http://seaade2016.vn/ | ||
source: https://github.com/thangngoc89/seaade | ||
|
||
- name: Stylelint | ||
url: http://stylelint.io/ | ||
source: https://github.com/stylelint/stylelint.io | ||
|
||
- name: Vinspee.me | ||
url: http://vinspee.me | ||
source: https://github.com/VinSpee/vinspee.me | ||
|
||
- name: Khoa Nguyen's Blog | ||
url: https://khoanguyen.me | ||
source: https://github.com/thangngoc89/blog | ||
|
||
- name: Learn C++ (Vietnamese) | ||
url: https://khoanguyen.me/dnh-cpp/ | ||
source: https://github.com/thangngoc89/dnh-cpp/ | ||
- name: ReactClass | ||
url: http://reactclass.com | ||
source: https://github.com/DavidWells/react-class/ | ||
|
||
# please make your proposal on top of this line | ||
# let this one at the end | ||
- name: Phenomic docs | ||
url: https://phenomic.io/ | ||
source: https://github.com/MoOx/phenomic/tree/master/docs | ||
--- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
import { resolve, join } from "path" | ||
import fs from "fs" | ||
import findCacheDir from "find-cache-dir" | ||
const cacheDir = findCacheDir({ name: "phenomic", create: true }) | ||
|
||
import grayMatter from "gray-matter" | ||
const showcasesFile = fs.readFileSync( | ||
__dirname + "/../content/showcase.md", | ||
{ encoding: "utf-8" } | ||
) | ||
const showcases = grayMatter(showcasesFile) | ||
const list = showcases.data.list | ||
// .slice(0,2) // for tests | ||
|
||
import urlToSlug from "../web_modules/url-to-slug" | ||
|
||
import Nightmare from "nightmare" | ||
const screenshotsLocation = resolve(__dirname, "../content/assets/showcases/") | ||
const screenshots = list.reduce((screenshots, { url }) => { | ||
const filename = urlToSlug(url) | ||
return [ | ||
...screenshots, | ||
{ | ||
url, | ||
tmpLocation: join(cacheDir, "screenshot-" + filename + "-large.png"), | ||
location: join(screenshotsLocation, filename + "-large.jpg"), | ||
width: 1366, | ||
height: 768, | ||
}, | ||
{ | ||
url, | ||
tmpLocation: join(cacheDir, "screenshot-" + filename + "-small.png"), | ||
location: join(screenshotsLocation, filename + "-small.jpg"), | ||
width: 360, | ||
height: 640, | ||
}, | ||
] | ||
}, []) | ||
|
||
const nightmare = Nightmare() | ||
let prevUrl | ||
screenshots.forEach(({ url, tmpLocation, width, height }) => { | ||
try { | ||
fs.readFileSync(tmpLocation) | ||
} | ||
catch (e) { | ||
console.log("Screenshots for ", url, width, height, tmpLocation) | ||
if (url !== prevUrl) { | ||
nightmare | ||
.goto(url) | ||
.wait(8000) | ||
} | ||
else { | ||
nightmare | ||
.wait(200) // wait for some logo animations & stuff (eg putaindecode.io) | ||
} | ||
nightmare | ||
.viewport(width, height) | ||
.screenshot(tmpLocation) | ||
} | ||
}) | ||
|
||
import pngToJpg from "png-jpg" | ||
import optimizer from "image-optim" | ||
|
||
nightmare | ||
.end() | ||
.then(() => { | ||
console.log("✅ Showcase screenshots ready.") | ||
console.log("✅ Showcase optimizing screenshots...") | ||
screenshots.forEach(({ tmpLocation, location }) => { | ||
try { | ||
fs.readFileSync(location) | ||
} | ||
catch (e) { | ||
pngToJpg( | ||
{ | ||
input: tmpLocation, | ||
output: location, | ||
options: { quality: 90 }, | ||
}, | ||
() => { | ||
optimizer.optimize(location) | ||
// .then(() => console.log(location, "optimized")) | ||
.catch((err) => console.log("Failed to optimize image", err)) | ||
} | ||
) | ||
} | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
export default (url) => ( | ||
url | ||
.replace(/https?:\/\//,"") | ||
.replace(/\/$/,"") | ||
.replace(/\//g,"_") | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters