Initial commit
This commit is contained in:
commit
2567f54602
13 changed files with 5373 additions and 0 deletions
110
.gitignore
vendored
Normal file
110
.gitignore
vendored
Normal file
|
@ -0,0 +1,110 @@
|
|||
# Logs
|
||||
logs
|
||||
*.log
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
lerna-debug.log*
|
||||
|
||||
# Diagnostic reports (https://nodejs.org/api/report.html)
|
||||
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
|
||||
|
||||
# Runtime data
|
||||
pids
|
||||
*.pid
|
||||
*.seed
|
||||
*.pid.lock
|
||||
|
||||
# Directory for instrumented libs generated by jscoverage/JSCover
|
||||
lib-cov
|
||||
|
||||
# Coverage directory used by tools like istanbul
|
||||
coverage
|
||||
*.lcov
|
||||
|
||||
# nyc test coverage
|
||||
.nyc_output
|
||||
|
||||
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
|
||||
.grunt
|
||||
|
||||
# Bower dependency directory (https://bower.io/)
|
||||
bower_components
|
||||
|
||||
# node-waf configuration
|
||||
.lock-wscript
|
||||
|
||||
# Compiled binary addons (https://nodejs.org/api/addons.html)
|
||||
build/Release
|
||||
|
||||
# Dependency directories
|
||||
node_modules/
|
||||
jspm_packages/
|
||||
|
||||
# TypeScript v1 declaration files
|
||||
typings/
|
||||
|
||||
# TypeScript cache
|
||||
*.tsbuildinfo
|
||||
|
||||
# Optional npm cache directory
|
||||
.npm
|
||||
|
||||
# Optional eslint cache
|
||||
.eslintcache
|
||||
|
||||
# Microbundle cache
|
||||
.rpt2_cache/
|
||||
.rts2_cache_cjs/
|
||||
.rts2_cache_es/
|
||||
.rts2_cache_umd/
|
||||
|
||||
# Optional REPL history
|
||||
.node_repl_history
|
||||
|
||||
# Output of 'npm pack'
|
||||
*.tgz
|
||||
|
||||
# Yarn Integrity file
|
||||
.yarn-integrity
|
||||
|
||||
# dotenv environment variables file
|
||||
.env
|
||||
.env.test
|
||||
|
||||
# parcel-bundler cache (https://parceljs.org/)
|
||||
.cache
|
||||
|
||||
# Next.js build output
|
||||
.next
|
||||
|
||||
# Nuxt.js build / generate output
|
||||
.nuxt
|
||||
dist
|
||||
|
||||
# Gatsby files
|
||||
.cache/
|
||||
# Comment in the public line in if your project uses Gatsby and *not* Next.js
|
||||
# https://nextjs.org/blog/next-9-1#public-directory-support
|
||||
# public
|
||||
|
||||
# vuepress build output
|
||||
.vuepress/dist
|
||||
|
||||
# Serverless directories
|
||||
.serverless/
|
||||
|
||||
# FuseBox cache
|
||||
.fusebox/
|
||||
|
||||
# DynamoDB Local files
|
||||
.dynamodb/
|
||||
|
||||
# TernJS port file
|
||||
.tern-port
|
||||
|
||||
# Jetbrain stuff
|
||||
.idea
|
||||
|
||||
# Compiled SCSS
|
||||
public/stylesheets/*.css*
|
21
LICENSE
Normal file
21
LICENSE
Normal file
|
@ -0,0 +1,21 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) 2021 Florian Charlaix
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
1
README.md
Normal file
1
README.md
Normal file
|
@ -0,0 +1 @@
|
|||
# OpenDeck
|
49
app.js
Normal file
49
app.js
Normal file
|
@ -0,0 +1,49 @@
|
|||
const createError = require("http-errors");
|
||||
const express = require("express");
|
||||
const path = require("path");
|
||||
const cookieParser = require("cookie-parser");
|
||||
const logger = require("morgan");
|
||||
const sassMiddleware = require("node-sass-middleware");
|
||||
const jsMiddleware = require("./middleware/jsMiddleware")
|
||||
|
||||
const indexRouter = require("./routes/index");
|
||||
|
||||
const app = express();
|
||||
|
||||
// view engine setup
|
||||
app.set("views", path.join(__dirname, "views"));
|
||||
app.set("view engine", "pug");
|
||||
|
||||
app.use(logger("dev"));
|
||||
app.use(express.json());
|
||||
app.use(express.urlencoded({ extended: false }));
|
||||
app.use(cookieParser());
|
||||
app.use(sassMiddleware({
|
||||
src: path.join(__dirname, "public"),
|
||||
dest: path.join(__dirname, "public"),
|
||||
includePaths: [path.join(__dirname), "node_modules"],
|
||||
indentedSyntax: true, // true = .sass and false = .scss
|
||||
sourceMap: true
|
||||
}));
|
||||
app.use(jsMiddleware("/javascripts/materialize.js", "materialize-css/dist/js/materialize"))
|
||||
app.use(express.static(path.join(__dirname, "public")));
|
||||
|
||||
app.use("/", indexRouter);
|
||||
|
||||
// catch 404 and forward to error handler
|
||||
app.use(function(req, res, next) {
|
||||
next(createError(404));
|
||||
});
|
||||
|
||||
// error handler
|
||||
app.use(function(err, req, res, next) {
|
||||
// set locals, only providing error in development
|
||||
res.locals.message = err.message;
|
||||
res.locals.error = req.app.get("env") === "development" ? err : {};
|
||||
|
||||
// render the error page
|
||||
res.status(err.status || 500);
|
||||
res.render("error");
|
||||
});
|
||||
|
||||
module.exports = app;
|
90
bin/www
Executable file
90
bin/www
Executable file
|
@ -0,0 +1,90 @@
|
|||
#!/usr/bin/env node
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
|
||||
const app = require("../app");
|
||||
const debug = require("debug")("opendeck:server");
|
||||
const http = require("http");
|
||||
|
||||
/**
|
||||
* Get port from environment and store in Express.
|
||||
*/
|
||||
|
||||
const port = normalizePort(process.env.PORT || "3000");
|
||||
app.set("port", port);
|
||||
|
||||
/**
|
||||
* Create HTTP server.
|
||||
*/
|
||||
|
||||
const server = http.createServer(app);
|
||||
|
||||
/**
|
||||
* Listen on provided port, on all network interfaces.
|
||||
*/
|
||||
|
||||
server.listen(port);
|
||||
server.on("error", onError);
|
||||
server.on("listening", onListening);
|
||||
|
||||
/**
|
||||
* Normalize a port into a number, string, or false.
|
||||
*/
|
||||
|
||||
function normalizePort(val) {
|
||||
const port = parseInt(val, 10);
|
||||
|
||||
if (isNaN(port)) {
|
||||
// named pipe
|
||||
return val;
|
||||
}
|
||||
|
||||
if (port >= 0) {
|
||||
// port number
|
||||
return port;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Event listener for HTTP server "error" event.
|
||||
*/
|
||||
|
||||
function onError(error) {
|
||||
if (error.syscall !== "listen") {
|
||||
throw error;
|
||||
}
|
||||
|
||||
const bind = typeof port === "string"
|
||||
? "Pipe " + port
|
||||
: "Port " + port;
|
||||
|
||||
// handle specific listen errors with friendly messages
|
||||
switch (error.code) {
|
||||
case "EACCES":
|
||||
console.error(bind + " requires elevated privileges");
|
||||
process.exit(1);
|
||||
break;
|
||||
case "EADDRINUSE":
|
||||
console.error(bind + " is already in use");
|
||||
process.exit(1);
|
||||
break;
|
||||
default:
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Event listener for HTTP server "listening" event.
|
||||
*/
|
||||
|
||||
function onListening() {
|
||||
const addr = server.address();
|
||||
const bind = typeof addr === "string"
|
||||
? "pipe " + addr
|
||||
: "port " + addr.port;
|
||||
debug("Listening on " + bind);
|
||||
}
|
11
middleware/jsMiddleware.js
Normal file
11
middleware/jsMiddleware.js
Normal file
|
@ -0,0 +1,11 @@
|
|||
const fs = require("fs")
|
||||
|
||||
module.exports = (src, path) => {
|
||||
return (req, res, next) => {
|
||||
if (req.url === src) {
|
||||
res.type(".js")
|
||||
res.send(fs.readFileSync("./node_modules/"+path+".js", "utf8"))
|
||||
} else
|
||||
next();
|
||||
}
|
||||
}
|
5038
package-lock.json
generated
Normal file
5038
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load diff
18
package.json
Normal file
18
package.json
Normal file
|
@ -0,0 +1,18 @@
|
|||
{
|
||||
"name": "opendeck",
|
||||
"version": "0.0.0",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"start": "node ./bin/www"
|
||||
},
|
||||
"dependencies": {
|
||||
"cookie-parser": "~1.4.4",
|
||||
"debug": "~2.6.9",
|
||||
"express": "~4.16.1",
|
||||
"http-errors": "~1.6.3",
|
||||
"materialize-css": "^1.0.0-rc.2",
|
||||
"morgan": "~1.9.1",
|
||||
"node-sass-middleware": "0.11.0",
|
||||
"pug": "2.0.0-beta11"
|
||||
}
|
||||
}
|
7
public/stylesheets/style.sass
Normal file
7
public/stylesheets/style.sass
Normal file
|
@ -0,0 +1,7 @@
|
|||
//noinspection CssUnknownTarget
|
||||
@import "materialize-css/sass/materialize.scss"
|
||||
|
||||
#deck>.row>.col
|
||||
border: black 3px solid
|
||||
margin: 0.3em
|
||||
text-align: center
|
9
routes/index.js
Normal file
9
routes/index.js
Normal file
|
@ -0,0 +1,9 @@
|
|||
const express = require("express");
|
||||
const router = express.Router();
|
||||
|
||||
/* GET home page. */
|
||||
router.get("/", function(req, res, next) {
|
||||
res.render("index", { title: ""});
|
||||
});
|
||||
|
||||
module.exports = router;
|
6
views/error.pug
Normal file
6
views/error.pug
Normal file
|
@ -0,0 +1,6 @@
|
|||
extends layout
|
||||
|
||||
block content
|
||||
h1= message
|
||||
h2= error.status
|
||||
pre #{error.stack}
|
5
views/index.pug
Normal file
5
views/index.pug
Normal file
|
@ -0,0 +1,5 @@
|
|||
extends layout
|
||||
|
||||
block content
|
||||
.container#deck
|
||||
h1.center OpenDeck
|
8
views/layout.pug
Normal file
8
views/layout.pug
Normal file
|
@ -0,0 +1,8 @@
|
|||
doctype html
|
||||
html
|
||||
head
|
||||
title= "OpenDeck" + (title ? " - " + title: "")
|
||||
link(rel="stylesheet", href="/stylesheets/style.css")
|
||||
body
|
||||
block content
|
||||
script(src="/javascripts/materialize.js")
|
Loading…
Reference in a new issue