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

Print site URL when running nanoc view #1204

Merged
merged 1 commit into from
Aug 20, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions lib/nanoc/cli/commands/view.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ def run
run Rack::File.new(site.config[:output_dir])
end.to_app

# Print a link
url = "http://#{options[:host] || 'localhost'}:#{options_for_rack[:Port]}/"
Copy link
Member

Choose a reason for hiding this comment

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

You could use options_for_rack[:host] instead of options[:host] || 'localhost'.

This made me wonder whether defaulting to 0.0.0.0, rather than 127.0.0.1, is a sensible default—it probably isn’t. :/

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh huh I had no idea http://0.0.0.0:3000/ would actually work in a browser, turns out it does. Feel free to change to your preferred form.

puts "View the site at #{url}"

# Run autocompiler
handler.run(app, options_for_rack)
end
Expand Down