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

unicorn-list

v1.0.4

Published

Simple web framework

Downloads

3

Readme

Unicorn web framework

The Unicorn framework generates a scaffold for a simple node server. It uses the well known .cats engine to populate pages dynamically.

Installation

  1. Install Node
  2. Create a new directory using mkdir <directory name>
  3. cd <directory name> to change into the directory
  4. Generate a Unicorn scaffold with npm install unicorn-list
  5. Start the server by running npm start
  6. Go to http://localhost:3000 to see the magic happen!

Usage

  • unicorn-style.css needs to be loaded inbetween the <head> tags
  • The library scripts need to be loaded just before the closing </body> tag in order for the interface.js to capture the template after the DOM has loaded
  • The unicorn-renderer.js needs to be loaded before any interface scripts
  • Add a class unicorn-container to the element holding the template. This hides the dynamic content of the template until it is rendered.
<!-- index.cats -->
<html>
  <head>
    <link type='text/css' rel='stylesheet' href='stylesheets/unicorn-style.css'>
  </head>

  <body>
    <h1>Title</h1>
    <p>Some example static content</p>

    <div id="example-container" class="unicorn-container">
      {% if object.length > 1 %}
        <p>Some example dynamic content</p>
      {% endif %}
    </div>

    <!-- scripts just before closing body tag -->
    <script type="text/javascript" src='scripts/unicorn-renderer.js'></script>
    <script type="text/javascript" src='scripts/interface.js'></script>
  </body>
</html>

Simply pass the object to be rendered into renderView as an argument, and the container holding the template tags as the second argument.

// interface.js
var exampleObject = {
  names: ['andreamazza89','mtaner','Jojograndjojo','vannio']
}

var exampleContainer = document.getElementById('example-container');

renderView(exampleObject, exampleContainer);

Routes

The index.cats file is a template for the main page, in which regular html syntax can be used along with custom template tags. If you want to use a different route, create a .cats file in the views directory with the matching name of the route.

Loops

You can use {% loop array %} template tags to loop through an array and display the contents. In our example, object.names is an array.

{% loop object.names %}
  <p>The index of this loop is {{ index }}.</p>
  <p>The contents of this loop are {{ item }}.</p>
{% endloop %}

Conditionals

You can use {% if expression %} template tags to render content, based on an expression that returns a boolean. In our example, the expression object.names.length > 1 returns true, therefore the HTML gets rendered.

{% if object.names.length > 1 %}
  <li>Hello, this is true</li>
{% endif %}

Examples

The unicorn framework is growing in popularity. If you use it in your project, please send it to us and we will add it to the list below: