mediatribe.net -- Sites web, programmation web, solutions sur mesure, sites bilingues, spécialiste Drupal

Blogue

CRÉEZ VOUS-MÊME VOTRE SITE

Voir le vidéo (4 min.)

Blogues,
vidéos, galeries photo, catégorisation avancée, copies de sauvegarde
hors-site, création de formulaires, magasin en-ligne, noms de domaine,
sites multilingues, images libres de droits d'auteurs. Nous avons
ingtégré les plus récents systèmes de logiciel libre et plusieurs
services existants en un ensemble facile à utiliser pour le commun des
mortels, à prix abordable.

Plus besoin d'avoir une équipe de tronches à votre disposition pour avoir un site dernier cri.

[en savoir plus]

Using diff and patch for directories, and managing patches during Drupal upgrades.

Background: I was recently making a Drupal site where I needed (as is often the case) a visual text editor along with image- and file-upload capabilities. I tried using the wysiwyg module in conjunction FCKEditor 2.6.x, which is a good combination for that purpose.

Since this does not work out of the box, I followed the instructions here.

This procedure requires modifying files in the Wysiwyg module (residing in sites/all/modules) as well as the FCKEditor library itself (in sites/all/libraries).

The causes potential problems when the module and library are upgraded. My solution is to use patches. Here is how.

  • Put the original file in its place (e.g. site/all/modules/wysiwyg or sites/all/libraries/fckeditor)
  • Copy the entire directory (e.g. cp sites/all/modules/wysiwyg sites/all/modules/wysiwyg.patched)
  • Make the required changes files in the patched (e.g. wysiwyg.patched/) directory
  • I like to make a directory for all my patches on the system (e.g. mkdir patches)
  • For each of your patched directories, execute the diff command. Here is an example for the wysiwyg directory. the options "c" and "r" tell the diff program to provide context and apply recursively to subdirectories. Providing context is not required, although the idea here is to be able to apply the patch to upgrades of the code, which might be different than the original, in which case context is very helpful.
        diff -cr sites/all/modules/wysiwyg/ sites/all/modules/wysiwyg.patched/ > patches/wysiwyg_module_allow_file_uploads.diff
     
  • Test your patch by executing the patch command, which applies it to the original, in this case "sites/all/modules/wysiwyg", directory. Here is an example with the wysiwyg directory. The "p0" option tells the patch command to apply the patch to the same directory structure as when the patch was created (in this case sites/all/modules/wysiwyg), which makes sense. The default value for "p" (if you don't specify it) tells patch to ignore the directory structure and apply the patch, in this case, to "wysiwyg".
        patch -p0 < patches/wysiwyg_module_allow_file_uploads.diff
     
  • You can now get rid of the patched directory
  • Next time an upgrade is released for a directory you patched (say, wysiwyg), just back up your old directory, put the new one in its place, and apply the patch with the "patch -p0" command.

Resources

(note: I sometimes use the IMCE module to integrate image uploading with visual editors, which does not require any patching. In this case it was decided to use upload capabilities already integrated into FCKEditor because it is easier for the end user.)

Réalisations

COMMENTAIRES DE NOS CLIENTS...

C'est
tellement merveilleux de pouvoir mettre du contenu sur le
site et surtout de pouvoir effectuer les nombreuses mises à jour. C'est
un vrai plaisir pour moi et j'aime à croire que c'est parce que le site
est bien conçu... Merci encore pour tes conseils. (Pascale Bironneau, atelierdecarole.com)

C'est ÇA que je voulais... je ne le savais même pas... très contente et impressionnée jusqu'ici. WOW. (Élise Gravel, illustratrice. elisegravel.com)

Après les tests ça marche et c'est exactement la configuration que je voulais (Marie-Louise, productionsqualia.com)

J'ai même fait plus que ce que vous avez recommandé. D'ici peu je deviendrai un grand informaticien. (Kouassi Bohui Melaire, reforestation.net)

Vous êtes vraiment des pros! (M.-H. Verville, monhebdo.ca)