NiklasGollenstede / re-style

A user style manager for Firefox 57+ which can load local files and apply UI styles
https://addons.mozilla.org/addon/re-style/
Mozilla Public License 2.0
38 stars 4 forks source link

Development mode inside profile folder #15

Closed Madis0 closed 6 years ago

Madis0 commented 6 years ago

Could I use a development mode folder inside the Fx profile folder? It would keep things consistent and contained.

Right now I get a "That didn't work... / Error: Can't create file..." popup, followed by the typical restart prompt (and no new style after the restart).


To give more information:

NiklasGollenstede commented 6 years ago

You mean like this?: image

From a technical perspective I don't see why not. It's probably not a good ides to use the chrome folder in the Firefox profile because reStyle will then read and watch the same directory multiple times (but it should work).

I wouldn't do it, though. The profile dir is Firefox' to manage and Firefox could always decide to delete unexpected stuff in there.


Regarding your error, I just fixed an infinite recursion when changing between valid local folders, but that doesn't seem to be your problem. I don't even see why reStyle would try to create files in your scenario ... Please try this again with version 0.4.1b21!

Madis0 commented 6 years ago

Wouldn't that also give reStyle an ability to create the folder on user's behalf?

I wouldn't do it, though. The profile dir is Firefox' to manage and Firefox could always decide to delete unexpected stuff in there.

The could be said for the whole chrome folder. Maybe reStyle could use just the userChrome.css and redirect other files to it's extension storage location?

Either way, I'll retry this later today.

NiklasGollenstede commented 6 years ago

Wouldn't that also give reStyle an ability to create the folder on user's behalf?

reStyle currently won't create the folder in the default location (as that wasn't the users choice), but if the path is changed and doesn't exist, it will now be created (regardless of where is is, as long as the user has access to that location). So now you can use local files without ever opening a file explorer (reStyle could already open the files in the native editor).

The could be said for the whole chrome folder.

Not quite. We are talking about the primary source location of styles here. You wouldn't want to loose that. No data would be lost if Firefox clears the chrome folder.

Maybe reStyle could use just the userChrome.css and redirect other files to it's extension storage location?

Not quite sure what you mean, but the userChrome.css is a way of applying styles, not a source to read styles from.

Madis0 commented 6 years ago

Not quite sure what you mean, but the userChrome.css is a way of applying styles, not a source to read styles from.

I meant that reStyle could just create .../chrome/userChrome.css and everything else (active, inactive, development styles, xml and js files) can point to another location using @import.

Could you explain the reasoning for not using a folder in the extension files again? I did not quite get that.

NiklasGollenstede commented 6 years ago

I don't think that using @import would solve the problem with the restart requirement (I might want to try it, though). And then I don't see much of a point in using @imports. It adds an additional layer of indirection and wouldn't work for remote styles (installed from URLs).


Could you explain the reasoning for not using a folder in the extension files again?

Sure. Here is why I wouldn't place the folder with the local styles inside Firefox' profile folder:

Try linking something inside the extensions folder in the profile. Firefox will (at startup or shutdown, I don't recall) recursively delete everything through the symlink. Happened to me, deleted the sources of an entire extension. I had backups, but imagine how shocked I was at first.

Besides that, I don't think it belongs in there. The set of user styles you create is not associated with a single Firefox profile. If you want to use only a subset of your styles in a given profile, you can use the exclude filter.

The files automatically placed in the chrome folder only contain composed copies of other files. Loosing them wouldn't really matter.

That said, you are of cause free to put your local folder in the profile. It works, but be prepared for Firefox deleting it (if not now, then maybe later).

Madis0 commented 6 years ago

Thanks for the explanation. Tried the initial issue now on v0.4.1b23 and this time only got the file creation error. The feature works fine for a folder outside the profile though.


Reason for suggesting to use @imports is that then you could protect the online styles too, and let users easily import-export them (if they prefer file-based organization instead of one text file). I have yet to try your Browser Toolbox hack though, so I am not sure how well does it work.

Also, what is the plan for when an online resource goes down, but the style works fine?

NiklasGollenstede commented 6 years ago

got the file creation error

I still don't understand why reStyle would even try to create any files. You are talking about an error right after changing the path in the textbox I took the screenshot of above, right?

what is the plan for when an online resource goes down, but the style works fine?

Currently it will simply stay as it is and be loaded from an internal copy. Updates will obviously fail, which will cause a notification at the time of the auto update. There is currently no way to disable the update check for individual styles, and reStyle doesn't handle the updateURL metadata property at all (which should booth be changed).

that then you could protect the online styles too

As in, make sure they aren't lost should Firefox ever clear the chrome folder? That is not a problem. reStyle keeps a list of URLs of installed styles in storage.sync and a cache of both the raw and the parsed styles themselves in storage.local. Firefox shouldn't ever clear those. Also, you shouldn't see the chrome dir as a storage location, but rather as an API (programming interface) to apply styles (at least that is how I think it should be and how reStyle treats it).

Madis0 commented 6 years ago

I still don't understand why reStyle would even try to create any files. You are talking about an error right after changing the path in the textbox I took the screenshot of above, right?

No, I just tried to create a style with the browser button after changing the path.

Also, you shouldn't see the chrome dir as a storage location, but rather as an API (programming interface) to apply styles

That sounds reasonable.

NiklasGollenstede commented 6 years ago

Ok, that makes a lot more sense. The error Can't create file "${path}" gets thrown if:

Are you using Linux, where the profile is in ~/.mozilla? That would explain the error. I can probably just drop the 2nd condition.

Madis0 commented 6 years ago

Are you using Linux, where the profile is in ~/.mozilla?

Yes.

Assuming you fixed the folder creation inside profile folders, and added an ability to create folders within reStyle itself (by path), I have now tried the original path again with v24. Here's the result: image

NiklasGollenstede commented 6 years ago

That error gets thrown when the installation of a remote style fails (URL to .css file in the textbox + click on "Add style").

To create a new local style, use the "Create new style" button (which uses the information of the current tab to populate the template).

I admit that the placement of both buttons underneath the textbox may be misleading.

Madis0 commented 6 years ago

Oops, I indeed did do that. Everything works fine now, inside profile or not so I guess it's time to close this issue.