25 Days of omg.lol

Day 19

OK, folks—buckle up, because I have a bunch of updates to share today. Jumping right in:

Search is here! It’s a bit rough, and pretty experimental... but it’s here! I haven’t yet whipped up a nice search UI that you could use via something like {search} yet, but for now you could add something like this to your template:

<form action="?" method="get">
<label for="search">Search</label>
<input type="text" name="search">
<button type="submit">Search</button>
</form>

Search is done by sending a search value via the query string. This means that you can link to search results if you wanted to. It’s pretty flexible.

There are three new configuration items related to search:

First up, a message that’s displayed when something was found for the search:

Search results success message: There [is|are] $count [result|results] for your search:

There are a couple of things going on here:

  1. The $count variable will indicate the number of matching posts.
  2. the [is|are] syntax allows for defining singular and plural words, based on the value of $count. (Same with [result|results].)

Next is the message shown when the search didn’t match anything:

Search results failure message: There were no results found for your search.

And then, finally, is the search template itself (which, if you remember yesterday’s post, should be a familiar setup):

Search results format: <<[
<h2>Results for “$search”</h2>
<p>$search_results_message</p>
[post:begin]<h3><a href="$location">$title</a></h3>
<p>$date</p>
<p>$snippet</p>[post:end]
]>>

You can play with the setup here and get the markup and output that you want, styled in the way that you want. The sky’s the limit!

There are a few more updates to share today:

When I wrote yesterday’s post, I was in a hurry when adding a link to the Day 8 post, and I typed [[day 8]]. I don’t know why I expected this to work, and of course it didn’t. It sat that way for hours, and I finally woke up and read this message from @zioibi. So, hey, why not make it into a feature?

Now you can use wiki-style links to reference the slug or title of an existing page or post. You can also use the special format that lets you set the link text separately, like this: [[day 8|Day Eight]]

Post count

A new {post-count} tag is now available, and it’ll provide the total number of posts in your weblog. Special thanks to omg.lol member @bix for this suggestion!

Post metadata variables

This is pretty cool, and comes by way of Jason Burk: you can now use any post metadata in your configuration templates (recent posts and post list). This means that if you include certain metadata in your posts, for example Mood: Happy, you can use $mood in your configuration templates (within the [post:begin] and [post:end] bumpers) to output the post’s mood value. Tons of potential power here!

Advanced variables

Another new feature suggested by omg.lol member @maxic is what I’m calling advanced variables. That’s a terrible name and I’ll change it, but I’m already 10 minutes late in publishing this post so there’s no time for wordsmithing.

Here’s how this works. In your weblog configuration, you can specify an arbitrary item that can hold a variable (or multiple variables, actually). For example:

Notice: <span class="notice">$message</span>

And then you can apply this wherever you want (in a post, or in your template), like this:

{notice:message=This is the message in my notice!}

Which would output:

<span class="notice">This is the message in my notice!</span>

Here’s an example with more than one variable:

Story: Once upon a time there was $article $noun that was $adjective.

And this could be used like this:

{story:article=an&noun=apple&adjective=red}

Which would output:

Once upon a time there was an apple that was red.

The multi-variable string format in the tag should look familiar, as it’s basically a URL query string. It’s intended to be urlencoded, too, so you can use values with ampersands and equals signs if needed.

This is yet another powerful aspect to the weblog.lol template engine. So much power!

And that’s it for today, our 19th day of the 25 Days of omg.lol. See you again tomorrow with who knows what!

— Adam