Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#13 2017-03-30 12:28:37

Destry
Member
From: Haut-Rhin
Registered: 2004-08-04
Posts: 4,912
Website

Re: Distill

I don’t know if I have things fixed or not (guessing not). The build error I get now is routinely:

unable to build page. Please try again later.

There is zero info about this error anywhere online that I’ve been able to find through DDG.

Yesterday I did have a different error about tabs (which can not be used in the front matter to create indents), which lead me to discover this great YAML Lint tool. After running all my front matter through the lint cleaner, it corrected your lines here:

yaml
authors:
  - name: 
    affiliation: 
    url: 
  - name: 
    affiliation: 
    url: 

To this:

yaml
authors:
  - 
    name: 
    affiliation: 
    url: 
  - 
    name: 
    affiliation: 
    url: 

I also learned from the lint cleaning that quotes are needed around all strings of two or more words, as well as any URIs, for example:

yaml
summary: "Yipes! Summary needed"

collaborators:
  - 
    who: "First Last"
    affiliation: "Entity Name"
    affiliation_url: "https://content-strategy-forum.github.io/csf-glossary/{{ page.title | slugify }}.html" 

I also made a lot of various changes to my markup as I found better ways of serializing things. The idea being to remove as much markup out of the way as possible. (Though I’m beginning to see a compromise point.)

For example, handling figures (only 1 per definition allowed), I’m hoping I can put the figure code in an include, create a single figure object in front matter, and use a conditional to add it all if there’s figure data…

Front matter:

yaml
figure: 
  - 
    fig_slug: placeholder
    fig_alt: "A placeholder. Huzza!"
    fig_caption: "A belle figure of mysterious nature."

Markup:

{% if ref="{{ page.figure }} %}
    {% include figure.html %}
{% endif %}

The figure.html Include:

<figure>
	<img alt="{{ item.fig_alt }}" src="{{ site.github.url }}/assets/images/{{ item.fig_slug }}.png">
	<figcaption>
		{{ item.fig_caption }}
	</figcaption>
</figure>

It seems to me that would work, but it’s still unverified.

I like the idea of treating the figure front matter as a single object instead of 3 separate variable strings, though I guess it doesn’t matter. It just looks better in the front matter; you easily see the association.

But… I’m at a loss about this current error which I’ve had since yesterday. No clue what to do at this point.

I was hoping not to have to install Jekyll locally, but the more I learn about using front matter to parse much of the content (touchiness with indent construction, quotes, and whatever else I’ve yet to learn), the less certain I am about it’s human-friendliness when low-tech folks start poking in things. I don’t want to end up being a full-time build troubleshooter on this project. At least with HTML it’s easy to see where the problem is. No hidden voodoo and cryptic error messages.

Offline

#14 2017-03-30 14:23:44

Destry
Member
From: Haut-Rhin
Registered: 2004-08-04
Posts: 4,912
Website

Re: Distill

Hmm… looks like the figure yaml I’m conceiving is better suited to a hash, not a sequence:

yaml
figure: 
  fig_slug: placeholder 
  fig_alt: "A placeholder. Huzza!"
  fig_caption: "A belle figure of mysterious nature."

Now, how to figure out the Liquid for that… That’s the challenge I’m having right now, getting my head around using Liquid under different objectives.

Also, it appears your authors/affiliations sequence (list array?) should have been fine, Bloke, looking at this, so I don’t know what’s up with that Lint tool, in fact.

Offline

#15 2017-03-30 15:16:41

Destry
Member
From: Haut-Rhin
Registered: 2004-08-04
Posts: 4,912
Website

Re: Distill

According the Array or hash access info there, I should be able to grab a hash key value by using variable[key]. That’s the bit I’ve been trying to figure out.

If I understand that correctly, then…

1) I could have the figure YAML structured like this:

yaml
figure:
  fig_slug: placeholder 
  fig_alt: "A placeholder. Huzza!"
  fig_caption: "A belle figure of mysterious nature."

Use an include that references the variable like this:

