Category Archives: Software Development

WordPress Block rending simple HTML

When I wrote my notes on the Grit boot I made a mini quiz based on the questions in the book – originally that was just in a “classic” WordPress posting, but with the recent update to Gutenberg the hacky little script stopped working. So I thought I’d have a look at coming up with a slightly less hacky WordPress Block. This is just some notes on what I did to basically create a block which is a block with predefined HTML (nothing fancy).

Using the WordPress command line interface (CLI) I created a simple package (needed to hold a block) followed by a block using:

$ php wp-cli.phar scaffold plugin "grit-quiz"
$ php wp-cli.phar scaffold block grit-quiz --title="Grit Quiz" --plugin="grit-quiz"

The changes then just need to be made to the index.js file in wp-content/plugins/grit-quiz/blocks/grit-quiz. After a bit of hunting I needed to have an element RawHTML returned so I changed the save method so that it would store the HTML directly.

save: function() {
	return el(
		"p", 
		null, 
		el(
			wp.element.RawHTML, 
			null, 
			formHtml // a variable with the basic HTML
		)
	);
}

As with all of these things the result is quite simple but only when you know the answer. I have popped the full code here for future reference.

Responsibilities of a team

The product owner, development team and scrum master have distinctly different roles.  The product owner is clearly the person responsible for building the right thing but sometimes the development team just think they are there to build what they are told – this is not the case at all, the development team has many more responsibilities such ensuring reliability, scalability, alerting, monitoring, and many more.  The scrum masters role is to remove impediments and to make sure the development team is able to work as fast as they can.  All three roles are responsible for the product being functionally appropriate, technically competent and delivered without delay.

Scrum responsibilities
Product Owner – Build the right thing; Development team – Build the thing right; Scrum Master – Build it fast. Everyone is responsible for the product.

AWS Lambdas Action Routing

I have been playing with AWS lambdas for a few weeks trying to create a project.  One of the complications which the standard approach to lambdas is that each handler is its own lambda.  This mean that for any shared models meed to go into a separate but for DAOs this is a little problem as you need to import AWS SDK into the separate project then exclude it before using it in your different lambda functions and it all gets a bit messy.

I have just come across a talk (included at the end).  Here he uses the AWS API gateway to append an action parameter to the JSON.  Using a little code within the app (here on GitHub) these requests are routed within the application to the relevant action to be performed.  This approach might not be best practice, as he highlights, but for a small prototype application this will allow applications to be developed much quicker and at a future stage it would be quite straight forward to split off the different Lambdas if the prototype is successful.