In this post, I’m going to introduce a PHP package I recently released for generating screenshots of web pages. It’s pretty straightforward to get up-and-running, as I’ll demonstrate.
Why Generate Screenshots?
There are a number of reasons you may wish to generate screenshots. My motivation behind the package originally was to build a simple “directory” of websites, using screenshots to illustrate the sites.
Screenshots are also useful in testing; you could even run a script to periodically generate a screenshot of one of the sites you maintain in order to check that everything is rendering okay.
What are the Options?
Before I introduce the package, it’s worth mentioning that there are a number of third-party services which make it even easier to generats screenshots such as Browshot, URL2PNG, Shrink the Web and Urlbox — but it’s worth noting that these are all paid services. If you’d rather do it yourself, or do it on-the-cheap, you might like to try out my package.
At time of writing, Spotify doesn’t provide a track’s artwork via its API.
So, I’ve written a simple function to get the image; but please note, not only is it quick and dirty, but it’s horribly inefficient and should be used sparingly — at the very least, make sure you cache the results somewhere!
You can access a public-facing web-page about a particular track using the following URL:
…where [TRACK-ID] is the last part of the track’s URI — so for example, for the track represented by the URIspotify:track:5fpizYGbi5IQoEraj6FP0R, the track ID would be 5fpizYGbi5IQoEraj6FP0R, and thus the URL to the page would be:
Laravel is the new kid on the block of PHP frameworks, and whilst in its early stages of evolution (the author wrote it, he says, in the early part of 2011) it does promise — and delivers, from what I can tell — an expressive syntax and an elegant (indeed, you might say eloquent) ORM. Laravel is a fully Object Oriented MVC framework which makes extensive use of features new or recent to PHP — you can forget about running it on PHP4. With PHP5.3 compliant namespacing mechanisms as opposed to, for example, Zend Framework’s pseudo-namespacing, it’s certainly what you might call a modern framework.
I needed the means to add a quote to a website I was working on — a simple task, which could be acheieved by simply adding a text or HTML block. However this can be taken a step further by implementing a simple block type specifically for quotes, with the markup generated for you.
To mark up a quote semantically, we’ll want a blockquote for the content and a cite for the source (or author), so the HTML needs to look something like this:
<p>It is the mark of an educated mind to be able to entertain a thought without accepting it.</p>
…which will give us something a little like this:
In this simple tutorial, I’m going to show how Concrete5 can be extended to integrate a third-party JQuery plugin to enhance an existing module, and then how this can be encapsulated in a package. I’m going to allow the slideshow module to display images using the clean & lightweight Craftyslide plugin, pictured below.
Concrete5 comes shipped with simple slideshow functionality in the form of a block called, imaginatively enough, slideshow. As this is part of the core you can find it in /concrete/blocks/slideshow. It’s in the concrete directory to keep it separate from custom code. And some custom code is what we’re going to produce — to override the output of that block, and then to encapsulate this into a package.
In the first part, I looked at creating the database schema for a simple Drupal module designed to allow you to associate colours with taxonomy terms. In this second part, I’ll look at the administration aspects of the module. In essence, what we need to do is as follows:
Since colour-coding may only be appropriate to certain vocabularies (e.g. categories) and not others (tags, perhaps). We need to provide the user with the option to specify which vocabularies are applicable.
The user needs to be able to specify a colour when adding or editing a term, where appropriate.
We need to provide a mechanism which allows the colour associated with a term to be stored, retrieved, and to be displayed.