Commit a93f10ee by Guillaume Lebigot

Ajout de JSDoc pour documenter le code source

parent 18147b01
......@@ -7,4 +7,6 @@ app/
src/app/
npm-debug.log
*.exe
toyundamugen.log
\ No newline at end of file
toyundamugen.log
out/
doc/
\ No newline at end of file
......@@ -6,4 +6,5 @@ Inscrivez ici la doc des modules pour vous y référer rapidement.
* cutlass : https://github.com/Daiz/cutlass
* async : https://caolan.github.io/async/docs.html
* fs-extras : https://www.npmjs.com/package/fs-extra
* winston (logger) : https://github.com/winstonjs/winston
\ No newline at end of file
* winston (logger) : https://github.com/winstonjs/winston
* jsdoc (génération de doc) : https://github.com/jsdoc3/jsdoc
\ No newline at end of file
{
"source": {
"includePattern": ".+\\.js(doc|x)?$"
},
"opts": {
"encoding": "utf8",
"destination": "./doc/",
"recurse": true
}
}
\ No newline at end of file
......@@ -13,6 +13,18 @@
"resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.3.tgz",
"integrity": "sha1-w8p0NJOGSMPg2cHjKN1otiLChMo="
},
"acorn": {
"version": "3.3.0",
"resolved": "https://registry.npmjs.org/acorn/-/acorn-3.3.0.tgz",
"integrity": "sha1-ReN/s56No/JbruP/U2niu18iAXo=",
"dev": true
},
"acorn-jsx": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-3.0.1.tgz",
"integrity": "sha1-r9+UiPsezvyDSPb7IvRk4ypYs2s=",
"dev": true
},
"after": {
"version": "0.8.2",
"resolved": "https://registry.npmjs.org/after/-/after-0.8.2.tgz",
......@@ -375,6 +387,12 @@
"resolved": "https://registry.npmjs.org/blob/-/blob-0.0.4.tgz",
"integrity": "sha1-vPEwUspURj8w+fx+lbmkdjCpSSE="
},
"bluebird": {
"version": "3.4.7",
"resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.4.7.tgz",
"integrity": "sha1-9y12C+Cbf3bQjtj66Ysomo0F+rM=",
"dev": true
},
"brace-expansion": {
"version": "1.1.8",
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.8.tgz",
......@@ -401,6 +419,12 @@
"integrity": "sha1-m7UwTS4LVmmLLHWLCKPqqdqlijk=",
"optional": true
},
"catharsis": {
"version": "0.8.8",
"resolved": "https://registry.npmjs.org/catharsis/-/catharsis-0.8.8.tgz",
"integrity": "sha1-aTR59DqsVJ2Aa9c+kkzQ2USVGgY=",
"dev": true
},
"center-align": {
"version": "0.1.3",
"resolved": "https://registry.npmjs.org/center-align/-/center-align-0.1.3.tgz",
......@@ -733,6 +757,12 @@
"resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz",
"integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ="
},
"espree": {
"version": "3.1.7",
"resolved": "https://registry.npmjs.org/espree/-/espree-3.1.7.tgz",
"integrity": "sha1-/V3ux2qXpRIKnNOnyxF3oJI7EdI=",
"dev": true
},
"esutils": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.2.tgz",
......@@ -1181,6 +1211,18 @@
"resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-3.0.1.tgz",
"integrity": "sha1-COnxMkhKLEWjCQfp3E1VZ7fxFNc="
},
"js2xmlparser": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/js2xmlparser/-/js2xmlparser-1.0.0.tgz",
"integrity": "sha1-WhcPLo1kds5FQF4EgjJCUTeC/jA=",
"dev": true
},
"jsdoc": {
"version": "3.4.3",
"resolved": "https://registry.npmjs.org/jsdoc/-/jsdoc-3.4.3.tgz",
"integrity": "sha1-5XQNYUXGgfZnnmwXeDqI292XzNM=",
"dev": true
},
"jsesc": {
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/jsesc/-/jsesc-1.3.0.tgz",
......@@ -1201,6 +1243,12 @@
"resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz",
"integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ="
},
"klaw": {
"version": "1.3.1",
"resolved": "https://registry.npmjs.org/klaw/-/klaw-1.3.1.tgz",
"integrity": "sha1-QIhDO0azsbolnXh4XY6W9zugJDk=",
"dev": true
},
"latest-version": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/latest-version/-/latest-version-1.0.1.tgz",
......@@ -1330,6 +1378,12 @@
"integrity": "sha1-5WqpTEyAVaFkBKBnS3jyFffI4ZQ=",
"dev": true
},
"marked": {
"version": "0.3.6",
"resolved": "https://registry.npmjs.org/marked/-/marked-0.3.6.tgz",
"integrity": "sha1-ssbGGPzOzk74bE/Gy4p8v1rtqNc=",
"dev": true
},
"match-stream": {
"version": "0.0.2",
"resolved": "https://registry.npmjs.org/match-stream/-/match-stream-0.0.2.tgz",
......@@ -1437,7 +1491,14 @@
"mkdirp": {
"version": "0.5.1",
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz",
"integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM="
"integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=",
"dependencies": {
"minimist": {
"version": "0.0.8",
"resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz",
"integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0="
}
}
},
"moment": {
"version": "2.18.1",
......@@ -1854,6 +1915,20 @@
"resolved": "https://registry.npmjs.org/repeating/-/repeating-2.0.1.tgz",
"integrity": "sha1-UhTFOpJtNVJwdSf7q0FdvAjQbdo="
},
"requizzle": {
"version": "0.2.1",
"resolved": "https://registry.npmjs.org/requizzle/-/requizzle-0.2.1.tgz",
"integrity": "sha1-aUPDUwxNmn5G8c3dUcFY/GcM294=",
"dev": true,
"dependencies": {
"underscore": {
"version": "1.6.0",
"resolved": "https://registry.npmjs.org/underscore/-/underscore-1.6.0.tgz",
"integrity": "sha1-izixDKze9jM3uLJOT/htRa6lKag=",
"dev": true
}
}
},
"right-align": {
"version": "0.1.3",
"resolved": "https://registry.npmjs.org/right-align/-/right-align-0.1.3.tgz",
......@@ -2898,6 +2973,12 @@
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz",
"integrity": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc="
},
"taffydb": {
"version": "2.6.2",
"resolved": "https://registry.npmjs.org/taffydb/-/taffydb-2.6.2.tgz",
"integrity": "sha1-fLy2S1oUG2ou/CxdLGe04VCyomg=",
"dev": true
},
"taskgroup": {
"version": "4.3.1",
"resolved": "https://registry.npmjs.org/taskgroup/-/taskgroup-4.3.1.tgz",
......@@ -2997,6 +3078,26 @@
"integrity": "sha1-7Mo6A+VrmvFzhbqsgSrIO5lKli8=",
"dev": true
},
"underscore": {
"version": "1.8.3",
"resolved": "https://registry.npmjs.org/underscore/-/underscore-1.8.3.tgz",
"integrity": "sha1-Tz+1OxBuYJf8+ctBCfKl6b36UCI=",
"dev": true
},
"underscore-contrib": {
"version": "0.3.0",
"resolved": "https://registry.npmjs.org/underscore-contrib/-/underscore-contrib-0.3.0.tgz",
"integrity": "sha1-ZltmwkeD+PorGMn4y7Dix9SMJsc=",
"dev": true,
"dependencies": {
"underscore": {
"version": "1.6.0",
"resolved": "https://registry.npmjs.org/underscore/-/underscore-1.6.0.tgz",
"integrity": "sha1-izixDKze9jM3uLJOT/htRa6lKag=",
"dev": true
}
}
},
"universalify": {
"version": "0.1.0",
"resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.0.tgz",
......
......@@ -68,6 +68,7 @@
"winston": "^2.3.1"
},
"devDependencies": {
"jsdoc": "^3.4.3",
"nodemon": "^1.11.0"
},
"false": {}
......
/**
* @fileoverview Main engine source file
*/
const path = require('path');
const logger = require('winston');
/**
* @module engine
* Main engine module.
*/
module.exports = {
SYSPATH:null,
SETTINGS:null,
DB_INTERFACE:null,
/**
* @private
* Engine status.
* Can be stop or play. Stop by default.
*/
_states:{
status:'stop', // [stop,play] // etat générale de l'application Karaoke - STOP => la lecture de la playlist est interrompu
private:true, // [bool(true|false)] // Karaoke en mode privé ou publique
......@@ -14,9 +26,13 @@ module.exports = {
playlist_controller: null,
player:null,
},
/**
* Base method for starting up the engine.
* It starts up the DB Interface, player, playlist controller and admin dashboard.
* @function {run}
*/
run: function(){
// méthode de démarrage de base
if(this.SYSPATH === null)
{
logger.error('SYSPATH is null');
......@@ -34,11 +50,18 @@ module.exports = {
this._start_admin();
this._broadcastStates();
},
exit:function(){
// coupe tout le système
/**
* Exits application.
* @function {exit}
*/
exit:function(){
process.exit();
},
/**
* Starts playing karaoke songs.
* @function {play}
*/
play:function(){
if(module.exports._states.status !== 'play')
{
......@@ -54,6 +77,10 @@ module.exports = {
module.exports._services.player.resume();
}
},
/**
* @function {stop}
* @param {boolean} now {If set, stops karaoke immediately. If not, karaoke will stop at end of current song}
*/
stop:function(now){
if(now)
module.exports._services.player.stop();
......@@ -64,6 +91,10 @@ module.exports = {
module.exports._broadcastStates();
}
},
/**
* @function {pause}
* Pauses current song in the player and broadcasts new status.
*/
pause:function(){
module.exports._services.player.pause()
// l'état globale n'a pas besoin de changer
......@@ -71,16 +102,26 @@ module.exports = {
module.exports._broadcastStates();
},
/**
* @function {setPrivateOn}
* @private
*/
setPrivateOn:function()
{
module.exports._states.private = true;
module.exports._broadcastStates();
},
/**
* @function {setPrivateOff}
*/
setPrivateOff:function()
{
module.exports._states.private = false;
module.exports._broadcastStates();
},
/**
* @function {togglePrivate}
*/
togglePrivate:function()
{
module.exports._states.private = !module.exports._states.private;
......@@ -89,27 +130,40 @@ module.exports = {
},
// Methode lié à la lecture de kara
/**
* @function
*
*/
playlistUpdated:function(){
module.exports.tryToReadNextKaraInPlaylist();
},
/**
* @function
*
* Function triggered on player ending its current song.
*/
playerEnding:function(){
module.exports.tryToReadNextKaraInPlaylist();
},
/**
* @function
* Try to read next karaoke in playlist.
*/
tryToReadNextKaraInPlaylist:function(){
if(module.exports._states.status === 'play' && !module.exports._services.player.playing)
{
kara = module.exports._services.playlist_controler.get_next_kara();
if(kara)
{
logger.success('next kara is '+kara.title);
logger.info('Next song is '+kara.title);
module.exports._services.player.play(
kara.videofile,
kara.subfile,
kara.kara_id
);
}
logger.log('warning','Next kara is not available');
logger.log('warning','Next song is not available');
module.exports._broadcastPlaylist();
}
},
......@@ -133,12 +187,22 @@ module.exports = {
// methodes de démarrage des services
// ------------------------------------------------------------------
/**
* @function _start_db_interface
* Starts database interface.
* Requires the db_interface.js script
*/
_start_db_interface: function()
{
module.exports.DB_INTERFACE = require(path.resolve(__dirname,'components/db_interface.js'));
module.exports.DB_INTERFACE.SYSPATH = module.exports.SYSPATH;
module.exports.DB_INTERFACE.init();
},
/**
* @function
* Starts the admin dashboard webservice on the selected port
* Broadcasts syspath and settings, as well as db interface to that module.
*/
_start_admin:function(){
module.exports._services.admin = require(path.resolve(__dirname,'../_admin/index.js'));
module.exports._services.admin.LISTEN = 1338;
......@@ -161,6 +225,11 @@ module.exports = {
// et on lance la commande pour ouvrir la page web
module.exports._services.admin.open();
},
/**
* @function
* Starts playlist controller
* Broadcasts syspath, database, and the playlistUpdated method
*/
_start_playlist_controller:function(){
module.exports._services.playlist_controller = require(path.resolve(__dirname,'components/playlist_controller.js'));
module.exports._services.playlist_controller.SYSPATH = module.exports.SYSPATH;
......@@ -185,11 +254,16 @@ module.exports = {
});
*/
// on ajoute 4 morceau dans la playlist
module.exports._services.playlist_controller.addKara(1,'toto');
module.exports._services.playlist_controller.addKara(2,'tata');
module.exports._services.playlist_controller.addKara(3,'titi');
module.exports._services.playlist_controller.addKara(4,'tutu');
//module.exports._services.playlist_controller.addKara(1,'toto');
//module.exports._services.playlist_controller.addKara(2,'tata');
//module.exports._services.playlist_controller.addKara(3,'titi');
//module.exports._services.playlist_controller.addKara(4,'tutu');
},
/**
* @function
* Starts player interface
* This is used to drive mpv or whatever video player is used.
*/
_start_player:function()
{
module.exports._services.player = require(path.resolve(__dirname,'../_player/index.js'));
......
/**
* @fileoverview Launcher source file
*/
const clc = require('cli-color');
const fs = require('fs');
const path = require('path');
......@@ -8,10 +12,12 @@ const logger = require('winston');
logger.add(logger.transports.File, {filename: 'toyundamugen.log'});
const argv = require('minimist')(process.argv.slice(2));
// Clear console - and welcome message
process.stdout.write('\033c');
/**
* Clear console - and welcome message
* Node does not like the octal clear screen sequence.
* So we wrote it in hexa (1B)
*/
process.stdout.write('\x1Bc');
console.log(clc.greenBright('+------------------------------------------------------------------+'));
console.log(clc.greenBright('| Project Toyunda Mugen ^^ |'));
console.log(clc.greenBright('+------------------------------------------------------------------+'));
......@@ -38,11 +44,15 @@ if (argv.version) {
process.exit(0);
}
/** Call to resolveSyspath to get the app's path in all OS configurations */
const SYSPATH = require('./_common/utils/resolveSyspath.js')('config.ini.default',__dirname,['./','../']);
if(SYSPATH)
{
logger.info('Detected SysPath is :'+clc.greenBright(SYSPATH));
logger.info('Detected SysPath is :'+SYSPATH);
// Lecture de la configuration par défault
/**
* Reading config.ini.default, then override it with config.ini if it exists.
*/
var SETTINGS = ini.parse(fs.readFileSync(path.join(SYSPATH,'config.ini.default'), 'utf-8'));
if(fs.existsSync(path.join(SYSPATH,'config.ini')))
{
......@@ -53,10 +63,18 @@ if(SYSPATH)
SETTINGS.os = 'Windows';
logger.info('Loading configuration.');
//console.log(SETTINGS);
logger.info(SETTINGS);
// Vérification que les chemins sont bien présents, sinon les créer
logger.info('Checking if data folders are in place...');
/**
* Checking if application paths exist.
* The app needs :
* app/bin
* app/data
* app/db
* app/temp
*/
logger.info('Checking if data folders are in place');
if(!fs.existsSync(path.join(SYSPATH,SETTINGS.Path.Karas))) {
logger.info(path.join(SYSPATH,SETTINGS.Path.Karas)+' does not exist, creating it...');
var ret = mkdirp.sync(path.join(SYSPATH,SETTINGS.Path.Karas));
......@@ -90,6 +108,9 @@ if(SYSPATH)
}
}
/**
* Calling engine.
*/
var engine = require('./_engine/index.js');
engine.SYSPATH = SYSPATH;
engine.SETTINGS = SETTINGS;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment