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

Improving hierarchical_pages. #179

Merged
merged 6 commits into from Oct 25, 2016
Merged

Improving hierarchical_pages. #179

merged 6 commits into from Oct 25, 2016

Conversation

@felixfontein
Copy link
Contributor

felixfontein commented Oct 15, 2016

Part 2 of accidentally merged #178.

@Kwpolska
Copy link
Member

Kwpolska commented Oct 15, 2016

I’m not sure I understand any of this plugin. This looks like a solution looking for a problem, with 179 lines of code that are just unneeded.

Why are they unnecessary? This is all you need to achieve your directory structure, with getnikola/nikola#2502 in place:

PAGES = (
    ("pages/about/team/*.rst", {"en": "about/team", "de": "ueber/mitarbeiter"}, "story.tmpl"),
    ("pages/about/*.rst", {"en": "about", "de": "ueber"}, "story.tmpl"),
    ("pages/*.rst", "", "story.tmpl"),
)
PRETTY_URLS = True

Which becomes:

(nikola) [kwpolska@Kw-Farore n]% tree pages
pages
├── about
│   ├── company.de.rst
│   ├── company.rst
│   ├── team
│   │   ├── nikola-tesla.de.rst
│   │   ├── nikola-tesla.rst
│   │   ├── roberto-alsina.de.rst
│   │   └── roberto-alsina.rst
│   ├── team.de.rst
│   └── team.rst
├── about.de.rst
└── about.rst

2 directories, 10 files
(nikola) [kwpolska@Kw-Farore n]% tree output/about
output/about
├── company
│   ├── index.html
│   └── index.rst
├── index.html
├── index.rst
└── team
    ├── index.html
    ├── index.rst
    ├── nikola-tesla
    │   ├── index.html
    │   └── index.rst
    └── roberto-alsina
        ├── index.html
        └── index.rst

4 directories, 10 files
(nikola) [kwpolska@Kw-Farore n]% tree output/de/ueber
output/de/ueber
├── firma
│   ├── index.html
│   └── index.rst
├── index.html
├── index.rst
└── mitarbeiter
    ├── index.html
    ├── index.rst
    ├── nikola-tesla
    │   ├── index.html
    │   └── index.rst
    └── roberto-alsina
        ├── index.html
        └── index.rst

4 directories, 10 files
@felixfontein
Copy link
Contributor Author

felixfontein commented Oct 15, 2016

Yes, you can solve it also like that, but that requires putting all that information into the config! Also, if you use more than one input format, you have to do a lot of repetitions which make it easy to screw something up accidentally.

Having to write everything out is for me the same as having to specify .. path: xxx in every post, which is what you didn't like about my original idea (and which I can understand very well).

This plugin allows to specify all paths by using a simple hierarchy in the input folders, and by using the metadata which is already there (i.e. .. slug: xx), to automatically construct the translated hierarchy without user intervention or complicated configuration changes.

@Kwpolska
Copy link
Member

Kwpolska commented Oct 15, 2016

This is not like .. path: at all. That meta tag would be repeated all over your posts, while this solution puts them just once in the config. And even a lot of input formats won’t make it that bad, if you can copy-paste stuff right.

This code, as it stands, looks bad. I see this FakePost is needed to use post.get_meta, but is that really necessary, including calculating meta twice? Here’s an idea of how to organize things better — and perhaps with less hacks:

  1. find only files in pages/*.rst → [about.rst] and turn them into Post objects, save into timeline and hierarchy
  2. find only files in pages/about/*.rst → [company.rst, team.rst] → find the directory path by checking the slug for about in hierarchy
  3. find only files in pages/about/team/*.rst and do the procedure again

Hierarchy in this example could be a dict of {path: {translations}} (having the post object here is not even needed). So by the time pages/about/company.rst is found, it would be able to see that 'about' can be translated into 'about' and 'ueber'. The os.walk function is perfect for this (other than you’ll have to take care of file extensions yourself)

(I reverted the merge for now, as you might have noticed.)

@felixfontein
Copy link
Contributor Author

felixfontein commented Oct 15, 2016

Using Post to load the metadata is a good idea. I'll implement that. Though without integrating it into the os.walk loop.

@felixfontein
Copy link
Contributor Author

felixfontein commented Oct 22, 2016

Is there any more discussion needed? Can I merge this?

@Kwpolska
Copy link
Member

Kwpolska commented Oct 22, 2016

I’m not sure if this plugin should exist. @ralsina?

@ralsina
Copy link
Member

ralsina commented Oct 25, 2016

Why not. plugins are by the will of those who do them.

El sáb., 22 oct. 2016 20:14, Chris Warrick notifications@github.com
escribió:

I’m not sure if this plugin should exist. @ralsina
https://github.com/ralsina?


You are receiving this because you were mentioned.

Reply to this email directly, view it on GitHub
#179 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAAGK-H1Il9MapKdrugLGBrjoMszes8wks5q2lJ2gaJpZM4KXpQD
.

@Kwpolska Kwpolska merged commit 6640529 into master Oct 25, 2016
2 checks passed
2 checks passed
continuous-integration/travis-ci/pr The Travis CI build passed
Details
continuous-integration/travis-ci/push The Travis CI build passed
Details
@Kwpolska Kwpolska deleted the improving-hierarchical-pages branch Oct 25, 2016
@felixfontein
Copy link
Contributor Author

felixfontein commented Oct 25, 2016

Thanks for merging!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants
You can’t perform that action at this time.