Closed felixfontein closed 8 years ago
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
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.
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:
about
in hierarchyHierarchy 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.)
Using Post
to load the metadata is a good idea. I'll implement that. Though without integrating it into the os.walk
loop.
Is there any more discussion needed? Can I merge this?
I’m not sure if this plugin should exist. @ralsina?
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 https://github.com/getnikola/plugins/pull/179#issuecomment-255544578, or mute the thread https://github.com/notifications/unsubscribe-auth/AAAGK-H1Il9MapKdrugLGBrjoMszes8wks5q2lJ2gaJpZM4KXpQD .
Thanks for merging!
Part 2 of accidentally merged #178.