Skip to content

Commit

Permalink
r56 will soon require Webpack|Brunch or other build tools
Browse files Browse the repository at this point in the history
- progressing on client side development, it becomes opinionated on the point to decide whether to continue with pug as main template and employ a build tool to render html files on load to integrate AngularJS better and SCSS to css.
- or revert the layout and other core views files to html with ejs
- The back-end code is pending migration to Angular2-Universal or Angular2-MeteorJS for better, agile, isomorphic, universal dev, ES6 import instead of require('module')..
- If MongoDB is used in the dev and prod,MEANJS stack or  Angular2-MeteorJS framework can be used right away without having to go through hoops of engineering this NodeMySQL app
- But as relational databases still prevail, NodeJS and MeteorJS dev requires some efforts wiring Sequelize and back-end RESTful coding to engineer the app
  • Loading branch information
zenithtekla committed Sep 30, 2016
1 parent 518b28f commit d14da99
Show file tree
Hide file tree
Showing 20 changed files with 314 additions and 68 deletions.
2 changes: 1 addition & 1 deletion _vault/design_aspects/ecms.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ var Schema1 = new Schema({
}
});

mongoose.model('User', Schema1);
mongoose.model('ECMS', Schema1);

/*
An equipment has a model.
Expand Down
4 changes: 3 additions & 1 deletion config/config.server.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ module.exports = function(app){

// override with the X-HTTP-Method-Override header in the request. simulate DELETE/PUT
app.use(methodOverride('X-HTTP-Method-Override'));
app.use(methodOverride('_method'));

if (app.get('env') === 'development') require('./env/development')(app);

Expand All @@ -66,7 +67,8 @@ module.exports = function(app){
// set the static files location /public/img will be /img for users
app.use(express.static(path.resolve('public'))); // app.use(express.static('uploads')); http://expressjs.com/en/starter/static-files.html
// app.use(express.static(path.resolve('modules/client/core')));

app.use(express.static(path.resolve('modules/core/client/views')));
app.use(express.static(path.resolve('modules/angular1/client/views')));

// render views
require('./config.view')(app);
Expand Down
57 changes: 57 additions & 0 deletions modules/angular1/client/views/angular1-ui.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>UI-Router</title>
<link href="/lib/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet">
<!--<link href="//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/2.3.1/css/bootstrap.min.css" rel="stylesheet">-->
</head>
<body>
<div ng-app="manukeApp">
<!--<div ng-controller="coreCtrl">-->
<body class="container">
<p><i>Best viewed in pop-out mode to see location changes. Click blue button on the right.</i></p>

<nav class="navbar navbar-dark" style="background-color:#44c764">
<button class="navbar-toggler hidden-sm-up" type="button" data-toggle="collapse" data-target="#responsiveCollapse">
</button>
<div class="collapse navbar-toggleable-xs" id="responsiveCollapse">
<a class="navbar-brand" href="#">angular1-ui-router /angular1-ui.html </a>
<ul class="nav navbar-nav">
<li class="nav-item active"><a class="nav-link" ui-sref="state1">State 1</a></li>
<li class="nav-item active"><a class="nav-link" ui-sref="state2">State 2</a></li>
</ul>
</div>
</nav>

<div class="row">
<div class="span12">
<div class="well" ui-view></div>
</div>
</div>
<!--</div>-->
</div>
<div class="script">
<script src="/lib/jquery/dist/jquery.min.js"></script>
<script src="/lib/angular/angular.min.js"></script>
<script src="/lib/moment/min/moment.min.js"></script>
<script src="/lib/tether/dist/js/tether.min.js"></script>
<script src="/lib/bootstrap/dist/js/bootstrap.min.js"></script>
<script src="/lib/angular-animate/angular-animate.min.js"></script>
<script src="/lib/angular-cookies/angular-cookies.min.js"></script>
<script src="/lib/angular-resource/angular-resource.min.js"></script>
<script src="/lib/angular-ui-router/release/angular-ui-router.min.js"></script>
<script src="/lib/angular-route/angular-route.min.js"></script>
<script src="/lib/angular-sanitize/angular-sanitize.min.js"></script>
<script src="/lib/angular-touch/angular-touch.min.js"></script>
<script src="/lib/lodash/dist/lodash.min.js"></script>
<script src="/lib/angular-bootstrap/ui-bootstrap-tpls.js"></script>
<!-- endbower-->
<!-- endbuild-->
<!-- build:js({.tmp,app}) js/app.js-->
<script src="/app/angular1.ui_router.js"></script>
<!--<script src="/app/core.client.controllers.js"></script>-->
</div>
</body>
</html>
3 changes: 3 additions & 0 deletions modules/angular1/client/views/includes/state1.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<h1>State 1</h1>
<hr>
<div ui-view></div>
3 changes: 3 additions & 0 deletions modules/angular1/client/views/includes/state1.list.pug
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
h3 List of State 1 Items
ul
li(ng-repeat='item in items') {{item}}
4 changes: 4 additions & 0 deletions modules/angular1/client/views/includes/state1.pug
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
h1 State 1
hr
a(ui-sref='state1.list') Show List
div(ui-view)
3 changes: 3 additions & 0 deletions modules/angular1/client/views/includes/state2.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<h1>State 2</h1>
<hr>
<div ui-view></div>
3 changes: 3 additions & 0 deletions modules/angular1/client/views/includes/state2.list.pug
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
h3 List of State 2 Items
ul
li(ng-repeat='item in items') {{item}}
4 changes: 4 additions & 0 deletions modules/angular1/client/views/includes/state2.pug
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
h1 State 2
hr
a(ui-sref='state2.list') Show List
div(ui-view)
10 changes: 9 additions & 1 deletion modules/calibrates/client/views/calibrate.pug
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ block content
table.table.table-striped
thead.thead-inverse
tr
th Actions
th Asset Number
th Model
th Location
Expand All @@ -19,6 +20,13 @@ block content
tbody
each calibrate in calibrates
tr
td
form(action='/calibrates/asset_number/' + calibrate.asset_number+'?_method=',method='post',enctype='application/x-www-form-urlencoded')
// temporarily obstrusive method
button(type='submit', onclick='this.form.action=this.form.action+"DELETE";').
Delete
button(type='submit', onclick='this.form.action=this.form.action+"GET";').
View
td= calibrate.asset_number
td= calibrate.model
td= calibrate.ECMS_Location.desc
Expand All @@ -27,4 +35,4 @@ block content
- if (calibrate.ECMS_Attributes[0].file) {
td= calibrate.ECMS_Attributes[0].file
- }
- }
- }
22 changes: 22 additions & 0 deletions modules/calibrates/client/views/list.pug
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
div
h3='Listing from ECMS main table'
- if (mains.length) {
table.table
tr
th id
th asset_number
th file
th last_cal
th next_cal
th schedule
each main in mains
tr
td= main.id
td= main.asset_number
td= main.file
td #{main.last_cal.toDateString()}
- if (main.next_cal) {
td #{main.next_cal.toDateString()}
- }
td= main.schedule
- }
22 changes: 1 addition & 21 deletions modules/calibrates/client/views/main.pug
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,4 @@ block page
- var menu = 'calibrates'
block content
div
h3='Listing from ECMS main table'
- if (mains.length) {
table.table
tr
th id
th asset_number
th file
th last_cal
th next_cal
th schedule
each main in mains
tr
td= main.id
td= main.asset_number
td= main.file
td #{main.last_cal.toDateString()}
- if (main.next_cal) {
td #{main.next_cal.toDateString()}
- }
td= main.schedule
- }
#content
18 changes: 18 additions & 0 deletions modules/core/client/views/includes/ui-menu.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<div class="menu">
<ul class="nav nav-pills">
<li class="nav-item"><a ui-sref-active='active' ui‐sref="/" class="nav-link">Home</a></li>
<li class="nav-item"><a ui-sref-active='active' ui‐sref="/article" class="nav-link">Article</a></li>
<li class="nav-item"><a ui-sref-active='active' ui‐sref="/chat" class="nav-link">Chat</a></li>
<li class="nav-item"><a ui-sref-active='active' ui‐sref="/xt_syncs/assembly" class="nav-link">XT_Syncs</a></li>
<li class="nav-item dropdown"><a ui-sref-active='active' ui‐sref="#" data-toggle="dropdown" role="button" class="nav-link dropdown-toggle">Calibrates</a>
<div class="dropdown-menu"><a ui-sref-active='active' ui‐sref="/calibrates/equipment" class="dropdown-item">List</a><a ui‐sref="#" class="dropdown-item">Create</a>
<div class="dropdown-divider"></div><a ui‐sref="/calibrates/table_main" class="dropdown-item">View Main table</a><a ui‐sref="/calibrates/table_equipment" class="dropdown-item">View Equipment table</a><a ui‐sref="/calibrates/table_location" class="dropdown-item">View Location table</a>
</div>
</li>
<li class="nav-item"><a ui-sref-active='active' ui‐sref="/query_approvals/pending_queries" class="nav-link">Pending_Queries</a></li>
<li class="nav-item"><a ui-sref-active='active' ui‐sref="/todos/tasks" class="nav-link">Tasks</a></li>
<li class="nav-item"><a ui-sref-active='active' ui‐sref="/services/api/work_order/191915a" class="nav-link">Services</a></li>
<li class="nav-item"><a ui-sref-active='active' ui‐sref="/login" class="nav-link">Log in</a></li>
<li class="nav-item"><a ui-sref-active='active' ui‐sref="/auth/twitter" class="nav-link">Sign in with Twitter</a></li>
</ul>
</div>
10 changes: 9 additions & 1 deletion modules/core/client/views/index.pug
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,12 @@ extends layout
block page
- var menu = 'index'
block content
p #{greet}!
p #{greet}!
div(ng-app='manukeApp')
div(ng-controller='coreCtrl')
div(ng-include="'includes/ui-menu.html'")
#content(ui-view)
a(ui-sref="state1") State 1
a(ui-sref="state2") State 2
- x = {"name": "john", "age": "5" }
input(type="text", name=x.name, value=x.age)
81 changes: 43 additions & 38 deletions modules/core/client/views/layout.pug
Original file line number Diff line number Diff line change
Expand Up @@ -6,42 +6,47 @@ html(lang='en')
link(rel='stylesheet', type='text/css', href='/css/core.css')
link(rel='stylesheet', href='/lib/bootstrap/dist/css/bootstrap.min.css')
body
#wrap
.container
h1 Manuke application
h2 #{title} application
span Environment: #{env}
block header
div.container-fluid
block page
block nav
div
include includes/menu
.content
br
block content
br
br
span.alert-success Tervetuloa, Välkommen, Velkommen, Bienvenue, Welcome, Willkommen !
block footer
footer
.container.floatright.right.italic-small.nopad.gray.inline-block
p
| Made from Helsinki with love Copyright &copy; ZeTekLA 2016 | Issues? Submit to &nbsp;
a(href="https://github.com/zenithtekla/NodeMySQL") GitHub
| .
.container#wrap
h1 Manuke application
h2 #{title} application
span Environment: #{env}
block header
block page
block nav
div
include includes/menu
.content
br
block content
br
br
span.alert-success Tervetuloa, Välkommen, Velkommen, Bienvenue, Welcome, Willkommen !
block footer
footer
.container.floatright.right.italic-small.nopad.gray.inline-block
p
| Made from Helsinki with love Copyright &copy; ZeTekLA 2016 | Issues? Submit to &nbsp;
a(href="https://github.com/zenithtekla/NodeMySQL") GitHub
| .
// build:js(.) scripts/vendor.js
// bower:js
script(src='/lib/jquery/dist/jquery.min.js')
script(src='/lib/angular/angular.min.js')
script(src='/lib/moment/min/moment.min.js')
script(src='/lib/tether/dist/js/tether.min.js')
script(src='/lib/bootstrap/dist/js/bootstrap.min.js')
script(src='/lib/angular-animate/angular-animate.min.js')
script(src='/lib/angular-cookies/angular-cookies.min.js')
script(src='/lib/angular-resource/angular-resource.min.js')
script(src='/lib/angular-ui-router/release/angular-ui-router.min.js')
script(src='/lib/angular-route/angular-route.min.js')
script(src='/lib/angular-sanitize/angular-sanitize.min.js')
script(src='/lib/angular-touch/angular-touch.min.js')
script(src='/lib/lodash/dist/lodash.min.js')
script(src='/lib/angular-bootstrap/ui-bootstrap-tpls.js')
.script
script(src='/lib/jquery/dist/jquery.min.js')
script(src='/lib/angular/angular.min.js')
script(src='/lib/moment/min/moment.min.js')
script(src='/lib/tether/dist/js/tether.min.js')
script(src='/lib/bootstrap/dist/js/bootstrap.min.js')
script(src='/lib/angular-animate/angular-animate.min.js')
script(src='/lib/angular-cookies/angular-cookies.min.js')
script(src='/lib/angular-resource/angular-resource.min.js')
script(src='/lib/angular-ui-router/release/angular-ui-router.min.js')
script(src='/lib/angular-route/angular-route.min.js')
script(src='/lib/angular-sanitize/angular-sanitize.min.js')
script(src='/lib/angular-touch/angular-touch.min.js')
script(src='/lib/lodash/dist/lodash.min.js')
script(src='/lib/angular-bootstrap/ui-bootstrap-tpls.js')
// endbower
// endbuild
// build:js({.tmp,app}) js/app.js
script(src='/app/core.client.config.js')
script(src='/app/core.client.controllers.js')
6 changes: 3 additions & 3 deletions modules/core/server/controllers/core.server.controllers.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
var models = require( process.cwd() + '/modules/core/server/models'),
env = process.env.NODE_ENV || "development";

exports.home = function (req,res) {
exports.layout = function (req,res) {
res.render('layout', {title: "CoreHomeApp", env: env});
};
exports.greet = function (req,res) {
res.render('index', {greet: "This is a greet text", title: "CoreIndexApp", env: env});
exports.home = function (req,res) {
res.render('index', {greet: "This is a greet text @ index page", title: "CoreIndexApp", env: env});
};

exports.article = function (req,res) {
Expand Down
4 changes: 2 additions & 2 deletions modules/core/server/routes/core.server.routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
var controller = require('../controllers/core.server.controllers');

module.exports = function(app){
app.get('/home', controller.home)
app.get('/layout', controller.layout)
.get('/', controller.home)
.get('/greet', controller.greet)
.get('/home', controller.home)
.get('/chat', controller.chat)
.get('/article', controller.article);

Expand Down
31 changes: 31 additions & 0 deletions public/app/angular1.ui_router.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
var myapp = angular.module('manukeApp', ["ui.router"])
myapp.config(function($stateProvider, $urlRouterProvider){

// For any unmatched url, send to /state1
$urlRouterProvider.otherwise("/state1")

$stateProvider
.state('state1', {
url: "/state1",
templateUrl: "includes/state1.html"
})
.state('state1.list', {
url: "/list",
templateUrl: "includes/state1.list.html",
controller: function($scope){
$scope.items = ["A", "List", "Of", "Items"];
}
})

.state('state2', {
url: "/state2",
templateUrl: "includes/state2.html"
})
.state('state2.list', {
url: "/list",
templateUrl: "includes/state2.list.html",
controller: function($scope){
$scope.things = ["A", "Set", "Of", "Things"];
}
})
})

2 comments on commit d14da99

@zenithtekla
Copy link
Owner Author

@zenithtekla zenithtekla commented on d14da99 Sep 30, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

latest changes in pug pugjs/pug#2305

@zenithtekla
Copy link
Owner Author

@zenithtekla zenithtekla commented on d14da99 Sep 30, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

http://anoopmd.github.io/brunch-example-compile-sass/

If you want to use git version of plugin, add to your package.json "javascript-brunch": "git+ssh://git@github.com:brunch/javascript-brunch.git"

This article explains some fundamentals of BrunchJS
http://www.js-attitude.fr/2015/03/04/brunch-mon-builder-prefere/

brunch/brunch#878 (comment)

Please sign in to comment.