Code Monkey home page Code Monkey logo

scaffold's Introduction

scaffold

The template I use for new web applications. It is based on Nodejs/Express for the backend, and handlebars for the frontend.

Get started

  • Clone the project
  • install grunt (required for the frontend folder).
  • use npm install at the root, and in the frontend project.
  • you might have to manually add a data folder at the root, and run mongod --dbpath ./data/db/ the first time (The reason why is to be investigated).
  • run grunt buildDev or grunt (to have watch running) in the frontend folder
  • run launchServer.sh to start the server
  • open localhost:3000 in your browser

Internationalization

I have added a very simple internationalization framework, to get me started. The API is pretty simple.

app.i18n.register('en', {
 user: {
  name: 'My name is %{name}',
  logout: 'Logout',
  age: {
    counter: 'age'
    1: 'I am one year old.',
    2: 'I am two years old',
    n: 'I am %{age} years old'
  }
 }
});

app.i18n.translate('user.logout'); // 'Logout'
app.i18n.translate('user.name', {name: 'Bob'}); // 'My name is Bob'

app.i18n.translate('user.age', {age: 1}); // 'I am one year old.'
app.i18n.translate('user.age', {age: 2}); // 'I am two years old.'
app.i18n.translate('user.age', {age: 13}); // 'I am 13 years old.'

app.i18n.setDefault('en'); // sets the default language to English
app.i18n.setLanguage('fr'); // sets the current language to French

and you have an internationalization framework in less than 80 lines of code (including comments).

It is also integrated with Handlebars through the i18n helper:

{{i18n string="user.name" name="Bob"}} // 'My name is Bob'
{{i18n string="user.age" age=13}} // 'I am 13 years old.'

It also works with variables present in the context

{{i18n string="user.age" age=context.age}} // 'I am 13 years old.'

Still to do

  • The production mode is not yet correctly handled. There is no way to run the server in production mode.
  • Testing
  • I'd like to have some stuff added to the layout:
    • In dev mode, have files added one by one (easier debugging)
  • Livereload?

scaffold's People

Contributors

stilltorik avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.