Skip to content

Commit

Permalink
Add watermarks to version control as a shared npm asset
Browse files Browse the repository at this point in the history
  • Loading branch information
ashley-hebler committed Jan 4, 2021
1 parent 8d86d8d commit bd7e575
Show file tree
Hide file tree
Showing 27 changed files with 19 additions and 30 deletions.
Binary file added assets/images/watermarks/1999.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/watermarks/2000.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/watermarks/2001.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/watermarks/2002.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/watermarks/2003.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/watermarks/2004.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/watermarks/2005.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/watermarks/2006.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/watermarks/2007.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/watermarks/2008.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/watermarks/2009.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/watermarks/2010.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/watermarks/2011.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/watermarks/2012.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/watermarks/2013.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/watermarks/2014.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/watermarks/2015.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/watermarks/2016.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/watermarks/2017.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/watermarks/2018.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/watermarks/2019.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/watermarks/2020.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 3 additions & 2 deletions docs/config/paths.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ const mappedIcons = [
},
];


const docsIcons = ['./assets/icons/'];

const mappedCopies = [
Expand All @@ -39,7 +38,7 @@ const mappedCopies = [
{
in: './docs/src/js',
out: `${buildDir}js`,
},
}
];

const mappedGithubData = {
Expand All @@ -48,6 +47,7 @@ const mappedGithubData = {
out: './docs/dist/data/github.json',
};

const docsImages = './assets/images/';

const siteURL =
process.env.SITE_ENV === 'production'
Expand All @@ -63,4 +63,5 @@ module.exports = {
mappedCopies,
buildDir,
siteURL,
docsImages,
};
19 changes: 14 additions & 5 deletions docs/config/tasks/watermark.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { buildDir } from '../paths';
import { docsImages } from '../paths';

const { createCanvas, Image, registerFont } = require('canvas');
const fs = require('fs-extra');
const ora = require('ora');
const path = require('path');

const bugHeight = 35;
const bugWidth = 30;
Expand All @@ -16,6 +17,8 @@ interface Watermark {
imagePath: string;
}

const watermarkDir = path.join(docsImages, 'watermarks', '/');

async function createWatermark(year: Number): Promise<Watermark> {
const width = 200;
const height = 50;
Expand All @@ -35,15 +38,15 @@ async function createWatermark(year: Number): Promise<Watermark> {
img.src = `data:image/svg+xml;charset=utf-8,${bug}`;
context.drawImage(img, 10, canvas.height / 2 - bugHeight / 2);
const buffer = canvas.toBuffer('image/png');
const imagePath = `${buildDir}/img/watermarks/${year}.png`;
fs.outputFile(`${buildDir}/img/watermarks/${year}.png`, buffer);
const imagePath = `${watermarkDir}${year}.png`;
fs.outputFile(imagePath, buffer);
return {
year,
imagePath,
};
}

module.exports = async () => {
async function build() {
const spinner = ora('Generating watermark images').start();
const now = new Date().getUTCFullYear();
const years = Array(now - 1998)
Expand All @@ -54,4 +57,10 @@ module.exports = async () => {
);
spinner.succeed();
return watermarks;
};
}

build().catch((err) => {
// eslint-disable-next-line no-console
console.log(err);
process.exit(1);
});
11 changes: 0 additions & 11 deletions docs/src/data/watermarks.js

This file was deleted.

11 changes: 0 additions & 11 deletions docs/src/icons-logos.njk
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,4 @@ layout: base.njk
</div>
{% endfor %}
</div>
<div class="q-spacer">
<h2 class="is-size-3 q-bottom-spacer">Watermarks</h2>
<ul class="q-tiles">
{% for watermark in watermarks %}
<li class="q-bottom-spacer">
{% set imagePath = '/img/watermarks/' + watermark.year + '.png' %}
<img src="{{ imagePath | url }}" alt="">
</li>
{% endfor %}
</ul>
</div>
</div>
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
"test": "npm run lint && npm run build",
"release": "np --any-branch",
"compile": "tsc",
"docs": "npm run compile && SITE_ENV=development node docs/src/data/docs.js"
"docs": "npm run compile && SITE_ENV=development node docs/src/data/docs.js",
"watermark": "npm run compile && node docs/build/config/tasks/watermark.js"
},
"files": [
"/assets"
Expand Down

0 comments on commit bd7e575

Please sign in to comment.