Skip to content

Commit

Permalink
added dark background
Browse files Browse the repository at this point in the history
  • Loading branch information
delianides committed Aug 29, 2020
1 parent 1f10c4b commit c681d53
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 29 deletions.
59 changes: 30 additions & 29 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,57 +1,58 @@
"use strict";
const { createHash } = require("crypto");
const through2 = require("through2");
const { readFile } = require("fs-extra");
const ejs = require("ejs");
'use strict';
const {createHash} = require('crypto');
const path = require('path');
const through2 = require('through2');
const {readFile} = require('fs-extra');
const ejs = require('ejs');

const action = async context => {
const uploadEndpoint = "https://api.vercel.com/v2/now/files";
const deploymentEndpoint = "https://api.vercel.com/v12/now/deployments";
const Authorization = "Bearer " + context.config.get("token");
const uploadEndpoint = 'https://api.vercel.com/v2/now/files';
const deploymentEndpoint = 'https://api.vercel.com/v12/now/deployments';
const Authorization = 'Bearer ' + context.config.get('token');

const filePath = await context.filePath();
const data = await readFile(filePath);
const sha = createHash("sha1")
const sha = createHash('sha1')
.update(data)
.digest("hex");
.digest('hex');
const stream = through2();
stream.write(data);
stream.end();

context.setProgress("Uploading…");
context.setProgress('Uploading…');
await context.request(uploadEndpoint, {
headers: {
"Content-Type": "application/octet-stream",
"x-now-digest": sha,
"x-now-size": data.length,
'Content-Type': 'application/octet-stream',
'x-now-digest': sha,
'x-now-size': data.length,
Authorization
},
body: stream
});

context.setProgress("Generating Landing Page…");
context.setProgress('Generating Landing Page…');
const page = await ejs.renderFile(
__dirname + "/template.ejs",
{ title: context.defaultFileName, format: context.format },
{ async: true }
path.join(__dirname, 'template.ejs'),
{title: context.defaultFileName, format: context.format},
{async: true}
);

context.setProgress("Creating Vercel deployment…");
context.setProgress('Creating Vercel deployment…');
const deploymentResponse = await context.request(deploymentEndpoint, {
headers: {
Authorization
},
json: true,
body: {
name: context.config.get("name"),
name: context.config.get('name'),
files: [
{
file: context.defaultFileName,
sha,
size: data.length
},
{
file: "index.html",
file: 'index.html',
data: page
}
],
Expand All @@ -68,20 +69,20 @@ const action = async context => {
};

const vercel = {
title: "Share on Vercel",
formats: ["gif", "mp4", "webm", "apng"],
title: 'Share on Vercel',
formats: ['gif', 'mp4', 'webm', 'apng'],
action,
config: {
token: {
title: "Vercel Personal Access Token",
description: "Create one here https://vercel.com/account/tokens",
type: "string",
title: 'Vercel Personal Access Token',
description: 'Create one here https://vercel.com/account/tokens',
type: 'string',
required: true
},
name: {
title: "Name used in the deployment URL",
type: "string",
default: "kapture",
title: 'Name used in the deployment URL',
type: 'string',
default: 'kapture',
required: true
}
}
Expand Down
2 changes: 2 additions & 0 deletions template.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
<style>
body {
font-family: 'san-serif';
background: #1E1E1E;
}
main {
display: flex;
Expand All @@ -33,6 +34,7 @@
main .video {
height: 432px;
width: 768px;
border: 1px solid #3A3A3A;
}
main .image {
height: 576px;
Expand Down

0 comments on commit c681d53

Please sign in to comment.