These are chat archives for jescalan/roots

21st
Jul 2014
Tobias Birmili
@toabi
Jul 21 2014 20:20
Hello :) I guess dynamic content is put into site.* after it has been rendered…
(by the way, I tried a lot of different static site gens and they all has some shortcomings or stupidities or were too blog-centric. Roots so far had pretty good design decisions. the site I'm buildout doesn't need any fancy blogging features except a 'next'/'prev' button.)
Jeff Escalante
@jescalan
Jul 21 2014 20:22
hi!
ok so im sorry, let me try to cover why the next/prev won’t work with the current design
the way dynamic content is handled internally is as such
first, it looks for any files with front matter. then it takes all those files and compiles them as quickly as possible, before other content
pulling out the front matter and adding it to an internal locals object
so these don’t go in an order, they are async
after that, the local object containing all the dynamic content is passed through as all other views are compiled
so they all have access to the dynamic content
so each piece of dynamic content doesnt have access to each other piece
in order for this to happen it would need 2 compile passes, which would slow it down significantly, but is still theoretically possible
if im not mistaken, someone who wanted similar functionality in the past forked roots and made it compile dynamic content twice in order to get this
Tobias Birmili
@toabi
Jul 21 2014 20:26
okay, but the layout could theoretically have access to the fully populated internal list of dynamic content front matters
Jeff Escalante
@jescalan
Jul 21 2014 20:26
on an entirely different note, the roots version you are using right now is currently being rewritten on the v3 branch
yes the layout does have access to everything
you are limited only when trying to access other dynamic content inside any given piece of dynamic content
Tobias Birmili
@toabi
Jul 21 2014 20:28
But the site.blog list grows with each rendering of blog/_detail.jade and is not always "full".
Because my first try was to just "look which index this post has in site.blog by matching titles and then render link to [index+1] and [index-1]
can I access the internal front-matter list in a layout somehow to see what's in there?
Jeff Escalante
@jescalan
Jul 21 2014 20:53
sorry, back now
yeah so you can try to access other dynamic content inside a given dynamic content piece, but like you have noticed, it will be incomplete
this is because all dyanmic content is compiled at the same time
async
as quickly as possible, with no thought given to ordering in any way
so it’s really not even worth trying, because it’s not reliable enough
like, maybe in one of the posts it will happen to be one of the later ones and you’ll be able to get it working
but the next time it might not
you should not be relying on being able to access site within any piece of dynamic content
Tobias Birmili
@toabi
Jul 21 2014 20:55
although it looks like they are rendered in alphabetical order
Jeff Escalante
@jescalan
Jul 21 2014 20:55
you cant rely on the order
its the same as a js object
although sometimes there is an order to the keys when you loop through a js object, you cant rely on the order
its not an enforced order
Tobias Birmili
@toabi
Jul 21 2014 20:56
jo. well okay. v3 doesn't yet have a solution to this either I guess?
Jeff Escalante
@jescalan
Jul 21 2014 20:57
v3 is a lot closer
and would be much easier to implement a solution
right now our biggest issue is the threading
roots v2 is made to be async but is actually sync
because compiled are CPU-heavy operations that run on the main thread
so larger sites with more content render very slowly
the only way to make it entirely async is to pull compiles into threads, which makes the interface much more complex, but is entirely necessary
it also has dynamic content split out into an entirely separate plugin
which makes it easier to deal with
Tobias Birmili
@toabi
Jul 21 2014 20:58
well, I dropped docpad because it was becoming very-very-very slow ¬_¬
Jeff Escalante
@jescalan
Jul 21 2014 20:59
yeah, i assume they have the same issue
it turns out this is incredibly difficult
i have been working on this issue full time, with someone else part time, for more than a month
the gist of it is that when passing between threads, you can only pass a string
so for example if you passed a function as a local into a jade template, or used a stylus plugin
that would not be able to be passed through to a thread
working around this is insane
another thing we’re working on is being able to load in content from a database, but still render static
even a remote database
so you could use an api, wordpress, contentful, tumblr, your own, etc
Tobias Birmili
@toabi
Jul 21 2014 21:01
that's also a nice feature
Jeff Escalante
@jescalan
Jul 21 2014 21:01
pass the url in to roots, and it would read that api and make the data available to views
this is necessary for us working on larger sites with more data
and also opens up the opportunity for content management, more complex queries, etc
i wish i could tell you a lot of this is finished and ready to use, but unfortunately it isn’t yet
there is a lot of hard work going into it though around the clock
we’re working on a bunch of related static workflows in parallel as well
right now im working on deployment
we’ll have very fast deployers with no external deps (not even git) to push to s3, heroku, github pages, linux vps, ftp, etc.
Tobias Birmili
@toabi
Jul 21 2014 21:04
well, that's nice, although in my experience deployment is usually the least of my problems with static-site-gens :D
Jeff Escalante
@jescalan
Jul 21 2014 21:04
hah for sure. but it is nice to have it be fast and simple
and ready for different environments etc
Tobias Birmili
@toabi
Jul 21 2014 21:05
is there any rough time-frame for when my 'prev/next' problem would be solvable in v3?
Jeff Escalante
@jescalan
Jul 21 2014 21:05
hm.. tbh it would probably be in the months range :(
If you’d like to jump in and help though it would speed it up too!
but i gotta warn you it’s a rabbit hole haha, you may never return
i never did
Tobias Birmili
@toabi
Jul 21 2014 21:07
hehe well, don't know if I'm ready for that. I'm usually more into python and this node/async things cause me headaches sometimes :D
I could just work around the next/prev with defining the links by hand in the front-matter for the time being.
ugly, but well
Jeff Escalante
@jescalan
Jul 21 2014 21:09
yeah… im sorry! i really wish that this all was worked out
best i can do is say we are working on it - it might help to file an issue in the dynamic content repo i linked above
to discuss accessing other content from any given piece of content
it definitely is an issue we want to address
if we do address it, it will be in v3
Tobias Birmili
@toabi
Jul 21 2014 21:12
once it's less bleeding I'll upgrade. shouldn't be hard I guess, probably just some config/magicvar changes?
Jeff Escalante
@jescalan
Jul 21 2014 21:12
yeah a few variable changes, a couple changes to app.coffee format
there are a lot of huge upgrades though. primarily that you manage your own dependency versions rather than roots locking them hah
Tobias Birmili
@toabi
Jul 21 2014 21:14
what would be also nice is to not be forced to define the "layout" for each file in a subfolder. intuitively I though app.config:layouts would take 'blog/*': 'that_layout' - but it didn't :D
Jeff Escalante
@jescalan
Jul 21 2014 21:22
ah yeah, layouts have changed entirely in v3 actually
Tobias Birmili
@toabi
Jul 21 2014 21:23
I am not using the layouts config in v2 now because it caused weird things.
Jeff Escalante
@jescalan
Jul 21 2014 21:23
ok
Tobias Birmili
@toabi
Jul 21 2014 21:24
I now have my template infrastructure with jade extends/block and only in the last child of a template I do a !=content to fill that in.
I first tried if I couldn't extends some_layout in a posts/blabla.jadebut that caused some weird effects too :D
Well, I'm confident that it'll some time grow into a pretty nice tool. Until that I'll use it with the bugs it has. But does it make sense to even report v2 issues anymore?
And thanks for all the information.
Tobias Birmili
@toabi
Jul 21 2014 21:29
I'll be off now. It's late enough :moon:
Jeff Escalante
@jescalan
Jul 21 2014 21:29
yeah, using jade’s native extend is how v3 handles it
doesnt make a ton of sense to report v2 issues - we’re busy working on v3
if it helps, we have been using v3 in production
for a bit, and it’s been ok
but thank you for jumping in and trying it, and for dealing with it’s incomplete-ness!
night ~
Tobias Birmili
@toabi
Jul 21 2014 21:32
I rarely find software which isn't complete :D good night
Jeff Escalante
@jescalan
Jul 21 2014 21:32
hah yup, the never ending job