Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support open "current content page" in browser #3645

Merged
merged 7 commits into from
Jun 26, 2017
Merged

Conversation

bep
Copy link
Member

@bep bep commented Jun 25, 2017

This is pretty cool.

Fixes #3643

@bep bep force-pushed the liveo branch 4 times, most recently from bd43d57 to 6efa7b1 Compare June 25, 2017 18:53
@bep bep changed the title WIP Support open "current content page" in browser Support open "current content page" in browser Jun 26, 2017
commands/hugo.go Outdated

if navigate {

// It is probably more confusing than usueful
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please fix minor typo: usuefuluseful

@anthonyfok
Copy link
Member

This is pretty cool.

This is really, really awesome! Totally love this new feature! Thank you Bjørn!

One minor detail that did get me confused though: the demo at https://twitter.com/GoHugoIO/status/879065641315119104, it Hugo not only get the web browser jumps to the current page, but it almost seems like it jumps to the current section! (No, wait, I am just imagining things... Hoho!)

Copy link
Member

@anthonyfok anthonyfok left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My Go coding skill is still at an novice level (I am serious, and not being humble), but at a quick glance, your code looks good, and it works in Google Chrome on Debian GNU/Linux, so yes, I think it is awesome!

@bep
Copy link
Member Author

bep commented Jun 26, 2017

but it almost seems like it jumps to the current section! (No, wait, I am just imagining things... Hoho!)

That would be magic!

But I agree, this is a feature that I really want myself, and is golden for site-wide edits (copy-edits etc.).

Thanks for testing it! I need some Windows user to take it for a spin, but I will ask in the forum.

@bep bep merged commit c825a73 into gohugoio:master Jun 26, 2017
@@ -87,6 +88,7 @@ func init() {
serverCmd.Flags().BoolVarP(&serverWatch, "watch", "w", true, "watch filesystem for changes and recreate as needed")
serverCmd.Flags().BoolVarP(&serverAppend, "appendPort", "", true, "append port to baseURL")
serverCmd.Flags().BoolVar(&disableLiveReload, "disableLiveReload", false, "watch without enabling live browser reload on rebuild")
serverCmd.Flags().BoolVar(&navigateToChanged, "navigateToChanged", false, "navigate to changed content file on live browser reload")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about "navigate to changed content file in browser on live reload" instead?

@digitalcraftsman
Copy link
Member

digitalcraftsman commented Jun 26, 2017

This feature is really nice and might have been a timer saver for @rdwatters during the rewrite of the docs 😉 .

Thanks for testing it! I need some Windows user to take it for a spin, but I will ask in the forum.

I tried it too and it worked perfectly. But I'm on Linux as well.

@anthonyfok
Copy link
Member

I need some Windows user to take it for a spin, but I will ask in the forum.

I could reboot into Windows 10 and do some testing there too. Hope I can post my result within half an hour? :-)

@bep
Copy link
Member Author

bep commented Jun 26, 2017

There is no rush with the testing, I assume it "just works" and it is some time before we release this to the public. This should work, the only gotcha would be path issues on Windows.

I'm on macOs, and that works fine, too, of course (in Chrome and Safari).

@anthonyfok
Copy link
Member

Preliminary result under Windows 10:

  • Using Notepad as the editor, it works with both Internet Explorer 11, Microsoft Edge, and Google Chrome. Hurray!
Source changed "C:\\Users\\Anthony\\go\\src\\github.com\\gohugoio\\hugo\\docs\\content\\release-notes\\release-notes.md": WRITE
INFO 2017/06/26 15:00:11 rereading C:\Users\Anthony\go\src\github.com\gohugoio\hugo\docs\content\release-notes\release-notes.md

filename = C:\Users\Anthony\go\src\github.com\gohugoio\hugo\docs\content\release-notes\release-notes.md
GetContentPage(): rel = release-notes\release-notes.md
GetContentPage(): pos = 114
  • Using Vim (from Git Bash, MINGW64) as the editor: No go... for some unknown reason, it generates a WRITE event on the directory instead of the file:
Source changed "C:\\Users\\Anthony\\go\\src\\github.com\\gohugoio\\hugo\\docs\\content\\release-notes": WRITE
Source changed "C:\\Users\\Anthony\\go\\src\\github.com\\gohugoio\\hugo\\docs\\content\\release-notes\\release-notes.md": RENAME
Source changed "C:\\Users\\Anthony\\go\\src\\github.com\\gohugoio\\hugo\\docs\\content\\release-notes\\release-notes.md": CREATE
Source changed "C:\\Users\\Anthony\\go\\src\\github.com\\gohugoio\\hugo\\docs\\content\\release-notes\\release-notes.md": WRITE
INFO 2017/06/26 15:04:58 rereading C:\Users\Anthony\go\src\github.com\gohugoio\hugo\docs\content\release-notes\release-notes.md
INFO 2017/06/26 15:04:58 rereading C:\Users\Anthony\go\src\github.com\gohugoio\hugo\docs\content\release-notes\release-notes.md
INFO 2017/06/26 15:04:58 rereading C:\Users\Anthony\go\src\github.com\gohugoio\hugo\docs\content\release-notes\release-notes.md

filename = C:\Users\Anthony\go\src\github.com\gohugoio\hugo\docs\content\release-notes
GetContentPage(): rel = release-notes
GetContentPage(): pos = -1

@bep
Copy link
Member Author

bep commented Jun 26, 2017

Using Vim (from Git Bash, MINGW64) as the editor: No go... for some unknown reason, it generates a WRITE event on the directory instead of the file:

But it ALSO generates one for the file. So, I should adjust my logic to pick the first file WRITE event. I will create a new PR with a fix tomorrow. Thanks for the testing.

@anthonyfok
Copy link
Member

But it ALSO generates one for the file. So, I should adjust my logic to pick the first file WRITE event. I will create a new PR with a fix tomorrow. Thanks for the testing.

You're very welcome! Yes, I am looking at pickOneWritePath() now too, and was wondering about the same. :-) I will create a PR too as an exercise for myself, but if it turns out to be an inefficient or incorrect way of doing it, please feel free to ignore my PR (if I ever get it done, haha).

Have a good night!

@bep
Copy link
Member Author

bep commented Jun 26, 2017

) I will create a PR too as an exercise for myself

Yea, that would be better -- so you could test it yourself. You can check if it is a file, but the easiest is maybe to pick the "longest WRITE event". We really should get some automatic server tests running, but that will have to wait for another day.

anthonyfok added a commit to anthonyfok/hugo that referenced this pull request Jun 27, 2017
This ensures the new "open 'current content page' in browser" works
on Windows, especially with Emacs and Vim.

Special thanks to @bep for coming up with the idea of the fix.

See gohugoio#3645
bep pushed a commit that referenced this pull request Jun 27, 2017
This ensures the new "open 'current content page' in browser" works
on Windows, especially with Emacs and Vim.

Special thanks to @bep for coming up with the idea of the fix.

See #3645
@github-actions
Copy link

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 11, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add option to open "current" content file in a browser
3 participants