Build with assets; Misc app work
This commit is contained in:
parent
2fc970d24c
commit
efc4c49a7f
17
App/Elems.js
17
App/Elems.js
|
@ -1,11 +1,22 @@
|
||||||
function MakeWindow(Attrs) {
|
function HtmlEl(Tag, Attrs) {
|
||||||
var Window = document.createElement('div');
|
var El = document.createElement(Tag);
|
||||||
if (Attrs) {
|
if (Attrs) {
|
||||||
Object.keys(Attrs).forEach(function(Attr){
|
Object.keys(Attrs).forEach(function(Attr){
|
||||||
Window[Attr] = Attrs[Attr];
|
El[Attr] = Attrs[Attr];
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
return El;
|
||||||
|
};
|
||||||
|
|
||||||
|
function MakeWindow(Attrs) {
|
||||||
|
var Window = HtmlEl('div', Attrs);
|
||||||
Window.className += ' Window';
|
Window.className += ' Window';
|
||||||
Root.appendChild(Window);
|
Root.appendChild(Window);
|
||||||
return Window;
|
return Window;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function Dropdown(Attrs) {
|
||||||
|
var Menu = HtmlEl('div', Attrs);
|
||||||
|
Window.className += ' Dropdown';
|
||||||
|
return Menu;
|
||||||
|
};
|
||||||
|
|
37
App/Main.js
37
App/Main.js
|
@ -3,6 +3,16 @@ var Present = CopyObj(Persist);
|
||||||
var Tasker = {};
|
var Tasker = {};
|
||||||
var ApiCache = {Urls: {},};
|
var ApiCache = {Urls: {},};
|
||||||
|
|
||||||
|
Assets._ = function _(Name) {
|
||||||
|
if (Name in Assets) {
|
||||||
|
if (Assets[Name].startsWith('data:')) {
|
||||||
|
return Assets[Name];
|
||||||
|
} else {
|
||||||
|
return `./Assets/${Assets[Name]}`;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
function DoAsync(First, Then, Data) {
|
function DoAsync(First, Then, Data) {
|
||||||
var Job = RndId();
|
var Job = RndId();
|
||||||
Tasker[Job] = {
|
Tasker[Job] = {
|
||||||
|
@ -149,10 +159,29 @@ function PostNote(Text) {
|
||||||
|
|
||||||
function ManageSettings() {
|
function ManageSettings() {
|
||||||
MakeWindow().innerHTML = `
|
MakeWindow().innerHTML = `
|
||||||
* Sources
|
<h2>Settings</h2>
|
||||||
* Identities
|
<h3>Misc</h3>
|
||||||
* Data Import/Export
|
<p>
|
||||||
* Cache Persistance
|
Language: ${Dropdown()}
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
Theme:
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
<label>Wait <input type="number"/> seconds after clicking send for a note to be sent</label>
|
||||||
|
</p>
|
||||||
|
<h3>Identities</h3>
|
||||||
|
...
|
||||||
|
<h3>Sources</h3>
|
||||||
|
...
|
||||||
|
<h3>Data</h3>
|
||||||
|
<p>
|
||||||
|
<button>Import User Data</button>
|
||||||
|
<button>Export User Data</button>
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
<label><input type="checkbox"/> Persist cache on app reload</label>
|
||||||
|
</p>
|
||||||
`;
|
`;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
25
Build.py
25
Build.py
|
@ -1,5 +1,7 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
import os
|
import os
|
||||||
|
from base64 import b64encode
|
||||||
|
from mimetypes import guess_type
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
os.chdir(os.path.dirname(os.path.abspath(__file__)))
|
os.chdir(os.path.dirname(os.path.abspath(__file__)))
|
||||||
|
@ -17,11 +19,26 @@ def FragReplace(Find, Replace, Pattern='*.*'):
|
||||||
with open(File, 'r') as Frag:
|
with open(File, 'r') as Frag:
|
||||||
Frag = Replace.format(File=File, Frag=Frag.read())
|
Frag = Replace.format(File=File, Frag=Frag.read())
|
||||||
for Prefix in ('', './'):
|
for Prefix in ('', './'):
|
||||||
File = Prefix + File
|
Name = Prefix + File
|
||||||
Base = Base.replace(Find.format(File=File), Frag)
|
Base = Base.replace(Find.format(File=Name), Frag)
|
||||||
|
|
||||||
#BaseNew = []
|
BaseNew = ''
|
||||||
#BaseNew += Base.split('<script data-build-json="true">')
|
Split = '<script data-build-json="true">'
|
||||||
|
Frags = Base.split(Split)
|
||||||
|
BaseNew += Frags[0] + Split
|
||||||
|
Split = '</script>'
|
||||||
|
Frags = Frags[1].split(Split)
|
||||||
|
for File in Path('./Assets').rglob('*.*'):
|
||||||
|
File = str(File)
|
||||||
|
Mime = guess_type(File)
|
||||||
|
Mime = (Mime[0] if Mime else 'application/octet-stream')
|
||||||
|
with open(File, 'rb') as Frag:
|
||||||
|
Frag = b64encode(Frag.read()).decode()
|
||||||
|
for Prefix in ('', './'):
|
||||||
|
Name = Prefix + '/'.join(File.split('/')[1:])
|
||||||
|
Frags[0] = Frags[0].replace(f'"{Name}"', f'"data:{Mime};base64,{Frag}"')
|
||||||
|
BaseNew += Split.join(Frags)
|
||||||
|
Base = BaseNew
|
||||||
|
|
||||||
FragReplace('<link rel="stylesheet" href="{File}"/>', '<style data-source="{File}">{Frag}</style>', '*.css')
|
FragReplace('<link rel="stylesheet" href="{File}"/>', '<style data-source="{File}">{Frag}</style>', '*.css')
|
||||||
FragReplace('<script src="{File}"></script>', '<script data-source="{File}">{Frag}</script>', '*.js')
|
FragReplace('<script src="{File}"></script>', '<script data-source="{File}">{Frag}</script>', '*.js')
|
||||||
|
|
Loading…
Reference in New Issue