Skip to content

Fix bug in LektorInfo.resolve_artifact (fix #16)#136

Closed
item4 wants to merge 1 commit into
lektor:masterfrom
item4:master
Closed

Fix bug in LektorInfo.resolve_artifact (fix #16)#136
item4 wants to merge 1 commit into
lektor:masterfrom
item4:master

Conversation

@item4
Copy link
Copy Markdown
Contributor

@item4 item4 commented Jan 29, 2016

lektor.admin.webui.resolve_artifact must need path param.
But if given path is pagination dir, older method return None and cause 404.
My patch make to test filename for checking its type. If it is dir, method find index file in it and resolve it.

lektor.admin.webui.resolve_artifact must need path param.
But if given path is pagination dir, older method return None and
cause 404.
My patch make to test filename for checking its type. If it is dir,
method find index file in it and resolve it.
@mitsuhiko
Copy link
Copy Markdown
Member

I'm a bit confused why this is necessary but I will check this in detail. Pretty sure this should resolve the filename from the main path and not the fallback.

@item4
Copy link
Copy Markdown
Contributor Author

item4 commented Jan 31, 2016

from #16

  • page 1: /
  • page 2: /page/2/ (403) → /page/2/index.html (200)
  • page 3: /page/3/ (403) → /page/3/index.html (200)

I generated /page/N/ by lektor pagination but lektor devserver cannot serve it.

I checked Pad.resolve_url_path first, but it do not touch /page/N/, it just return None.

@item4
Copy link
Copy Markdown
Contributor Author

item4 commented Jan 31, 2016

Pad.resolve_url_path use two method.

Page.resolve_url_path can not find /page/N/ because /page/N/ does not have slug.
Directory.resolve_url_path also can not find because is not asset.

@mitsuhiko
Copy link
Copy Markdown
Member

Page.resolve_url_path can not find /page/N/ because /page/N/ does not have slug.

I'm confused. Why would that not be able to resolve the URL path? It has a branch to support pagination.

@item4
Copy link
Copy Markdown
Contributor Author

item4 commented Jan 31, 2016

>>> from lektor.project import Project
>>> project = Project.discover()
>>> env = project.make_env()
>>> pad = env.new_pad()
>>> pad.root
<Page model=u'blog' path='/'>
>>> pad.root.children
<Query '/' alt='_primary'>
>>> pad.root.children.all()
[<Page model=u'blog-post' path=u'/2016-01-29-Thinking-In-Company-Framework'>, <Page model=u'blog-post' path=u'/2016-01-26-Homepage-101'>, <Page model=u'blog-post' path=u'/2015-12-23-Move-to-Lektor'>, <Page model=u'blog-post' path=u'/2015-12-19-Naver-and-HTTPS'>, <Page model=u'blog-post' path=u'/2015-12-15-My-New-Otaku-Blog'>, <Page model=u'blog-post' path=u'/2015-12-13-Ichimatsu-no-Hide-and-Seek'>, <Page model=u'blog-post' path=u'/2015-12-12-Time-Machine-For-CS-Part-3'>, <Page model=u'blog-post' path=u'/2015-11-21-Arguments-of-setuptools.setup'>, <Page model=u'blog-post' path=u'/2015-11-13-Time-Machine-For-CS-Part-2'>, <Page model=u'blog-post' path=u'/2015-11-02-Time-Machine-For-CS-Part-1'>, <Page model=u'blog-post' path=u'/2015-10-30-A-Short-Postscript-about-Using-PHP-7.0rc6'>, <Page model=u'blog-post' path=u'/2015-10-26-Understanding-Python-__getitem__-and-slice'>, <Page model=u'blog-post' path=u'/2015-10-24-Story-of-Developing-Front-End-Nowaday'>, <Page model=u'blog-post' path=u'/2015-10-21-Install-TT-RSS-on-Ubuntu-15.04'>, <Page model=u'blog-post' path=u'/2015-10-13-Misunderstanding-about-Mental-Health'>, <Page model=u'blog-post' path=u'/2015-10-12-How-to-Become-a-Great-JavaScript-Developer'>, <Page model=u'blog-post' path=u'/2015-10-10-International-Aheui-Developer-Conf'>, <Page model=u'blog-post' path=u'/2015-10-08-An-Advice-About-Mildly-Better-Way-to-Write-a-Cover-Letter'>, <Page model=u'blog-post' path=u'/2015-09-29-Make-ELB-And-Apply-SSL(HTTPS)'>, <Page model=u'blog-post' path=u'/2015-09-28-Find-Password-Slowly-If-You-Lost-Password-of-RAR-File'>, <Page model=u'blog-post' path=u'/2015-09-24-I-Do-Not-Read-Your-Facebook-Post'>, <Page model=u'blog-post' path=u'/2015-09-15-Defend-Software-Maestro'>, <Page model=u'blog-post' path=u'/2015-08-31-Closers-House-Keeper-Costume-Simulator'>, <Page model=u'blog-post' path=u'/2015-08-20-Looking-for-a-Job'>, <Page model=u'blog-post' path=u'/2015-08-20-There-is-NO-Seperation-Productive-Hobby-Comsuming-Hobby'>, <Page model=u'blog-post' path=u'/2015-08-20-Come-Back-to-My-World'>, <Page model=u'blog-post' path=u'/2015-07-29-Windows-Update-Sucks'>, <Page model=u'blog-post' path=u'/2015-07-27-Successful-Yak-Shaving-Unsuccessful-Yak-Shaving'>, <Page model=u'blog-post' path=u'/2015-07-24-Extension-of-Basical-Data-Type'>, <Page model=u'blog-post' path=u'/2015-07-22-Do-Not-Brew-Language-Installing-Language-by-Homebrew-Is-NOT-Clean'>, <Page model=u'blog-post' path=u'/2015-07-20-Python-AST-101'>, <Page model=u'blog-post' path=u'/2015-07-18-Some-Ambiguousness-in-Python-Tutorial-Call-by-What'>, <Page model=u'blog-post' path=u'/2015-07-16-Library-Idea-Emaillib'>, <Page model=u'blog-post' path=u'/2015-07-14-The-Syntax-Highlighter-of-Jekyll-with-GitHub-Pages'>, <Page model=u'blog-post' path=u'/2015-07-11-I18n-of-JS-The-Right-Way'>, <Page model=u'blog-post' path=u'/2015-07-09-Creating-Custom-AES-Functions-for-SQLAlchemy'>, <Page model=u'blog-post' path=u'/2015-07-07-What-is-the-PKCS-algorithm-version-of-PostgreSQL'>, <Page model=u'blog-post' path=u'/2015-07-05-Internal-of-sqlalchemy.sql.expression.func'>, <Page model=u'blog-post' path=u'/2015-07-05-Cute-Polar-Bear'>]

I can't find pagination page in root.children

@mitsuhiko
Copy link
Copy Markdown
Member

I see. In that case the code for pagination lookup is broken for the root case and should be fixed. I will investigate this.

@mitsuhiko
Copy link
Copy Markdown
Member

BTW. Pagination is not supposed to be in root.children. It's only supposed to show up via resolve_url_path. There is custom code for it.

@item4
Copy link
Copy Markdown
Contributor Author

item4 commented Jan 31, 2016

information in my env

>>> pad.root.supports_pagination
True
>>> pad.root.pagination
<lektor.pagination.Pagination object at 0x10e728410>
>>> pad.root.pagination.pages
8

@mitsuhiko mitsuhiko closed this in 9fcd60c Jan 31, 2016
@mitsuhiko
Copy link
Copy Markdown
Member

@item4 can you check if my commit fixes the problem?

@item4
Copy link
Copy Markdown
Contributor Author

item4 commented Jan 31, 2016

@mitsuhiko It works fine. 👍

xlotlu pushed a commit that referenced this pull request Jun 13, 2020
xlotlu pushed a commit that referenced this pull request Jun 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants