Pelican-Elegant / elegant

Best theme for Pelican Static Blog Generator
https://elegant.oncrashreboot.com/
MIT License
293 stars 187 forks source link

Need to specify the link in nav-bar #250

Closed azzamsa closed 5 years ago

azzamsa commented 5 years ago

Hi

I saw some issue about this. The original code using "hard coded" .html url. Then someone change it to non hard code.

It took me long time to read the issue and searching the web. Till I find this solution

It works after I specify

TAGS_URL = 'tags.html'
CATEGORIES_URL = 'categories.html'
ARCHIVES_URL = 'archives.html'

Why it doesn't work by default, at least for me ? Am I missing something ?

Thank you for this beloved theme :)

silverhook commented 5 years ago

@azzamsa, glad you like the theme!

We’re currently wrapping things up for the 2.0 release, so there are still some untied ends.

We have also set up a new website for Elegant, where we host the theme’s documentation as well: https://pelican-elegant.github.io/

The feature you are asking about still needs to be documented, and the issue for it is here: https://github.com/Pelican-Elegant/documentation/issues/23

In short, hard-coding was a limitation of Elegant due to the dependency on Tipue Search. The change in https://github.com/Pelican-Elegant/elegant/pull/186 was a compromise between Pelcan’s flexibility and Tipue Search’s inflexibility.

Since you’ve done some research on this already, but weren’t involved with writing the change in the first place, you’d be a perfect candidate to write that little piece. If you’re willing to volunteer, of course :wink:

talha131 commented 5 years ago

@azzamsa that's strange. You should not have to add these settings. See our code here

https://github.com/Pelican-Elegant/elegant/blob/master/templates/base.html#L70-L72

Notice the defaults function. For example,

 CATEGORIES_URL|default('categories') 

The code should have worked outside the box.

Can you please,

  1. Make sure you have the latest HEAD from elegant repo?
  2. If it is, then please create a repo with your source and we will try to reproduce it at our end.
azzamsa commented 5 years ago

See our code here

@talha131 Sure I read those code carefully. So that I opened the issue here. I am using the latest version of this repo. I read the code carefully, even I modify archives.html, categories.html and other to have ability for hiding page with my custom metadata.

If it is, then please create a repo with your source and we will try to reproduce it at our end.

This is my source

azzamsa commented 5 years ago

glad you like the theme!

@silverhook yes. it's very neat and beautiful :). I migrated from octopress this morning after using it for about 2 year. Very happy today, because I understand what every files are doing. I don't have any ideas why those bunch of octropess exist. Have more control now with pelican :)

We have also set up a new website for Elegant,

This conf and article examples help me a lot in this migration. It easier to see the real world example. Those "real" source really helped A LOT.

Since you’ve done some research on this already, but weren’t involved with writing the change in the first place, you’d be a perfect candidate to write that little piece. If you’re willing to volunteer, of course wink

Sure, I love python, I may take a look at this.

talha131 commented 5 years ago

@azzamsa Thanks for the quick response. I need the source code of your blog. What you have pointed me towards, is the generated html.

I need the repository which has your markdown files and pelican configuration in order to reproduce the issue at my end.

azzamsa commented 5 years ago

@talha131 Indeed that was the "source".

I put them together with the output in Github, in different branch. One for source files, another for output

talha131 commented 5 years ago

@iranzo if possible can you spare some time for this?

I tested it cursory on my end but failed to reproduce the issue. I will revisit it later, but meanwhile please look into it if it's not a trouble for you.

iranzo commented 5 years ago

I would say, based on https://github.com/getpelican/pelican/issues/1111 that 'defaults' are empty, so as we do use them we should use a comparison and use ARCHIVES_URL or 'archives.html' instead on those ocurrences

talha131 commented 5 years ago

I am lost here. I thought default function in the code should have made sure such issue do not occur.

If we change default('categories') to default('categories.html') for eg, would it fix the issue?

iranzo commented 5 years ago

AFAIK, it should, if @azzamsa confirms, I'll use the source files he indicates without the variables he indicated in this post to test

