| @ -0,0 +1,11 @@ | |||||
| <div class="row"> | |||||
| <div class="col-md-6"> | |||||
| <center><h1 class="align-content-center">{errorMessage}</h1></center> | |||||
| <br> | |||||
| <img class="mx-auto d-block" src="/404.jpg" alt="Page not found" width="60%" /> | |||||
| <br><br> | |||||
| </div> | |||||
| <div class="col-md-6"> | |||||
| {>login} | |||||
| </div> | |||||
| </div> | |||||
| @ -1,19 +1,24 @@ | |||||
| <div class="row"> | <div class="row"> | ||||
| <div class="col-4"> | <div class="col-4"> | ||||
| <div class="card"> | |||||
| <div class="card-header"> | |||||
| <h3>Profile</h3> | |||||
| </div> | |||||
| <div class="card-body"> | |||||
| <p>Welcome {username}.</p> | |||||
| <br> | |||||
| <form action="/user/logout" method ="post" class="p-2"> | |||||
| <div class="text-center"> | |||||
| <button class="btn btn-lg btn-secondary">LogOut</button> | |||||
| </div> | |||||
| {if loggedIn} | |||||
| <div class="card"> | |||||
| <div class="card-header"> | |||||
| <h3>Profile</h3> | |||||
| </div> | |||||
| <div class="card-body"> | |||||
| <p>Welcome {username}.</p> | |||||
| <br> | <br> | ||||
| </form> | |||||
| <form action="/user/logout" method ="post" class="p-2"> | |||||
| <div class="text-center"> | |||||
| <button class="btn btn-lg btn-secondary">LogOut</button> | |||||
| </div> | |||||
| <br> | |||||
| </form> | |||||
| </div> | |||||
| </div> | </div> | ||||
| </div> | |||||
| {else} | |||||
| {>login} | |||||
| {/if} | |||||
| </div> | </div> | ||||
| </div> | </div> | ||||
| @ -1,12 +1,7 @@ | |||||
| {>header} | {>header} | ||||
| <div class="container"> | <div class="container"> | ||||
| {if loggedIn} | |||||
| {>main} | |||||
| {else} | |||||
| {>login} | |||||
| {/if} | |||||
| {>main} | |||||
| </div> | </div> | ||||
| {>footer} | {>footer} | ||||
| @ -0,0 +1,28 @@ | |||||
| { | |||||
| "name": "HomeBrewPlex", | |||||
| "version": "0.1.0", | |||||
| "description": "Light weight alternative for Plex", | |||||
| "main": "server.js", | |||||
| "scripts": { | |||||
| "test": "echo \"Error: no test specified\" && exit 1", | |||||
| "start": "node server.js" | |||||
| }, | |||||
| "repository": { | |||||
| "type": "git", | |||||
| "url": "git+https://github.com/jrtechs/HomeBrewPlex.git" | |||||
| }, | |||||
| "author": "Jeffery Russell", | |||||
| "license": "MPL 2.0", | |||||
| "bugs": { | |||||
| "url": "https://github.com/jrtechs/HomeBrewPlex/issues" | |||||
| }, | |||||
| "homepage": "https://github.com/jrtechs/HomeBrewPlex#readme", | |||||
| "dependencies": { | |||||
| "download-file": "^0.1.5", | |||||
| "express-session": "^1.15.6", | |||||
| "fs": "0.0.2", | |||||
| "path": "^0.12.7", | |||||
| "url": "^0.11.0", | |||||
| "whiskers": "^0.4.0" | |||||
| } | |||||
| } | |||||
| @ -0,0 +1,125 @@ | |||||
| const configManager = require('./configManager'); | |||||
| const recursive = require('./recursiveTraversal'); | |||||
| const filepreview = require('filepreview'); | |||||
| const fs = require('fs'); | |||||
| var privateVideos = null; | |||||
| var publicVideos = null; | |||||
| module.exports = | |||||
| { | |||||
| indexVideos: function(rootDir, videos, templateKey) | |||||
| { | |||||
| return new Promise(function(resolve, reject) | |||||
| { | |||||
| recursive(rootDir, function (err, files) | |||||
| { | |||||
| files.forEach(file => | |||||
| { | |||||
| var splitArray = file.split('/'); | |||||
| var name = splitArray[splitArray.length -1]; | |||||
| const icon = './icon/' + templateKey + '/' + name + ".png"; | |||||
| if (!fs.existsSync(icon)) | |||||
| { | |||||
| var options = { | |||||
| width: 200, | |||||
| quality: 50, | |||||
| previewTime: '00:05:00.000' | |||||
| }; | |||||
| filepreview.generate(file, icon, options,function(error) { | |||||
| if (error) { | |||||
| return console.log(error); | |||||
| } | |||||
| console.log('File preview is located ' + icon); | |||||
| }); | |||||
| } | |||||
| videos.push({name: file.replace(rootDir, '')}); | |||||
| }); | |||||
| resolve(); | |||||
| }); | |||||
| }).catch(function(error) | |||||
| { | |||||
| //console.log(error); | |||||
| }) | |||||
| }, | |||||
| getVideosForTemplate: function(templateContext, templateKey) | |||||
| { | |||||
| return new Promise(function(resolve, reject) | |||||
| { | |||||
| var videos, rootDir; | |||||
| if(templateKey === "public") | |||||
| { | |||||
| videos = publicVideos; | |||||
| rootDir = configManager.getPublicDirectory(); | |||||
| } | |||||
| else | |||||
| { | |||||
| videos = privateVideos; | |||||
| rootDir = configManager.getRootDirectory(); | |||||
| } | |||||
| if(videos === null) | |||||
| { | |||||
| videos = []; | |||||
| module.exports.indexVideos(rootDir, videos, templateKey) | |||||
| .then(function() | |||||
| { | |||||
| templateContext[templateKey] = videos; | |||||
| if(templateKey === "public") | |||||
| publicVideos = videos; | |||||
| else | |||||
| privateVideos = videos; | |||||
| resolve(); | |||||
| }) | |||||
| } | |||||
| else | |||||
| { | |||||
| templateContext[templateKey] = videos; | |||||
| resolve(); | |||||
| } | |||||
| }) | |||||
| }, | |||||
| isPublicVideo: function(videoName) | |||||
| { | |||||
| if(publicVideos == null) | |||||
| { | |||||
| publicVideos = []; | |||||
| rootDir = configManager.getPublicDirectory(); | |||||
| module.exports.indexVideos(rootDir, publicVideos, "public").then(function() | |||||
| { | |||||
| for(var i = 0; i < publicVideos.length; i++) | |||||
| { | |||||
| const splitArray = publicVideos[i].name.split('/'); | |||||
| const name = splitArray[splitArray.length -1]; | |||||
| if(name === videoName) | |||||
| { | |||||
| return true; | |||||
| } | |||||
| } | |||||
| return false; | |||||
| }); | |||||
| } | |||||
| else | |||||
| { | |||||
| for(var i = 0; i < publicVideos.length; i++) | |||||
| { | |||||
| const splitArray = publicVideos[i].name.split('/'); | |||||
| const name = splitArray[splitArray.length -1]; | |||||
| if(name === videoName) | |||||
| { | |||||
| return true; | |||||
| } | |||||
| } | |||||
| return false; | |||||
| } | |||||
| } | |||||
| }; | |||||