User login


Drupal 8 default content the Agaric way

For the moment, we're following the crowd and using the Default content module. It is nice and has built-in integration with installation profiles, but the export could be more convenient (multiple items of content at once, please!) and import could be made much more robust (given half a chance, we'll reimplement it on migrate).

Is Git corrupting your font files?

I was getting errors like this in the console:

downloadable font: incorrect file size in WOFF header (font-family: "Graphik" style:normal weight:bold stretch:normal src index:1) source: ... themes/butaro/fonts/Graphik-Bold-Web.woff
downloadable font: rejected by sanitizer (font-family: "Graphik" style:normal weight:bold stretch:normal src index:1) source: ... themes/butaro/fonts/Graphik-Bold-Web.woff

Git would have given you warnings that look like this when you git added the fonts:

Saving message entities programmatically

Our use case, re-saving existing messages, is a bit more complex than it should be, but not bad. This code will work for new or existing messages.

Where $exports is an array of long text strings that is each the JSON dump received form exporting a message type through the UI:

Figuring out what Django permission names are and what permissions a user has

You can see the permissions a particular user has, in the 'machine-readable' form Django uses, quite easily through the Django shell. For a user with the username 'david', for example:

Set a separate browser window page title from HTML page title (Drupal 7)

This code shows how to set the browser bar page title the Page Title module way, without that module. (This was motivated simply because we were already gathering the info for another purpose in hook_node_view_alter(); there's no reason not to use Page Title!)

Setting breadcrumbs to exactly what you want

In Drupal it is quite easy to set breadcrumbs with the function drupal_set_breadcrumb(), which takes an array of links (as you would make with the l() function). It's a bit of a blunt instrument but it works (and wins out over hook_menu_breadcrumb_alter()).

Using Redshift with Mint on Debian

Redshift is a program that gives your computer screen a dimmer brightness, and indeed a more red hue, at night.

It fails silently on most non-Ubuntu Debian systems. Well, it seems like a silent fail or crash if you don't run the command in the terminal. If you do run the command gtk-redshift in the terminal, the output is perfectly comprehensible:

Initialization of gnome-clock failed.
Trying next provider...
Latitude and longitude must be set.

Set date and time on virtual machine independent of host machine

Our setup is a Debian guest with VirtualBox on an Ubuntu host, but the two basic steps look like they are the same on any combination.

Shut down all virtual machines and close VirtualBox first.

To the main VirtualBox configuration file — ~/.VirtualBox/VirtualBox.xml — and to the specific virtual machine's configuration file — something like ~/VirtualBox\ VMs/somename_default_1415392315537_7406/somename_default_1415392315537_7406.vbox — add the following, identical line into the existing <ExtraData> sections:

How to programmatically rename a content type (change node type machine name)

Set old_type if you want to programmatically update a node type / machine name.

(This is not about changing the type of a node, but changing what type is called on the machine-info level.)

$type->old_type is what node_type_save() checks for when updating a node type, if it's not set it will create a new node type even if orig_type is set to an existing bundle. So really all you need to do right before saving a modified content type is set the old_type to the orig_type, such as:

Syndicate content