Elsewhere

Open Source Training: Filter Drupal Content Based on File Type

Planet Drupal - Tue, 09/12/2014 - 19:11

One of our members asked an interesting question about Views.

They had a file field on their user profiles. In that field, the user could upload an image, an audio file, or link to a YouTube video. So far, so good. However, in Views, they only wanted to show that field if it contained a video.

Here's the solution to that problem. We're going to show you how to filter Drupal content based on the type of file that's attached to it.

Categories: Elsewhere

Drupal Watchdog: Test Now! - Travis Integration for your Drupal Modules

Planet Drupal - Tue, 09/12/2014 - 18:46

Travis-CI is a free-for-OSS continuous integration server, which has become very popular in the PHP world. Drush, Symfony, and dreditor all use it for frequently testing their code base and pull requests for regressions and ensuring new functionality has the needed test coverage.

Compared to the current Drupal testbot, Travis-CI allows testing of not only simpletest on PHP 5.3 (for Drupal 7 projects), but of most everything that you can install on a Debian system, e.g. QUnit for JavaScript, Behat, PHPUnit, but also Ruby based projects, Bash projects, Go projects, etc.

You can also test various scenarios in a matrix like setup, e.g. different PHP versions to ensure your code runs on both PHP 5.3 and 5.4 or with different versions of a dependent library.

This flexibility comes with a price however, because you need to setup the whole environment yourself. The selected PHP version (with xdebug) and composer are pre-installed, but that's it. The Drupal base installation, the running of the tests, the parsing of the test output, and ensuring dependencies are there is all your own responsibility.

And because of that there are many different .travis.yml files floating around the net for various scenarios of setting up this or that, but in the end everyone re-invents the wheel. Until now…

As Easy as it Gets

I am proud to announce the drupal_ti project, which allows any module on drupal.org to easily leverage travis-ci.org for testing:

  • PHPUnit
  • SimpleTest
  • Behat

The process (which I will show in more detail below) is as simple as copying a generic .travis.yml.dist file as .travis.yml to your modules root, push your repository to Github, activate the repository at travis-ci.org and you are done.

Oh, and while you are at it, if you add a .coveralls.yml file, then code coverage is automatically reported to coveralls.io, too (for PHPUnit).

All the hard work of installing drupal, running a web server, setting up Selenium, etc. is done by drupal_ti.

So you don't have to copy some .travis.yml you found on the net and spend hours debugging little edge cases (HHVM and sendmail, how to parse the simpletest output, etc.), but can depend on a proven and self-tested code base.

Features
  • Drupal 8 ready: drupal_ti supports both Drupal 7 and 8 modules. Use DRUPAL_TI_ENVIRONMENT="drupal-8" for your Drupal 8 modules.
  • Tested: drupal_ti tests its own code base for both Drupal 7 and Drupal 8 modules.
  • Modular architecture: drupal_ti has so called 'runners' and you can combine either e.g. "phpunit simpletest" or run them as separate workers by specifying a matrix.
  • Environment aware: drupal_ti has a file for each environment, which makes the code generic for both Drupal 7 and 8.
  • Examples provided: drupal_ti provides easy examples of the needed files in tests/drupal-{7,8}/drupal_ti_test. So you can get started easily!
  • Extensible: By specifying DRUPAL_TI_SCRIPT_DIR_BEFORE or DRUPAL_TI_SCRIPT_DIR_AFTER you can easily create your own runners and environment includes that run before or after the main runners. This could even come from composer.
  • Usable for non-travis CI: Because drupal-ti is just a command and because .travis.yml just has some environment vars, you can just copy the main declarations to some environment.sh file, set the TRAVIS_BUILD_DIR and use it locally, too.
An Example Conversion

My module registry_autoload uses simpletest on drupal.org to test its features. Now I want to test some advanced trait support, which needs PHP 5.4, so travis-ci.org is an option to do so.

Step 1 - Create the GitHub Repository and Push Your Code
  1. Sign in to github.com
  2. Click: + > New repository, enter: registry_autoload
  3. Click: Create repository

Copy the commands displayed by Github to push your code to GitHub. I like to use drupal.org as my upstream and GitHub as my origin remote:

$ git clone --branch 7.x-1.x Fabianx@git.drupal.org:project/registry_autoload.git $ cd registry_autoload $ git remote rename origin upstream $ git remote add origin git@github.com:LionsAd/registry_autoload.git $ git push -u origin 7.x-1.x Step 2 - Activate Travis-ci.org

Now head over to travis-ci.org:

  1. Choose "Sign in with GitHub" and follow instructions
  2. Click on your name at the top right, "Fabian Franz" for me
  3. Click: "Sync now" if you don't see the repository, yet
  4. Simply switch the toggle to "ON" for the project
  5. Click on the repository settings icon (the "tools icon")
  6. Toggle "Build only if .travis.yml is present"
  7. Click on "Build history"
  8. Leave the browser window open
Step 3 - Add drupal_ti .travis.yml

Now checkout a new branch, and add the .travis.yml file:

$ git checkout -b travis-integration $ curl https://raw.githubusercontent.com/LionsAd/drupal_ti/master/.travis.yml.dist -O $ mv .travis.yml.dist .travis.yml

Then, customize the following parts of the file:

# Configuration vars. - DRUPAL_TI_MODULE_NAME="registry_autoload" - DRUPAL_TI_SIMPLETEST_GROUP="Registry"

And:

matrix: # [[[ SELECT ANY OR MORE OPTIONS ]]] - DRUPAL_TI_RUNNERS="simpletest"

The simpletest group is returned from getInfo() in Drupal 7, but an annotation @group x in Drupal 8. Despite the name of the variable, you could also put in a class like RegistryAutoloadTestCase. Basically anything that SimpleTest accepts on the command line as last argument. The clue is that this variable accepts spaces e.g. "DrupalTi Test", which is else very difficult to achieve when passing variables around.

Now add the file and push to GitHub:

$ git add .travis.yml $ git commit -m "Added travis integration" $ git push origin travis-integration Step 4 - Watch the Test Run

Now head back over to your browser window and magically there will be a new build, click on it and you will see a matrix like structure, here shown for build #2:

Click on PHP 5.4 and click the little button on the far right with "follow", to follow the output.

After a while the build is finished and all tests passed:

Congratulations, your project is now tested on travis-ci.org!

Now merge, the branch into your mainline and whenever you want to test a change on travis-ci.org just push a branch or make a pull request:

$ git checkout 7.x-1.x $ git merge travis-integration $ git push origin 7.x-1.x # Also push the changes back to drupal.org $ git push upstream 7.x-1.x

The easiest way to work with this kind of integration is to push all patches to origin first and once satisfied, push to upstream. That way GitHub and drupal.org are always in sync.

To be Continued…

In the next part of this series, I will explore how you can get started with unit testing locally and on travis-ci.org (using drupal_ti) and afterwards we will take a look at some easy behat setup.

If you are curious and want to start now, take a look at the run-* scripts in:

Enjoy and please leave me feedback either in the Drupal issue queue or on the GitHub project page.

About the Author

Fabian Franz is a Senior Performance Engineer and Technical Lead at Tag1
Consulting. He is author of the registry_autoload, service_container and render_cache modules for Drupal 7 and a contributor to Drupal 8 Core in the form of reviews, patches, and co-leader of the Twig initiative.

Tags:  Testing Contributed modules Third-party tools Images: 
Categories: Elsewhere

C.J. Adams-Collier: MySQL Meet-up 20141208

Planet Debian - Tue, 09/12/2014 - 18:31

I had an enjoyable time last night at Twitter with local MySQL DBAs and developers. We had an attendee who has no experience with SQL or programming at all. She is interested in organizing her collection of recipes and had heard a rumor that MySQL was a good tool to use for this task. She indicated that her desktop runs Windows 7. I think I’m going to encourage her to turn her concept in to a community project, as she is not the first person I’ve met who wants to organize recipes!

We were hosted by Rob at Twitter, who used to work with Lisa back before she retired. He’s a member of the site reliability team and keeps the fail whale from rearing its blubbery head.

Pizza was provided by my dear friend and long-time open source buddy Gerry Narvaja with the assistance of the folks in the kitchen at Zeek’s.

We discussed new techniques in the areas of load balancing and high availability. Five nines is no longer the thing that people talk about, instead it’s six nines. It’s a brave new world out there!

I was not the only person who was excited about one of the latest features in MariaDB / MySQL to come out of HP, the high resolution time data types.

One of the attendees is an old hand at COBOL and was asking if anyone knows where one can get a COBOL runtime environment. I’ve never thought about that before… Let me ask the googs… Looks like there’s an active project called GNU COBOL which is officially part of the GNU project:

Categories: Elsewhere

Aten Design Group: Debugging New to You Drupal Blocks

Planet Drupal - Tue, 09/12/2014 - 17:20

