Skip to content

Commit

Permalink
Login and dashboard routes/views
Browse files Browse the repository at this point in the history
  • Loading branch information
Brad Traversy authored and Brad Traversy committed Jun 19, 2020
1 parent 5731cd1 commit 707962c
Show file tree
Hide file tree
Showing 9 changed files with 151 additions and 0 deletions.
24 changes: 24 additions & 0 deletions app.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
const path = require('path')
const express = require('express')
const dotenv = require('dotenv')
const morgan = require('morgan')
const exphbs = require('express-handlebars')
const connectDB = require('./config/db')

// Load config
Expand All @@ -9,6 +12,27 @@ connectDB()

const app = express()

// Logging
if (process.env.NODE_ENV === 'development') {
app.use(morgan('dev'))
}

// Handlebars
app.engine(
'.hbs',
exphbs({
defaultLayout: 'main',
extname: '.hbs',
})
)
app.set('view engine', '.hbs')

// Static folder
app.use(express.static(path.join(__dirname, 'public')))

// Routes
app.use('/', require('./routes/index'))

const PORT = process.env.PORT || 3000

app.listen(
Expand Down
22 changes: 22 additions & 0 deletions public/css/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
p {
margin: 10px 0 !important;
}

.login-container {
width: 400px;
margin-top: 50px;
text-align: center;
}

.fa-small {
font-size: 16px !important;
}

.btn-float {
float: left;
margin-right: 10px;
}

.img-small {
width: 180px;
}
18 changes: 18 additions & 0 deletions routes/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
const express = require('express')
const router = express.Router()

// @desc Login/Landing page
// @route GET /
router.get('/', (req, res) => {
res.render('login', {
layout: 'login',
})
})

// @desc Dashboard
// @route GET /dashboard
router.get('/dashboard', (req, res) => {
res.render('dashboard')
})

module.exports = router
1 change: 1 addition & 0 deletions views/dashboard.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<h1>Dashboard</h1>
26 changes: 26 additions & 0 deletions views/layouts/login.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/css/materialize.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.12.0-2/css/all.min.css"
integrity="sha256-46r060N2LrChLLb5zowXQ72/iKKNiw/lAmygmHExk/o=" crossorigin="anonymous" />
<link rel="stylesheet" href="/css/style.css">
<title>StoryBooks Login</title>
</head>

<body>
<div class="container login-container">
<div class="card">
<div class="card-content">
{{{body}}}
</div>
</div>
</div>

<script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js"></script>
</body>

</html>
35 changes: 35 additions & 0 deletions views/layouts/main.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/css/materialize.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.12.0-2/css/all.min.css"
integrity="sha256-46r060N2LrChLLb5zowXQ72/iKKNiw/lAmygmHExk/o=" crossorigin="anonymous" />
<link rel="stylesheet" href="/css/style.css">
<title>StoryBooks</title>
</head>

<body>
{{> _header}}
{{> _add_btn}}
<div class="container">
{{{body}}}
</div>

<script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/ckeditor/4.14.1/ckeditor.js"
integrity="sha256-bEIQpI72w9NJuIVhTLFUF2/8uxl0u5800r8ddViuv+o=" crossorigin="anonymous"></script>

<script>
M.Sidenav.init(document.querySelector('.sidenav'))
M.FormSelect.init(document.querySelector('#status'))
CKEDITOR.replace('body', {
plugins: 'wysiwygarea, toolbar, basicstyles, link'
})
</script>
</body>

</html>
10 changes: 10 additions & 0 deletions views/login.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<h3><i class="fas fa-book-reader"></i> StoryBooks</h3>
<div class="section">
<p class="lead">Create public and private stories from your life</p>
</div>
<div class="divider"></div>
<div class="section">
<a href="/auth/google" class="btn red darken-1">
<i class="fab fa-google left"></i> Log In With Google
</a>
</div>
3 changes: 3 additions & 0 deletions views/partials/_add_btn.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<div class="fixed-action-btn">
<a href="/stories/add" class="btn-floating btn-large waves-effect waves-light red"><i class="fas fa-plus"></i></a>
</div>
12 changes: 12 additions & 0 deletions views/partials/_header.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<nav class="grey darken-3">
<div class="nav-wrapper container">

<a href="#!" class="brand-logo center">StoryBooks</a>
<a href="#" data-target="mobile-demo" class="sidenav-trigger show-on-large"><i class="fas fa-bars"></i></a>
<ul class="sidenav" id="mobile-demo">
<li><a href="/stories">Public Stories</a></li>
<li><a href="/dashboard">Dashboard</a></li>
<li><a href="/auth/logout">Logout</a></li>
</ul>
</div>
</nav>

0 comments on commit 707962c

Please sign in to comment.