Tagged with #lamb

Sander @ June 12 at 4:11 pm

Trying out a new 2024 theme I've started working on. It's not super clear yet where a new post begins, and it's a bit bland. #lamb #projects

Sander @ January 3 at 2:07 pm

What would it take to make writing vanilla JavaScript more pleasant? After reviewing the code for my blogging engine Lamb I concluded:

Most of the code adding interactivity to personal websites comes down to running code after the page has loaded; niceties to query the DOM and hook into events. There's probably more but this is a start. The result is shorthand.js. Hint: it's not dissimilar to jQuery, but you can fully learn it in 5 minutes.

Which simplifies code to:

onLoaded(() => {
    const forms = $$('form.form-delete')
    forms?.forEach($form => $form.on('submit', ev => {
        cancel(ev)
        let confirmed = confirm(`Really delete status ${ev.target.dataset.id}?`)
        if (!confirmed) return
        ev.target.submit()
    }))
})

This is just a prototype and will evolve.

#technology #projects #lamb

Sander @ December 6 at 2:28 pm

Lamb image test

Image upload support has landed in the Lamb repo:

Drag images into the composer textarea and they will be automatically uploaded behind the scenes and inserted into the post as markdown, similar to how GitHub works:

Peek 2023-12-06 14-36.gif

This has been the main missing piece for me, so I'm very pleased. #lamb #projects

Sander @ July 28, 2023 at 11:43 am

Lamb 0.3.0

Introducing Lamb 0.3.0 - Literally Another Micro Blog. This release brings new features, improvements, and bug fixes, making blogging even easier. The update includes Docker support, an optional config.ini with support for menu items to customize your installation, improved documentation, and more.

Lamb offers a simple, self-hosted single-author blog with a Twitter-like interface, friction-free Markdown entry, discoverable Atom feed, hashtags support, and a 404 fallback URL feature.

Download the latest release from GitHub and provide your valuable feedback. #lamb #projects

Sander @ March 24, 2023 at 9:46 am

Lamb 0.2

I've released Lamb 0.2, my micro blogging app that's powering this site.

What's new?

#lamb #projects

More info and download link

Sander @ March 21, 2023 at 12:41 pm

Basic routing using REQUEST_URI

So for nginx it is not straightforward to setup PHP-FPM so that PATH_INFO is correctly populated. Lamb uses the following /index.php/some/other type routing, where /some/other should be the PATH_INFO. Instead I want to make setup for a variety of web-servers straightforward, so I've switched to the more robust REQUEST_URI. This simplifies nginx configuration and Caddy and the PHP built-in web-server are compatible.

REQUEST_URI contains everything after the domain name, including the query string, so that needs to be removed:

$request_uri = '/home';
if ( $_SERVER['REQUEST_URI'] !== '/' ) {
    $request_uri = strtok( $_SERVER['REQUEST_URI'], '?' );
}

We can see that for a request for the root of the site, REQUEST_URI returns / whereas PATH_INFO would be empty, so the code above takes that into account. We can then deduct a router action as follows:

$action = strtok( $request_uri, '/' );

Once the $action is known, it can be checked against an allowed list of actions:

switch ( $action ) {
    case 'edit':
        ...
        break;
    default:
        respond_404();
        break;

#php #lamb

Sander @ March 16, 2023 at 4:49 pm

404 Fallback comes to Lamb

I've added a 404 fallback feature to Lamb. What this means is that if you request a URL that doesn't exist on your Lamb instance, it will redirect to the same relative path on the domain you have provided in the configuration, if you enabled this feature.

This means you can move your site from example.com to say 2023.example.com and then set that as the 404 fallback url and you will not lose any SEO traffic! Here's an example! #lamb #projects

Sander @ March 15, 2023 at 12:42 pm

Alright got the webserver configuration figured out and the full site is up. Didn't forget about Caddy. #lamb #projects