Let’s say a friend (or a new client) asks you to make a small change to their Drupal website. You’ve never seen this site before and the original developer(s) are long gone. Of course the text is in some obscure block. Sometimes finding where to make the requested change is easy. Sometimes it’s not. I’m going to go through some debugging tips for such a case.

The first thing you should do is inspect that part of the page with your browser’s dev tools (e.g. Firefox, Chrome). Often IDs and class names will help identify the block.

Here’s an example of the DOM of a view block from the nodequeue module.

<div id="block-views-nodequeue-2-block" class="block block-views contextual-links-region block--marquee">

The ID "block-views-nodequeue-2-block" means this is a views block. "nodequeue-2" is the view machine name, and "block" is the name of the specific display in that view. You can browse the list of views at /admin/structure/views, or in this case, go directly to /admin/structure/views/view/nodequeue_2/edit/block. The path to edit a view in Drupal 7 is always at /admin/structure/views/view/[VIEW NAME]/edit/[DISPLAY NAME]. If contextual links are on, it may be even quicker to access the edit page from the options available. Look for a gear icon in the upper right corner of the section.

Here’s a block defined in code:

<div id="block-cei-custom-blocks-cei-unicef-timeline" class="block block-cei-custom-blocks contextual-links-region">

In this case in cei_custom_blocks_block_info() defines a block delta: $blocks['cei_unicef_timeline'] The code that defines this block’s output will either be in cei_custom_blocks_block_view() or that function will call another.

In one particular case I didn’t have a lot to go on. There was very little in the DOM. This members page consisted of user images, name, and title. The client requested one additional field be included for each user on the members page. It wasn’t a view or anything else easily identifiable. The output was in system block 0 which doesn't give me anything to go on. One particularly unique class name was block-totem-common-embed-type-search-0 (this was the totem install profile) but a search of the code turned up nothing. That’s because the code that built these blocks was highly abstracted. Reviewing that code didn’t reveal where I could add the field either. Finally I searched on another class name. I didn’t find exactly where the class name was inserted, but it happened to match a template file that was in one of the submodule's ‘inc’ directories.

<div<?php print $attributes; ?>> <?php print $user_profile['images']['user_thumb']; ?> <?php print render($title_prefix); ?> <h3><?php print render($user_profile['name']); ?></h3> <?php print render($title_suffix); ?>   <div class="clearfix"></div> </div>

Once I found that, making the needed modification was simple.

To help identify a block, you can also look at what is placing the block on the page. Some ways this can be done include the blocks UI, Context module, Panels, print directly in code, and template files. If a lot of blocks are placed using the blocks UI, this page can get unwieldy. It’s worth searching the codebase for any distinct phrases. A quick search in the database can also be useful.

Blocks saved in the database are in the blocks and blocks_custom tables. One way to find such a block in the database uses a query for some matching text:

SELECT * FROM block_custom WHERE body LIKE "%participate in discussions%"\G

The query matched the following entry:

*************************** 1. row *************************** bid: 3 body: <p><strong>A message from the GEC team</strong></p> <p>During the recent GEC baseline sharing events, one of the key messages that came through loud and clear from you was the value of meeting other projects and exchanging knowledge, sharing challenges, solutions, experiences and advice. We began to see the GEC community take root, and to continue this momentum we are launching the GEC forum &ndash; a place for the GEC Community of Practice to develop and grow. This will be the place for you share your expertise, participate in discussions, and interact with other projects that form the community of the Girls&rsquo; Education Challenge. <a href="http://www.educationinnovations.org/forums/introducing-girls%E2%80%99-education-challenge-forum">Read more...</a></p> <p>&nbsp;</p>   info: GEC welcome message (deliberately not in code) format: full_html

Such a block can be edited at /admin/structure/block/manage/block/3/configure. The path to edit a block is always at /admin/structure/block/manage/[Block ID]/configure.

Hopefully these tips will be useful the next time a completely unknown website is dropped in your lap.

Categories: Elsewhere

Acquia: PHP: Under the Hood, Running the Web

Planet Drupal - Tue, 09/12/2014 - 17:13

Most non-technical people out on the Web haven't heard of PHP before. They might not have even heard of many of the products that were built with this technology like Drupal, Magento, or WordPress. And together with other products built with PHP, these run about 83% of all internet web applications. The technology of PHP is very important to an enormous number of businesses, governments, and organisations around the world, so even though people might not be familiar with the language itself, there’s a very good chance they’ve used it online today.

Categories: Elsewhere

Enrico Zini: radicale-davdroid

Planet Debian - Tue, 09/12/2014 - 16:35
Radicale and DAVDroid

radicale and DAVdroid appeal to me. Let's try to make the whole thing work.

A self-signed SSL certificate

Generating the certificate:

openssl req -nodes -x509 -newkey rsa:2048 -keyout cal-key.pem -out cal-cert.pem -days 3650 [...] Country Name (2 letter code) [AU]:IT State or Province Name (full name) [Some-State]:Bologna Locality Name (eg, city) []: Organization Name (eg, company) [Internet Widgits Pty Ltd]:enricozini.org Organizational Unit Name (eg, section) []: Common Name (e.g. server FQDN or YOUR name) []:cal.enricozini.org Email Address []:postmaster@enricozini.org

Installing it on my phone:

openssl x509 -in cal-cert.pem -outform DER -out cal-cert.crt adb push cal-cert.crt /mnt/sdcard/ enrico --follow-instructions http://davdroid.bitfire.at/faq/entry/importing-a-certificate Installing radicale in my VPS

An updated radicale package, with this patch to make it work with DAVDroid:

apt-get source radicale # I reviewed 063f7de7a2c7c50de5fe3f8382358f9a1124fbb6 git clone https://github.com/Kozea/Radicale.git Move the python code from git to the Debian source dch -v 0.10~enrico "Pulled in the not yet released 0.10 work from upstream" debuild -us -uc -rfakeroot

Install the package:

# dpkg -i python-radicale_0.10~enrico0-1_all.deb # dpkg -i radicale_0.10~enrico0-1_all.deb

Create a system user to run it:

# adduser --system --disabled-password radicale

Configure it for mod_wsgi with auth done by Apache:

# For brevity, this is my config file with comments removed [storage] # Storage backend # Value: filesystem | multifilesystem | database | custom type = filesystem # Folder for storing local collections, created if not present filesystem_folder = /var/lib/radicale/collections [logging] config = /etc/radicale/logging

Create the wsgi file to run it:

# mkdir /srv/radicale # cat <<EOT > /srv/radicale/radicale.wsgi import radicale radicale.log.start() application = radicale.Application() EOT # chown radicale.radicale /srv/radicale/radicale.wsgi # chmod 0755 /srv/radicale/radicale.wsgi Make radicale commit to git # apt-get install python-dulwich # cd /var/lib/radicale/collections # git init # chown radicale.radicale -R /var/lib/radicale/collections/.git Apache configuration

Add a new site to apache:

$ cat /etc/apache2/sites-available/cal.conf # For brevity, this is my config file with comments removed <IfModule mod_ssl.c> <VirtualHost *:443> ServerName cal.enricozini.org ServerAdmin enrico@enricozini.org Alias /robots.txt /srv/radicale/robots.txt Alias /favicon.ico /srv/radicale/favicon.ico WSGIDaemonProcess radicale user=radicale group=radicale threads=1 umask=0027 display-name=%{GROUP} WSGIProcessGroup radicale WSGIScriptAlias / /srv/radicale/radicale.wsgi <Directory /srv/radicale> # WSGIProcessGroup radicale # WSGIApplicationGroup radicale # WSGIPassAuthorization On AllowOverride None Require all granted </Directory> <Location /> AuthType basic AuthName "Enrico's Calendar" AuthBasicProvider file AuthUserFile /usr/local/etc/radicale/htpasswd Require user enrico </Location> ErrorLog{APACHE_LOG_DIR}/cal-enricozini-org-error.log LogLevel warn CustomLog{APACHE_LOG_DIR}/cal-enricozini-org-access.log combined SSLEngine on SSLCertificateFile /etc/ssl/certs/cal.pem SSLCertificateKeyFile /etc/ssl/private/cal.key </VirtualHost> </IfModule>

Then enable it:

# a2ensite cal.conf # service apache2 reload Create collections

DAVdroid seems to want to see existing collections on the server, so we create them:

$ apt-get install cadaver $ cat <<EOT > /tmp/empty.ics BEGIN:VCALENDAR VERSION:2.0 END:VCALENDAR EOT $ cat <<EOT > /tmp/empty.vcf BEGIN:VCARD VERSION:2.1 END:VCARD EOT $ cadaver https://cal.enricozini.org WARNING: Untrusted server certificate presented for `cal.enricozini.org': [...] Do you wish to accept the certificate? (y/n) y Authentication required for Enrico's Calendar on server `cal.enricozini.org': Username: enrico Password: **** dav:/> cd enrico/contacts.vcf/ dav:/> put /tmp/empty.vcf dav:/> cd ../calendar.ics/ dav:/> put /tmp/empty.ics dav:/enrico/calendar.ics/> ^D Connection to `cal.enricozini.org' closed. DAVdroid configuration
  1. Add a new DAVdroid sync account
  2. Use server/username configuration
  3. For server, use https:////
  4. Add username and password