{% if ref="{{ page.figure }} %}{% include figure.html %}{% endif %}

Then grab each variable key like this in the include markup:

<figure>
  <img alt="{{ page.figure[fig_alt] }}" src="{{ site.github.url }}/assets/images/{{ page.figure[fig_slug] }}.png">
  <figcaption>{{ page.figure[fig_caption] }}</figcaption>
</figure>

I hope it works like that, because that would be useful for lots of other things.

Offline

#16 2017-03-30 15:31:49

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,453
Website GitHub

Re: Distill

Destry wrote #305150:

I hope it works like that, because that would be useful for lots of other things.

ymmv, but I don’t know if you can access page-level variables in an include. Like you say, it’d be neat if you could, but the example I saw passed in the info via a variable name and then used that in the included file.

Compare yours with:

{% if ref="{{ page.figure }} %}{% include figure.html figure_info=page.figure site_info=site.github %}{% endif %}

And then in your include:

<figure>
  <img alt="{{ include.figure_info[fig_alt] }}" src="{{ site_info.url }}/assets/images/{{ include.figure_info[fig_slug] }}.png">
  <figcaption>{{ include.figure_info[fig_caption] }}</figcaption>
</figure>

Note that variables inside includes are prefixed with include instead of page because they’re passed in. After that you can reference them as you would on the main page.

It might work the easy way, it depends how Liquid is scoped.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#17 2017-03-30 15:54:45

Destry
Member
From: Haut-Rhin
Registered: 2004-08-04
Posts: 4,912
Website

Re: Distill

Bloke wrote #305151:

it’d be neat if you could, but…

Drat.

figure_infosite_info

Where did those come from? Does liquid just understand them like that? Constants?

You can’t assume I know anything when it comes to code conventions outside of regular ol’ HTML/CSS.

Note that variables inside includes are prefixed with include instead of page because they’re passed in.

Okay, that’s good to know.

I see that figure_info again.

Offline

#18 2017-03-30 15:58:19

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,453
Website GitHub

Re: Distill

Destry wrote #305152:

Where did [figure_info et al] come from?

I just made them up. You could call them jim and bob if you like, then use them as include.jim and include.bob. Just variables of your choice.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#19 2017-03-30 16:05:26

Destry
Member
From: Haut-Rhin
Registered: 2004-08-04
Posts: 4,912
Website

Re: Distill

Ah, okay, I see what you mean. You just created a new variable on the spot and that’s what’s used in the include. I would have never realized/figured you could do something like that. I think it takes someone with coding experience to grasp this stuff.

I’ll give it a whirl.

Offline

#20 2017-03-30 16:15:34

Destry
Member
From: Haut-Rhin
Registered: 2004-08-04
Posts: 4,912
Website

Re: Distill

I think I’ll have to try that with the authors/affils parts too, because I kind of set that block up in a similar way yesterday.

Offline

#21 2017-03-30 16:22:30

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,453
Website GitHub

Re: Distill

Destry wrote #305154:

I think it takes someone with coding experience to grasp this stuff.

Stef just found an example on the internet and copied it. Stef not clever. Google clever.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#22 2017-03-30 16:36:10

Destry
Member
From: Haut-Rhin
Registered: 2004-08-04
Posts: 4,912
Website

Re: Distill

Might be getting somewhere. The site finally built that time without throwing an error, though it’s all messed up still somewhere. Some elements not showing up. But at least it’s a change. ;)

Offline

#23 2017-03-30 16:55:10

Destry
Member
From: Haut-Rhin
Registered: 2004-08-04
Posts: 4,912
Website

Re: Distill

Victory! There were some stray tabs in the authors/affiliations array in front matter. That shite is tricky because you can’t see it. you basically have to position cursor on each line and arrow key back for forth to see what’s going on. Spaces only for the win.

Anyway, figuring out the home index page will be a monster. But that’s a fight for another day. Cheers, Bloke!

Offline

#24 2017-03-30 17:02:45

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,453
Website GitHub

Re: Distill

Ah yes, like Python, YAML is very keen on spaces as it’s a positional language. Tabs really screw things up, as you found.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

Board footer

Powered by FluxBB