I recently moved from Text Wrangler to Sublime Text for editing YAML files for Ansible. Getting it set up right involves very little and now with Ansible syntax highlighting it offers a light weight editor for your plays.
In this post I note down some of the steps to get it setup the way I like it.
In this article I look at a very simple example of how to convert complex variable structures to simple lists using Jinja2 filters within an Ansible task.
Working on a long Ansible play today - I was tripped up by a hidden unicode character inadvertently entered in to a YAML file - resulting in a UnicodeDecodeError: 'ascii' codec can't decode byte 0xc2 in position 0: ordinal not in range(128) slap in the face. Here is how to deal with that!
One of the great things about Ansible is being able to use Jinja filters both in templates and in yaml files.
I came across a not so great thing today though. Running a play I got the following error: "template error while templating string: expected token 'end of print statement', got ':'"
But the error was 'thrown' by a task I haven't changed in ages. It appears it actually related to a jinja filter error in a subsequent task.
I came across a great Ansible tip recently that showed how to use the validate option of the template module in Ansible. A great solution for testing configuration before it goes live. However it doesn't work with Apache (apachectl -t -f) - you get a validation error like "Invalid command 'Order', perhaps misspelled or defined by a module not included in the server configuration" for syntax that is perfectly valid. A bit of investigation shows though that this is expected and you have to go a bit further - but I came up with a solution.
I regularly encounter issues that arise from reviews of server security, log reviews etc that provide good examples of how Ansible can be used to respond to an issue.
If you are using a utility like Logwatch to keep an eye on activity on your servers you may occasionally see an entry such as 'Connection attempts using mod_proxy' - Addressing this with Ansible is simple, and maintains the state of your security measures.
We were commissioned to create a Drupal Commerce based web site for a top Moscow bakery.
The site is a custom themed multilingual site offering online ordering, delivery slot choice alongside recipes and other product information.
The Drupal Commerce framework is an ideal platform for the creation of an online shop and with a degree of customisation provides an excellent base for this multilingual online bakery.
This is a follow on post to the 'Using Apache to block Spammers' post.
It shows how to use Includes in your Apache configuration to re-use useful rules.
We have pledged support to get Rules 8 ready for Drupal 8.
Rules is a key part of a lot of developments we have done in the past and certainly will be in the future so we are happy to pledge support to get the development ready for Drupal 8. This is a small contribution back to such a key module and we encourage others do do the same!
The Royal Botanical Gardens at Kew engaged us to convert an existing MS Access desktop database into a multilingual CMS based web site. The site is a responsive mobile and tablet friendly CMS based web site that enables the management of a database of tree data for conservation purposes. The data relate to trees native to the Atlantic Forests of Brazil that could be used for reforestation - The South Eastern Bahia Atlantic forest database.
The following gists shows a few approaches for working with Drupal commerce order totals.
All three examples retrieve the order total as two components Ex Vat and VAT:
The first example shows how to get nicely formatted amounts. This is easily done using two functions:
commerce_price_component_total() - Returns the total value and currency for the specified price component in a price array.
commerce_currency_format() - formats the amount with the correct localization and currency symbol
The internationally renowned manufacture of hard wearing and fashionable workwear - Dickies - engaged us to create a web site for their workwear range.
The web site presents their range of workwear and links through to a network of online distributors and retail shops. The site is presented in 10 languages, is responsive and optimised for multilingual SEO.
The site also provides access to corporate information and enables the ordering of custom workwear, embroidery and access to the extensive image library of Dickies products.
I didn't see this one coming but on a Multilingual Russian site we recently built, the client asked us to translate the Russian Rubble symbol "руб" to "RUB" when viewing products in English.
As there are no localized options for currency settings I had a look around the commerce code and came across commerce_currency_format() in commerce.module.
I have come across a lot of discussions about how to add a reset button to a form in Drupal 7. Also it would be nice if when we added a reset button it didn't get a class of 'form-submit'. To get around this, rather than using standard method of adding a button to the render array of the form, most solutions opt for using #markup.
I gave a presentation at Drupal Somerset the other night on some simple tips for using the command line to help with your Drupal development.
I have included the slides here. I have annotated the slides since they don't have the verbal explanations!
Log files can get filled up with repeated calls to files such as favicon, robots.txt, images, css js etc
This can be a pain when you need to scan the logs for issues and they are full of unimportant requests.
This is especially so if you use Ultimate Cron in Drupal and run cron every minute - the logs get swamped with the cron calls.
Mostly you want to log the initial request for a page and not all of the resources subsequently requested.
Troubleshooting other issues may mean you would log files such as favicon, images etc - but generally they needlessly fill up your logs.
There are certain PHP files that you want access to but don't want to make public.
Common examples of these are:
You also don't really want to deploy these on all of your sites on a server nor have them in your git repositories for sites.
A neat way of dealing with this is to use rewriting in your web server config files (e.g. Apache, NGINX, IIS etc) to do the following:
Having created a Drupal Commerce site it is likely you may need to have a mechanism to list the best sellers / a count of orders by product or similar.
Her's a quick solution that will help you.
Even if you are familiar with the structure of the commerce model this is still a complex task; linking line items, orders, products, product displays etc.
There is some background discussion here: https://drupal.org/node/1292104
This is going to be a step by step guide for localizing & translating a Drupal 7 commerce site. there are many ways and tools Drupal and its contributed modules support and this is just one of them.
I will not go into too much explanations but will try and make sure I cover all the steps needed to translate a Drupal commerce site.
Note: commerce kickstart 2 comes with some of this but last time I checked it did not provide full localization and translations features.
Sometimes you come across a problem in SQL that is far more complex than you first imagine. One classic of these is 'Relational Division' - a poorly understood aspect of SQL that can help answer what must be a common question:
Return the things that have all of the items in a given list