Elsewhere

Microserve: Caching beyond the norm in Drupal 7

Planet Drupal - Tue, 09/02/2016 - 10:19
Caching beyond the norm in Drupal 7Feb 9th 2016

When developing in a drupal centric environment there are two general methods used to cache information on the system in modules, these can be used to persist while a page is loading using drupal static or for a longer periods using cache set and cache get.

I have used some other simple and alternative methods, and from reading notes before the drupal_static function declaration in bootstrap.inc; ways of getting even more efficient caching.

First I’ll address drupal static; it’s explained very neatly on this Lullabot article.

This is not necessarily always required. If you have a simple function in your code that you want to remember, a setting and speed is a must, you can just use a static variable.

function get_a_value($value_name) { static $function_settings = array(); if (!isset($function_settings[$value_name])) { //get variable from database and set it to $fetched_value $function_settings['$value_name'] = $fetched_value; } else { return $function_settings[$value_name]; } }

The static variable $function_settings stays persistent throughout the execution of your page, and the caching stays localised to your function / module.

Another way to do something similar to above, but to include the drupal_static function, would be to do an advanced drupal_static pattern (this is mentioned in the drupal_static notes).

function user_access($string, $account = NULL) { // Use the advanced drupal_static() pattern, since this is called very often. static $drupal_static_fast; if (!isset($drupal_static_fast)) { $drupal_static_fast['perm'] = &drupal_static(__FUNCTION__); } $perm = &$drupal_static_fast['perm']; //... }

This is taken directly from the notes. Here we assign a local static variable as in the previous example but if the local static variable is not set, we assign the local static variable to drupal_static. Now other functions and code outside of the function can call on drupal_static_reset and reset the locally declared static variable, but will still retain the efficiency of having the static variable locally as in the previous example.

The last method I would like to approach is by using a cache in an object:

class SomeClass { /** * * @var array */ protected $localCache = array(); public function getData($cid) { if ($data = $this->getCache($cid)) { return $data; } //nothing set //do time intensive task here and set to data $this->cache($cid, $data); return $data; } /** * * @param type $cid * @param type $data */ protected function cache($cid, $data) { $this->setLocalCache($cid, $data); cache_set($cid, $data, 'cache', strtotime('+7 days', time())); } protected function getCache($cid) { if ($data = $this->getLocalCache($cid)) { return $data; } if ($cache = cache_get($cid)) { return $cache->data; } return FALSE; } /** * * @param any $cid * @param any $data */ protected function setLocalCache($cid, $data) { $this->localCache[$cid] = $data; } /** * * @param any $cid * @return any */ protected function getLocalCache($cid) { return isset($this->localCache[$cid]) ? $this->localCache[$cid] : FALSE; } }

In this example, I do all the local caching within the object but if needs be, I will retrieve and save to the system cache if the required data is not saved locally. One thing I have omitted is methods to clear the local cache. This caching this essentially using a local property.

If you wanted to clear the cache externally, you could create a public method or a static method.

So that about wraps this one up. Have you used any different methods? Can it be done better? Tell me what you think in the comment section below.

Written by: Darren Whittington, Senior Developer

Microserve is a Drupal Agency based in Bristol, UK. We specialise in Drupal Development, Drupal Site Audits and Health Checks, and Drupal Support and Maintenance. Contact us for for further information.

Categories: Elsewhere

Deeson: Drupal Focal Point Module: Making the most of your images

Planet Drupal - Tue, 09/02/2016 - 10:15

Focal point is a Drupal module that allows site administrators to select an important portion of an image to focus on.

It’s similar in many ways to the Image field focus module. But rather than giving a square box with crosshairs for focusing and another for cropping (which you can only do inside the focus area and can be quite confusing), focal point allows you to select a single point on the image to focus on. It is also fully compatible with the Media module.

User experience

Let's take a look at focal point from an administrator's perspective. The user can click on the image at any point which adds an icon over that particular area, representing the chosen focal point (see below).

From this, the administrator can then select the “Image preview” link below the image which will display a page with both the original image and how the image will look with the different image styles.

As you can see below, the image has now been focused upon the parrot on the right.

Setup and configuration

Firstly, you need to download and enable the focal point module (https://www.drupal.org/project/focal_point).

Upon enabling the module you will find a new image style called “Focal Point Preview”. This is used for the admin page and is the default preview style for setting the focal point. It rescales the image width to 250px with upscaling allowed.

You will also have two new image effects available for cropping “Focal Point Crop” and “Focal Point Scale And Crop” within the drupal image styles at admin/config/media/image-styles.

These both crop down to the point to which the user has selected on the image, and ensure that the chosen focal point will not be cropped out of the image.

Now you can create a new image style with one of these image effects, and then apply this image style to an image field within the manage display page of your content type. The images will then crop to the selection the user has chosen.

Media

To enable the compatibility with the media module, you should ensure that the “Media module image fields” setting at admin/config/media/focal_point is enabled.

Then, after adding an image via a field using the media browser widget, another step is provided in the media browser overlay. You can now add a focal point as you would in a standard image field.

You can also edit previously uploaded images to set an individual focal point.

Categories: Elsewhere

DrupalCon News: You are the Coding & Development Track

Planet Drupal - Mon, 08/02/2016 - 18:40

With core Drupal 8 now in full swing and the contrib space rapidly maturing, now is an excellent time to get more deeply involved with one of the world’s largest open-source development communities. The Coding and Development track is focused on educating developers on the latest techniques and tools for increasing the quality and efficacy of their projects.

Categories: Elsewhere

blog.studio.gd: Views Plugins (Part 1) : Simple area handler plugin

Planet Drupal - Mon, 08/02/2016 - 11:56
In this series I will show you how to make use of the new Drupal 8 Plugin system, we begin with a simple example : the views area handler plugins.
Categories: Elsewhere

blog.studio.gd: Overview of CMI in Drupal 8

Planet Drupal - Mon, 08/02/2016 - 11:56
Some notes about the new Configuration management system in Drupal 8
Categories: Elsewhere

Janez Urevc: janezurevc.name runs on Drupal 8!

Planet Drupal - Mon, 08/02/2016 - 07:30
janezurevc.name runs on Drupal 8!

Drupal 8 was officially released last November. Since then I was planning to try migrating my blog from previous version of this great CMS. Drupal 8 comes with many improvements and I definitely wanted to leverage those also on my site.

Besides that I always used my personal site also as an experimental sandbox where I tested new Drupal modules, themes, technologies. Even if I am very active contributor to Drupal core and contributed modules and I've been working on an enterprise Drupal 8 project at my work I actually never migrated a site to Drupal 8 to this date. It was definitely something I wanted to try.

Previous version of janezurevc.name was running on Drupal 7. It is important to note migration from 7 to 8 isn't officially supported yet. Drupal 7 won't reach EOL for at least few more years, which makes this migration not critical. However, migrations from Drupal 6 have been fully supported since the day 8 was release. 6 will reach EOL this month, which makes migration from 6 to 8 an absolute priority.

Migration

My site is actually very basic. I am using content (2 content types), taxonomy (1 vocabulary), few contributed modules and that is really it. It turns out that every that I needed migrates reliably.

I started the process by reading official documentation. Besides Migrate and Migrate Drupal modules that come with core I needed few contributed modules. Drupal upgrade, Migrate tools and Migrate plus.

Migration itself was extremely easy. I installed Drupal 8 site, enabled migrate modules, started migration and waited for a few minutes. That's it! At least for core stuff. There are some glitches when it comes to contributed modules, but even that was fairly easy to resolve.

I can just thank to everyone that contributed to Migrate in Drupal core. You did an awesome job!

Theme

Drupal 7 version of my blog used Sky theme, which is unfortunately not ported to 8 yet. For that reason I needed to search theme repository and came across Bootstrap clean blog.

It looked nice and it had a Drupal 8 -dev release. Regardless of that it works as a charm. I even contributed minor patches and am planning to contribute few more.

How do you like the theme?

Modules

Like almost every Drupal website out there mine also uses few contributed modules. Let's see how that went.

Disqus

Disqus module has been ported as part of the Google summer of code project, which I've mentored in 2014. Module itself works very well. We changed architecture a bit; instead of having a custom database table we rather used a dedicated field type. This approach comes with many benefits. By doing this we're not limited to nodes any more. Disqus can be used on any entity type now.

Even if the port was there migration was not. I used this opportunity to dig into this part of Drupal a bit more. I wrote 7 to 8 migration support for everything Disqus needs. This includes general configuration, fields on entities, statuses and identifiers. My code is already committed and you can give it a try.

Did you try Disqus migration? Let me know how did it work for you.

Pathauto and Redirect

D8 ports are available on their Drupal.org project pages. They work as a charm. While core migrates existing aliases alias patterns, redirects and other configuration aren't supported yet. I had just 3 alias patterns and less than 10 redirects on my old site so this wasn't hard to fix manually.

If you meet @Berdir please buy him a beer. He did an awesome job porting this (any many other) modules.

Media

I was using media to embed images in WYSIWYG, which is using legacy embed token in Drupal 7. This part was unfortunately not ported yet. I was using this on lees than 10 places so I decided to fix this manually too. I used a simple SQL query to get node IDs of content that used legacy token. Then I simply changed it to standard tag with data-entity-* attributes, which Drupal 8 uses for it's own image embeds.

Markdown filter

Recently I found out that I prefer Markdown when producing written content. It doesn't interfere my writing flow nearly as much as WYSIWYG editors do. When using Markdown I focus on content instead of the appearance (for the same reason I really liked LaTeX during my university years).

Guess what? There is a module for that! Markdown filter comes with a text filter that will convert Markdown syntax to HTML when displaying it. And it also has a Drupal 8 port. Download, install, configure, use. It was as easy as that!

How does Markdown work for you? Do you prefer it over WYSIWYG editor as much as I do?

Other modules

I use few other modules on the page. All of them have some kind of Drupal 8 release:

All of them work without any problem. I downloaded, installed and configured them. Google analytics even comes with support for migration (which meant 3rd step was not needed).

Great work maintainers and contributors!

Other interesting stuff

I also used this migration to move my blog to a new hosting solution. Old blog was hosted on a VPS that I used in the past and am slowly moving away from it. Most of my sites and services are currently hosted on a dedicated server at Hetzner (they provide excellent value for a price so I'd definitely recommend them).

Recently I started using Docker for my development environments and I wanted to try it in production too (I mentioned I am (ab)using my personal site for experimenting, right? :)). As a result of that I'm hosting janezurevc.name in a Dockerized environment managed via Docker compose. Compose is super nice as it allows you to describe your infrastructure stack in a single YAML file. This allows you to commit it to a VCS repository and replicate infrastructure anywhere you want. But this is already a topic for some of my future posts.

Did you try to migrate your Drupal 6 or 7 sites to 8? How did it go? Which contributed modules are you using?

slashrsm Mon, 08.02.2016 - 07:30 Tags Drupal

View the discussion thread.

Categories: Elsewhere

ARREA-Systems: Drupal 8 Guided Tour module

Planet Drupal - Sun, 07/02/2016 - 01:38
Drupal 8 Guided Tour module JK Sun, 02/07/2016 - 08:38

In Drupal 8 there is a Tour module in core that is very useful when it comes to web applications. In EK management tools we target professional users with small to medium scale companies. They usually have limited resources and time to spend on back office trainings. This is where the Tour module is very convenient to introduce functionalities to users who can quickly grasp the functions available to manage their back office.

We use the Tour functionality in our pages to guide users in their daily tasks like for instance in the form to create a new invoice or project page:

 

 

Categories: Elsewhere

Entity Pilot: New in beta6 - share and move content between different Drupal sites

Planet Drupal - Sat, 06/02/2016 - 23:36

Entity pilot beta-6 comes with the ability to share and move content between different Drupal 8 sites.

Up until beta-5 your sites had to share the same configuration: i.e. content-types, fields etc.

From beta 6, you can now enable the Entity Pilot Map Config sub-module and decide how to handle missing fields and content-types.

Categories: Elsewhere

HollyIT: D8 Notes: 'Fields pending deletion' Exception

Planet Drupal - Sat, 06/02/2016 - 16:15
Categories: DrupalPlanet Drupal

While working on a module that defines a custom field I attempted a reinstall of the module. During the uninstall process I received the following exception:

Categories: Elsewhere

TimOnWeb.com: How To Force Search API To Reindex a Node / an Entity

Planet Drupal - Sat, 06/02/2016 - 05:36

By default Search API (Drupal 7) reindexes a node when the node gets updated. But what if you want to reindex a node / an entity on demand or via some other hook i.e. outside of update cycle? Turned out it is a quite simple exercise. You just need to ...

Read now

Categories: Elsewhere

TimOnWeb.com: Adding a custom extra field to entity / node display

Planet Drupal - Sat, 06/02/2016 - 05:36

I had a case recently, where I needed to add custom data to the node display and wanted this data to behave like a field, however the data itself didn't belong to a field. By "behaving like a field" I mean you can that field at node display settings and ...

Read now

Categories: Elsewhere

TimOnWeb.com: Replacing Menu Item Visibility module with custom "in code" solution

Planet Drupal - Sat, 06/02/2016 - 05:36

I'm a big fan of fighting with Drupal's inefficiencies and bottlenecks. Most of these come from contrib modules. Everytime we install a contrib module we should be ready for surprises which come on board with the module.

One of the latest examples is Menu item visibility (https://drupal.org/project ...

Read now

Categories: Elsewhere

Hideki Yamane: playing to update package (failed)

Planet Debian - Sat, 06/02/2016 - 04:51

I thought to build gnome-todo package 3.19 branch.

Once tried to do that, it seems to need gtk+3.0 (>= 3.19.5), however Debian doesn't have it yet (of course, it's development branch). Then tried to build gtk+3, it needs wayland 1.90 that has not been in Debian yet, too. So, update local package to wayland 1.91, found tiny bug and sent patch, and build it (package diff was sent to maintainer - and merged), easy task.

Build again, gtk+3.0 needs "wayland-protocols" that has not been packaged in Debian, yet. Okay... (20 min work...) done! Make wayland-protocols package (not ITPed yet since who should be maintainer, under same umbrella as wayland?), not difficult.

Build newest gtk+3.0 source as 3.19.8 with cowbuilder chroot with those package (cowbuilder --login --save-after-exec --inputfile foo.deb --inputfile bar.deb), ...and failed with testsuite ;) I don't have enough knowledge to investigate it.

Back to older gtk+3.0 source, build 3.19.1 is fine (diff), but 3.19.2 was failed to build, 3.19.3 to 3.19.8 were failed with testsuite.


Time is up, "You lose!"... that's one of typical days.
Categories: Elsewhere

Daniel Pocock: Giving up democracy to get it back

Planet Debian - Fri, 05/02/2016 - 23:07

Do services like Facebook and Twitter really help worthwhile participation in democracy, or are they the most sinister and efficient mechanism ever invented to control people while giving the illusion that they empower us?

Over the last few years, groups on the left and right of the political spectrum have spoken more and more loudly about the problems in the European Union. Some advocate breaking up the EU, while behind the scenes milking it for every handout they can get. Others seek to reform it from within.

Most recently, former Greek finance minister Yanis Varoufakis has announced plans to found a movement (not a political party) that claims to "democratise" the EU by 2025. Ironically, one of his first steps has been to create a web site directing supporters to Facebook and Twitter. A groundbreaking effort to put citizens back in charge? Or further entangling activism in the false hope of platforms that are run for profit by their Silicon Valley overlords? A Greek tragedy indeed, in the classical sense.

Varoufakis rails against authoritarian establishment figures who don't put the citizens' interests first. Ironically, big data and the cloud are a far bigger threat than Brussels. The privacy and independence of each citizen is fundamental to a healthy democracy. Companies like Facebook are obliged - by law and by contract - to service the needs of their shareholders and advertisers paying to study and influence the poor user. If "Facebook privacy" settings were actually credible, who would want to buy their shares any more?

Facebook is more akin to an activism placebo: people sitting in their armchair clicking to "Like" whales or trees are having hardly any impact at all. Maintaining democracy requires a sufficient number of people to be actively involved, whether it is raising funds for worthwhile causes, scrutinizing the work of our public institutions or even writing blogs like this. Keeping them busy on Facebook and Twitter renders them impotent in the real world.

Big data is one of the areas that requires the greatest scrutiny. Many of the professionals working in the field are actually selling out their own friends and neighbours, their own families and even themselves. The general public and the policy makers who claim to represent us are oblivious or reckless about the consequences of this all-you-can-eat feeding frenzy on humanity.

Pretending to be democratic is all part of the illusion. Facebook's recent announcement to deviate from their real-name policy is about as effective as using sunscreen to treat HIV. By subjecting themselves to the laws of Facebook, activists have simply given Facebook more status and power.

Data means power. Those who are accumulating it from us, collecting billions of tiny details about our behavior, every hour of every day, are fortifying a position of great strength with which they can personalize messages to condition anybody, anywhere, to think the way they want us to. Does that sound like the route to democracy?

I would encourage Mr Varoufakis to get up to speed with Free Software and come down to Zurich next week to hear Richard Stallman explain it the day before launching his DiEM25 project in Berlin.

Will the DiEM25 movement invite participation from experts on big data and digital freedom and make these issues a core element of their promised manifesto? Is there any credible way they can achieve their goal of democracy by 2025 without addressing such issues head-on?

Or put that the other way around: what will be left of democracy in 2025 if big data continues to run rampant? Will it be as distant as the gods of Greek mythology?

Categories: Elsewhere

Mediacurrent: Dropcast - Episode 16: If You're not Working with us...

Planet Drupal - Fri, 05/02/2016 - 22:41

On this episode our guest is Amanda Loggins, HR Manager here at Mediacurrent, who is joining us to discuss all the great career options available to you. Make sure you tell them we sent you (not just Mario)! Bob will discuss all things bloggy, Ryan will have some information about Big Pipe on the Final Bell, and Mark will continually be disappointed with the MailDrop.

Categories: Elsewhere

Drupal.org Featured Case Studies: Intelligent Life web and app development

Planet Drupal - Fri, 05/02/2016 - 22:25
Completed Drupal site or project URL: http://intelligentlifemagazine.com/

Intelligent Life is a bi-monthly cultural premium magazine published by the Economist Group, describes its coverage as "the arts, style, food, wine, cars, travel and anything else under the sun, as long as it’s interesting".

The Intelligent Life digital presence was failing to do the print edition justice and it took multiple amounts of effort to create each individual piece of content for 3 different types of devices. The project aim was to mimic the style and grace of the print edition online without it being a real challenge for The Economist team to create content. The site also needed to provide the functionality for the editors to manage the web and app back-ends as one. Also, we had to provide the possibility for the editorial team to publish great imagery on web and app similarly to the print edition, as this is a key element of both their print and online presences. By creating a fresh, modern UI and optimising the structure, our aim was to increase the number of visitors and foster longer periods of engagement with the content.

Key modules/theme/distribution used: CKeditor adv settingsmanualcropEntityqueueInsertMigratePanels IPE Role VisibilityViewsOrganizations involved: Cameron and Wilding LtdTeam members: ericgsmithitaratosamkeenldtsenAndrea SzellAxel Pressbutton
Categories: Elsewhere

Bernd Zeimetz: bzed-letsencrypt puppet module

Planet Debian - Fri, 05/02/2016 - 20:55

With the announcement of the Let’s Encrypt dns-01 challenge support we finally had a way to retrieve certificates for those hosts where http challenges won’t work. Also it allows to centralize the signing procedure to avoid the installation and maintenance of letsencrypt clients on all hosts.

For an implementation I had the following requirements in my mind: * Handling of key/csr generation and certificate signing by puppet. * Private keys don’t leave the host they were generated on. If they need to (for HA setups and similar cases), handling needs to be done outside of the letsencrypt puppet module. * Deployment and cleanup of tokens in our DNS infrastructure should be easy to implement and maintain.

After reading trough the source code of various letsencrypt client implementations I decided to use letsencrypt.sh. Mainly because its dependencies are available pretty much everywhere and adding the necessary hook is as simple as writing some lines of code in your favourite (scripting) language. My second favourite was lego, but I wanted to avoid shipping binaries with puppet, so golang was not an option.

It took me some days to find enough spare time to write the necessary puppet code, but finally I managed to release a working module today. It is still not perfect, but the basic tasks are implemented and the whole key/csr/signing chain works pretty well.

And if your hook can handle it, http-01 challenges are possible, too!

Please give the module a try and send patches if you would like to help to improve it!

Categories: Elsewhere

Jose M. Calhariz: Preview of amanda 3.3.8-1

Planet Debian - Fri, 05/02/2016 - 20:49

While I sort out a sponsor, my sponsor is very busy, here is a preview of the new packages. So anyone can install and test them on jessie.

The source of the packages is in collab-maint.The debs files for jessie are here:

amanda-common_3.3.8-1_cal0_i386.deb

amanda-server_3.3.8-1_cal0_i386.deb

amanda-client_3.3.8-1_cal0_i386.deb

Here comes the changelog:

amanda (1:3.3.8-1~cal0) unstable; urgency=low * New Upstream version * Changes for 3.3.8 * s3 devices New NEARLINE S3-STORAGE-CLASS for Google storage. New AWS4 STORAGE-API * amcryptsimple Works with newer gpg2. * amgtar Default SPARSE value is NO if tar < 1.28. Because a bug in tar with some filesystem. * amstar support include in backup mode. * ampgsql Add FULL-WAL property. * Many bugs fix. * Changes for 3.3.7p1 * Fix build in 3.3.7 * Changes for 3.3.7 * amvault new --no-interactivity argument. new --src-labelstr argument. * amdump compute crc32 of the streams and write them to the debug files. * chg-robot Add a BROKEN-DRIVE-LOADED-SLOT property. * Many bugs fix. * Refreshed patches. * Dropped patches that were applied by the upstream: fix-misc-typos, automake-add-missing, fix-amcheck-M.patch, fix-device-src_rait-device.c, fix-amreport-perl_Amanda_Report_human.pm * Change the email of the maintainer. * "wrap-and-sort -at" all control files. * swig is a new build depend. * Bump standard version to 3.9.6, no changes needed. * Replace deprecated dependency perl5 by perl, (Closes: #808209), thank you Gregor Herrmann for the NMU. -- Jose M Calhariz <jose@calhariz.com> Tue, 02 Feb 2016 19:56:12 +0000
Categories: Elsewhere

Ben Hutchings: Debian LTS work, January 2016

Planet Debian - Fri, 05/02/2016 - 20:32

In January I carried over 10 hours from December and was assigned another 15 hours of work by Freexian's Debian LTS initiative. I worked a total of 15 hours. I had a few days on 'front desk' at the start of the month, as my week in that role spanned the new year.

I fixed a regression in the kernel that was introduced to all stable suites in December. I uploaded this along with some minor security fixes, and issued DLA 378-1.

I finished backporting and testing fixes to sudo for CVE-2015-5602. I uploaded an update and issued DLA 382-1, which was followed by DSA 3440-1 for wheezy and jessie.

I finished backporting and testing fixes to Claws Mail for CVE-2015-8614 and CVE-2015-8708. I uploaded an update and issued DLA 383-1. This was followed by DSA 3452-1 for wheezy and jessie, although the issues are less serious there.

I also apent a little time on InspIRCd, though this isn't a package that Freexian's customers care about and it seems to have been broken in squeeze for several years due to a latent bug in the build system. I had already backported the security fix by the time I discovered this, so I went ahead with an update fixing that regression as well, and issued DLA 384-1.

Finally, I diagnosed the regression in the update to isc-dhcp in DLA 385-1.

Categories: Elsewhere

Another Drop in the Drupal Sea: Drupal Chat: The Drupal Learning Curve

Planet Drupal - Fri, 05/02/2016 - 19:33

There is a joke about the Drupal learning curve that relates it to the Drupal learning cliff. And while the graph generally gets things confused (by placing time on the x-axis instead of the y-axis), the sentiment is understood. Until a person is able to get her/his head around how Drupal does things, it's quite possible to spend a great deal of time to accomplish very little. Even worse, it's possible to spend a great deal of time developing really bad habits.

read more

Categories: Elsewhere

Pages

Subscribe to jfhovinne aggregator - Elsewhere