Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Jan 23 08:13

    ddfreyne on main

    Enable binary compiled content … Merge branch 'enable-binary-com… (compare)

  • Jan 21 13:02

    ddfreyne on enable-binary-compiled-content-cache

    Enable binary compiled content … (compare)

  • Jan 21 12:55

    ddfreyne on main

    Use COW for binary compiled con… Merge branch 'binary-compiled-c… Make PostCompileItemRepView spe… (compare)

  • Jan 21 12:12

    ddfreyne on enable-binary-compiled-content-cache

    Merge branch 'binary-compiled-c… Enable binary compiled content … (compare)

  • Jan 21 12:03

    ddfreyne on binary-compiled-content-cache-clonefile

    Use COW for binary compiled con… (compare)

  • Jan 21 12:03

    ddfreyne on main

    Fix subtly broken PostCompileIt… (compare)

  • Jan 21 11:30

    ddfreyne on binary-compiled-content-cache-clonefile

    Use COW for binary compiled con… (compare)

  • Jan 21 11:26

    ddfreyne on binary-compiled-content-cache-clonefile

    Use COW for binary compiled con… (compare)

  • Jan 21 11:17

    ddfreyne on main

    Upgrade Rubocop (compare)

  • Jan 20 12:01

    ddfreyne on enable-binary-compiled-content-cache

    Enable binary compiled content … Use copy-on-write for binary co… (compare)

  • Jan 16 20:51

    ddfreyne on main

    Upgrade dependencies Use Bundler 2.x (compare)

  • Jan 16 20:50

    ddfreyne on main

    Upgrade nanoc, nanoc-live (compare)

  • Jan 16 20:44
    ddfreyne commented #1537
  • Jan 16 20:43

    ddfreyne on main

    nanoc-live: Set version to 1.0.… nanoc-live: Add release notes f… Set version to 4.11.23 and 1 more (compare)

  • Jan 16 20:42

    ddfreyne on 4.11.23

    nanoc-live: Set version to 1.0.… nanoc-live: Add release notes f… Set version to 4.11.23 and 1 more (compare)

  • Jan 16 20:42

    ddfreyne on nanoc-core-v4.11.23

    nanoc-live: Set version to 1.0.… nanoc-live: Add release notes f… Set version to 4.11.23 and 1 more (compare)

  • Jan 16 20:41

    ddfreyne on nanoc-cli-v4.11.23

    nanoc-live: Set version to 1.0.… nanoc-live: Add release notes f… Set version to 4.11.23 and 1 more (compare)

  • Jan 16 20:41

    ddfreyne on nanoc-live-v1.0.0b8

    nanoc-live: Set version to 1.0.… nanoc-live: Add release notes f… Set version to 4.11.23 and 1 more (compare)

  • Jan 16 20:33
    ddfreyne commented #1538
  • Jan 13 15:51
    ddfreyne commented #1539
Christian Tietze
@DivineDominion
ah I thought the documentation was more up to date than I was :)
Denis Defreyne
@ddfreyne
My bad! Looks like the incorrect documentation has survived for a while :see_no_evil:
Christian Tietze
@DivineDominion
@ddfreyne I am still not certain why the link_to_unless_current helper produces a span when I use it in e.g. overview/index.md and it's part of the content, but the same call won't work in the nav bar (default calls _navigation.erb.html which uses lib/helpers/menu.rb's render_menu). The code to link_to_unless_current is rather simple, too. My best guess would be that the partial is cached, but using puts @item.path + " -- " + @items["/overview.*"].path reveals that this line is called for each item indeed, and that the == comparison inside link_to_unless_current should be true. :/
Denis Defreyne
@ddfreyne
@DivineDominion Could it be that you have multiple item representations? Linking from one item representation to another representation of the same item will make link_to_unless_current return a link rather than a <span>
Christian Tietze
@DivineDominion
Thanks for the hint! I think I created the problem by using Struct.new(...) to represent menu item configurations, and have a render method inside, and call link_to_unless_current from there. @item_rep is nil there. I think this is because of the way use_helper includes the module itself (works from there), but not the module's inner Struct definitions
Denis Defreyne
@ddfreyne
@DivineDominion You can also pass items to the rendered layout, e.g. <%= render 'head', item: @item %>
Christian Tietze
@DivineDominion
Passing a reference to the helper again works; maybe I should reconsider the approach and only create the data structures in my helper, and render partials like you suggest for each item instead
I know I'm not a great help to the nanoc community myself even though I use it for what now, 7, 8 years? But there aren't very many people writing about their setup
Denis Defreyne
@ddfreyne
hehe no worries :) Glad to have you around!
Christian Tietze
@DivineDominion
How do y'all deal with sensitive information by the way? I wonder if I should put my nanoc.yml with the deploy rsync paths onto GitHub, for example. Or the path to an htpasswd file in my htaccess source.
Denis Defreyne
@ddfreyne
Hmmm, this is a bit of a tricky one. I wouldn’t consider deploy rsync paths to be sensitive (since they’d be protected anyway), and in the past I’ve put those in nanoc.yaml.
I have, though, created aliases for some hosts that were in nanoc.yaml, to create some obscurity… but it generally isn’t that useful
You could also use dotenv (https://github.com/bkeepers/dotenv) to load sensitive information
Den Sig
@xdeoniss_gitlab
Hi!
Christian Tietze
@DivineDominion
:wave:
Christian Tietze
@DivineDominion
@ddfreyne Experimented with the ENV approach. During compilation, nanoc skips files that would change whent he ENV variable changes -- their modification date is the same, though. Is there a way to mark files as dirty? 🤔
I could touch each file that includes an "ENV" in it, but that's kinda weird
Denis Defreyne
@ddfreyne

@DivineDominion Are you using the ENV variable directly in code? (e.g. <%= ENV['SOMETHING'] %>) That’ll not work because Nanoc does not track changes to ENV.

What you can do, is copy stuff from ENV to @config in the preprocessor, and then only use the stuff that you copied to @config.

Alternatively, if all you need is to switch between different environments, you can use the built-in environments support: https://nanoc.ws/doc/sites/#environments
@DivineDominion Here’s how nanoc.ws does it:
https://github.com/nanoc/nanoc.ws/blob/main/Rules#L5-L11
Daniel Aleksandersen
@da2x
Is there a way to mark files as dirty?
That depends on what types of files you're modifying. Layouts? Auxiliary libs? Content?
Christian Tietze
@DivineDominion
@da2x Content files in this case
Is the environment stuff "new"? I'm positive I went with ENV some 6 years ago because I found no other way. The environment stuff looks way better than what I have, though!
Christian Tietze
@DivineDominion
Does using @config check for changes to the value between compilation runs?
Denis Defreyne
@ddfreyne
Changes to @config are tracked indeed
@DivineDominion The Environment support was added in Nanoc 4.4 which is 2016 ^^
Harald
@a4z
I would like to create a second atom feed, for articles that have a certain tag.
is there a way to combine the #atom_feed() with a filter ?
Denis Defreyne
@ddfreyne
@DivineDominion The only place where you can use ENV as a variable is in the Rules file — but not layouts, content files, lib, …
@a4z Yep! atom_feed(articles: @items.find_all('/blog2/*')
Harald
@a4z
awesome, thanks !!!
Denis Defreyne
@ddfreyne
Harald
@a4z
I was there, but did not see it, but now I do. Thanks again!
Christian Tietze
@DivineDominion
For zettelkasten.de, I added a helper to select articles by tag/author/... and sort them by date. This is super handy to create author feeds, or tag feeds, I find! -- For authors in particular, changing the metadata a bit further is a nice touch, too, btw:
<%= atom_feed :limit => 50, 
              :articles => sorted_posts_by("sascha"), 
              :title => "Zettelkasten Posts by Sascha",
              :author_name => "Sascha Fast",
              :author_uri => "http://zettelkasten.de/authors/sascha/" %>
Denis Defreyne
@ddfreyne
@da2x Hey there — could you take a look at nanoc/nanoc#1511 so that I can get it merged and released?
Kristian Lumme
@klumme

Hi, and first of all a big thank you to the Nanoc developers! I’ve been looking for an extensible static site generator and so far Nanoc seems to fit the bill perfectly: it’s quite bare-bones on the surface but the provided mechanisms for rules, helpers etc seem to be very powerful.

As I’m working on some features for our own workflow, I thought I’d bring them up here to see if anyone has any experience doing similar things, before I go on reinventing the wheel.

  • First, we’d like to have something like “page bundles” in Hugo where a page is based on a directory rather than a single file. So, for example, in a blog context, the main file for a post may be content/posts/my-post/index.md, resulting in a URL of /posts/my-post. In addition, it should be easy to refer to assets in that particular directory from the layout for the post. I did get something like this up-and-running already, just curious as to whether anyone else has done the same thing and come across any dos and don’ts?

  • Other static site generators provide mechanisms for managing URLs, for example in the case where your site runs in a subdirectory (like /blog/) in production, but you’d like to link to assets without the /blog/ prefix internally. Does Nanoc have something built-in for managing this?

  • We often store so-called content in Markdown front matter: things like an intro or an excerpt for a blog post. It could be argued that these belong in separate Markdown files, but having them in the same file is convenient when it comes to editing. To that end, I’m wondering if it’s possible to run the front matter attributes for items through Markdown? Actually, considering that these attributes may include things like image tags and considering the subdirectory URL situation mentioned above, it would be great to even have ERB in the front matter, but this sounds like it might get complicated if you refer to item attributes from item attributes… Is there a better way to go about this?

Appreciate any input! Thank you!

Denis Defreyne
@ddfreyne

Hey @klumme! I’ll give a brief answer to your points and we can go into more detail if you need it:

  1. Nanoc doesn’t have the concept of page bundles, but it’s also quite flexible in where you put your stuff. I usually put assets (images and videos) in the directory that corresponds to the page, because it makes it easier to find things and this way I don’t end up with a giant assets or images directory.

  2. For sites that run in subdirectories, there is the relativize_paths filter (https://nanoc.ws/doc/reference/filters/#relativize_paths). This way, Nanoc can pretend everything is an absolute path, and then afterwards make all the paths relative.

  3. You could use the filtering helper (https://nanoc.ws/doc/reference/helpers/#filtering) and do something like <% filter :kramdown do %><%= item[:excerpt] %><% end %>.

Kristian Lumme
@klumme
Awesome, thanks for the pointers! relativize_paths looks really useful, as does the filtering helper!
Achilleas Pipinellis
@axil_gitlab
:wave: quick question: is the shebang in Rules needed? It fails with some rubocop rules. I see it is created by default by https://github.com/nanoc/nanoc/blob/bbad4ad44208f59cbd335dc8de0e1f08b4e669bf/nanoc-cli/lib/nanoc/cli/commands/create-site.rb#L36. If it's not needed, I can create a PR to remove it.
Denis Defreyne
@ddfreyne
@axil_gitlab It is not needed, but it helps editors pick the right syntax for the file (otherwise editors tend to think it’s plaintext)
Achilleas Pipinellis
@axil_gitlab
@ddfreyne ah, it makes sense then, thanks!
Kristian Lumme
@klumme
Hi! As a follow-up to my earlier question: we often have use-cases where it’s useful to look up one item and use its data when rendering another item (think “featured post” rendered on a blog home page, for example). Creating a helper doing something like @items.detect {|item| item.path == <url>} is no problem. However, it would be useful for the helper to establish a block inside which @item is reassigned to the page we just looked up, instead of the rendered one — that way, other helpers and partials can be used in the same way both inside such a block and outside it, always referring to @item. Given that this may be trivial, as I’m not yet that familiar with Ruby: is there a nice way to accomplish this in Nanoc?
Denis Defreyne
@ddfreyne
@klumme I believe that you should be able to do this with the rendering helper. See https://nanoc.ws/doc/reference/helpers/#rendering — in particular, the second example (<%= render 'head', :title => 'Foo' %> will be relevant to you, as it shows you how to pass in variables to render

One more thing — I recommend finding items using @items['/blog/2020/something.*'] rather than checking the path. It’s more idiomatic and also faster.

It uses identifiers rather than paths, so the example above would match a file at content/blog/2020/something.md, regardless of where that file is written to in the Rules file.

Kristian Lumme
@klumme

@ddfreyne: Thanks again! I don't want to have to rely on the rendering helper as I may want to temporarily reassign @item without rendering a partial, but I should be able to look at the rendering helper source code and do something similar with the assigns.

Regarding the @items lookup: yeah, that makes sense... as it's clearly covered in the docs I wonder if I had some particular reason to do it differently, but can't recall... that should work fine!

Christian Tietze
@DivineDominion
@klumme Hmm I render 10 blog posts in full on my / main page and then there's the blog posts individual page, of course. Would that be similr to what you want to accomplish or am I missing a nuance?
Kristian Lumme
@klumme

@DivineDominion: I think that's similar, the main thing for me is to be able to specify a certain post/posts and have @item refer to that other post temporarily, instead of the one currently being rendered. This would, I guess, happen in your case when rendering your /page — fetching the 10 blog posts and rendering them in turn. For that, it's probably enough to use the rendering helper, passing in different items? It's possible that will cover it for me as well, though I'm not sure.

However, I was probably over-complicating things massively — a helper along these lines seems to work fine:

def with_item(id, &block)
  orig_item = @item
  @item = @items[id]
  yield
  @item = orig_item
end

As I'm new to Ruby, I wasn't sure I could just reassign the instance variable @item without it creating problems elsewhere... which it might still do, but it appears to be working!

Christian Tietze
@DivineDominion
@klumme the decorator you came up with could make sense, too! I went a slightly different route. I extracted the post rendering into a partial _post.erb.html template that doesn't use @item but a post variable. Then I include this partial from 2 places: the overview page, where I fetch the 10 posts and pass them in as a parameter to the template, and the post detail page, where I pass in render 'post', post: @item
Kristian Lumme
@klumme
@DivineDominion: I see! This is probably where the nuance comes in: the structure of our sites can occasionally get quite complicated, with items being rendered at the "top level" as well as inside the blocks of helpers like the one above. For example, If I write a custom helper for outputting a responsive image tag, looking up images in the directory of the current content file, I want to have it refer to @item so I can use it anywhere, if that makes sense. (Supplying the item as an argument to the helper function would also work, I guess.)