reorganized folder structure to make the root a little cleaner. will continue restructuring of source and assets.
parent
55c77ebefe
commit
49e6cd8dfd
@ -1,4 +1,5 @@
|
|||||||
node_modules/
|
node_modules/
|
||||||
.idea/
|
.idea/
|
||||||
util/
|
util/
|
||||||
out/
|
out/
|
||||||
|
build/
|
||||||
|
Before Width: | Height: | Size: 101 KiB After Width: | Height: | Size: 101 KiB |
@ -1,6 +1,8 @@
|
|||||||
{
|
{
|
||||||
"default-links": [
|
"default-links": [
|
||||||
"https://gmail.com",
|
"https://gmail.com",
|
||||||
|
"https://drive.google.com",
|
||||||
|
"https://calendar.google.com",
|
||||||
"https://archive.carolina.engineering",
|
"https://archive.carolina.engineering",
|
||||||
"https://www.paycor.com/"
|
"https://www.paycor.com/"
|
||||||
]
|
]
|
||||||
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
@ -1,8 +1,8 @@
|
|||||||
<html lang="en">
|
<html lang="en">
|
||||||
<div id="{{{id}}}" class="media d-inline-flex mx-2 file-card">
|
<li id="{{{id}}}" class="media d-flex mx-2 file-card">
|
||||||
<img class="align-self-center mr-3 py-2 thumbnail64" src="{{{imagePath}}}" alt="File icon">
|
<img class="align-self-center mr-3 py-2 thumbnail64" src="{{{imagePath}}}" alt="File icon">
|
||||||
<div class="media-body align-self-center">
|
<div class="media-body align-self-center">
|
||||||
<p class="pr-3 mb-0">{{fileName}}</p>
|
<p class="pr-3 mb-0">{{fileName}}</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</li>
|
||||||
</html>
|
</html>
|
||||||
@ -1,10 +1,9 @@
|
|||||||
<html lang="en">
|
<html lang="en">
|
||||||
<div id="{{{id}}}" class="media d-inline-flex mx-2 file-card">
|
<li id="{{{id}}}" class="media d-lex mx-2 file-card">
|
||||||
<img class="align-self-center mr-3 py-2 thumbnail32" src="{{{imagePath}}}" alt="File icon">
|
<img class="align-self-center mr-3 py-2 thumbnail32" src="{{{imagePath}}}" alt="File icon">
|
||||||
<div id="{{{id}}}-title" class="media-body align-self-center">
|
<div id="{{{id}}}-title" class="media-body align-self-center">
|
||||||
<div class="spinner-border" role="status">
|
<div class="spinner-border" role="status">
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</li>
|
||||||
</html>
|
</html>
|
||||||
@ -0,0 +1,50 @@
|
|||||||
|
import {FileUtils} from './fileutils';
|
||||||
|
import {CardModel} from "./viewFactory";
|
||||||
|
|
||||||
|
let fs = require('fs');
|
||||||
|
let Mustache = require('mustache');
|
||||||
|
const crypto = require('crypto');
|
||||||
|
let path = require('path');
|
||||||
|
|
||||||
|
interface TemplateCallbackType {
|
||||||
|
(rendered: string[]): void
|
||||||
|
}
|
||||||
|
|
||||||
|
const templateCache = {};
|
||||||
|
|
||||||
|
export function cacheTemplates() {
|
||||||
|
let fu = new FileUtils();
|
||||||
|
let basePath = path.join(fu.getPathToAssets(), "views");
|
||||||
|
fs.readdirSync(basePath)
|
||||||
|
.forEach((file) => {
|
||||||
|
templateCache[file] = fs.readFileSync(path.join(basePath.toString(), file)).toString();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export function loadTemplate(filename: string, objs: object[], cb: TemplateCallbackType) {
|
||||||
|
let contents = templateCache[filename];
|
||||||
|
if (!contents) throw new Error("No such template: " + filename);
|
||||||
|
let results: string[] = []
|
||||||
|
for (let i = 0, l = objs.length; i < l; i++) {
|
||||||
|
let obj = objs[i]
|
||||||
|
let rendered = Mustache.render(contents, obj)
|
||||||
|
results.push(rendered)
|
||||||
|
}
|
||||||
|
cb(results)
|
||||||
|
}
|
||||||
|
|
||||||
|
export function loadTemplateSingle(filename: string, obj: CardModel, cb: (content: string, id: string) => void) {
|
||||||
|
let contents = templateCache[filename];
|
||||||
|
if (!contents) throw new Error("No such template: " + filename);
|
||||||
|
obj['id'] = createId(obj.fileName);
|
||||||
|
let rendered = Mustache.render(contents, obj);
|
||||||
|
cb(rendered, obj['id']);
|
||||||
|
}
|
||||||
|
|
||||||
|
function createId(fileName: String) {
|
||||||
|
return crypto.createHash('md5').update(fileName).digest('hex');
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = {loadTemplate, loadTemplateSingle}
|
||||||
|
|
||||||
|
cacheTemplates()
|
||||||
@ -1,42 +0,0 @@
|
|||||||
let fs = require('fs')
|
|
||||||
let Mustache = require('mustache')
|
|
||||||
const crypto = require('crypto')
|
|
||||||
import {FileUtils} from './fileutils'
|
|
||||||
import {CardModel} from "./viewFactory";
|
|
||||||
|
|
||||||
interface TemplateCallbackType {
|
|
||||||
(rendered: string[]): void
|
|
||||||
}
|
|
||||||
|
|
||||||
export function loadTemplate(filename: string, objs: object[], cb: TemplateCallbackType) {
|
|
||||||
let fu = new FileUtils();
|
|
||||||
let path = fu.getPathToView(filename);
|
|
||||||
fs.readFile(path, 'utf8', (err, contents) => {
|
|
||||||
if (err) throw err;
|
|
||||||
let results: string[] = []
|
|
||||||
for (let i = 0, l = objs.length; i < l; i++) {
|
|
||||||
let obj = objs[i]
|
|
||||||
let rendered = Mustache.render(contents, obj)
|
|
||||||
results.push(rendered)
|
|
||||||
}
|
|
||||||
cb(results)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
export function loadTemplateSingle(filename: string, obj: CardModel, cb: (content: string, id: string) => void) {
|
|
||||||
let fu = new FileUtils();
|
|
||||||
let path = fu.getPathToView(filename);
|
|
||||||
fs.readFile(path, 'utf8', (err, contents) => {
|
|
||||||
if (err) throw err;
|
|
||||||
obj['id'] = createId(obj.fileName);
|
|
||||||
let rendered = Mustache.render(contents, obj)
|
|
||||||
cb(rendered, obj['id'])
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
function createId(fileName: String){
|
|
||||||
return crypto.createHash('md5').update(fileName).digest('hex');
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = {loadTemplate, loadTemplateSingle}
|
|
||||||
|
|
||||||
Loading…
Reference in New Issue