Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Jan 13 15:51
    ddfreyne commented #1539
  • Jan 13 14:23
    bluebear94 closed #1539
  • Jan 13 14:23
    bluebear94 commented #1539
  • Jan 13 14:21
    bluebear94 edited #1539
  • Jan 13 14:18
    bluebear94 opened #1539
  • Jan 13 13:07

    ddfreyne on main

    Set up GitLab CI Merge branch 'gitlab-ci' into '… (compare)

  • Jan 13 11:28

    ddfreyne on gitlab-ci

    Set up GitLab CI wip (compare)

  • Jan 07 15:01
    ddfreyne commented #1536
  • Jan 07 14:19
    ddfreyne labeled #1537
  • Jan 07 14:18
    ddfreyne synchronize #1536
  • Jan 07 14:18

    ddfreyne on debug-timeout

    Debug why nanoc tests sometimes… (compare)

  • Jan 07 14:18

    ddfreyne on default-listen-opts

    (compare)

  • Jan 07 14:18

    ddfreyne on main

    Use default Listen latency/wait… Merge pull request #1538 from n… (compare)

  • Jan 07 14:18
    ddfreyne closed #1538
  • Jan 06 15:35
    ddfreyne opened #1538
  • Jan 06 15:34

    ddfreyne on default-listen-opts

    Use default Listen latency/wait… (compare)

  • Jan 06 15:25
    ddfreyne commented #1537
  • Jan 06 15:22
    iay commented #1537
  • Jan 06 15:21
    iay commented #1537
  • Jan 05 19:28
    Ecco edited #1537
Christian Tietze
@DivineDominion
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.)
Christian Tietze
@DivineDominion
I can see that this would work, too. You'd only run into trouble when you want to use a helper for a piece of a page that is now assigned to @item and you cannot figure out where it is used. You'd have to pass in the "hosting" path as a parameter in that case, whereas my existing stuff would be the other way around: @item would tell if I'm on the landing page or some archive page or whatever, while the render helper parameter contains the data to be renderes. -- Apart from that, a simple search and replace makes our approaches totally interchangeable, it seems. If it works, don't change it, I guess :)
I'll keep this in mind when I set up more complicated view hierarchies in the future. That @item reassignment trick could be helpful to save a parameter in some lib/helpers.rb code, where I have to pass in the post parameter while you can just work with the @item context variable.
Denis Defreyne
@ddfreyne
That item reassignment trick is neat and should not cause problems1
You could stick an ensure right before the @item = orig_item but it probably doesn’t matter
Kristian Lumme
@klumme

@DivineDominion: Yeah, I think I see what you mean. Hugo has a nice version of this where . is originally the page being rendered, but as you reassign that, for example using the with statement, you still have access to the original context using $... though you'd still have to keep track of which of the variables you're using. Whichever drawback is preferable depends on the structure of your sites, I guess 🙂.

@ddfreyne: Nice to hear that it shouldn't cause problems!

Denis Defreyne
@ddfreyne
@DivineDominion I started using the Zettelkasten method (hurrah) and I’m figuring out how I can publish a subset of my notes — preferably with Nanoc, because of reasons. Have you given that some thought?
I’ve attempted the Zettelkasten method a while ago but it did not click. There definitely is a click now, heh. (Case in point: I started writing down some of the problems that I think Nanoc has, and realised that it’s very much connected to some other thoughts I’ve been having.)