npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

hng-process-certificates-on-the-backend

v1.0.0

Published

This is a cli application that parses html files into json certificate templates.

Downloads

1

Readme

Certificate Template Parser

This is a cli application that parses html files into json certificate templates.

Getting Started

To run this program, you should already have NodeJs installed.

Install all dependencies by running

npm install

Overview

The essence of this application is to simplify the process of generating certificate templates. This is done by parsing a html file containing the desired template.

Creating the Html file

To begin designing a template, it is advised that you start from the starter file provided i.e starter.html. You can add texts and elements by following the instructions below

Texts

A text object refers to anyform of text that is on a certificate. Texts could be attributes or hard text values. Attributes will get replaced by the data from the certificate object e.g a name attribute would get replaced by the name of the certificate holder.

<!-- Add Texts  -->
<h2 id="text-8">Lorem Ipsum has been the industry.</h2>

<!-- Add Texts that are attributes   -->
<h2 id="text-10" data-attribute="date">{{date}}</h2>

Texts should be created using "h2" tags. There's no hard reason for this except when the json is parsed back into a template, a h2 tag is used to represent the text. If a text is an attribute, the h2 tag should contain data-attribute="<enter_attribute>" as seen above. When a text is an attribute, the innerText wouldn't be taken into consideration. As a result the example above could be rewritten as

...

<!-- Add Texts that are attributes   -->
<h2 id="text-10" data-attribute="date">Anything you want</h2>

Another important thing to note is that all texts should have an id that begins with text- followed by any random string

Elements

A element object refers to any form of image that is on a certificate that isn't the background image. Texts could be replaced by the users logo by specifying the data-logo with any data inside. The image will get replaced by the logo from the user.

<!-- Add elements  -->
<img src="https://somesource" alt="" id="#element-1" />

<!-- Add elements that would be replaced by the logo  -->
<img src="https://somesource" alt="" id="#element-1" data-logo="true" />

Elements should be created using "img" tags. The src of the image tags should be live links to where the logo image

Usage

There are two command for this CLI application,

  • parse
  • preview

Here's how to use them

Parse

Usage: node index parse [options] filename

Parse a html file to a json certificate template

Arguments: filename path to html file

Options: -o, --output output Name of output json file (default: "output.json") -h, --help display help for command

Example

Parse to default output.json file

node index parse example.html

Specify output file

node index parse -o template1.json example.html

Preview

Usage: node index preview [options] filename

Generates a preview of the json certificate template

Arguments: filename path to json file

Options: -o, --output output Name of output pdf file (default: "output.pdf") -h, --help display help for command

Example Create preview to default output.pdf file

node index preview output.json

Specify output file

node index parse -o template1.pdf output.json

Other Important Notes

  • The a font url should be provided from google fonts api.
  • The background image should maintain the aspect ratio of a landscape A4 format.
  • The background image should have an id of "bg"
  • Always make use of the starter files to save yourself trouble
  • All font sizes should be specified in em
  • All width, height, top and left values should be specified in %