azzamsa commented 5 years ago

1) If I disable the variables setting and add '.html' to base.html : worked

modified   pelicanconf.py
@@ -6,9 +6,9 @@ AUTHOR = 'azzamsa' 
-TAGS_URL = 'tags.html'
-CATEGORIES_URL = 'categories.html'
-ARCHIVES_URL = 'archives.html'
+# TAGS_URL = 'tags.html'
+# CATEGORIES_URL = 'categories.html'
+# ARCHIVES_URL = 'archives.html'

modified   templates/base.html
@@ -73,9 +73,9 @@
-                            <li {% if page_name == 'archives' %} class="active"{% endif %}><a href="{{ SITEURL }}/{{ ARCHIVES_URL|default('archives') }}">Archives</a></li>
-                            <li {% if page_name == 'categories' %} class="active"{% endif %}><a href="{{ SITEURL }}/{{ CATEGORIES_URL|default('categories') }}">Categories</a></li>
-                            <li {% if page_name == 'tags' %} class="active"{% endif %}><a href="{{ SITEURL }}/{{ TAGS_URL|default('tags') }}">Tags</a></li>
+                            <li {% if page_name == 'archives' %} class="active"{% endif %}><a href="{{ SITEURL }}/{{ ARCHIVES_URL|default('archives.html') }}">Archives</a></li>
+                            <li {% if page_name == 'categories' %} class="active"{% endif %}><a href="{{ SITEURL }}/{{ CATEGORIES_URL|default('categories.html') }}">Categories</a></li>
+                            <li {% if page_name == 'tags' %} class="active"{% endif %}><a href="{{ SITEURL }}/{{ TAGS_URL|default('tags.html') }}">Tags</a></li>

HTTP request indicates that the file found

127.0.0.1 - - [14/Jan/2019 20:00:15] "GET /archives.html HTTP/1.1" 200 -
127.0.0.1 - - [14/Jan/2019 20:00:17] "GET /categories.html HTTP/1.1" 200 -
127.0.0.1 - - [14/Jan/2019 20:00:18] "GET /categories.html HTTP/1.1" 200 -
127.0.0.1 - - [14/Jan/2019 20:00:19] "GET /tags.html HTTP/1.1" 200 -

2) If I disable the variables setting and without adding '.html' to base.html : failed

127.0.0.1 - - [14/Jan/2019 20:02:18] "GET /categories HTTP/1.1" 404 -
127.0.0.1 - - [14/Jan/2019 20:02:18] code 404, message File not found
127.0.0.1 - - [14/Jan/2019 20:02:18] "GET /favicon.ico HTTP/1.1" 404 -
127.0.0.1 - - [14/Jan/2019 20:02:25] code 404, message File not found
127.0.0.1 - - [14/Jan/2019 20:02:25] "GET /tags HTTP/1.1" 404 -

2019-01-14-20 08 09

3) adding .html manually in step 2.

2019-01-14-20 08 24

iranzo commented 5 years ago

While testing #270 , I've tried removing the values for:

#TAGS_URL = 'tags.html'
# CATEGORIES_URL = 'categories.html'
# ARCHIVES_URL = 'archives.html'

by commenting them and it worked fine.

Please note that my updated files for 270 were rebased against master, so not sure if there was any other missing commit there

Categories, archives and tags does work and the default is the 'folder' so /categories/ /tags/ or /archives/

@azzamsa can you test the files attached to 270 and revalidate this issue?

azzamsa commented 5 years ago

@azzamsa can you test the files attached to 270 and revalidate this issue?

Dunno what happened. Tried:

1) make html with master revision

2019-01-15-11 09 50

2) make html with hide-article branch

2019-01-15-11 12 47

Nothing works. Maybe the error comes from my local machine.

iranzo commented 5 years ago

Check too with the tarball on 270

azzamsa commented 5 years ago

Downloaded, tried, no luck.

2019-01-15-14 42 52

No different in code, just some untracked files.

azzamsa commented 5 years ago

Check too with the tarball on 270