It should work.

Related links
Categories: Elsewhere

Tanguy Ortolo: Using BSD tar to change an archive format

Planet Debian - Tue, 09/12/2014 - 16:00
Using BSD tar to change an archive format Streamable archive formats

Archive formats such as tar(5) and cpio(5) have the advantage of being streamable, so you can use them for transferring data with pipes and remote shells, without having to store the archive in the middle of the process, for instance:

$ cd public_html/blog $ rgrep -lF "archive" data/articles \ | pax -w \ | ssh newserver "mkdir public_html/blog ; cd public_html/blog ; pax -r" Turning a ZIP archive into tarball

Unfortunately, many people will send you data in non-streamable archive formats such as ZIP¹. For such cases, bsdtar(1) can be useful, as it is able to convert an archive from one format to another:

$ bsdtar -cf - @archive.zip \ | COMMAND

These arguments tell bsdtar to:

  • create an archive;
  • write it to stdout (contrary to GNU tar which defaults to stdout, BSD tar defaults to a tape device);
  • put into it the files it will find in the archive archive.zip.

The result is a tape archive, which is easier to manipulate in a stream than a ZIP archive.

Notes
  1. Some will say that although ZIP is based on an file index, it can be stream because that index is placed at the end of the archive. In fact, that characteristic only allows to stream the archive creation, but requires to store the full archive before being able to extract it. .
Categories: Elsewhere

Hideki Yamane: ThinkPad X121e with UFEI boot

Planet Debian - Tue, 09/12/2014 - 14:09
I have ThinkPad X121e and recenly exchanged its HDD to SSD, then I've tried to boot from UEFI but I couldn't. And I considered its something wrong with this old BIOS verion but new one can improve the situation, tried to update it. Steps are below.
  1. get iso image file from Lenovo (Japanese site) (release note)
  2. put iso image into /boot
  3. add custom grub file as /etc/grub.d/99_bios (note: I don't separate /boot partition, maybe you should specify path for file if you don't do so). $ sudo sh -c "touch /etc/grub.d/99_bios; chmod +x /etc/grub.d/99_bios"and edit /etc/grub.d/99_bio file. #! /bin/sh
    menuentry "BIOS Update" {
    linux16 memdisk iso
    initrd16 xxxxxxxxxx.iso
    }
  4. update grub menu with and check /boot/grub/grub.cfg file $ sudo update-grub
    $ tail /boot/grub/grub.cfg
  5. make sure memdisk command is installed $ sudo apt-get install syslinux
  6. just reboot and select bios update menu
Looks okay, its firmware update was success but I cannot boot it (installation was okay). Hmm...

