Skip to content
Louis Maddox edited this page Nov 9, 2015 · 8 revisions

freenode#jekyll chat log 8/11/15

<lmmx> so my site is http://plotspot.github.io - a catalogue of graphs (etc) and the code that generates them, in the style of the R Graph Catalog (but multi language/library). I have a general idea for the file tree (important part being http://git.io/v80Ii) but the idea of writing it programmatically is a bit of an open question
<jekyllrb> Title: plotspot (at plotspot.github.io)
<lmmx> I just watched the Jekyll v3 announcement talk, I think Parker M mentioned that it's difficult at the moment to use the same generic iterator method as you do with _posts for other things (e.g. _plots in my case)
<lmmx> I just put a test file in a subdirectory of _includes and it seems to be accessible to {% include filename.html %} so I was thinking perhaps I should write html files there, "for plot in each folder of _plots, read the YML file and determine if there's code/images present for each language and library"
<lmmx> sorry if noone followed that :')
<lmmx> basically I'm just wondering if anyone can give thumbs up / warn against that general organisation, & any tips on execution appreciated
<jaybe> sure. include all the things.
<osfameron> lmmx: so you're using collections?
<osfameron> collections rock
<lmmx> osfameron: I literally just watched the v3 announcement speech and realised collections are what I'm after, yeah :-)
<osfameron> ah, I've not seen that :-)
<osfameron> I just read http://jekyllrb.com/docs/collections/
<jekyllrb> Title: Collections (at jekyllrb.com)
<lmmx> so for example the 'cards' / 'gallery panes' on main page - each card can be generated under _includes/plots from the equivalent of _posts called _plots
<osfameron> I'm using them for charaters in a novel
<osfameron> and probably a few other things, eventually
<lmmx> ah cool
<osfameron> well, each item in plots, e.g. _plots/foo.md can have metadata and content. I guess you could encode which things to then {% include %} from that?
<osfameron> have you got a link to the v3 announcement talk?
<osfameron> lmmx: yeah, so you'd basically do what your pseudocode above did :-)
<osfameron> {% for plot in plots %}...
<osfameron> and you can even just {{ plot }} if the .md file renders to the card
<osfameron> (or {% include _plot_card.html plot=plot %} if it doesn't)
<lmmx> ah ok...
<osfameron> you want subfolders, which is a little different
<osfameron> but I think you can set default metadata per subfolder
<lmmx> yeah..?
<lmmx> hmm
<osfameron> yeah, like in http://jekyllrb.com/docs/configuration/#front-matter-defaults
<jekyllrb> Title: Configuration (at jekyllrb.com)
<osfameron> (that's for posts and pages, but I believe the same applies to collections)
<lmmx> right, right
<lmmx> for plot in plots, plot.yaml_option
<osfameron> yeah
<lmmx> ohhh that default key is amazing
<lmmx> ty
<osfameron> yeah :-) I'm using that for sections of the book. e.g. _posts/book1/... (to make it print "Book 1" in the contents list etc.)
<osfameron> not used subfolders per collection yet though
<osfameron> I dislike the interface a little. I'd have preferred a _posts/book1/defaults.yml instead of the rather awkward nested configuration in _config.yml
<lmmx> hm, but then you'd have to edit N YAML files for N chapters
<lmmx> will see how it goes
<osfameron> well you'd still have per folder defaults, as well as the individual files
<osfameron> but yeah, for your plots collection, it's a separate file per plot
<osfameron> hopefully that'll work out for you!
<osfameron> if you don't need a whole file, then maybe something under _data will work
<lmmx> so, to use collections (Ruby 2.5) am I gonna want Octopress Paginate https://github.com/octopress/paginate/
<jekyllrb> Title: octopress/paginate · GitHub (at github.com)
<osfameron> no idea... doesn't jekyll come with a paginator?
<osfameron> I don't really understand what octopress is for tbh...
* ursooperduper (~[email protected]) has joined
<lmmx> haha take that as a no then, ok! Will take a look at the data setup instead
<osfameron> but don't take my word for anything (I basically started using Jekyll seriously about a week ago :-)
<osfameron> good luck with that anyway, looks like a good project
* osfameron heads off to bed
<lmmx> it's fine, been very helpful, cheers

Docs to look at:

Liquid

<div class="4u$ 12u$(mobile)">
{% for plot in plots %}
  {% assign loopindex = forloop.index | modulo: 3 %}
  {% if loopindex == 1 %}
    <article class="item">
    <a href="#{{ plot.title | slugify }}" class="image fit"><img src="images/{% plot.image %}" alt="" /></a>
    <header>
      <h3>{{ plot.title }}</h3>
    </header>
    </article>
  {% endif %}
{% endfor %}
</div>

<div class="4u$ 12u$(mobile)">
{% for plot in plots %}
  {% assign loopindex = forloop.index | modulo: 3 %}
  {% if loopindex == 2 %}
    <article class="item">
    <a href="#{{ plot.title | slugify }}" class="image fit"><img src="images/{% plot.image %}" alt="" /></a>
    <header>
      <h3>{{ plot.title }}</h3>
    </header>
    </article>
  {% endif %}
{% endfor %}
</div>

<div class="4u$ 12u$(mobile)">
{% for plot in plots %}
  {% assign loopindex = forloop.index | modulo: 3 %}
  {% if loopindex == 0 %}
    <article class="item">
    <a href="#{{ plot.title | slugify }}" class="image fit"><img src="images/{% plot.image %}" alt="" /></a>
    <header>
      <h3>{{ plot.title }}</h3>
    </header>
    </article>
  {% endif %}
{% endfor %}
</div>

Webapp

Guide for JS webapps (in favour of traditional URLs).

  • See how e.g. talk.jekyllrb.com handle it (comment highlighted in URL when scrolling)
Clone this wiki locally