routes like nanoc/acrylamid #915

Closed
gour opened this Issue Nov 16, 2013 · 15 comments

Comments

Projects
None yet
5 participants

gour commented Nov 16, 2013

Another possible enhancement in Nikola to make it more capable of building larger general (aka non-blog) sites by having routes similar to Nanoc and available in Acrylamid...

Kwpolska referenced this issue Nov 16, 2013

Closed

acrylamid-like filters #914

2 of 3 tasks complete
Owner

ralsina commented Apr 18, 2014

Looks like we are not getting this done for 7.0.0 ...

gour commented Apr 18, 2014

Roberto Alsina notifications@github.com writes:

Looks like we are not getting this done for 7.0.0 ...

Yeah, it maybe requires something like 8.0 if it is going to break
compatibility...

@Kwpolska Kwpolska modified the milestone: Whenever, v7.0.0 May 16, 2014

Owner

Kwpolska commented Jun 13, 2015

I would like to see some sample usage of this with real examples, and if it really makes sense to implement…

Well, I'm also looking for a good static non-blog site generator. Despite so many projects being available literally none of them suits my needs (at least a few months ago, when I was reviewing most popular ones), nanoc being the closest one, thanks to its generic approach (unfortunately its written in Rubby, and I'm a Python guy).

What I need is a possibility to build a site structured like this:

/projects/
/projects/foo/
/projects/foo/docs/
/projects/foo/downloads/
...
/projects/bar/
/blog/...
/about/

With nanoc I can easily declare rules mapping my source files to destination files anyway I want (using so called routes). Here's an excerpt - rules handling image galleries (which can be anywhere in the source tree):

# If there is 'gl' subdirectory anywhere, it copies images in it as-is to 'hires' subdir 
route '/*/gl/*', :rep => :hires do
  item.identifier.chop.sub(/\/gl\//, '/hires/') + '.' + item[:extension]
end

# This compile rule thumbnalize those images
compile '/*/gl/*', :rep => :thumbnail do
  filter :thumbnailize, :width => 200
end
# ...and this one copies them with '.tn.' added before extension
route '/*/gl/*', :rep => :thumbnail do
  item.identifier.chop + '.tn.' + item[:extension]
end

Such routes gives me a lot of flexibility, as opposed to those site generators that enforce a site structure. If only it was Python, I'd look no further :-)

Owner

ralsina commented Jun 16, 2015

@codepainters Well ... you can do that site layout with Nikola as it is now, AFAICS.

Since when it's possible? Either I wasn't looking to carefully at that time, or it wasn't yet there, or it wasn't obvious :)

I remember reading this very page: https://getnikola.com/creating-a-site-not-a-blog-with-nikola.html
If I remember correctly, I (perhaps incorrectly) assumed that source files for the pages need to be stored flat in a single directory (and I don't want to add multiple tuples to PAGES), this very line in the config made me believe so:

PAGES = [("pages/*.txt", "", "story.tmpl")]

What I'd really like is to have a source tree matching the URL tree - is that possible? Or even better - have control over this source path <-> URL mapping, and that's exactly where nanoc shines.

Owner

ralsina commented Jun 16, 2015

@codepainters No, no need to keep pages/ flat. You can have as many levels as you want there and they will appear in the same place in the output.

So, with that same PAGES you have there, pages/foo/bar.txt will appear in output/foo/bar.html (assuming its slug is also bar)

Owner

Kwpolska commented Jun 16, 2015

Also, if you set PRETTY_URLS=True, you can get /projects/foo/downloads/ with pages/projects/foo/downloads.rst (slug=downloads). And if you want a .tar.gz to go in that directory, that would be files/projects/foo/downloads/foo-0.1.0.tar.gz.

(.rst is a better extension than .txt)

So it seems I wasn't persistent enough experimenting with it (it was quite some time ago, and I no longer remember all the gory details).

Adding a "hierarchical" sample to the tutorial would be a great addition then, as it is not obvious if this is supported (and, as most static site generators suck when it comes to non-blog sites, it'd be a great selling point).

Owner

ralsina commented Jun 16, 2015

We have an open issue to create better and more example sites :-)

Owner

Kwpolska commented Jun 16, 2015

We could also add your comment about flat pages mashed with mine to both the manual and the notablog tutorial.

ralsina self-assigned this Sep 15, 2015

Owner

ralsina commented Sep 15, 2015

I'll try to document this tomorrow.

Owner

Kwpolska commented Sep 15, 2015

Bonus points for landing it before the release.

@ralsina ralsina added a commit that referenced this issue Sep 15, 2015

@ralsina ralsina added note mentioned in #915 f5f3cd2
Contributor

tritium21 commented Jun 23, 2016

Is this still open for a reason? It looks like the Nikola way of doing non-blog sites is well and truly implemented, unless I am missing something?

Owner

Kwpolska commented Jun 23, 2016

Those routes seem like a way to complicate things anyway and generally don’t work with our idea of things. I’ll close this.

Kwpolska closed this Jun 23, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment