Browse Source

handlebars

windhamdavid 3 years ago
parent
commit
b2ec9d0a0f

+ 1 - 3
.gitignore

@@ -1,10 +1,8 @@
 .DS_Store
-logs
 *.log
 npm-debug.log*
 node_modules
 *.rdb
 dump.rdb
-config.js
-config-dev.js
+config/*
 app/*

+ 13 - 0
.jshintrc

@@ -1,4 +1,17 @@
 {
+  "globals": { 
+    "console": false,
+    "exports": false,
+    "module": false,
+    "require": false
+  },
+  "predef": [
+    "console",
+    "exports",
+    "module",
+    "require",
+    "__dirname"
+  ],
 	"node": true,
 	"esnext": true,
 	"bitwise": true,

+ 71 - 0
.jslintrc

@@ -0,0 +1,71 @@
+{
+  "predef": [
+    "console",
+    "module",
+    "require",
+    "__dirname"
+  ],
+
+
+  "bitwise":      true,
+  "curly":        true,
+  "eqeqeq":       false,
+  "forin":        false,
+  "immed":        true,
+  "latedef":      false,
+  "newcap":       true,
+  "noarg":        true,
+  "noempty":      true,
+  "nonew":        true,
+  "plusplus":     false,
+  "regexp":       false,
+  "undef":        true,
+  "strict":       false,
+  "trailing":     true,
+
+
+  "asi":          false,
+  "boss":         true,
+  "debug":        false,
+  "eqnull":       true,
+  "es5":          true,
+  "esnext":       true,
+  "evil":         true,
+  "expr":         true,
+  "funcscope":    false,
+  "globalstrict": false,
+  "iterator":     false,
+  "lastsemic":    false,
+  "laxbreak":     false,
+  "laxcomma":     false,
+  "loopfunc":     true,
+  "multistr":     false,
+  "onecase":      false,
+  "proto":        false,
+  "regexdash":    false,
+  "scripturl":    false,
+  "shadow":       true,
+  "smarttabs":    true,
+  "sub":          false,
+  "supernew":     false,
+  "validthis":    true,
+
+
+  "browser":      true,
+  "couch":        false,
+  "devel":        false,
+  "dojo":         false,
+  "jquery":       true,
+  "mootools":     false,
+  "node":         true,
+  "nonstandard":  false,
+  "prototypejs":  false,
+  "rhino":        false,
+  "wsh":          false,
+
+  
+  "nomen":        false,
+  "onevar":       false,
+  "passfail":     false,
+  "white":        false
+}

+ 1 - 0
.tm_properties

@@ -9,4 +9,5 @@ softTabs = true
 tabSize = 2
 
 projectDirectory = "$CWD"
+TM_PROJECT_DIRECTORY = "$projectDirectory"
 windowTitle = "$TM_DISPLAYNAME — ${CWD/^.*\///} ($TM_SCM_BRANCH)"

+ 31 - 5
app.js

@@ -1,28 +1,49 @@
+/*global require:true, __dirname:true */
+
 var express = require('express');
 var session = require('express-session');
 var exphbs = require('express-handlebars');
-var cookieParser = require('cookie-parser')
+var cookieParser = require('cookie-parser');
 var bodyParser = require('body-parser');
+var favicon = require('serve-favicon');
+var errorHandler = require('errorhandler');
 var events = require('events');
 var http = require('http');
 var path = require('path');
 var logger = require('morgan');
 
-
 var app = express();
 
 var config = {
   development: require('./config/config-dev.js'),
   production: require('./config/config.js')
 };
+var secrets = require('./config/secrets');
+var passportConf = require('./config/passport');
 
-var app = express(),
-    server = http.createServer(app);
-    server.listen(conf.port);
 
+var homeController = require('./controllers/home');
+var userController = require('./controllers/user');
+
+app.use(errorHandler());
 app.use(bodyParser.json());
 app.use(bodyParser.urlencoded({ extended: false }));
+app.use(cookieParser());
+
 app.use(express.static(path.join(__dirname, 'app')));
+app.use(favicon(path.join(__dirname, 'app/img', 'favicon.ico')));
+
+app.engine('.hbs', exphbs({ 
+  defaultLayout: 'main', 
+  extname: '.hbs',
+  layoutsDir:'app/views/layouts',
+  partialsDir:'app/views/partials'
+}));
+app.set('view engine', '.hbs');
+app.set('views', path.join(__dirname, 'app/views'));
+
+app.get('/', homeController.index);
+app.get('/login', userController.getLogin);
 
 
 var logger = new events.EventEmitter();
