Skip to content

Commit

Permalink
flares update
Browse files Browse the repository at this point in the history
  • Loading branch information
phoenixbf committed Jun 28, 2024
1 parent dc525c1 commit 13ff341
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 8 deletions.
12 changes: 10 additions & 2 deletions public/src/ATON.js
Original file line number Diff line number Diff line change
Expand Up @@ -880,18 +880,26 @@ ATON.addFlare = (P)=>{
ATON.registerFlare = ATON.addFlare;

// Setup flares
ATON._setupFlareScripts = (fid)=>{
let F = ATON.Flares[fid];

// TODO
};

ATON._setupFlares = ()=>{
for (let p in ATON.Flares){
let P = ATON.Flares[p];

// Experimental
// Experimental (TODO: move in _setupFlareScripts)
if (P._deps.length > 0){
let cc = P._deps.length;

for (let s in P._deps){
let jss = document.createElement("script");
jss.src = P._deps[s];
document.documentElement.firstChild.appendChild(jss);
jss.async = false;
//document.documentElement.firstChild.appendChild(jss);
document.head.appendChild(jss);

jss.onload = ()=>{
cc--;
Expand Down
18 changes: 17 additions & 1 deletion services/API/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@
"/api/v2/flares/":{
"get":{
"tags":["Flares"],
"summary": "Get list of flares on this instance",
"summary": "Get list of flares installed on this instance",
"description": "....",

"responses":{
Expand All @@ -360,6 +360,22 @@
}
}
}
},

"/api/v2/flares/{fid}":{
"get":{
"tags":["Flares"],
"summary": "Get flare details",
"description": "....",

"responses":{
"200":{
"description": "Successful operation, returns flare information",
"content":{
}
}
}
}
}
},

Expand Down
19 changes: 19 additions & 0 deletions services/API/v2.js
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,7 @@ API.init = (app)=>{
/*===============================
FLARES
===============================*/
// Get list of flares currently hosted
app.get(API.BASE + "flares", (req,res)=>{
if ( !Core.Auth.isUserAdmin(req) ){
res.status(401).send([]);
Expand All @@ -352,6 +353,24 @@ API.init = (app)=>{
res.send( Core.flares );
});

// Get a flare client info
app.get(API.BASE + "flares/:fid", (req,res)=>{
let f = req.params.fid;

let F = Core.flares[f];
if (!F){
res.send(false);
return;
}

let O = {};

if (F.name) O.name = F.name;
if (F.client && F.client.files) O.files = F.client.files;

res.send( O );
});

/*===============================
INSTANCE
===============================*/
Expand Down
6 changes: 3 additions & 3 deletions services/ATON.service.main.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,9 @@ app.use('/dav', createProxyMiddleware({
//==================================
Core.setupFlares(app);

for (let f in Core.flares){
let flarename = Core.flares[f];
app.use('/flares/'+flarename, express.static(Core.DIR_FLARES+flarename+"/public/"));
for (let fid in Core.flares){
//let fid = Core.flares[f];
app.use('/flares/'+fid, express.static(Core.DIR_FLARES+fid+"/public/"));
}

// START
Expand Down
5 changes: 3 additions & 2 deletions services/Core.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ Core.logYellow = (str)=>{


// Flares
Core.flares = [];
Core.flares = {};

Core.setupFlares = (app)=>{
if (!fs.existsSync(Core.DIR_FLARES)) return;
Expand All @@ -114,7 +114,7 @@ Core.setupFlares = (app)=>{

let fbasepath = Core.DIR_FLARES + flarename + "/";

Core.flares.push( flarename );
//Core.flares.push( flarename );

// Client (public) components
if (P.client){
Expand All @@ -133,6 +133,7 @@ Core.setupFlares = (app)=>{

if (P.respatterns && P.respatterns.length>2) Core.mpattern += ","+P.respatterns;

Core.flares[flarename] = P;
}

console.log("\nFlares (plugins) found: ");
Expand Down

0 comments on commit 13ff341

Please sign in to comment.