Automating Drupal Development with Patterns: introducing 7.x-2.x

download Automating Drupal Development with Patterns: introducing 7.x-2.x

of 47

  • date post

    17-Jan-2015
  • Category

    Technology

  • view

    458
  • download

    2

Embed Size (px)

description

Slides for session "Automating Drupal Development with Patterns: introducing 7.x-2.x" at DrupalCamp London 2013 - http://2013.drupalcamplondon.co.uk/session/automating-drupal-development-patterns

Transcript of Automating Drupal Development with Patterns: introducing 7.x-2.x

  • 1. Automating DrupalDevelopment with Patterns:introducing 7.x-2.xDavid Rozas and many others This work was partly supported by the Future and Emerging Technologies Programme (FP7-COSI-ICT) of the European Commission through the project QLectives (grant no.:231200).

2. A brief presentation ...David Rozas Domingo (@drozas) Almost 3 years working with Drupal. Recently joined CRESS (Centre for Research in SocialSimulation) at University of Surrey (UK). Interest areas: free software, education and technology,distributed systems programming, CSCW, collaborativelearning, socially intelligent information systems, +info: http://www.davidrozas.com DrupalCamp London 2013 02-03-20132 www.qlectives.eu 3. the othersStefano Balietti (ETH)Liao Hao (Uni Fribourg)Xiao Rui (Uni Science & Tech. China)Dengcheng Yan (Uni Science & Tech. China)Matus Medo (Uni Fribourg)Zhou Yanbo (Uni Fribourg)Dirk Helbing (ETH)Vahe Tshitoyan (ETH)Vahan Hovhannisyan (ETH)Christoph Schwirzer (ETH)Christian Schulz (ETH)Sasa Tomic (ETH)Mark Jelasity (Uni Szeged)Kornl Csernai (Uni Szeged)Tamas Kojedzinszky (Uni Szeged)Nigel Gilbert (Uni Surrey)Maria Xenitidou (Uni Surrey) DrupalCamp London 201302-03-20133 www.qlectives.eu 4. Outline The big picture: QLectives and QScience Patterns overview: components and Patterns files Patterns 7.x-1.x Introducing Patterns 7.x-2.x new featuresDrupalCamp London 201302-03-2013 4www.qlectives.eu 5. OutlineThe future: CM in Drupal 8A bit of code: making a modulePatterns ReadyFuture WorkDemoQ&ADrupalCamp London 201302-03-2013 5www.qlectives.eu 6. The big picture: QLectivesWhat is quality?If half a million people give a YouTubevideo the thumbs up, does that mean it isgood?Perhaps... but you would probably ratherwatch a recommendation from a friendCan we do it in a P2P way? DrupalCamp London 201302-03-20136 www.qlectives.eu 7. The big picture: QLectives Take features of social networking to help groups of people share resources: from home videos to scientific papers Quality ratings in a distributed wayDrupalCamp London 201302-03-2013 7www.qlectives.eu 8. The big picture: QLectivesTwo application domains:QMedia: P2P media distribution fullydecentralized - http://www.tribler.orgQScience: distributed platform forscientists allowing them to locate orform new communities and qualityreviewing mechanismsDrupalCamp London 201302-03-2013 8www.qlectives.eu 9. QScience: Science todayFrom...Rembrandt, A Scholar (1631) To... CommunityNetworks Big DataDrupalCamp Spain 201202-03-2013 9 www.qlectives.eu 10. Can we have it all?Many software packages are available that fitone (or more) of those needs, but not all.QScience is an attempt to pull them alltogether in a modular fashion: a Drupaldistribution DrupalCamp London 201302-03-201310 www.qlectives.eu 11. QScience: contributing backPatterns: configuration managementD2D (DrupalToDrupal): secure exchange ofinformation between different Drupal instances ina P2P network.QTR: Implements a Quality Trust and Reputationalgorithm to rate contents (e.g.: academicpublications) in Drupal.Living Science: Drupal based search andvisualization tool.DrupalCamp London 201302-03-201311www.qlectives.eu 12. Patterns What we want: reuse and shareconfiguration. The main issue: configuration anddata are mixed up in the DB. Patterns allows developers to takecontrol of it. DrupalCamp London 201302-03-201312 www.qlectives.eu 13. Patterns DrupalCamp London 201302-03-201313 www.qlectives.eu 14. Patterns Patterns is built to bypass this bottleneck bymanaging and automating site configuration Patterns approach to solve it: Components (Software driver concept) Store the configuration in files decoupledarchitecture Node Taxonomy User VariablesDrupalCamp London 201302-03-2013www.qlectives.eu14 15. Patterns ComponentsEach Drupal module can have acorresponding component, e.g. Blocks,Nodes, Taxonomy, Users, System settings.The component handles tasks directed atthe module, acts much like a softwaredriver. DrupalCamp London 201302-03-2013 15 www.qlectives.eu 16. Patterns ComponentsDefines a set of hooks which are accessedby the Patterns core during the differentphases: prepare, validate, callbacks,execution, cleanup...Actions are preprocessed andreformatted so that they can be the inputof one or more Drupal forms. DrupalCamp London 201302-03-201316 www.qlectives.eu 17. Patterns OverviewDrupalCamp London 201302-03-2013 17www.qlectives.eu 18. Patterns FilesStore configuration in filesThere is not any dependency with anyspecific format: hook_patterns_parser():http://drupal.org/node/1545346Currently supported formatsYAML: easy to read and write(human-readabledata serialization format)XML: interoperabilityPHP arrays: performance DrupalCamp London 201302-03-201318 www.qlectives.eu 19. Patterns Files: structureDivided in sections:Metadata: author, category, version,description, etc.Sub-sections:Actions: create, modify, delete, includeDrupalCamp London 201302-03-2013 19www.qlectives.eu 20. Patterns FilesDrupalCamp London 201302-03-2013 20www.qlectives.eu 21. Patterns 7.x-1.xWrite or re-use patterns using the alreadydeveloped components (content types,menus, blocks, users, permissions, roles,etc.)Make your module Patterns ReadyExport configuration automatically (in amore raw way than the new version) DrupalCamp London 201302-03-2013 21 www.qlectives.eu 22. Introducing Patterns 7.x-2.xMajor new release: 7.x-2.0-rc1 (26th Feb2013)Syntantic and Semantic validation: assistanceto solve conflicts.Automatic extraction of the configurationimproved.Patterns server/client: new (sub)modules toallow pushing/pulling patterns.DrupalCamp London 201302-03-201322www.qlectives.eu 23. Patterns 7.x-2.x: syntactic and semantic validationSimilar approach to name collision anddependencies resolution of compilers.Two separated layers and different type ofwarnings/errors:Already Defined ElementElement UndefinedUnmet DependencyNot Unique Alias... DrupalCamp London 201302-03-2013 23 www.qlectives.eu 24. Patterns 7.x-2.x: syntactic and semantic validationRule of thumb:Syntactic errors/warnings: wrong grammarstatements.Semantic warnings: related to the meaning ofthat pattern itself in certain context.Inclusive relationship: a pattern semanticallyvalid will always be syntactically valid, but notthe other way around. DrupalCamp London 201302-03-201324 www.qlectives.eu 25. Patterns 7.x-2.x: syntactic and semantic validationExample: Roles name collision (semantic warning)DrupalCamp London 201302-03-2013 25www.qlectives.eu 26. Patterns 7.x-2.x: export functionsAll the main core components possess nowautomatic export capabilities.Options to choose the type of actions generated: CREATE actions: intended for the creation of patterns for fresh installation.MODIFY actions: intended for the creation ofpatterns to override the current settings (i.e.: todeploy changes from test to stage).Depends on the component: certain actions mightnot make sense in some cases: create colour? DrupalCamp London 201302-03-201326 www.qlectives.eu 27. Patterns 7.x-2.x: export functionsDrupalCamp London 201302-03-2013 27www.qlectives.eu 28. Patterns 7.x-2.x: server/clientAct as a HUB to share Patterns between Drupalusers using a secure channel.Pushed via UI / DrushImplemented as a module: anyone can set uphis/her own serverProvides functionalities to search patterns,generate statistics, etc.Default Patterns Server: drupal-patterns.org (comingsoon)DrupalCamp London 201302-03-2013 28www.qlectives.eu 29. Patterns 7.x-2.x: server/client DrupalCamp London 201302-03-201329 www.qlectives.eu 30. So, what s the differencebetween Patterns and...? Distribution/Installation Profile: Granularity: the configuration can besplit into smaller definitions Simplicity: easier to write YAML filesthan an installation profile Can be used in existing sites DrupalCamp London 201302-03-2013 30 www.qlectives.eu 31. So, what s the differencebetween Patterns and...? Features+Strongarm: Paradigm: Features is more use case oriented, Patterns is more CM oriented (Interesting blog post from Tom Friedhof about this at http://activelamp.com/blog/new-way-manage-config uration-your-site) DrupalCamp London 201302-03-2013 31 www.qlectives.eu 32. So, what s the differencebetween Patterns and...? Features+Strongarm: Storage: Features stores the configuration in Drupal modules, patterns stores it in files as D8 will (see D8 Config Management Initiative)DrupalCamp London 201302-03-201332www.qlectives.eu 33. So, what s the differencebetween Patterns and...? Features+Strongarm: Implementation: Features uses module specific APIs (e.g: Views API), Patterns uses mostly FAPI (although can use specific ones as well). The trick is drupal_form_submit() Advantage: Validation for free! Disadvantage: PerformanceDrupalCamp London 201302-03-201333www.qlectives.eu 34. The future?DrupalCamp London 201302-03-2013 34www.qlectives.eu 35. The future?DrupalCamp London 201302-03-2013 35www.qlectives.eu 36. CM in Drupal 8Two issues to address:#1: Save configuration data into files (in core!): CMI [!] @alexpotts presentation tomorrow: Drupal 8Configuration System for Coders #2: Bundle functionality into a package that can be re-used in another site: Features v3.x, Patterns v3.x?Patterns (as features) currently combines #1 & #2Features maintainers contacted to collaborate since we are working on the same directionDrupalCamp London 201302-03-201336www.qlectives.eu 37. Getting a bit teckie... How to create your own Drupalicon Munny, by Andre Molnar (http://becircle.com/how_create_your_own_custom_drupalicon_munny) DrupalCamp London 201302-03-201337 www.qlectives.eu 38. How to make my module Patterns Ready?You need to implement hook_patterns() todeclare which actions your module is able tohandle: DrupalCamp London 201302-03-2013 38 www.qlectives.eu 39. How to make my module Patterns Ready?Hooks available to interacton each phase:hook