These are chat archives for satan/666

10th
Mar 2016
MVCR node and shits
npm init
mkdir ./app_modules
mkdir ./app_modules/lib
app.js
'use strict';
//
global.__root = __dirname
global.__api = [];
//
var express = require('express');
var exphbs  = require('express-handlebars');
var Handlebars = require('handlebars');
//
var fs = require('fs');
//
var path = require('path');
var cookieParser = require('cookie-parser');
var bodyParser = require('body-parser');
//
var session = require('express-session');
//
var helpers = require(__root+'/app_modules/lib/helpers');
//
var app = express();
//
var server = app//https.createServer(options, app)
//
server.listen(port, function () {
    console.log('server listening on: '+port);

    if(process.getuid() == 0 ){
        console.log('Running as root')
    } else {
        console.log('Running as NON root')
    }
});
so we use express, handlebars, fs, path, cookie-parser, body-parser, express-session
we also include an application level control on who is running the app whether he is root or jsut a user
on the getUID part
SΔTΔN
@satan
Mar 10 2016 08:30
anything that has to do with application functionality will be included in lib folder
like a function to include all the models or all the routes or whatever
lets go make the first module
gts00k
@gts00k
Mar 10 2016 08:33
re ebgales ton kosmo ?
SΔTΔN
@satan
Mar 10 2016 08:33
add a file named helpers.js inside lib for handlebars magic
alo room einai
gts00k
@gts00k
Mar 10 2016 08:33
lol
pioi einai oi alloi ?
SΔTΔN
@satan
Mar 10 2016 08:33
kalese opoion thes an thes
an kai uparxei to repo
anyway
i like handlebars because i can do trippy shit to my templates
gts00k
@gts00k
Mar 10 2016 08:35
akous?
SΔTΔN
@satan
Mar 10 2016 08:35
re grafe sto alo room
edo diavaze
i like handlebars because i can do pythonic checks like "if in" while im iterating a list
gts00k
@gts00k
Mar 10 2016 08:36
den katalabainw gt to kaneis etsi
SΔTΔN
@satan
Mar 10 2016 08:37
{{#ifIn @key "virgin" }}

{{else}}

{{/ifIn}}
this would be the ifin helper at work
gts00k
@gts00k
Mar 10 2016 08:39
ok
SΔTΔN
@satan
Mar 10 2016 08:39
and that would look like this in the lib/helpers.js
'use strict';

var Handlebars = require('handlebars');

exports.ifIn = function(elem, list, options) {

    var string = elem,
    substrings = list.split(',');

    for (var i = 0; i < substrings.length; i++) {

        if(string.indexOf(substrings[i]) > -1) {
            return options.fn(this);
        }

    };
    return options.inverse(this);
};

Handlebars.unregisterHelper('ifIn');
gts00k
@gts00k
Mar 10 2016 08:40
if you say so
SΔTΔN
@satan
Mar 10 2016 08:40
the first module will be responsible for handlign the layouts for each other module
mkdir ./app_modules/layouts/
mkdir ./app_modules/layouts/routes
mkdir ./app_modules/layouts/views
mkdir ./app_modules/layouts/views/layouts
mkdir ./app_modules/layouts/views/partials
mkdir ./app_modules/layouts/views/home.hbs
gts00k
@gts00k
Mar 10 2016 08:43
klaiw
SΔTΔN
@satan
Mar 10 2016 08:43
as well as serve the home page
jsut upd the repo to reflect
gts00k
@gts00k
Mar 10 2016 08:49
?
SΔTΔN
@satan
Mar 10 2016 08:50
removed some files cause of the popy paste
back on track now
seems like there was no port designated
so now it is and the app starts
gts00k
@gts00k
Mar 10 2016 08:53
ok bye
SΔTΔN
@satan
Mar 10 2016 08:54
we specify a default layout engine in the app so handlebars know where to find all the partials and tempaltes
we up the application mb limit to 50 for uploads
also dissable the xpowered by
and now we have the app running with the partials loading
every other module will depend on this layout module when we create it so we keep our shit organized
every module will have a version
tomorrow with some more crap