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

sitecore

v1.1.1

Published

This project is used to demonstrate how you should write a module in SPEAK

Downloads

53

Readme

#bootjS

##Introduction

bootJS is used by SPEAK in order to parse the DOM, create the appropriate components and executing pageCodes.

bootJS size minified and gzip is just 8KB !

There is no dependency on jQuery, Backbone, Knockout, Underscore but it does not mean you can't use them in your component.

##What bootJS is not ?

  • bootJS is not opionated, bootJS can make any kind of components working. Pick your favorite libraries, create some components with them and make it availabe to SPEAK by creating a Presenter (if needed).
  • bootJS is not a AMD loader, it can use an in-house AMD loader or the famous requireJS.
  • bootJS does not provide a template engine but expects one for creating "Javascript Template" component. By default, bootJS expect HandlebarsJS otherwise you need to configure a small adapter.

##What bootJS is ?

  • bootJS parses the DOM in order to re-create an application tree which is available to your pageCodes.
  • bootJS provides you a simple default component that you can use in order to add behavior to your components.
  • bootJS makes different kind of components working together with the help of a Presenter.
  • bootJS helps you in enhancing existing components or applications by creating plugins.
  • bootJS helps you in creating complex properties for your component and exposes them in a consistant manner. This makes those properties "speak" with other components via cross-bindings.

##Development

###Re-generate the file

If you want to change the code of bootJS and rebuild it, you will need to install node.js (with npm).

As soon as you have node.js installed, you can go to the directory where bootJS's source code is and execute:

npm install

This will install all the dependencies needed by the project in order to generate the files and execute the tests.

When done, to generate the dist file, you can execute:

on windows

grunt.cmd

on mac os or linux

grunt

###Coding Style

####commonJS

We have applied the commonJS pattern for splitting the code into different modules. We use a tool called "browserify" in order to reassemble the code into one file supported by the browser.

index.js is the main file.

####Comments We use the docBlockR notation for our comments.

####Styles

We use JSformatter to automatically format the JS code as we have decided.

####Configuration

You can find those configurations inside the "conf" folder of our structureJS repository.

####Documentation

You will find in the docs folder, a doc website generated based on the comments written in the Code.

####Test

The test folder has all the tests that can be run inside a node.js environment. The testClient folder has all the tests that must be run in the browser (we use phantomjs for executing them automatically).

To run the test:

grunt test

##Component

SPEAK is all about components, in a case you want special behaviour for a component, you will need to register this behaviour using the component method.

###Object literal

You can use object literal notation.

sitecore.component({
  name: "name", //required
  initialize: function() {
    this.test = true;
  },
  doSomething: function() {
    alert("Hello World");
  }
});

###Class

You can also pass a pure javascript object or a typescript class to the component method. In that case you will need to pass the name of the component as a parameter at the end.

class MyTypescriptClass {
  initialize() {
    this.isInitialize = true;
    this.isInitialized = true;
  }
}

sitecore.component(MyTypescriptClass, "MyTypescriptClass");

###Depedencies

If you need some dependencies for your component. You can pass those in the first parameter using an array.

sitecore.component(["/path/to/deps1", "/path/to/deps2"], { name: "MyComponent" initialize: function () { this.test = "Hello World" } });

##PageCode

To register a pageCode using bootJS, you will need to use the pageCode method.

sitecore.pageCode({
  initialize: function() {
    this.Component01.test = "Wouhou!";
  }
});

###Depedencies

If you need some dependencies for your pageCode. You can pass those in the first parameter using an array.

sitecore.pageCode(["/path/to/deps1", "/path/to/deps2"], {
  initialize: function() {
    this.Component01.test = "Wouhou!";
  }
});

##Plugins

A plugin is an object which can extend all the components inside your page and/or all the applications inside your page.

Here is a basic example, on how to create a plugin for adding jQuery.

sitecore.plugin(["path/to/jQuery"], {
  extendComponent: function(component) {
    component.$el = $(component.el);
  },
  extendApplication: function(app) {
    app.$el = $(app.el);
  }
});

Please note, those code wil be executed just after your initialize method.

##Presenter

A presenter lets you use the framework of your choice in order to add shared behaviour for a set of components.

sitecore.presenter(["path/to/knockout"], {
  initialize: function() {
    this.createViewModel();
  },
  createViewModel: function () {
     //some magics
  }
});

##Property

This method is used by SPEAK in order to register custome type for your property.

Here is an example of a property which could expose a property fullName constructed by the firstname and lastname property present inside your component.

sitecore.propertyType( {
  name: "fullname",
  get: function () {
    return this.component.firstname + " " + this.component.lastname;
  }
} );

##more to come