Gathering detailed insights and metrics for serval-backbone
Gathering detailed insights and metrics for serval-backbone
Gathering detailed insights and metrics for serval-backbone
Gathering detailed insights and metrics for serval-backbone
npm install serval-backbone
Typescript
Module System
NPM Version
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
#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 !
Ok, let's run : npm install
This application contains some helpers :
openPage(page,delay)
resetTimeout()
: Clean your app's timeoutsrepeatAction(cb, delay, msg)
: Reapeat a custom action after a delay (s).resetActions()
: Clean your app's intervals (from repeatAction)tpl(partialName)
: Load your templatei18nLoader(cb)
: Activate i18n inside your app. Init your app inside the callback.App.currentLang()
: An object with your current language dataApp.lang('lang-Lang')
: Access to another languageApp.Languages.available
: An array of each languages availableApp.view(ViewNameInstance)
: Direct access to an instance of a viewApp.model(ModelNameInstance)
: Direct access to an instance of a ModelApp.collection(CollectionNameInstance)
: Direct access to an instance of a CollectionApp.lang(LanguageName)
: Direct access to a LanguageApp.currentLang()
: Direct access to the current instance of a languageIt 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 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
1title: "Bienvenue petit papillon de lumière !" 2baseline: "Bienvenue sur" 3baselineInfo: "Serval-boilerplate avec Backbone.js" 4includes: "Tu peux désormais coder. Tu disposes de :" 5launchApp: "Ouvre une console et saisi cette commande :" 6aboutTpl: "On utilise une version customisée du template lodash cf:" 7aboutTpl2: "Tu peux modifier ça dans la variable templateSettings, on trouve ça dans ce fichier" 8aboutLink: "Tu peux aller à la page suivante avec ce lien : " 9aboutLink2: "ou, en utilisant ce bouton avec un event" 10aboutAnchor: avec une ancre 11buttonMsg: 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 befr-FR.yml
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.
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.
1<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.
You have to put something like this button :
1<button type="button" data-i18n="fr-FR" class="btn-i18n">fr-FR</button>
It can be anything else, but he has to have these:
btn-i18n
1. 2├── GulpFile.js 3├── README.md 4├── .jshintrc 5├── .editorconfig 6├── package.json 7├── build // final files 8├── i18n // for i18n 9 ├── fr-FR.yml // A translation 10 └── languages.json // i18n translations (build with gulp) 11├── doc // API documentation 12├── src // where you code 13 ├── layout // Your app layout (header,footer...) 14 ├── partials // HTML partials 15 ├── styles // Your css 16 ├── assets // static files 17 └── js // Your backbone app 18 ├── start.js // Setup App Namespace 19 ├── app.js // $(document).ready 20 ├── bootstrap.js 21 ├── collections // http://backbonejs.org/#Collection 22 ├── models // http://backbonejs.org/#Model 23 ├── routers // http://backbonejs.org/#Router 24 └── views // http://backbonejs.org/#View 25└── tasks // Directory for each of your gulp tasjs
$ gulp
$ gulp doc
The gulpFile contains our tasks in order to built|dev the application, there are
src/assets/
to build/assets/
vendor.min.js
index.html
with each partials as scriptsbuild/styles/
languages.json
fileThis 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.
You can modify each task, there are in the directory tasks
.
Templates,default,scripts are inside the gulpfile.
Run serval generate
, you will be able to create :
Serval backbone boilerplate is built on top of Marrow.
No vulnerabilities found.
No security vulnerabilities found.