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

Pelican --listen directory fix #2930

Closed

Conversation

MinchinWeb
Copy link
Contributor

When trying to fix some issues with pelican --listen, I couldn't get it to work. It turns out it was trying to serve from the project root directly, rather than the output directory.

It now serves the output directory, although it still needs to be invoked from the project's root (i.e. the folder that holds your pelicanconf.py file).

Pull Request Checklist

  • Ensured tests pass and (if applicable) updated functional test output
  • Conformed to code style guidelines by running appropriate linting tools
  • Added tests for changed code
  • Updated documentation for changed code

@MinchinWeb
Copy link
Contributor Author

P.S. If this could be marked "hacktoberfest-accepted" (so it counts towards my Hacktoberfest Pull Requests), that would be appreciated!

@avaris
Copy link
Member

avaris commented Oct 2, 2021

When trying to fix some issues with pelican --listen, I couldn't get it to work. It turns out it was trying to serve from the project root directly, rather than the output directory.

I need a lot more context to understand the issue. pelican --listen is very much like a pelican invocation. It uses the same machinery to determine where the output path is. So it should be invoked the same way you generate your site. e.g. If you're passing --output in the command line when generating the site, you should do the same with --listen.

Given that, I cannot replicate the issue you are describing.

@MinchinWeb
Copy link
Contributor Author

@avaris

I need a lot more context to understand the issue.

I'm using the test site that is part of my nojekyll plugin, from here --> https://github.com/pelican-plugins/nojekyll/tree/master/test-site

There's nothing crazy with this site; it's trying to be a very simple but complete site. I don't have a requirement file, so you'll have to install those manually: clone the nojekyll repo (to get the test site), create a virtual environment, and install the requirements:

pip install pelican minchin.pelican.plugins.nojekyll invoke

Next, generate the site. From the site root (the test-site directory, the one that contains the pelicanconf.py file), run:

pelican

You should get output like this:

image

Then start the pelican server (we haven't changed directories or anything):

pelican --listen

You can pull up the generated site in your web browser at http://localhost:8000/


With the existing server (i.e. 4.7.0), the front page of the site will load, but the CSS won't and any other page (like the authors page or the category page) will return a 404 Error.

With this code active, the front page loads, and the CSS shows HTTP code 200 (or 304) and all the other pages will load (actually, Firefox asks if you want to save the secondary pages to disk, but this is the Mimetype issue solved in #2928; this Mimetype issue is the same reason the front page isn't styled).


If there's a simplier or easier or better way, by all means let me know.

@avaris
Copy link
Member

avaris commented Oct 3, 2021

Again, I cannot replicate. Everything works perfectly fine here. I tested this on Vivaldi (4.2.2406.54), Chrome (94.0.4606.71) and Firefox (50.0.2).

Below is after: cloning your repo, creating a venv, pip install pelican (gets 4.7.0) and afterwards doing pip install -e . in your repo root:

D:\workspace\X\nojekyll\test-site (master)
(nojekyll) $ pelican
Done: Processed 1 article, 0 drafts, 0 hidden articles, 0 pages, 0 hidden pages and 0 draft pages in 0.20 seconds.

D:\workspace\X\nojekyll\test-site (master)
(nojekyll) $ pelican -l

Serving site at: http://127.0.0.1:8000 - Tap CTRL-C to stop
127.0.0.1 - - [03/Oct/2021 03:20:35] "GET /theme/css/main.css HTTP/1.1" 304 -
127.0.0.1 - - [03/Oct/2021 03:20:35] "GET /theme/css/reset.css HTTP/1.1" 304 -
127.0.0.1 - - [03/Oct/2021 03:20:35] "GET /theme/css/pygment.css HTTP/1.1" 304 -
127.0.0.1 - - [03/Oct/2021 03:20:35] "GET /theme/css/typogrify.css HTTP/1.1" 304 -
127.0.0.1 - - [03/Oct/2021 03:20:35] "GET /theme/css/fonts.css HTTP/1.1" 304 -
[03:20:36] WARNING  Unable to find `/favicon.ico` or variations:                                                                                   log.py:91
                    /favicon.ico.html
                    /favicon.ico/index.html
                    /favicon.ico/
                    /favicon.ico
127.0.0.1 - - [03/Oct/2021 03:20:37] "GET /theme/fonts/Yanone_Kaffeesatz_400.woff HTTP/1.1" 304 -
127.0.0.1 - - [03/Oct/2021 03:20:46] "GET /author/minchinweb.html HTTP/1.1" 200 -
127.0.0.1 - - [03/Oct/2021 03:20:53] "GET /test-article.html HTTP/1.1" 200 -
127.0.0.1 - - [03/Oct/2021 03:21:00] "GET /category/misc.html HTTP/1.1" 200 -

@MinchinWeb
Copy link
Contributor Author

@avaris : This seems to have been fixed (if this ever was more than my local issues...), likely by #2931. I'm still not sure how the server get redirected to the output directory, but that's fine. In any case, I'm excited to learn about the built-in server and look forward to use it going forward.

I'm going to close this, as this PR doesn't seem to anything that hasn't been fixed better elsewhere. :)

@MinchinWeb MinchinWeb closed this Oct 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants