mirror of
https://gitlab.com/octtspacc/Friendiiverse
synced 2024-12-21 20:54:02 +01:00
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) {
|
||||
var Window = document.createElement('div');
|
||||
function HtmlEl(Tag, Attrs) {
|
||||
var El = document.createElement(Tag);
|
||||
if (Attrs) {
|
||||
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';
|
||||
Root.appendChild(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 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) {
|
||||
var Job = RndId();
|
||||
Tasker[Job] = {
|
||||
@ -149,10 +159,29 @@ function PostNote(Text) {
|
||||
|
||||
function ManageSettings() {
|
||||
MakeWindow().innerHTML = `
|
||||
* Sources
|
||||
* Identities
|
||||
* Data Import/Export
|
||||
* Cache Persistance
|
||||
<h2>Settings</h2>
|
||||
<h3>Misc</h3>
|
||||
<p>
|
||||
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
|
||||
import os
|
||||
from base64 import b64encode
|
||||
from mimetypes import guess_type
|
||||
from pathlib import Path
|
||||
|
||||
os.chdir(os.path.dirname(os.path.abspath(__file__)))
|
||||
@ -17,11 +19,26 @@ def FragReplace(Find, Replace, Pattern='*.*'):
|
||||
with open(File, 'r') as Frag:
|
||||
Frag = Replace.format(File=File, Frag=Frag.read())
|
||||
for Prefix in ('', './'):
|
||||
File = Prefix + File
|
||||
Base = Base.replace(Find.format(File=File), Frag)
|
||||
Name = Prefix + File
|
||||
Base = Base.replace(Find.format(File=Name), Frag)
|
||||
|
||||
#BaseNew = []
|
||||
#BaseNew += Base.split('<script data-build-json="true">')
|
||||
BaseNew = ''
|
||||
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('<script src="{File}"></script>', '<script data-source="{File}">{Frag}</script>', '*.js')
|
||||
|
Loading…
Reference in New Issue
Block a user