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

@yogthos/doc-builder

v0.1.2

Published

A data driven HTML/PDF document builder

Downloads

5

Readme

doc-builder

A simple data driven document builder for ClojureScript. A document is described using two files. One file conains HTML markup for the document in Hiccup format, and the other contains document data in EDN format. The library will inject the EDN data into the markup and compile it to either HTML or PDF formats.

Overview

The document data should be placed in an EDN file in the :source directory. See documents/sample.edn for an example.

The content of the data file is referenced by the template using a namespaced keyword in the following format:

:data/path.to.field

The keyword represents a get-in path to provide support for accessing nested fields in the document. The above will be translated into [:path :to :field] when the template is compiled.

When the template is loaded, the values from the data file will be injected into it. Templates can contain code referencing functions from Clojure core, e,g:

[:div.row
 (for [{:keys [network username url]} :data/basics.profiles]
   [:div.col-sm-6
    [:strong.network network]
    [:div.username
    [:div.url
    [:a {:href url} username]]]])]

Corresponding data payload should look as follows:

{:basics
 {:network  "Twitter"
  :username "john"
  :url      "http://twitter.com/john"}}

Templates use the following directory structure:

templates
  <template name>
    template.edn
    <related files>

Templates can reference CSS in files from the template directory, e.g:

[:page/css
   "css/bootstrap.min.css"
   "css/octicons.min.css"
   "css/resume.css"]

Templates can reference images in files relative to the source directory, e.g:

[:page/image {:src :data/basics.picture :width "100px"}]

The image will be injected into the document as a base 64 string.

See the default template for a complete example.

Usage

  1. check out this project locally
  2. run npm install @yogthos/doc-builder
  3. update documents/sample.edn with your data
  4. update config.edn as needed, sample config:
{;name of the template relative to the templates directory
 :template :default
 ;formats to output 
 :formats  [:pdf :html]
 ;puppeteer options, format defaults to Letter
 :pdf-opts {:format "A4"} 
 ;document template folder
 :source   "documents"
 ;output folder
 :target   "build"}
  1. build the resume by passing one or more documents following the --docs flag:
doc-builder --docs sample.edn

It's also possible to specify the template using the --template flag. This will override the template specified in the config:

doc-builder --docs sample.edn --template :resume

Development mode

  • run lein cljsbuild watch release to start cljs compiler
  • run the compiled script with node doc-builder.js --docs sample.edn
  • compiling for release lein cljsbuild once release

License

Copyright © 2020 Dmitri Sotnikov

This program and the accompanying materials are made available under the terms of the Eclipse Public License 2.0 which is available at http://www.eclipse.org/legal/epl-2.0.

This Source Code may also be made available under the following Secondary Licenses when the conditions for such availability set forth in the Eclipse Public License, v. 2.0 are satisfied: GNU General Public License as published by the Free Software Foundation, either version 2 of the License, or (at your option) any later version, with the GNU Classpath Exception which is available at https://www.gnu.org/software/classpath/license.html.