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

ludr

v1.1.0

Published

A JavaScript SPA (Single Page Application) Framework

Downloads

4

Readme

Ludr.js

A JavaScript Single Page Application (SPA) Framework

Under development, Requires the handlebars framework

Usage


src\app.js

import Ludr from "Ludr";

import layouts from "./layouts";
import components from "./components";
import routes from "./routes";
import events from "./events";
import groups from "./groups";
import middleware from "./middleware";

routes();
middleware();
layouts();
components();
groups();
events();

Ludr.Config.showInfo = true;

Ludr.Load();

Layouts

Define the layout of components to use when a page loads


src\layouts\index.js

import { Layout } from "Ludr";

Layout('basic.layout', 'basic', {
    name: 'John Doe'
})

src\layouts\basic.hbs

<p>My name is: {{ name }}</p>

{{{ component 'profile' }}}

Components

Building blocks of the application, they are loaded individually, cached and re-used where necessary


src\components\index.js

import { Component } from "Ludr";

Component('profile', {
    path: 'profile',
    data: { 
        foo: 'bar'
    }
});

Component('generic.component.1', {
    path: 'generic-component-1',
});

Component('generic.component.2', {
    path: 'generic-component-2'
});

src\components\profile.hbs

<p>This is my profile.</p>
<p>And i know stuff: {{ foo }}</p>

Groups

Components can be grouped together and automatically chosen based on the current page


src\groups\index.js

import { Group } from "Ludr";

// when browser is on /generic-page-1, generic.component.1 will be loaded as baisic-group
Group('basic.group', [
    { component: 'generic.component.1', url: '/generic-page-1' }
    { component: 'generic.component.2', url: '/generic-page-2' }
]);

src\components\another.hbs

<p>The following component is dynamic</p>

{{{ component 'basic.group' }}}

Routes

Routes are pages :)


src\routes\index.js

import { Route } from "Ludr";

export default () => {
    Route('profile', {
        title: 'User profile',
        uri: '/:user/profile',
        layout: 'basic.layout'
    });
};

Events


src\events\index.js

import { Events } from "Ludr";

export default () => {
    new (class User extends Events {
        constructor () {
            super(User)
        }

        SignIn (type, e) {
            e.preventDefault();

            // Auth logic here
        }
    });
};

src\component\logger.hbs

<form class="sign-in" onsubmit 'User.SignIn("Admin")'>
    <input type="email" placeholder="Email address">
    <input type="password" placeholder="Password">
    <button>Login</button>
</form>

Middleware

Middleware are used for doing somethings before the whole app loads, Middleware.add can be overloaded (not recommended) use Middleware.once instead


src\middleware\index.js

import { Middleware } from "Ludr";

// Run everywhere
Middleware.add('all', (next) => {
    // do stuff

    next() // goes to next middleware
    // returns, do more
})

// Runs once in the profile page
Middleware.once('profile', (next) => { next() })

// Runs once in the profile page and once in 'page.name.two'
Middleware.once(['profile', 'page.name.two'], (next) => { next() })