You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Option to use the filename as slug instead #+TITLE #27
I like the possibility of using a post title as the slug but it would be great to support the filename as source for the "slugify" function as well. Maybe a variable weblog-filename-slugs and :filename-slugs option in routes to switch to filename based slugs works great.
I would to be able to rename a title without worrying about it changing the URL that might have been bookmarked or indexed already, or add a #+SLUG on every file. Also I would to be able to use [[file:path/to/file.org]] to link internal pages so I could browse my Org files in Emacs the same way in a web browser.
I like the idea of adding it as a configuration switch; and the direct translation of the file name in an existing archive makes the point extremely compelling!
Hmm, I think I may have overthought this issue; what if instead of adding a switch, we added just another property to the post? something like file_slug? Which would then contain the output of feeding basename of the file path into slugify. Do you think that would work for you?
On Tue, 2 Mar 2021, at 23:54, Lincoln de Sousa wrote:
Hmm, I think I may have overthought this issue; what if instead of adding a switch, we added just another property to the `post`? something like `file_slug`? Which would then contain the output of feeding basename of the file path into slugify. Do you think that would work for you?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub <#27 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AAAHJJVC3NVN7XACDGZNFK3TBWQFBANCNFSM4X7FBAGQ>.
I can't use {{ file_slug }} in :url, and in templates {{ post.slug }} should be rewritten to {{ post.file_slug }}. So I'm wondering if we could change this to a different implementation, a slug-format option per route:
Where FORMAT could be a callback function, which defaults to slugified title, what allow me have a function (lambda (post) (weblorg--slugify (file-name-sans-extension (file-name-nondirectory post.file))). The default value for slug-format could be (weblorg-site :slug-format) or the slugified title if none is set.
With this in mind, every reference to slug, either in templates or (weblorg-route :url), would refer to the return value of the slug format function.
Would be great to support this kind of strings in routes as well: "{{ post.date | slugify }}". A full example:
hi @semente, thank you for the PR removing the file extension; I don't know why I left it in there 😄
hmm, why can't you use file_slug in :url?
On the idea around slug-format, I wonder if you have a use case for these other variants. I think the file_slug thing would help with the use case you have with the tree of org files that you want to just publish with the same name but .html. I'm just asking because there's some refactoring I'm planning to do on the way we're piping parsed data from org files to the aggregation function and I'm trying to see how flexible this new thing I'm planning would need to be.
Template Error: parameter :url of route pages: Variable `file_slug' not declared
I wonder if you have a use case for these other variants
I was thinking about allowing URLs like /2021-03-16-slug.html or any other popular format but that could be the case of just having the filename in the format you wish when using file_slug...
Anyway, file_slug works but it is currently confusing/inconsistent. Look how it looks like:
As you can see only :output property needs to have file_slug. And it won't work if you use it in other places, which is actually right for templates once if the site is reusing a theme it will work without the need of modifications everywhere it uses post.slug. But because of that this makes it confusing for the developer because it is not clear how it works.
That is how it works currently: if you use file_slug in :output, it makes all references to slug return the value of file_slug. But that is hard to interpret. In this case an option would be more clear:
yeah, I think adopting a more flexible way of creating the slug might be a better solution.
The one thing I still have in mind is the possible connection of this issue with #32.
I wanted to try to find a good design for supporting the use case you mentioned, where you're trying to mimic the structure of a file system directory with org mode files that just translate into .html files.
Do you think it makes sense to try to find something in common in these two issues or do you think by implementing these two separate things (this issue and #32) we'd give you that experience? Sorry for all the back and forth and thanks for all the help and feedback 😄
You mean having a function similar to (weblorg-route) that could export a directory, converting orgs to htmls and copying the other files? It works too and looks interesting but not sure.
In any case, #32 still might be interesting for some use cases but I'm actually using rsync to copy other files than ".org" and that is enough for me.
(weblog-directory
:name "my-directory"
:directory "path/to/dir/"
:recursive nil
:template "page.html" ;; the default template, set a different one per file using `#+TEMPLATE:`
:output ".build/my-directory/"
:url "/my-directory/"
:copy-other-files t)
I think the proposal that you have here for a field for configuring the slug is the nicest one, where we can provide default functions for "replacing extension", "slugifying", "slugifying with title" etc. I think it'd be nice to implement this in terms of #32 though, just so we can do this on a per "handler" basis. (Definition of handling is described in #32)
I think it'd be nice to implement this in terms of #32 though, just so we can do this on a per "handler" basis. (Definition of handling is described in #32)
Activity
clarete commentedon Feb 21, 2021
I like the idea of adding it as a configuration switch; and the direct translation of the file name in an existing archive makes the point extremely compelling!
clarete commentedon Mar 3, 2021
Hmm, I think I may have overthought this issue; what if instead of adding a switch, we added just another property to the
post? something likefile_slug? Which would then contain the output of feeding basename of the file path into slugify. Do you think that would work for you?semente commentedon Mar 3, 2021
clarete commentedon Mar 3, 2021
Just added it, try it out! 😄
tests: add fixture to test of issue #27
semente commentedon Mar 4, 2021
I think this deserve a mention in https://emacs.love/weblorg/api.html#symbol-weblorg-route :)
semente commentedon Mar 4, 2021
And thank you very much by the way! I'll be testing all the recent changes asap!
semente commentedon Mar 6, 2021
Hey @clarete, I'm using this now. It works and, with the help of #39, I now can do what I would but I felt it a bit confusing. Look what I got:
I can't use
{{ file_slug }}in:url, and in templates{{ post.slug }}should be rewritten to{{ post.file_slug }}. So I'm wondering if we could change this to a different implementation, aslug-formatoption per route:Where FORMAT could be a callback function, which defaults to slugified title, what allow me have a function
(lambda (post) (weblorg--slugify (file-name-sans-extension (file-name-nondirectory post.file))). The default value forslug-formatcould be(weblorg-site :slug-format)or the slugified title if none is set.With this in mind, every reference to
slug, either in templates or(weblorg-route :url), would refer to the return value of the slug format function.Would be great to support this kind of strings in routes as well:
"{{ post.date | slugify }}". A full example:Well, that is what I have in mind but I'm not sure what is the best solution here or if this is too complex to implement.
clarete commentedon Mar 8, 2021
hi @semente, thank you for the PR removing the file extension; I don't know why I left it in there 😄
hmm, why can't you use
file_slugin:url?On the idea around
slug-format, I wonder if you have a use case for these other variants. I think thefile_slugthing would help with the use case you have with the tree of org files that you want to just publish with the same name but.html. I'm just asking because there's some refactoring I'm planning to do on the way we're piping parsed data from org files to the aggregation function and I'm trying to see how flexible this new thing I'm planning would need to be.semente commentedon Mar 16, 2021
Hey @clarete! It doesn't work:
I was thinking about allowing URLs like
/2021-03-16-slug.htmlor any other popular format but that could be the case of just having the filename in the format you wish when usingfile_slug...Anyway,
file_slugworks but it is currently confusing/inconsistent. Look how it looks like:And in templates
As you can see only
:outputproperty needs to havefile_slug. And it won't work if you use it in other places, which is actually right for templates once if the site is reusing a theme it will work without the need of modifications everywhere it usespost.slug. But because of that this makes it confusing for the developer because it is not clear how it works.That is how it works currently: if you use
file_slugin:output, it makes all references toslugreturn the value offile_slug. But that is hard to interpret. In this case an option would be more clear:But my proposal is to make it more flexible to fit in different use cases:
Also would be great to have a way to set a default slug format for all routes:
clarete commentedon Apr 10, 2021
yeah, I think adopting a more flexible way of creating the slug might be a better solution.
The one thing I still have in mind is the possible connection of this issue with #32.
I wanted to try to find a good design for supporting the use case you mentioned, where you're trying to mimic the structure of a file system directory with org mode files that just translate into
.htmlfiles.Do you think it makes sense to try to find something in common in these two issues or do you think by implementing these two separate things (this issue and #32) we'd give you that experience? Sorry for all the back and forth and thanks for all the help and feedback 😄
semente commentedon May 26, 2021
hey @clarete, sorry for the delay!
You mean having a function similar to
(weblorg-route)that could export a directory, converting orgs to htmls and copying the other files? It works too and looks interesting but not sure.In any case, #32 still might be interesting for some use cases but I'm actually using rsync to copy other files than ".org" and that is enough for me.
semente commentedon May 26, 2021
This came in my mind:
clarete commentedon Sep 6, 2021
I think the proposal that you have here for a field for configuring the slug is the nicest one, where we can provide default functions for "replacing extension", "slugifying", "slugifying with title" etc. I think it'd be nice to implement this in terms of #32 though, just so we can do this on a per "handler" basis. (Definition of handling is described in #32)
semente commentedon Sep 11, 2021
I agree