Exposing a directory via webrick

18 views
Skip to first unread message

Lukas Zapletal

unread,
Jan 18, 2022, 11:38:25 AMJan 18
to nanoc
Hello,

we have a nanoc site in ./web and then bunch of guides (documentation) in ./guides/build. I would like nanoc's web server to publish ./guides/build under path /nightly as well as /X.Y. Is this possible without any plugin? Or how would I do this?

Thanks for help, this is our site:




Chers!

Denis Defreyne

unread,
Jan 25, 2022, 3:58:46 AMJan 25
to noreply-spamdigest
Hey Lukas,

Would it be a solution to use multiple #write directives? For example:

compile '/guides/build/*.md' do
  filter :kramdown
  write '/12.7/'    + item.identifier.without_ext.split('/').last + '/index.html'
  write '/nightly/' + item.identifier.without_ext.split('/').last + '/index.html'
end

You’ll have to adjust it to make it work for your specific use case, but that’s the gist of it. Lemme know how that works.

Cheers,

Denis Defreyne
[dəˈni] • pronouns: he/him

--
You received this message because you are subscribed to the Google Groups "nanoc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nanoc+un...@googlegroups.com.

Lukas Zapletal

unread,
Jan 25, 2022, 8:55:35 AMJan 25
to na...@googlegroups.com
Hello,

sorry I did not make it clear earlier, but build artifacts are
generated by something else (asciidoctor books) and are actually just
HTML files with images. I do not want to build them via Nanoc, just
publish them (make them available through webrick when testing the
site). I was hoping for some trick just to tell the webserver to
publish them. I tried to create symlinks via Ruby in Rules but Nanoc
hated it :)

Thanks for help!

LZ
> You received this message because you are subscribed to a topic in the Google Groups "nanoc" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/topic/nanoc/9N5FP2R8m2o/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to nanoc+un...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/nanoc/9b206222-2d42-43af-b791-2e7acb201b54%40www.fastmail.com.



--
Later,
Lukas @lzap Zapletal

Denis Defreyne

unread,
Feb 12, 2022, 5:33:33 AMFeb 12
to noreply-spamdigest
Hi Lukas,

There’s no trivial way to tell the web server to serve files from two locations. You could create your own Rack config.ru file which uses Rack::Builder with Rack::File and Adsf::Rack::IndexFileFinder (see https://github.com/ddfreyne/adsf#indexfilefinder). But that’s not the most straightforward, for sure.

Alternatively, you could compile the Asciidoctor books into content/ anyway, and then use Nanoc’s `passthrough` rule (https://nanoc.app/doc/rules/#convenience-methods) to copy those compiled Asciidoctor files as-is to output/. That might reflect better how you deploy your site, too (it is the approach I use when I use other tools in combination with Nanoc). It’d look something like this:

1. Use asciidoctor with `--destination-dir`:

asciidoctor --destination-dir=content/book

2. Set up Nanoc’s rules to copy everything in /book recursively, as-is:

passthrough "/book/**/*"

There are variations available for that too, like matching all of /content/**/* and then writing them to a different path (using `compile` and `write`). Hope that helps!

Best,

Denis Defreyne
[dəˈni] • pronouns: he/him

+49 1573 1969 173
he...@denisdefreyne.com
https://denisdefreyne.com
> https://groups.google.com/d/msgid/nanoc/CAP80Qm3EtaG1BrZTeomUFUEt4GprScVx_QxDbsVqw_hbwh0A%3Dg%40mail.gmail.com.
Reply all
Reply to author
Forward
0 new messages