jeff-zucker / solid-content-manager

A syntax-highlighting editor and file manager for Solid data stores.
https://jeff-zucker.github.io/solid-content-manager/
MIT License
32 stars 14 forks source link

re: 'alert-danger' #1

Open kustomzone opened 5 years ago

kustomzone commented 5 years ago

Hey Jeff, been enjoying your solside app, but just came across a small bug... In the older version, 'solid-auth-simple.js' throws "Not authorized to access [path-to-file]" alert. In the current version, 'solid-ide-solidHandler.js' throws "undefined (undefined)" alert. They do this with any file that contains the text "alert-danger" due to the following code..

if(body && body.value && body.value.match('alert-danger')
           && !thing.url.match('solid-auth-simple')
        ) { // throw error..
        }

I'm not sure why the body text 'alert-danger' is targeted in this code, but also 'solid-auth-simple' is no longer present (ie. self-excluded from the alert).

Cheers.

jeff-zucker commented 5 years ago

Thanks much. Yes, ugly code. The thing is, either I need to do a recursive ACL search to find out if user is authorized by the file (in the works but tricky to do) or I need to try to get the file. If you try to get a file you aren't authorized for, you get back an HTML page including the words "alert-danger" so that is what I used to trap the error. Previously, when I was storing the code for solid -ide on the POD, that could cause problems because the words "alert-danger" occur in the javascript, so I excluded that. No longer relevant since everything moved to Github. Thanks for the reminder I need to clean this up, much appreciated. Maybe I should change it to look for /danger Will Robinson/ :-).

kustomzone commented 5 years ago

Ah, nice hack!

But tricky cos 'alert-danger' is in Warp's app.css and bootstrap.css and many other css files i suspect. I'm still using solid-auth-simple so the error puzzled me for a couple of days while i messed around with permissions until i noticed it was a specific css file throwing an authorization alert, which made no sense. Even an alert saying "swy, 'alert-danger' found in body text" might save a little confusion. ;O)

Also, in Spoggy4 the file is renamed "solid-tools.js" so self-exclusion could be done dynamically..

var parts = document.currentScript.src.split("/");
var result = parts[parts.length - 1]; // "test.js"
// ... && !thing.url.match(result)
jeff-zucker commented 5 years ago

Proof once again, that clever as it may be, a hack is still a hack. I'll figure out something better and will let @smag0 know for spoggy. BTW, I'm about to release a new solid-file-client - that, with help of @linonetwo, will have tests and ec6 and other improvements.

kustomzone commented 5 years ago

Yes, linonetwo's been busy! Cool, ready to pull upstream! :)

ping Smag0: @scenaristeur

scenaristeur commented 5 years ago

@kustomzone & @jeff-zucker thxs for the mention, I'll take a look. What i did for solid-tools of Spoggy4 was a 'pseudo-ugly-clone' of the solid-ide.

jeff-zucker commented 5 years ago

Spoggy looks cool, I hope to have time to actually explore it soon. I think the only major interface change will be that readFile() will return the body of the file, not an object with the body in body.value - a pain but worth it for consistency in the long run.

scenaristeur commented 5 years ago

spoggy4 was a test with Polymer3 & Solid', but Polymer3 is not stable. A more stable version on which i'm working on is Spoggy with Polymer2 https://spoggy.herokuapp.com ( wait 15sec & refresh to let the server awake) Look at the Menu / Solid' connect https://github.com/scenaristeur/heroku-spoggy I must refactor all thé interface, any contribution / suggestions are welcome https://github.com/scenaristeur/heroku-spoggy/projects/1