Adds different web backends and cleans up options #92

Manually merged
sloum merged 8 commits from web-backends into develop 2019-11-15 05:01:26 +00:00
Owner

The manpage will need to be updated (and maybe the readme, not sure) to reflect this change. I am hopeful that this will be a good change that gives people more options and simplifies things a good amount.

I have been trying to find a way to detect whether a graphical environment is present or not so that we can add a guard clause to the gui setting for webmode. No great luck as of yet. I'll keep digging.

If I get time today I'll update the docs before fully merging this.

The manpage will need to be updated (and maybe the readme, not sure) to reflect this change. I am hopeful that this will be a good change that gives people more options and simplifies things a good amount. I have been trying to find a way to detect whether a graphical environment is present or not so that we can add a guard clause to the `gui` setting for `webmode`. No great luck as of yet. I'll keep digging. If I get time today I'll update the docs before fully merging this.
sloum added this to the 2.0.0 milestone 2019-11-14 17:48:19 +00:00
asdf was assigned by sloum 2019-11-14 17:48:20 +00:00
sloum added the
enhancement
http
labels 2019-11-14 17:48:20 +00:00
Author
Owner

Ok. Updated the manpage. Hopefully I made it clear enough but I'd appreciate you taking a look and updating if something doesn't make sense or could use more info.

I also updated the linux version of open in browser to run type Xorg. If this errors then they do not have access to a graphical environment. This should help, but will not solve all of the problems. For example, sdf seems to be running an X server so this will not function to guard this for sdf users. It does work on circumlunar space, rawtext.club, and colorfield.space. It also, correctly, showed that my laptop had a graphical environment and proceeded to open in a browser. So while not perfect I think it is a solid step in the right direction and can serve until something better is discovered. OSX/Darwin should not need any additional checks since there is always a graphical environment available. We are not really handling BSD or Plan9 for open in browser and they will always get an error message.

Ok. Updated the manpage. Hopefully I made it clear enough but I'd appreciate you taking a look and updating if something doesn't make sense or could use more info. I also updated the linux version of open in browser to run `type Xorg`. If this errors then they do not have access to a graphical environment. This should _help_, but will not solve all of the problems. For example, sdf seems to be running an X server so this will not function to guard this for sdf users. It does work on circumlunar space, rawtext.club, and colorfield.space. It also, correctly, showed that my laptop had a graphical environment and proceeded to open in a browser. So while not perfect I think it is a solid step in the right direction and can serve until something better is discovered. OSX/Darwin should not need any additional checks since there is always a graphical environment available. We are not really handling BSD or Plan9 for open in browser and they will always get an error message.
Collaborator

This might not be the latest version in the repo as there are compilation errors (fmt not imported, err := used twice), and type can't be run in this way because it is a shell builtin.

It's also an interesting approach to issue #91. It's detecting if Xorg is installed, but not necessarily if it is running? If that's the case, instead of type we can use exec.LookPath() instead of type.

I have found another alternative that might help too - check environment variables $DISPLAY or $WAYLAND_DISPLAY. If they are not set, I think this means there is no graphical environment available. This seems to work as expected on RTC, tilde town, and a local computer when accessed via SSH.

By the way, if you think #91 is going to delay this PR, I'm happy to put it in another PR.

This might not be the latest version in the repo as there are compilation errors (`fmt` not imported, `err :=` used twice), and `type` can't be run in this way because it is a shell builtin. It's also an interesting approach to issue #91. It's detecting if Xorg is installed, but not necessarily if it is running? If that's the case, instead of type we can use `exec.LookPath()` instead of `type`. I have found another alternative that might help too - check environment variables $DISPLAY or $WAYLAND_DISPLAY. If they are not set, I think this means there is no graphical environment available. This seems to work as expected on RTC, tilde town, and a local computer when accessed via SSH. By the way, if you think #91 is going to delay this PR, I'm happy to put it in another PR.
Author
Owner

Whoops. Sorry about that. I made that update while I was at work and clearly neglected a few things. I have cleaned up the errors and linted the code for the http module (which had some issues since this update).

I updated to using exec.LookPath("Xorg") as well as using os.Getenv to look for $DISPLAY and $WAYLAND_DISPLAY. If LookPath errors and the other two are an empty string, then we bail out. Otherwise we continue with xdg-open.

Whoops. Sorry about that. I made that update while I was at work and clearly neglected a few things. I have cleaned up the errors and linted the code for the http module (which had some issues since this update). I updated to using `exec.LookPath("Xorg")` as well as using `os.Getenv` to look for `$DISPLAY` and `$WAYLAND_DISPLAY`. If `LookPath` errors and the other two are an empty string, then we bail out. Otherwise we continue with `xdg-open`.
asdf reviewed 2019-11-15 03:50:40 +00:00
Collaborator

I think this might need to be:
if (disp == "" || wayland == "") && err != nil {
If either variable is set there could be a GUI environment.

I think this might need to be: `if (disp == "" || wayland == "") && err != nil {` If either variable is set there could be a GUI environment.
asdf reviewed 2019-11-15 03:57:00 +00:00
main.go Outdated
Collaborator

Should the additional settings be removed from here?

Should the additional settings be removed from here?
asdf reviewed 2019-11-15 03:58:15 +00:00
main.go Outdated
Collaborator

Also from lowerCaseOpt()?

Also from `lowerCaseOpt()`?
Collaborator

I've reviewed the documentation and made some further changes. There's also a couple of comments on the Files Changed tab. Let me know if you can't see them.

I've reviewed the documentation and made some further changes. There's also a couple of comments on the Files Changed tab. Let me know if you can't see them.
sloum reviewed 2019-11-15 04:34:02 +00:00
Author
Owner

I think it should be the &&. The logic being if neither wayland nor x has a display variable then that is an indication that there is no gui present. Inversely if wayland had a value then there is a gui, so we do not want to enter the error block.

I think the logic is correct, but if I'm wrong definitely push back on it.

I think it should be the `&&`. The logic being if _neither_ wayland nor x has a display variable then that is an indication that there is no gui present. Inversely if wayland had a value then there is a gui, so we do not want to enter the error block. I think the logic is correct, but if I'm wrong definitely push back on it.
Author
Owner

I made the change to remove the options that no longer exist and left a comment on the other one. I think the logic is right as is, though maybe there is a more clear way to write it? Or maybe a comment would be good?

I made the change to remove the options that no longer exist and left a comment on the other one. I think the logic is right as is, though maybe there is a more clear way to write it? Or maybe a comment would be good?
asdf reviewed 2019-11-15 04:39:11 +00:00
Collaborator

Sorry I'm having trouble remembering how this logic works...you are 100% correct.

Sorry I'm having trouble remembering how this logic works...you are 100% correct.
asdf approved these changes 2019-11-15 04:42:31 +00:00
asdf left a comment
Collaborator

This is a really nice change. Well done!

This is a really nice change. Well done!
Collaborator

I was just confused by how xdg-open does a similar evaluation. It's all good, I think it's ready to merge in.

I was just confused by how `xdg-open` does a similar evaluation. It's all good, I think it's ready to merge in.
sloum closed this pull request 2019-11-15 05:01:23 +00:00
sloum deleted branch web-backends 2019-11-15 05:03:04 +00:00
Sign in to join this conversation.
No reviewers
No Milestone
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: sloum/bombadillo#92
No description provided.