When running the 'untouched' pure tarball. It can't work, page not found. I have to uncomment the commented line from you.

iranzo commented 5 years ago

That's my diff for your pelicanconf: diff --git a/pelicanconf.py b/pelicanconf.py index 5c776d6..4e0d8d3 100755 --- a/pelicanconf.py +++ b/pelicanconf.py @@ -6,9 +6,9 @@ AUTHOR = 'azzamsa' SITENAME = 'AZZAMSA' SITEURL = 'http://localhost:8000'

-TAGS_URL = 'tags.html' -CATEGORIES_URL = 'categories.html' -ARCHIVES_URL = 'archives.html' +# TAGS_URL = 'tags.html' +# CATEGORIES_URL = 'categories.html' +# ARCHIVES_URL = 'archives.html'

And the tarball uploaded again, with 'standard' Elegant pelican theme (without customizations):

rm -Rfv themes plugins git submodule update peru sync

azzamsa.github.io-v2.zip

When running make devserver, the generated page has working ccategories, archives and tags, and the url shown in my browser is:

http://localhost:8000/archives http://localhost:8000/tags http://localhost:8000/categories/

azzamsa commented 5 years ago

Tried azzamsa.github.io-v2.zip with no changes : failed. then tried with make html:faied

Btw, I never use make deserver. I use make html/make publish then $ python -m http.server

anim

iranzo commented 5 years ago

Hi,


 iranzo  /  tmp  azzamsa  ls
azzamsa.github.io  azzamsa.github.io-v2.zip
 iranzo  /  tmp  azzamsa  cd azzamsa.github.io/
 iranzo   test  /  tmp  azzamsa  azzamsa.github.io  ls
content   output          peru.yaml  publishconf.py  requirements.txt  themes
Makefile  pelicanconf.py  plugins    __pycache__     tasks.py
 iranzo   test  /  tmp  azzamsa  azzamsa.github.io  make devserver
pelican -lr /tmp/azzamsa/azzamsa.github.io/content -o /tmp/azzamsa/azzamsa.github.io/output -s /tmp/azzamsa/azzamsa.github.io/pelicanconf.py 

-> Modified: content, theme, settings, [static]theme/images, [static]images. re-generating...
Done: Processed 19 articles, 0 drafts, 0 pages, 0 hidden pages and 0 draft pages in 0.59 seconds.
127.0.0.1 - - [16/Jan/2019 14:55:45] "GET / HTTP/1.1" 200 -
127.0.0.1 - - [16/Jan/2019 14:55:45] "GET /theme/css/style.min.css?8bdcf96a HTTP/1.1" 304 -
127.0.0.1 - - [16/Jan/2019 14:55:46] "GET /archives HTTP/1.1" 200 -
127.0.0.1 - - [16/Jan/2019 14:55:47] "GET /categories/ HTTP/1.1" 200 -
127.0.0.1 - - [16/Jan/2019 14:55:49] "GET /tags HTTP/1.1" 200 -
127.0.0.1 - - [16/Jan/2019 14:55:50] "GET /archives HTTP/1.1" 304 -

Still works for me on a new temporary folder being created for this.

If you've pipsi installed can you try with latest pelican version and use make devserver which uses the pelican builtin server?

azzamsa commented 5 years ago

Strange, make devserver work, but why python -m http.server didn't work.

So, if make devserver worked. If I do make github if this work in my github pages deployment ?

azzamsa commented 5 years ago

As far as I know browser will read index.html if it read a folder, this same behavior of jekyll, when we created pages about. it created about-dir/index.html.

I suspect devserver handle this 'magically'.

iranzo commented 5 years ago

I always did make devserver, tested and then make github and it worked, but it's easy for you to give it a try :-)

azzamsa commented 5 years ago

DONE. Summary:

Even if non direct link didn't work with python -m http.server github pages will render it just fine.

I think pelican had already handle non direct link magically. If I am not mistaken.

Thank you for all the help, thanks a ton for very very kind and supportive, Elegant team. :tada:

talha131 commented 5 years ago

Thanks a lot @iranzo. Great job.