Let nikola serve work together with non-root BASE_URL or SITE_URL. Fixes #3726 #3804
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Pull Request Checklist
Description
With the previous implementation, check out
nikola-site
, editconfig.py
to say something likeSITE_URL = "https://getnikola.com/documentation"
and build anew, then runnikola serve --browser
. This breaks in several ways, which is exactly the point of #3726 .Now apply this pull request to
nikola
, and do the same again: It works.I have also added some tests. They let the
nikola server
functionality run in a different thread, opening up an HTTP port. The main thread sends HTTP requests to the server and checks whether the answers are as expected.Doing so exposed an assumption of the server plugin: "When I'm running, I'm the only thing that matters, so when I'm done, I might as well shut down the entire application." I don't like that from an architectural point of view. To put application-level shutdown into the hands of one of several components feels wrong to me. Essentially, such a component is not testable.
I left it in there, but guarded: This now happens only if running on the main thread. My tests runs the functionality on a different thread, so then the guard sees to it that the whole application is not shut down. In the process, I found the plugin didn't even try to stop the internal HTTP server when
shutdown
was called. This is somewhat improved now, at least for the case when the HTTP server runs in a thread of its own.