As Matthew Garrett blogged before, probably ThinkPad X121e's firmware doesn't allow to boot from any entries in UEFI except "Windows Boot Manager" :-(

 ...So I have to back to legacy BIOS. *sigh*
Categories: Elsewhere

Thorsten Glaser: The colon in the shell: corrigenda

Planet Debian - Tue, 09/12/2014 - 11:40

Bernhard’s article on Plänet Debian about the “colon” command in the shell could use a clarification and a security-relevant correcture.

There is, indeed, no difference between the : and true built-in commands.

Stéphane Chazelas points out that writing : ${VARNAME:=default} is bad, : "${VARNAME:=default}" is correct. Reason: someone could preset $VARNAME with, for example, /*/*/*/*/../../../../*/*/*/*/../../../../*/*/*/* which will exhaust during globbing.

Besides that, the article is good. Thanks Bernhard for posting it!

PS: I sometimes use the colon as comment leader in the last line of a script or function, because it, unlike the octothorpe, sets $? to 0, which can be useful.

Categories: Elsewhere

Russ Allbery: wallet 1.2

Planet Debian - Tue, 09/12/2014 - 06:39

wallet is a system for secure credential management and distribution.

This release renames the duo object type to duo-pam (since it really only handles PAM integrations) and adds new object types duo-radius, duo-ldap, and duo-rdp to handle other types of Duo Security integrations.

It also adds a rename command, which can be used to rename existing objects without destroying them and recreating them. Currently, this only supports file objects.

My only role in this release was to do the final release management and a bit of release testing. The new code was implemented by Jon Robertson (who's also done a lot of work on wallet in the past).

You can get the latest release from the wallet distribution page.

Categories: Elsewhere

Damien McKenna: Need help with (final?) release of Panels for Drupal 6

Planet Drupal - Tue, 09/12/2014 - 04:11

After more than two and a half years since the last release, we need some help putting together what might be the final release of Panels for Drupal 6:

Tags: 
Categories: Elsewhere

James Oakley: Installing the latest version of Drush

Planet Drupal - Tue, 09/12/2014 - 00:21

In case you missed it, Drush has evolved recently.

Quick primer for beginners follows. (Although, if you haven't heard of Drush, the chances are this post was not written with you in mind. I blog about many subjects, and there aren't many readers who are interested in all of them!)

Drush stands for Drupal shell - it's a very powerful shell environment for managing Drupal sites using the command-line shell. … Read more about Installing the latest version of Drush

Blog Category: Drupal Planet
Categories: Elsewhere

Gregor Herrmann: GDAC 2014/8

Planet Debian - Mon, 08/12/2014 - 21:49

today, a pkg-perl member who was not very active for the last 2 or so years "re-appeared", & together we prepared & uploaded a new package. – always good to see people coming back!

this posting is part of GDAC (gregoa's debian advent calendar), a project to show the bright side of debian & why it's fun for me to contribute.

Categories: Elsewhere

Visitors Voice: Milestone reached regarding Search API for Drupal 8

Planet Drupal - Mon, 08/12/2014 - 20:55
For all of us who care about site search for Drupal, the maintainer Thomas Seidl has written a report about the current status of Search API for Drupal 8. The search crew’s vision is not only to port Search API to Drupal 8, but also to remove all known limitations, making site search for Drupal […]
Categories: Elsewhere

Bernhard R. Link: The Colon in the Shell.

Planet Debian - Mon, 08/12/2014 - 20:35

I was recently asked about some construct in a shell script starting with a colon(:), leading me into a long monologue about it. Afterwards I realized I had forgotten to mention half of the nice things. So here for your amusement some usage for the colon in the shell:

To find the meaning of ":" in the bash manpage[1], you have to look at the start of the SHELL BUILTIN COMMANDS section. There you find:

: [arguments] No effect; the command does nothing beyond expanding arguments and performing any specified redirections. A zero exit code is returned.

If you wonder what the difference to true is: I don't know any difference (except that there is no /bin/:)

So what is the colon useful for? You can use it if you need a command that does nothing, but still is a command.

  • For example, if you want to avoid using a negation (for fear of history expansion still being on by default on a interactive bash or wanting to support ancient shells), you cannot simply write if conditon ; then # this will be an error else echo condition is false fi but need some command there, for which the colon can be used: if conditon ; then : # nothing to do in this case else echo condition is false fi To confuse your reader, you can use the fact that the colon ignores it's arguments and you only have normal words there: if conditon ; then : nothing to do in this case # <- this works but is not good style else echo condition is false fi though I strongly recommend against it (exercise: why did I use a # there for my remark?).
  • This of course also works in other cases: while processnext ; do : done
  • The ability to ignore the actual arguments (but still processing them as with every command that ignores it arguments) can also be used, like in: : ${VARNAME:=default} which sets VARNAME to a default if unset or empty. (One could also use that the first time it is used, or ${VARNAME:-default} everywhere, but this can be more readable).
  • In other cases you do not strictly need a command, but using the colon can clear things up, like creating or truncating a file using a redirection: : > /path/to/file

Then there is more things you can do with the colon, most I'd put under "abuse":

  • misuing it for comments: : ====== here While it has the advantage of also showing up in -x output, the to be expected confusion of the reader and the danger of using any shell active character makes this general a bad idea.
  • As it practically the same as true it can be used as a shorter form of true. Given that true is more readable that is a bad idea. (At least it isn't as evil as using the empty string to denote true.) # bad style! if condition ; then doit= ; doit2=: ; else doit=false ; doit2=false ; fi if $doit ; then echo condition true ; fi if $doit2 && true ; then echo condition true ; fi
  • Another way to scare people: ignoreornot= $ignoreornot echo This you can see. ignoreornot=: $ignoreornot echo This you cannot see. While it works, I recommend against it: Easily confusing and any > in there or $(...) will likely rain harvoc over you.
  • Last and least, one can shadow the built-in colon with a different one. Only useful for obfuscation, and thus likely always evil. :(){:;:};: anyone?

This is of course not a complete list. But unless I missed something else, those are the most common cases I run into.

[1] <rant>If you never looked at it, better don't start: the bash manpage is legendary for being quite useless as hiding all information in other information in a quite absurd order. Unless you look at documentation about how to write a shell script parser, then the bash manpage is really what you want to read.</rant>

Categories: Elsewhere

Appnovation Technologies: How to properly use PHP on Drupal views fields

Planet Drupal - Mon, 08/12/2014 - 18:58

Every once in a while, as a Drupal site builder you will come across this problem.

var switchTo5x = false;stLight.options({"publisher":"dr-75626d0b-d9b4-2fdb-6d29-1a20f61d683"});
Categories: Elsewhere

Nuvole: Atrium Folders for Open Atrium 2

Planet Drupal - Mon, 08/12/2014 - 18:19
Subtitle: Nuvole's files and documents management feature is now available for the latest version of Open Atrium

We received many requests to make an updated version of our Atrium Folders feature available for the latest version of Open Atrium, the excellent Drupal-based solution for Intranets developed by Phase2.

OECD sponsored the development of the new version as an open source project, in order to add a file management functionality to the Innovation Policy Platform site that it manages together with the World Bank. Atrium Folders for Open Atrium 2 is thus now available to everybody.

The usual features, a new way

Open Atrium changed completely and so did Atrium Folders. There are many differences under the hood, with a complete code rewrite, but the familiar user experience is still there.

Uploading and downloading files

Creating folders and adding files to the folders is as easy as creating any other content in Open Atrium 2: it is enough to create "Files sections". When you are viewing a folder, specific buttons allow to create subfolders, upload files and directly download any file.

Access management

The access management works like for other nodes in Open Atrium. Access to the folder can be restricted for both viewing and editing separately, and it can be determined at a folder level.

Notifications

The notification system of Open Atrium can also be used for folders. Users can be informed when new files are added, with the same interface used by other Open Atrium features.

And much more Media module support

The files are attached with the Media widget and it is thus possible to manage not only files, but everything Media supports, like for example YouTube videos or files attached to other content.

Multiple uploads, with drag and drop support

The multi-upload feature of Open Atrium 2 can also be used with Folders to upload several files at the same time. Drag and drop uploads are supported too.

Download folder as ZIP file

The download button for files exists also for folders and it allows to download a folder with its subfolders and all included files as a ZIP archive. This functionality is available as a submodule, bundled with Atrium Folders.

File and folder revisions

Atrium Folders supports history and revisions both for folders and files. You can view previous versions of a file and optionally restore an older version. This functionality is available as a submodule, bundled with Atrium Folders.

Download, installation and support

The Open Atrium Folders feature can be downloaded and installed like any other module.

It is available on drupal.org at https://www.drupal.org/project/oa_folders/

Please report any issues in the module's issue queue at drupal.org

Tags: Drupal PlanetOpen Atrium
Categories: Elsewhere

Andrew Pollock: [tech] A geek Dad goes to Kindergarten with a box full of Open Source and some vegetables

Planet Debian - Mon, 08/12/2014 - 18:04

Zoe's Kindergarten encourages parents to come in and spend some time with the kids. I've heard reports of other parents coming in and doing baking with the kids or other activities at various times throughout the year.

Zoe and I had both wanted me to come in for something, but it had taken me until the last few weeks of the year to get my act together and do something.

I'd thought about coming in and doing some baking, but that seemed rather done to death already, and it's not like baking is really my thing, so I thought I'd do something technological. I just wracked my brains for something low effort and Kindergarten-age friendly.

The Kindergarten has a couple of eduss touch screens. They're just some sort of large-screen with a bunch of inputs and outputs on them. I think the Kindergarten mostly uses them for showing DVDs and hooking up a laptop and possibly doing something interactive on them.

As they had HDMI input, and my Raspberry Pi had HDMI output, it seemed like a no-brainer to do something using the Raspberry Pi. I also thought hooking up the MaKey MaKey to it would make for a more fun experience. I just needed to actually have it all do something, and that's where I hit a bit of a creative brick wall.

I thought I'd just hack something together where based on different inputs on the MaKey MaKey, a picture would get displayed and a sound played. Nothing fancy at all. I really struggled to get a picture displayed full screen in a time efficient manner. My Pi was running Raspbian, so it was relatively simple to configure LightDM to auto-login and auto-start something. I used triggerhappy to invoke a shell script, which took care of playing a sound and an image.

Playing a sound was easy. Displaying an image less so, especially if I wanted the image loaded fast. I really wanted to avoid having to execute an image viewer every time an input fired, because that would be just way too slow. I thought I'd found a suitable application in Geeqie, because it supported being out of band managed, but it's problem was it also responded to the inputs from the MaKey MaKey, so it became impossible to predictably display the right image with the right input.

So the night before I was supposed to go to Kindergarten, I was up beating my head against it, and decided to scrap it and go back to the drawing board. I was looking around for a Kindergarten-friendly game that used just the arrow keys, and I remembered the trusty old Frozen Bubble.

This ended up being absolutely perfect. It had enough flags to control automatic startup, so I could kick it straight into a dumbed-down full screen 1 player game (--fullscreen --solo --no-time-limit)

The kids absolutely loved it. They were cycled through in groups of four and all took turns having a little play. I brought a couple of heads of broccoli, a zucchini and a potato with me. I started out using the two broccoli as left and right and the zucchini to fire, but as it turns out, not all the kids were as good with the "left" and "right" as Zoe, so I swapped one of the broccoli for a potato and that made things a bit less ambiguous.

The responses from the kids were varied. Quite a few clearly had their minds blown and wanted to know how the broccoli was controlling something on the screen. Not all of them got the hang of the game play, but a lot did. Some picked it up after having a play and then watching other kids play and then came back for a more successful second attempt. Some weren't even sure what a zucchini was.

Overall, it was a very successful activity, and I'm glad I switched to Frozen Bubble, because what I'd originally had wouldn't have held up to the way the kids were using it. There was a lot of long holding/touching of the vegetables, which would have fired hundreds of repeat events, and just totally overwhelmed triggerhappy. Quite a few kids wanted to pick up and hold the vegetables instead of just touch them to send an event. As it was, the Pi struggled to play Frozen Bubble enough as it was.

The other lesson I learned pretty quickly was that an aluminium BBQ tray worked a lot better as the grounding point for the MaKey MaKey than having to tether an anti-static strap around each kid's ankle as they sat down in front of the screen. Once I switched to the tray, I could rotate kids through the activity much faster.

I just wish I was a bit more creative, or there were more Kindergarten-friendly arrow-key driven Linux applications out there, but I was happy with what I managed to hack together with a fairly minimal amount of effort.

Categories: Elsewhere

Dries Buytaert: Announcing the Drupal 8 Accelerate Fund

Planet Drupal - Mon, 08/12/2014 - 18:01
Topic: DrupalDrupal Association

Today the Drupal Association announced a new program: the Drupal 8 Accelerate Fund. Drupal 8 Accelerate Fund is a $125,000 USD fund to help solve critical issues and accelerate the release of Drupal 8.

The Drupal Association is guaranteeing the funds and will try to raise more from individual members and organizations within the Drupal community. It is the Drupal 8 branch maintainers — Nathaniel Catchpole, Alex Pott, Angie Byron, and myself — who will decide on how the money is spent. The fund provides for both "top-down" (directed by the Drupal 8 branch maintainers) and "bottom-up" (requested by other community members) style grants. The money will be used on things that positively impact the Drupal 8 release date, such as hiring contributors to fix critical bugs, sponsoring code sprints to fix specific issues, and other community proposals.

Since the restructuring of the Drupal Association, I have encouraged the Drupal Association staff and Board of Directors to grow into our ambitious mission; to unite a global open source community to build and promote Drupal. I've also written and talked about the fact that scaling Open Source communities is really hard. The Drupal 8 Accelerate Fund is an experiment with crowdsourcing as a means to help scale our community which is unique compared to other efforts because it is backed by the official non-profit organization that fosters and supports Drupal.

I feel that the establishment of this fund is an important step towards more sustainable core development. My hope is that if this round of funding is successful that this can grow over time to levels that could make an even more meaningful impact on core, particularly if we complement this with other approaches and steps, such as organization credit on Drupal.org.

This is also an opportunity for Drupal companies to give back to Drupal 8 development. The Drupal Association board is challenging itself to raise $62,500 USD (half of the total amount) to support this program. If you are an organization who can help support this challenge, please let us know. If you're a community member with a great idea on how we might be able to spend this money to help accelerate Drupal 8, you can apply for a grant today.

Categories: Elsewhere

Code Enigma: Meaningful commit messages

Planet Drupal - Mon, 08/12/2014 - 13:51
At Code Enigma, most of our Jenkins builds post a git log into one of our IRC channels on completion. This helps the ops team to keep an eye on what's going on and to quickly spot any build failures. It also gives us a chance to see the commit messages that people are posting.
Categories: Elsewhere

Pages

Subscribe to jfhovinne aggregator - Elsewhere