emacs-love / weblorg

Static Site Generator for Emacs
https://emacs.love/weblorg
GNU General Public License v3.0
280 stars 21 forks source link

Links in menu, posts sorting, tag based parsing and rules #55

Open MorphicResonance opened 3 years ago

MorphicResonance commented 3 years ago

Template question. How to edit template to not include link into site menu to the same page. For example on the site of weblorg we go on the page "Blogging". Into the footer of this page we see active link to the same "Blogging". I want to make such links inactive.

Post sorting. Is there way to make sorting of posts not just as datestamps but under other conditions. Be able to pin one post higher than others.

Is there a plan to make publishing with weblorg from defined node of any .org file. I mean that some function may parse .org files search for tagged nodes (as :blog: or :publish: , something like this) and create .org files for weblorg. Then run standart publishing procedure. This can be developed with cascade of functions into Elisp . For me this can be really realized with python script Orgparse.

Do you plan to develop an autoextraction of first n-words of the post (anounce) for index page of the blog?

Idea of tags as rules for the choice of template(route). If I have one file tagged as :blog: and other tagges as :homepage: being in one folder they will be processed with different templates. So users be able to have not only flat real site structure but also the same flat/virtual on desktop.

clarete commented 3 years ago

hi hi @MorphicResonance, sorry it took me quite a bit to get to this issue. here goes my attempt to answer your questions:

Template question. How to edit template to not include link into site menu to the same page. For example on the site of weblorg we go on the page "Blogging". Into the footer of this page we see active link to the same "Blogging". I want to make such links inactive.

after parsing each Org-Mode file, weblorg attaches the route object (currently providing only the name attribute) to the parsed structure. That way, when that file is rendered, the route.name attribute will be the route that file belongs. I ended up just using that to make manual comparisons when building the menu of the weblorg documentation website theme. e.g:

<li><a href="{{ url_for("index") }}">home</a></li>
<li{% if route.name == "docs" %} class="active"{% endif %}>
    <a href="{{ url_for("docs", slug="index") }}">documentation</a>
</li>
<li{% if route.name == "api" %} class="active"{% endif %}>
    <a href="{{ url_for("api") }}">api reference</a>
</li>

this is an excerpt from the layout file weblorg's website.

Post sorting. Is there way to make sorting of posts not just as datestamps but under other conditions. Be able to pin one post higher than others.

I tried to get ready to answer this question by publishing some preliminary documentation on how aggregation functions work. and also took a stab at documenting what you already seem to know about the sorting via timestamps and the date attribute:

That said, the short answer to this question is no. There is no aggregation function that sorts posts in any way that's different from the timestamp. That is indeed something wanted and any insights in how we could get a nice API to allow that to happen would be very much appreciated.

If you allow me some rambling: Sorting might be too special of a situation to the point that it'd be nice to decouple it from the aggregation. if that's the case, meaning that they're really actually better to be handled together, maybe sorting still needs its own set of parameters instead of just relying on new aggregate functions being written that don't really change aggregation but just sorting. (this is what we have right now, we have aggregate functions with and without the suffix -desc. With this current style, the API might grow quite repetitive, and we won't be able to re-use the sorting. I feel like following changes would allow us to accommodate more flexible sorting:

  1. Make weblorg--compare-posts-desc public (and maybe be explicit about the fact that it's sorting with the date attribute)
  2. Add something like :input-sort to weblorg-route so we can take the sorting function as a parameter to be applied to whatever aggregate function
  3. deprecate the -desc aggregate functions in favor of sorting functions with the -desc suffix (maybe we don't need to deprecate them, maybe they can just be shortcuts to providing :input-aggregate and :input-sort 🤷🏾)
  4. Identify what other useful sorting functions we could ship by default

Is there a plan to make publishing with weblorg from defined node of any .org file. I mean that some function may parse .org files search for tagged nodes (as :blog: or :publish: , something like this) and create .org files for weblorg. Then run standart publishing procedure. This can be developed with cascade of functions into Elisp . For me this can be really realized with python script Orgparse.

this question reminds me of the discussion in https://github.com/emacs-love/weblorg/issues/18. this feels like perfect use-case for :input-source. And I think it'd be cool to see new packages that extended weblorg instead of depending on different packages. My goal has been to limit the pipeline as little as possible to any specific use-case, but to adhere to a very small feature set. It may sound a bit contradictory, but the goal is to make it extendable so other people use it as a library.

Do you plan to develop an autoextraction of first n-words of the post (anounce) for index page of the blog?

That sounds very useful, and I think it'd be a good template filter to add to templatel even. (I bet there's something along those lines in jinja that we can get the inspiration from)

Idea of tags as rules for the choice of template(route). If I have one file tagged as :blog: and other tagges as :homepage: being in one folder they will be processed with different templates. So users be able to have not only flat real site structure but also the same flat/virtual on desktop.

hmm, I feel like this can be achieved with a custom :input-filter function. We only have one public API that relies on that property currently.: https://emacs.love/weblorg/api.html#symbol-weblorg-input-filter-drafts that's used to filter out Org-Mode files that have #+DRAFT: t on them. https://emacs.love/weblorg/doc/file-properties.html#draft I wonder if we could provide a nice and cliean weblorg-input-filter-tags or something like that. Would that be something you could use?