@@ -30,3 +51,8 @@ logger.on('newEvent', function(event, data) {
   console.log('%s: %s', event, JSON.stringify(data));
 });
 
+app.listen(conf.port), function() {
+  console.log('listening on port %d in %s mode', app.get('port'), app.get('env'));
+}
+
+module.exports = app;

+ 5 - 0
controllers/home.js

@@ -0,0 +1,5 @@
+exports.index = function(req, res) {
+  res.render('home', {
+    title: 'Home'
+  });
+};

+ 8 - 0
controllers/user.js

@@ -0,0 +1,8 @@
+exports.getLogin = function (req, res) {
+  if (req.user) {
+    return res.redirect('/');
+  }
+  res.render('account/login', {
+    title: 'Login'
+  });
+};

+ 1 - 1
gulpfile.js

@@ -41,7 +41,7 @@ var buildTask = function() {
   gulp.src('./src/index.html')
     .pipe(minifyHTML())
     .pipe(gulp.dest('./app'));
-  gulp.src('./src/views/*')
+  gulp.src('./src/views/**/*')
     .pipe(gulp.dest('./app/views'));
   gulp.src('./src/views/layouts/*')
     .pipe(gulp.dest('./app/views/layouts'));

+ 1 - 0
package.json

@@ -17,6 +17,7 @@
     "body-parser": "^1.14.1",
     "cookie-parser": "^1.3.5",
     "debug": "~2.2.0",
+    "errorhandler": "^1.4.2",
     "express": "^4.13.3",
     "express-handlebars": "^2.0.1",
     "express-session": "^1.12.1",

views/layouts/login.hbs → src/views/account/login.hbs


views/layouts/register.hbs → src/views/account/register.hbs


views/layouts/user.hbs → src/views/account/user.hbs


+ 67 - 0
src/views/home.hbs

@@ -0,0 +1,67 @@
+<!DOCTYPE html>
+<head>
+   <meta charset="utf-8">
+   <meta http-equiv="x-ua-compatible" content="ie=edge">
+   <meta name="viewport" content="width=device-width, initial-scale=1">
+   <title></title>
+   <meta name="description" content="Juryd Judging Everything">
+   <link rel="stylesheet" href="css/style.min.css">
+</head>
+<body>
+
+ <nav id="mainNav" class="navbar navbar-default navbar-fixed-top">
+     <div class="container">
+         <div class="navbar-header">
+             <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar-collapse">
+                 <span class="sr-only">Toggle navigation</span>
+                 <span class="icon-bar"></span>
+                 <span class="icon-bar"></span>
+                 <span class="icon-bar"></span>
+             </button>
+             <a class="navbar-brand page-scroll" href="#page-top">Juryd</a>
+         </div>
+
+         <div class="collapse navbar-collapse" id="navbar-collapse">
+             <ul class="nav navbar-nav navbar-right">
+                 <li><a class="btn page-scroll" href="#">Sign In</a></li>
+             </ul>
+         </div>
+     </div>
+ </nav>
+
+{{{body}}}
+
+
+<footer class="bg-dark">
+   <div class="container bg-dark">
+      <div class="row">
+         <div class="col-sm-3 col-sm-offset-2">
+            <h5>About</h5>
+            <p>Documentation</p>
+            <p>History</p>
+            <p>About Us</p>
+         </div>
+         <div class="col-sm-3">
+            <h5>Support</h5>
+            <p>System Status</p>
+            <p>Support Ticket</p>
+            <p>Account Preferences</p>
+         </div>
+         <div class="col-sm-3">
+            <h5>About</h5>
+            <p>Contact</p>
+            <p>Privacy Policy</p>
+            <p>Terms of Use</p>
+         </div>
+      </div>
+   </div>
+</footer>
+   
+<script src="js/lib.min.js"></script>
+<script src="js/main.min.js"></script>
+ <!--[if lt IE 9]>
+   <script src="js/html5shiv.min.js"></script>
+   <script src="js/respond.min.js"></script>
+ <![endif]-->
+</body>
+</html>

+ 67 - 0
src/views/layouts/main.hbs

@@ -0,0 +1,67 @@
+<!DOCTYPE html>
+<head>
+   <meta charset="utf-8">
+   <meta http-equiv="x-ua-compatible" content="ie=edge">
+   <meta name="viewport" content="width=device-width, initial-scale=1">
+   <title></title>
+   <meta name="description" content="Juryd Judging Everything">
+   <link rel="stylesheet" href="css/style.min.css">
+</head>
+<body>
+
+ <nav id="mainNav" class="navbar navbar-default navbar-fixed-top">
+     <div class="container">
+         <div class="navbar-header">
+             <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar-collapse">
+                 <span class="sr-only">Toggle navigation</span>
+                 <span class="icon-bar"></span>
+                 <span class="icon-bar"></span>
+                 <span class="icon-bar"></span>
+             </button>
+             <a class="navbar-brand page-scroll" href="#page-top">Juryd</a>
+         </div>
+
+         <div class="collapse navbar-collapse" id="navbar-collapse">
+             <ul class="nav navbar-nav navbar-right">
+                 <li><a class="btn page-scroll" href="#">Sign In</a></li>
+             </ul>
+         </div>
+     </div>
+ </nav>
+
+{{body}}
+
+
+<footer class="bg-dark">
+   <div class="container bg-dark">
+      <div class="row">
+         <div class="col-sm-3 col-sm-offset-2">
+            <h5>About</h5>
+            <p>Documentation</p>
+            <p>History</p>
+            <p>About Us</p>
+         </div>
+         <div class="col-sm-3">
+            <h5>Support</h5>
+            <p>System Status</p>
+            <p>Support Ticket</p>
+            <p>Account Preferences</p>
+         </div>
+         <div class="col-sm-3">
+            <h5>About</h5>
+            <p>Contact</p>
+            <p>Privacy Policy</p>
+            <p>Terms of Use</p>
+         </div>
+      </div>
+   </div>
+</footer>
+   
+<script src="js/lib.min.js"></script>
+<script src="js/main.min.js"></script>
+ <!--[if lt IE 9]>
+   <script src="js/html5shiv.min.js"></script>
+   <script src="js/respond.min.js"></script>
+ <![endif]-->
+</body>
+</html>

+ 0 - 177
views/home.hbs

@@ -1,177 +0,0 @@
-<!DOCTYPE html>
-<head>
-   <meta charset="utf-8">
-   <meta http-equiv="x-ua-compatible" content="ie=edge">
-   <meta name="viewport" content="width=device-width, initial-scale=1">
-   <title>Jury'd - You Be the Judge</title>
-   <meta name="description" content="Juryd Judging Everything">
-   <link rel="stylesheet" href="css/style.min.css">
-</head>
-<body>
-
- <nav id="mainNav" class="navbar navbar-default navbar-fixed-top">
-     <div class="container">
-         <div class="navbar-header">
-             <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar-collapse">
-                 <span class="sr-only">Toggle navigation</span>
-                 <span class="icon-bar"></span>
-                 <span class="icon-bar"></span>
-                 <span class="icon-bar"></span>
-             </button>
-             <a class="navbar-brand page-scroll" href="#page-top">Juryd</a>
-         </div>
-
-         <div class="collapse navbar-collapse" id="navbar-collapse">
-             <ul class="nav navbar-nav navbar-right">
-                 <li><a class="btn page-scroll" href="#">Sign In</a></li>
-             </ul>
-         </div>
-     </div>
- </nav>
-
-<header>
-   <div class="container-fluid">
-      <div class="header-content">
-         <div class="header-content-inner">
-            <div class="row">
-               <div class="col-sm-8">
-                  <h1>Juryd</h1>
-                  <h2>You be the Judge</h2>
-                  <hr>    
-                  <h4>Juryd is an application that allows the participants to register and vote.</h4>
-               </div>
-               <div class="col-sm-4">
-                  <img src="img/ribbon.svg" class="svg">
-               </div>
-            </div>
-         </div>
-		</div>
-   </div>
-</header>
-
-<section id="about">
-   <div class="container">
-      <div class="row">
-         <div class="col-lg-8">
-            <img src="img/ipad.svg" class="svg">
-         </div>
-         <div class="col-sm-4 text-center">
-            <h2 class="section-heading">How It Works</h2>
-            <hr class="light">
-            <p>Some Copy</p>
-         </div>
-      </div>
-   </div>
-</section>
-
-<section id="details">
-   <div class="container">
-      <div class="row text-center">
-         <div class="col-sm-4">
-            <h3 class="section-heading">Juried Competition</h3>
-            <p>Some Copy</p>
-         </div>
-         <div class="col-sm-4">
-            <h3 class="section-heading">Registrant Jury</h3>
-            <p>Some Copy</p>
-         </div>
-         <div class="col-sm-4">
-            <h3 class="section-heading">Registered Judges</h3>
-            <p>Some Copy</p>
-         </div>
-      </div>
-   </div>
-</section>
-
-<section id="features">
-   <div class="container">
-      <div class="row text-center">
-         <div class="col-sm-6">
-            <h2 class="section-heading">Features</h2>
-            <p>Some Copy</p>
-            <img src="img/ribbon.svg" class="svg icon-small blue-ribbon">
-            <img src="img/ribbon.svg" class="svg icon-small red-ribbon">
-            <img src="img/ribbon.svg" class="svg icon-small yellow-ribbon">
-         </div>
-         <div class="col-sm-6">
-            <img src="img/phone.svg" class="svg">
-         </div>
-      </div>
-   </div>
-</section>
-
-<section id="account">
-   <div class="container">
-      <div class="row text-center">
-         <div class="col-sm-6">
-            <h2 class="section-heading">About</h2>
-            <p>Some Copy</p>
-         </div>
-         <div class="col-sm-6">
-            <h2 class="section-heading">About</h2>
-            <p>Some Copy</p>
-         </div>
-      </div>
-   </div>
-</section>
-
-<section id="call">
-   <div class="container">
-      <div class="row">
-         <div class="col-sm-4 col-lg-offset-2 text-center">
-            <h4 class="section-heading">Connect</h4>
-            <hr class="light">
-            <p>(Social Media Icons)</p>
-         </div>
-         <div class="col-sm-4 text-center">
-            <h4 class="section-heading">Get the Latest</h4>
-            <form class="form-inline">
-               <div class="form-group">
-                  <label class="sr-only" for="exampleInputAmount">Email Addresss</label>
-                  <div class="input-group">
-                     <input type="text" class="form-control" id="email-address" placeholder="Email Address">
-                     <div class="input-group-addon">
-                        <button type="submit" class="btn btn-primary">GO</button>
-                     </div>
-                  </div>
-               </div>
-            </form>
-         </div>
-      </div>
-   </div>
-</section>
-
-
-<footer class="bg-dark">
-   <div class="container bg-dark">
-      <div class="row">
-         <div class="col-sm-3 col-sm-offset-2">
-            <h5>About</h5>
-            <p>Documentation</p>
-            <p>History</p>
-            <p>About Us</p>
-         </div>
-         <div class="col-sm-3">
-            <h5>Support</h5>
-            <p>System Status</p>
-            <p>Support Ticket</p>
-            <p>Account Preferences</p>
-         </div>
-         <div class="col-sm-3">
-            <h5>About</h5>
-            <p>Contact</p>
-            <p>Privacy Policy</p>
-            <p>Terms of Use</p>
-         </div>
-      </div>
-   </div>
-</footer>
-   
-<script src="js/lib.min.js"></script>
-<script src="js/main.min.js"></script>
- <!--[if lt IE 9]>
-   <script src="js/html5shiv.min.js"></script>
-   <script src="js/respond.min.js"></script>
- <![endif]-->
-</body>
-</html>

+ 0 - 177
views/layouts/main.hbs

@@ -1,177 +0,0 @@
-<!DOCTYPE html>
-<head>
-   <meta charset="utf-8">
-   <meta http-equiv="x-ua-compatible" content="ie=edge">
-   <meta name="viewport" content="width=device-width, initial-scale=1">
-   <title>Jury'd - You Be the Judge</title>
-   <meta name="description" content="Juryd Judging Everything">
-   <link rel="stylesheet" href="css/style.min.css">
-</head>
-<body>
-
- <nav id="mainNav" class="navbar navbar-default navbar-fixed-top">
-     <div class="container">
-         <div class="navbar-header">
-             <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar-collapse">
-                 <span class="sr-only">Toggle navigation</span>
-                 <span class="icon-bar"></span>
-                 <span class="icon-bar"></span>
-                 <span class="icon-bar"></span>
-             </button>
-             <a class="navbar-brand page-scroll" href="#page-top">Juryd</a>
-         </div>
-
-         <div class="collapse navbar-collapse" id="navbar-collapse">
-             <ul class="nav navbar-nav navbar-right">
-                 <li><a class="btn page-scroll" href="#">Sign In</a></li>
-             </ul>
-         </div>
-     </div>
- </nav>
-
-<header>
-   <div class="container-fluid">
-      <div class="header-content">
-         <div class="header-content-inner">
-            <div class="row">
-               <div class="col-sm-8">
-                  <h1>Juryd</h1>
-                  <h2>You be the Judge</h2>
-                  <hr>    
-                  <h4>Juryd is an application that allows the participants to register and vote.</h4>
-               </div>
-               <div class="col-sm-4">
-                  <img src="img/ribbon.svg" class="svg">
-               </div>
-            </div>
-         </div>
-		</div>
-   </div>
-</header>
-
-<section id="about">
-   <div class="container">
-      <div class="row">
-         <div class="col-lg-8">
-            <img src="img/ipad.svg" class="svg">
-         </div>
-         <div class="col-sm-4 text-center">
-            <h2 class="section-heading">How It Works</h2>
-            <hr class="light">
-            <p>Some Copy</p>
-         </div>
-      </div>
-   </div>
-</section>
-
-<section id="details">
-   <div class="container">
-      <div class="row text-center">
-         <div class="col-sm-4">
-            <h3 class="section-heading">Juried Competition</h3>
-            <p>Some Copy</p>
-         </div>
-         <div class="col-sm-4">
-            <h3 class="section-heading">Registrant Jury</h3>
-            <p>Some Copy</p>
-         </div>
-         <div class="col-sm-4">
-            <h3 class="section-heading">Registered Judges</h3>
-            <p>Some Copy</p>
-         </div>
-      </div>
-   </div>
-</section>
-
-<section id="features">
-   <div class="container">
-      <div class="row text-center">
-         <div class="col-sm-6">
-            <h2 class="section-heading">Features</h2>
-            <p>Some Copy</p>
-            <img src="img/ribbon.svg" class="svg icon-small blue-ribbon">
-            <img src="img/ribbon.svg" class="svg icon-small red-ribbon">
-            <img src="img/ribbon.svg" class="svg icon-small yellow-ribbon">
-         </div>
-         <div class="col-sm-6">
-            <img src="img/phone.svg" class="svg">
-         </div>
-      </div>
-   </div>
-</section>
-
-<section id="account">
-   <div class="container">
-      <div class="row text-center">
-         <div class="col-sm-6">
-            <h2 class="section-heading">About</h2>
-            <p>Some Copy</p>
-         </div>
-         <div class="col-sm-6">
-            <h2 class="section-heading">About</h2>
-            <p>Some Copy</p>
-         </div>
-      </div>
-   </div>
-</section>
-
-<section id="call">
-   <div class="container">
-      <div class="row">
-         <div class="col-sm-4 col-lg-offset-2 text-center">
-            <h4 class="section-heading">Connect</h4>
-            <hr class="light">
-            <p>(Social Media Icons)</p>
-         </div>
-         <div class="col-sm-4 text-center">
-            <h4 class="section-heading">Get the Latest</h4>
-            <form class="form-inline">
-               <div class="form-group">
-                  <label class="sr-only" for="exampleInputAmount">Email Addresss</label>
-                  <div class="input-group">
-                     <input type="text" class="form-control" id="email-address" placeholder="Email Address">
-                     <div class="input-group-addon">
-                        <button type="submit" class="btn btn-primary">GO</button>
-                     </div>
-                  </div>
-               </div>
-            </form>
-         </div>
-      </div>
-   </div>
-</section>
-
-
-<footer class="bg-dark">
-   <div class="container bg-dark">
-      <div class="row">
-         <div class="col-sm-3 col-sm-offset-2">
-            <h5>About</h5>
-            <p>Documentation</p>
-            <p>History</p>
-            <p>About Us</p>
-         </div>
-         <div class="col-sm-3">
-            <h5>Support</h5>
-            <p>System Status</p>
-            <p>Support Ticket</p>
-            <p>Account Preferences</p>
-         </div>
-         <div class="col-sm-3">
-            <h5>About</h5>
-            <p>Contact</p>
-            <p>Privacy Policy</p>
-            <p>Terms of Use</p>
-         </div>
-      </div>
-   </div>
-</footer>
-   
-<script src="js/lib.min.js"></script>
-<script src="js/main.min.js"></script>
- <!--[if lt IE 9]>
-   <script src="js/html5shiv.min.js"></script>
-   <script src="js/respond.min.js"></script>
- <![endif]-->
-</body>
-</html>