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

civinky

v0.2.1

Published

Civinky: a web service to convert Pug with Inky into html ready for CiviMail

Downloads

1

Readme

Civinky: Pug and Inky for CiviMail

Convert Pug with Inky into html ready for CiviMail.

This repository contains the Civinky library; a simple web service based on this library; and a browserified version of the library.

You may also be interested in the CiviCRM Inky Compose extension that allows you to compose with Inky using the CiviMail's UI.

Installation

  1. Download Civinky from https://github.com/3sd/civinky-service.
  2. cd to the downloaded directory and npm install
  3. Run the service with npm run service

Civinky is now ready to generate HTML in response to post requests on http://localhost:30649/generate.

Specifying a port

You can specify a specific port with CIVINKY_PORT=N npm run service where N is the number of the port you want to run it on.

Running Civinky with PM2

You can run Civinky with PM2 - an 'advanced, production process manager for Node.js' - as follows:

  1. Download and install pm2
  2. Create a process.yml file.
# process.yml
apps:
  - script: /var/www/civinky-service/service.js
    env:
      CIVINKY_PORT: 30649 # optional, allows you to specific a port
  1. Start pm2 start process.yml

Usage

  1. Make a post requests to http://localhost:3000/generate. Include your params as json in the request body (see below for details).
  2. You will recive response containing email friendly HTML.

Hint: tools like Postman are useful for experimenting with requests.

Parameters

pug

Valid pug for example:

container
  row
    columns
      h1 Hello #{planet}!

Some tips on using Pug and inky to generate email friendly HTML for CiviMail:

  • Use Inky tags rather than html tags when available to ensure that the generated HTML is email friendly.
  • Insert values from the json object, use the following Pug syntax: #{key}
  • Add smarty tokens as normal, e.g. {contact.first_name}.
  • Remember that the entirety of Pug's syntax (control flow, etc.) is available for your use.

css

Valid CSS for example:

h1{color:red}

This CSS will be appended to Foundation's base CSS and inlined into the html.

json

A valid json object, for example:

{"planet":"World"}

This will be available for use in the Pug.

snippet

Boolean, defaults to false.

By default, Civinky wraps the Pug with appropriate HTML to ensure proper rendering across clients. Setting snippet to true will prevent the output being wrapped, which is useful, for example, if you want to use Civinky to generate HTML for a CiviMail token that will be included as part of another Civinky based email.

Demo

To see Civinky in action, visit https://civinky.demo.3sd.io/.

You might also be interested in this extension that implements tokens based on Civinky: https://github.com/elifesciences/civicrm-elife-token

Civinky in the browser

There is a browserified version of Civinky, which runs in the browser and can be found in dist/civinky.bundle.js. This version is used in the CiviCRM Inky Compose extension.

The browserified version exports a promise (CRM.civinky) that can be used as follows:

CRM.civinky({pug: 'p hello world', css: "p {color:red}"})
.then(result => console.log(result))

Test out Civinky in the browser with the civinky-browserified.html file.

A gulp script to create the browserified version can be found in gulpfile.js and can be run with gulp browserify. Beware that it the browserified version weighs it at a fairly hefty 1.1MB - help on trimming off some fat welcome.

Tests

The Civinky service has a simple suite of tests that also serve to test the library. Ensure that the service is running as outlined above and then run npm test to execute the tests.

Contributing

PRs are very welcome. Feel free to open an issue to discuss any improvements first if that would be helpful.

Please ensure all tests are passing and don't forget to write new tests as appropriate for any new functionality before submitting PRs.

Credits

Funding provided by eLife Sciences, a unique, non-profit collaboration between the funders and practitioners of research to improve the way important results are presented and shared.