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

serval-backbone

v2.2.1

Published

Backbone boilerplate generator with gulp

Downloads

1

Readme

#Serval backbone boilerplate

A boilerplate for backbone.js. From Marrow. It's ready for i18n with Yaml files, it's also ready for mobile thanks to Swiftclick.

If you have docker.js you can also build your API documentation !

How to install ?

Requirements

  • node.js
  • npm

Ok, let's run : npm install

Not included:

  • Magic code oh noooes!
  • Coffee bad for your heart anyway
  • Give you the opportunity to twiddle your thumbs sorry buddy

Included:

  • A structure
  • A great compilation process via Gulp
  • Browserify
  • Templating via lodash
  • Lo-Dash instead of underscore for performance!
  • Normalize.css
  • jQuery 2.1
  • SwiftClick
  • Moment.js
  • i18n
  • Documentation with Docker
  • An HTTP server with Express.js
  • pushState
  • some helpers
  • ... all you need to begin a great app and being happy

Helpers

This application contains some helpers :

  • openPage(page,delay)
  • resetTimeout() : Clean your app's timeouts
  • repeatAction(cb, delay, msg) : Reapeat a custom action after a delay (s).
  • resetActions() : Clean your app's intervals (from repeatAction)
  • tpl(partialName) : Load your template

i18n

  • i18nLoader(cb) : Activate i18n inside your app. Init your app inside the callback.
  • App.currentLang(): An object with your current language data
  • App.lang('lang-Lang'): Access to another language
  • App.Languages.available: An array of each languages available

Direct access to your app's components

  • App.view(ViewNameInstance) : Direct access to an instance of a view
  • App.model(ModelNameInstance) : Direct access to an instance of a Model
  • App.collection(CollectionNameInstance) : Direct access to an instance of a Collection
  • App.lang(LanguageName) : Direct access to a Language
  • App.currentLang() : Direct access to the current instance of a language

It also provides a verbose mode, the default value it set to 1, so you can view App's internal debugs. If you change the value to 0 it hides them.

You can view these helpers inside src/js/bootstrap.js.

i18n inside your application

I18n is built on top of Yaml files and Gulp. We concatenate them, then we convert it to a file languages.json inside the directory i18n

French translation for the boilerplate

title: "Bienvenue petit papillon de lumière !"
baseline: "Bienvenue sur"
baselineInfo: "Serval-boilerplate avec Backbone.js"
includes: "Tu peux désormais coder. Tu disposes de :"
launchApp: "Ouvre une console et saisi cette commande :"
aboutTpl: "On utilise une  version customisée du template lodash cf:"
aboutTpl2: "Tu peux modifier ça dans la variable templateSettings, on trouve ça dans ce fichier"
aboutLink: "Tu peux aller à la page suivante avec ce lien : "
aboutLink2: "ou, en utilisant ce bouton avec un event"
aboutAnchor: avec une ancre
buttonMsg: Page suivante

You must respect a convention for the filename

Language are defined with a - as defined inside the BCP 47. cf Value of the HTML5 lang attribute. So the filename will be fr-FR.yml

Built i18n for your app

Run gulp (for the dev), it will create the i18n, it will also watch for changes inside each file in i18n/ and refresh the page.

You can run the task without the dev's server, just run gulp i18n

languages.json is a JSON object, with primary key as language. If you don't configure the ShopParameters inside the manager, the first key will be your default language.

Some tips

Go to another page on click

You can create a button or anything else to redirect to another page. It's easy, you don't need to write a line of JavaScript.

<button type="button" data-page-dest="form">Go to form</button>

That's it, just add data-page-dest attribute. Then add a page name and when you click, the application will know where is your destination.

For the root page, just add root.

Switch to another language on click

You have to put something like this button :

<button type="button" data-i18n="fr-FR" class="btn-i18n">fr-FR</button>

It can be anything else, but he has to have these:

  • a className : btn-i18n
  • an attribute : data-i18n with the value to change

Explanation

.
├── GulpFile.js
├── README.md
├── .jshintrc
├── .editorconfig
├── package.json
├── build // final files
├── i18n // for i18n
    ├── fr-FR.yml // A translation
    └── languages.json // i18n translations (build with gulp)
├── doc // API documentation
├── src // where you code
    ├── layout // Your app layout (header,footer...)
    ├── partials // HTML partials
    ├── styles // Your css
    ├── assets // static files
    └── js // Your backbone app
        ├── start.js // Setup App Namespace
        ├── app.js // $(document).ready
        ├── bootstrap.js
        ├── collections // http://backbonejs.org/#Collection
        ├── models // http://backbonejs.org/#Model
        ├── routers // http://backbonejs.org/#Router
        └── views // http://backbonejs.org/#View
└── tasks // Directory for each of your gulp tasjs

Development

$ gulp

Documentation

$ gulp doc

About the gulpFile.js

The gulpFile contains our tasks in order to built|dev the application, there are

  • assets : Move our assets from src/assets/ to build/assets/
  • vendor : Concatenate Backbone,lodash etc. and build a vendor.min.js
  • templates : Build an index.html with each partials as scripts
  • scripts : Build the backbone application
  • styles : Move our CSS to build/styles/
  • manifest : Update our app manifest an update the version
  • i18n : Build the i18n languages.json file
  • zip : Zip de content of build directory
  • doc : Create an API documentation with Docco
  • prod : Build the application, aggregate each previous tasks
  • default : Default task

default task, to dev

This task will start a server with express.js, it will start the server and open the browser to : http://localhost:8080/build/.

It also provides you a wrappper for an API, http://localhost:8080/apitest, it can be access throught POST|GET|DELETE|PUT|PATCH... Any http request you want.

This task launch liverload, so you have to install Livereload for Chrome in your browser.

Other tasks

You can modify each task, there are in the directory tasks.

Templates,default,scripts are inside the gulpfile.

Do you have serval ?

Run serval generate, you will be able to create :

  • A backbone view
  • A new route
  • A new partial
  • A backbone view + its partial and add the route

Note

Serval backbone boilerplate is built on top of Marrow.