Skip to content
Permalink
Browse files
Fix #3166 — make auto/serve URL clickable
Signed-off-by: Chris Warrick <kwpolska@gmail.com>
  • Loading branch information
Kwpolska committed Sep 27, 2018
1 parent 1caf3a9 commit f58ba9a31031009a8185ad3337ccf652660b8e5d
Showing with 17 additions and 13 deletions.
  1. +3 −0 CHANGES.txt
  2. +6 −6 nikola/plugins/command/auto/__init__.py
  3. +8 −7 nikola/plugins/command/serve.py
@@ -4,6 +4,9 @@ New in master
Features
--------

* Make URL displayed by ``nikola auto`` and ``nikola serve`` clickable
(Issue #3166)

Bugfixes
--------

@@ -238,13 +238,13 @@ def _execute(self, options, args):

host, port = srv.sockets[0].getsockname()

self.logger.info("Serving HTTP on {0} port {1}...".format(host, port))
if browser:
if options['ipv6'] or '::' in host:
server_url = "http://[{0}]:{1}/".format(host, port)
else:
server_url = "http://{0}:{1}/".format(host, port)
if options['ipv6'] or '::' in host:
server_url = "http://[{0}]:{1}/".format(host, port)
else:
server_url = "http://{0}:{1}/".format(host, port)
self.logger.info("Serving on {0} ...".format(server_url))

if browser:
self.logger.info("Opening {0} in the default web browser...".format(server_url))
webbrowser.open('http://{0}:{1}'.format(host, port))

@@ -139,14 +139,15 @@ def _execute(self, options, args):
httpd = OurHTTP((options['address'], options['port']),
OurHTTPRequestHandler)
sa = httpd.socket.getsockname()
self.logger.info("Serving HTTP on {0} port {1}...".format(*sa))
if ipv6:
server_url = "http://[{0}]:{1}/".format(*sa)
elif sa[0] == '0.0.0.0':
server_url = "http://127.0.0.1:{1}/".format(*sa)
else:
server_url = "http://{0}:{1}/".format(*sa)
self.logger.info("Serving on {0} ...".format(server_url))

if options['browser']:
if ipv6:
server_url = "http://[{0}]:{1}/".format(*sa)
elif sa[0] == '0.0.0.0':
server_url = "http://127.0.0.1:{1}/".format(*sa)
else:
server_url = "http://{0}:{1}/".format(*sa)
self.logger.info("Opening {0} in the default web browser...".format(server_url))
webbrowser.open(server_url)
if options['detach']:

0 comments on commit f58ba9a

Please sign in to comment.