Logs for #nikola for 2016-10-07

09:40:55 <KwBot> [nikola] popey opened issue #2524: Missing dependency in snap https://github.com/getnikola/nikola/issues/2524
21:59:52 <njs> hello! I would like to do something a little unusual. I want to write a blog post + associated source code files and put them all into the same directory, so like: posts/my-post/index.rst, posts/my-post/example.py, and have those end up at /posts/my-post/ and /posts/my-post/example.py.html
22:00:44 <ToApolytoXaos> njs: why would you want to do such thing?
22:00:54 <ToApolytoXaos> you can simply include your portion inline
22:01:33 <njs> ToApolytoXaos: because the example code is complicated enough that I want to write it in its own file, where I get proper editor support and can run the code to test it
22:02:03 <njs> ToApolytoXaos: and potentially take advantage of the fancier listing features to include only selected portions of the code inline while linking to the full example for those who want it
22:02:21 <njs> it seems like this is.... almost supported? for getting the post body itself into the right place, it seems to work if I set STRIP_INDEXES = True, and name the file "index.rst", and leave the slug empty.
22:03:52 <njs> And if I set LISTINGS_FOLDERS = {'listings': 'listings', 'posts': 'posts'} .... then I get an error with the demo site, because the demo has a file listings/hello.py and a page that does .. listing:: hello.py, and somehow when I add posts to the LISTINGS_FOLDER dict then nikola stops being able to find hello.py
22:05:09 <njs> but if I kill the regular 'listings' directory by setting LISTINGS_FOLDER = {
22:05:11 <njs> but if I kill the regular 'listings' directory by setting LISTINGS_FOLDER = {
22:05:31 <njs> but if I kill the regular 'listings' directory by setting LISTINGS_FOLDER = {'posts': 'posts'} then I guess that's okay. Then the one remaining problem is:
22:05:33 <njs> ERROR: Two different tasks can't have a common target.'output/posts/test2/index.html' is a target for render_listings:output/posts/test2/index.html and render_pages:output/posts/test2/index.html.
22:06:18 <ToApolytoXaos> hmm, I haven't done such thing before, but I would guess you could include those files inside files/ directory
22:06:22 <ToApolytoXaos> I could be wrong here though
22:06:29 <njs> So (a) is there any way to disable the generation of listings index pages? and (b) should I be reporting some sort of bug for the weird behavior with LISTINGS_FOLDERS = {'listings': 'listings', 'posts': 'posts'}?
22:06:39 <ToApolytoXaos> ChrisWar1ick or ralsina would be the right people to ask such kind of questions
22:07:06 * ralsina peeks
22:07:47 <ralsina> njs: you can do that by either adding your listing folder in POSTS or your posts folder in LISTINGS
22:08:02 <ralsina> either way you will end up with a folder where you can put posts and listings :-)
22:08:17 <ralsina> I suggest adding listings/ to POSTS for less noise
22:08:54 <ralsina> OTOH that is totally untested and can easily end up trying to create the same file twice and failing to build
22:08:58 <ralsina> so consider it a hint
22:09:25 <ralsina> Other than that, maybe something doing symlinks to make the folder be in both places (waves hands to avoid figuring out details)
22:10:03 <njs> ralsina: so I tried adding posts to LISTINGS_FOLDER, and got (a) weird errors trying to refer to listings, and (b) got the ERROR pasted above with conflicting index.htmls
22:11:25 <ToApolytoXaos> ralsina: but njs wants to use those files for demonstrative purposes; why not place them inside files/ directory and make another sub-directory called assets, much like we do with a custom css file?
22:13:17 <njs> ToApolytoXaos: because I don't want these to be simply copied raw to the output, actually like the special listings behavior (integration with .. listing:, generation of a syntax-highlighted foo.py.html page, etc.)
22:14:30 <ToApolytoXaos> then, indeed you need to include them as ralsina told you
22:14:41 <ToApolytoXaos> they need to get parsed and become .py.html
22:20:35 <ralsina> ToApolytoXaos: things put in files are not transfotrmed at all
22:20:44 <ralsina> ToApolytoXaos: listings/ does pretty things to source code
22:21:04 <ralsina> njs: then I have an idea
22:21:05 <ToApolytoXaos> ralsina: that's why I said "then, indeed you need to include them as ralsina told you"
22:21:25 <ralsina> njs: are you on linux?
22:21:28 <njs> yes
22:21:42 <ralsina> njs: ok, then create the post in posts/ and the listings in listings
22:22:05 <ralsina> then do a link (not a symlink) from the post to the listings/ folder where your code is
22:22:11 <ralsina> no changes in conf.py
22:22:22 <ralsina> and then just edit the post from listings/ and everyone is happy
22:22:23 <njs> (btw I have now read the listings rst plugin code, and now do understand what's going on with the rules for referring to the file. kinda annoyed by it because it doesn't allow for using a relative path, but understand it :-))
22:22:38 <njs> ralsina: when you say link you mean a hard link?
22:22:42 <ralsina> njs: as a rule, try to always use absolute paths in nikola
22:22:46 <ralsina> njs: yes, a hard link
22:22:55 <ralsina> "absolute" as in "from output/"
22:23:09 <ralsina> you can even link to listings by name without path if they are unique
22:23:24 <ralsina> link://listing/foo.py ... as long as there is only one foo.py that will point to the right place
22:23:35 <njs> ralsina: of course the final html should use absolute links, but it would be nice to be able to have foo.rst and foo-example.py in the same directory and then just write '.. listing: foo-example.py', this isn't ambiguous :-)
22:23:52 <ralsina> that will work most of the time, actually
22:24:16 <ralsina> but yes, nikola imposes an artificial separation into multiple trees that is ... weird in some cases, I know.
22:24:17 <njs> ralsina: and AFAICT that's not true for the filename in .. listing:. there it either has to be absolute, or if you have exactly one entry in LISTINGS_FOLDER then it can be relative to that path. but there's no search logic.
22:24:47 <ralsina> then file me a bug, because I know I can fix it since I already did it for the link:// syntax :-)
22:25:04 <njs> https://github.com/getnikola/nikola/blob/master/nikola/plugins/compile/rest/listing.py#L178
22:25:13 <ralsina> the code is there, it just needs some small rewiring
22:25:54 <ralsina> https://github.com/getnikola/nikola/blob/master/nikola/plugins/task/listings.py#L275
22:26:08 <ralsina> just need to make one use the other or both use a 3rd thing
22:26:38 <ralsina> heck, self.site.path('listing', 'foo.py') in the listing directive would do 90% of the work
22:27:11 <njs> nod
22:27:37 <njs> though to be fair, I'd actually rather relative path lookup take priority over 'search everything and guess'
22:28:40 <njs> If I have post1/index.rst, post1/example.py, post2/index.rst, post2/example.py, then that seems totally reasonable (the examples belong to particular posts, they aren't a global property of the blog), and inside post1/index.rst examplepy should refer to post1/example.py, similarly for post2/index.rst
22:29:30 <ralsina> njs: well, the directive doesn't really know what the URL of the file you are compiling is
22:29:51 <ralsina> although it could
22:30:18 <ralsina> njs: usually the ideal way to fix this is to start an issue with a carefully thought-out description of a "good" behaviour
22:30:41 <ralsina> then if that doesn't break expectations of others much, it usually gets done sooner or later
22:31:35 <njs> it also looks like the simple fix for my main bug with the conflicting index.html things would be if there were some way to override the index_file name that listings.py uses
22:31:40 <njs> e.g at this line: https://github.com/getnikola/nikola/blob/master/nikola/plugins/task/listings.py#L65
22:31:46 <njs> replace with:
22:32:16 <njs>   "index_file": site.config.get("LISTINGS_INDEX_FILE", site.config[INDEX_FILE])  # use LISTINGS_INDEX_FILE if defined, otherwise fall back on INDEX_FILE
22:33:45 <ralsina> well, usually index files should all be called the same, right?
22:34:14 <ralsina> we could not do listing indexes but those are usually a good idea
22:34:42 <ralsina> nikola already has too many options :-P
22:35:31 <ralsina> if you add the post to listings/ and listings/ to POSTS, then you can do something like listings/foo/post.txt listings/.foo/code/whatever.py
22:35:43 <ralsina> that should avoid conflicts
22:36:29 <njs> I would really prefer a solution that ends up with urls like https://.../my-post/, https://.../my-post/example.py.html
22:37:01 <njs> since that's what makes sense on the URL side, and there is the theory that you should start with your URL structure and design everything else to match it
22:37:12 <njs> esp. since the URLs are what you'll be stuck with if you ever switch to another system :-)
22:37:21 <ralsina> yeah, and nikola usually lets you do almost any URL schema, you found one we can't :-P
22:38:00 <ralsina> you can do a patch to disable generating indexes for listings, of course, it's a couple of lines
22:38:28 <ralsina> OR
22:38:32 <njs> yeah. would that be likely to be accepted if I send a PR?
22:38:40 <ralsina> I could do a "listings compiler"!!!!
22:39:08 <ralsina> You would have https://....my-post/ and https://.../my-post/example.py/
22:39:18 <ralsina> Should be a rather simple plugin, too
22:39:51 <ralsina> njs: if you do it with a setting, sure, why not, specially if you describe the usecase
22:40:07 * ralsina wonders how many settings we have already
22:40:53 <ralsina> Answer is 170
22:40:56 <ralsina> or so
22:41:54 <njs> this listings compiler idea sounds intriguing, though I'm not sure I understand :-)
22:42:19 <ralsina> maybe better than a setting would be an extra, optional field in LISTINGS, like {'listings':: 'listings', 'listingswithoutindexes' ('posts/' , False)}
22:42:40 <ralsina> njs: well, something that takes source code and produces the equivalent of its listings/ page
22:44:08 <ralsina> even some convention, like "listings: listings" generates indexes but listings: *listings doesn't
22:44:13 <ralsina> but that's probably bad UX
22:44:37 <njs> a bit messy too since there are multiple places int he codebase that directly access the LISTINGS_FOLDER dict
22:44:50 <ralsina> yes, but hey, that's life
22:45:08 <ralsina> njs: please file an issue describing the usecase so this discussion doesn't leak out of my brain today.
22:45:11 <ralsina> Now I gotta go :-)
22:45:12 <njs> okay
22:45:15 <njs> see ya
22:45:17 <njs> and thanks!
22:55:38 <KwBot> [nikola] ralsina assigned issue #2524 to ralsina: Missing dependency in snap https://github.com/getnikola/nikola/issues/2524
23:41:55 <ToApolytoXaos> ralsina: oh shoot..you left? I think I might have detected a bug with import_blogger
23:44:04 <ToApolytoXaos> when the data gets imported from a Greek dump blogger file, it does not take the title to build a slag inside .meta files
23:44:47 <ToApolytoXaos> it tries to guess the blog post name and either uses a generic name, like "blog-post" or a plain number it finds inside the title tag
23:45:58 <ToApolytoXaos> for instance, if my title were "αυτή είναι μια δοκιμή", which translates to "this is a test", shouldn't the slag take that title and generate something like "αυτή-είναι-μια-δοκιμή"?
23:52:05 <ToApolytoXaos> aaaaah, it's not a bug :/ it's the shitty blogger -_-
23:52:30 <ToApolytoXaos> it behaves the same with original blogspot website