From 673f9e800488d95e8488492f7f77dbe0c4ef9538 Mon Sep 17 00:00:00 2001 From: Oliver Davies Date: Thu, 2 Apr 2015 21:37:34 +0100 Subject: [PATCH 01/19] Not just Drupal --- source/index.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/index.md b/source/index.md index 60100772..7288df64 100644 --- a/source/index.md +++ b/source/index.md @@ -10,6 +10,6 @@ use: Hi, I'm Oliver Davies - a [Drupal](https://www.drupal.org/about) Developer and Systems Administrator based in Wales. I work for the [Drupal Association](https://assoc.drupal.org/about) Engineering team, working on Drupal.org, it's sub-sites and infrastructure, as well as providing part-time freelance services. -I'm an active member of the Drupal community - organising and [speaking](/talks/) at local user groups and DrupalCamps, mentoring at DrupalCons, and contributing code to core and various contrib modules and themes. I'm the Git Documentation Maintainer for the Drupal project and a provisional member of the [Drupal Security team](https://www.drupal.org/security-team). +I'm an active member of the Drupal and PHP communities - organising and [speaking](/talks/) at user groups and conferences, mentoring at DrupalCons, and contributing code to core and various contrib modules and themes. I'm the Git Documentation Maintainer for the Drupal project and a provisional member of the [Drupal Security team](https://www.drupal.org/security-team). -I have active social media profiles on [Twitter](https://twitter.com/opdavies) and [LinkedIn](https://www.linkedin.com/in/opdavies), and you can view my code on [Drupal.org](https://www.drupal.org/user/381388/track/code) and [GitHub](https://www.github.com/opdavies?tab=activity). \ No newline at end of file +I have active social media profiles on [Twitter](https://twitter.com/opdavies) and [LinkedIn](https://www.linkedin.com/in/opdavies), and you can view my code on [Drupal.org](https://www.drupal.org/user/381388/track/code) and [GitHub](https://www.github.com/opdavies?tab=activity). From d1a9c400ef4e1211954bd03c6b2dad1e5f121ce3 Mon Sep 17 00:00:00 2001 From: Oliver Davies Date: Fri, 3 Apr 2015 20:31:19 +0100 Subject: [PATCH 02/19] How to define minimum Drupal core version --- .../_posts/2015-04-03-minimum-core-version.md | 58 +++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 source/_posts/2015-04-03-minimum-core-version.md diff --git a/source/_posts/2015-04-03-minimum-core-version.md b/source/_posts/2015-04-03-minimum-core-version.md new file mode 100644 index 00000000..b8b2608b --- /dev/null +++ b/source/_posts/2015-04-03-minimum-core-version.md @@ -0,0 +1,58 @@ +--- +title: How to Define a Minimum Drupal Core Version +description: How to define a minimum Drupal core version for your module or theme. +nav: blog +use: + - posts +tags: + - Drupal + - Drupal 7 + - Drupal Planet +--- +This week, my first code patch was [committed to Drupal core](https://www.drupal.org/node/2394517#comment-9773143). The patch adds the `user_has_role()` function to theu user module, to simplify the way to check whether a user in Drupal has been assigned a specific role. This is something that I normally write a custom function for each project, but it's now available in Drupal core as of [7.36](https://www.drupal.org/drupal-7.36-release-notes). + +But what if someone is using a core version less than 7.36 and tries using the function? The site would return an error because that function wouldn't exist. + +If you're building a new Drupal site, then I'd assume that you're using a latest version of core, or you have the opportunity to update it when needed. But what if you're writing a contrib module? How can you be sure that the correct minimum version of core? + +## Setting Dependencies + +What I'm going to be doing for my contrib projects is defining a minimum version of Drupal core that the module is compatible with. If this dependency isn't met, the module won't be able to be enabled. This is done within your module's .info file. + +### Adding a Simple Dependency + +You can define a simple dependency for your module by adding a line this this to your project's .info file: + + dependencies[] = views + +This would make your module dependant on having the [Views](https://www.drupal.org/project/views) module present and enabled, which you'd need if you were including views as part of your module, for example. + +### Adding a Complex Dependency + +In the previous example, our module would enable if _any_ version of Views was enabled, but we need to specify a specific version. We can do this by including version numbers within the dependencies field in the following format: + + dependencies[] = modulename (major.minor) + +This can be a for a specific module release or a branch name: + + dependencies[] = modulename (1.0) + dependencies[] = modulename (1.x) + +We can also use the following as part of the field for extra granularity: + +* = or == equals (this is the default) +* > greater than +* < lesser than +* >= greater than or equal to +* <= lesser than or equal to +* != not equal to + +In the original scenario, we want to specify that the module can only be enabled on Drupal core 7.36 or later. To do this, we can use the "greater than or equal to" option. + + dependencies[] = system (>=7.36) + +Because we need to check for Drupal's core version, we're using the system module as the dependency and specifying that it needs to be either equal to or greater than 7.36. If this dependency is not met, e.g. Drupal 7.35 is being used, then the module cannot be enabled rather than showing a function not found error for `user_has_role()` when it is called. + +## External Links + +* [Writing module .info files (Drupal 7.x)](https://www.drupal.org/node/542202#dependencies) \ No newline at end of file From fb225e7c640eb15bc79741fb50f1dca5347cd2a2 Mon Sep 17 00:00:00 2001 From: Oliver Davies Date: Fri, 3 Apr 2015 21:39:53 +0100 Subject: [PATCH 03/19] Added text --- source/contact.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/source/contact.md b/source/contact.md index 67b65406..4c344ba7 100644 --- a/source/contact.md +++ b/source/contact.md @@ -7,6 +7,8 @@ use: --- # Contact +If you find any issues or want to suggest any improvements to the site, you can [create an issue](https://github.com/opdavies/oliverdavies.co.uk/issues/new) in the GitHub repository. If you want to suggest an improvement to a blog post, please feel free to fork the repository and submit a pull request. + Email : [oliver@oliverdavies.co.uk](mailto:oliver+contact@oliverdavies.co.uk?subject=Contact%20Oliver%20Davies) From 50876f7763ad4afd2d4f9d74d000c33f2e0afbde Mon Sep 17 00:00:00 2001 From: Oliver Davies Date: Sun, 5 Apr 2015 07:31:49 +0100 Subject: [PATCH 04/19] Small change --- source/contact.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/contact.md b/source/contact.md index 4c344ba7..50a719f1 100644 --- a/source/contact.md +++ b/source/contact.md @@ -7,7 +7,7 @@ use: --- # Contact -If you find any issues or want to suggest any improvements to the site, you can [create an issue](https://github.com/opdavies/oliverdavies.co.uk/issues/new) in the GitHub repository. If you want to suggest an improvement to a blog post, please feel free to fork the repository and submit a pull request. +If you find any issues or want to suggest any improvements to the site, you can [create an issue](https://github.com/opdavies/oliverdavies.co.uk/issues/new) on GitHub. If you want to suggest an improvement to a blog post, please feel free to fork the repository and submit a pull request. Email : [oliver@oliverdavies.co.uk](mailto:oliver+contact@oliverdavies.co.uk?subject=Contact%20Oliver%20Davies) From 8d29f081832dce53475c26f6ddb6c512a77d0040 Mon Sep 17 00:00:00 2001 From: Oliver Davies Date: Wed, 8 Apr 2015 03:17:21 +0100 Subject: [PATCH 05/19] Added slides link --- source/talks.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/talks.md b/source/talks.md index 5055642f..942bba9c 100644 --- a/source/talks.md +++ b/source/talks.md @@ -10,7 +10,7 @@ use: ## Upcoming Talks April 2015 - [PHPSW](http://phpsw.org.uk/events/221484360-lightning-talks) -: Drupal 8 (lightning talk) +: [Drupal 8](http://opdavies.github.com/phpsw-drupal8) (lightning talk) ## Previous Talks @@ -33,4 +33,4 @@ July 2013 - South Wales Drupal User Group : An overview of the [Drupal LDAP module](http://www.drupal.org/project/ldap) and how I customised it for a client project. September 2012 - [unified.diff](http://unifieddiff.co.uk) -: [So, what is this Drupal thing?](http://vimeo.com/49827006) - an introduction to Drupal. \ No newline at end of file +: [So, what is this Drupal thing?](http://vimeo.com/49827006) - an introduction to Drupal. From 4347b17b86516e647f1cfecc5a74be3a1387196a Mon Sep 17 00:00:00 2001 From: Oliver Davies Date: Wed, 8 Apr 2015 03:17:21 +0100 Subject: [PATCH 06/19] Added slides link --- source/talks.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/talks.md b/source/talks.md index 5055642f..942bba9c 100644 --- a/source/talks.md +++ b/source/talks.md @@ -10,7 +10,7 @@ use: ## Upcoming Talks April 2015 - [PHPSW](http://phpsw.org.uk/events/221484360-lightning-talks) -: Drupal 8 (lightning talk) +: [Drupal 8](http://opdavies.github.com/phpsw-drupal8) (lightning talk) ## Previous Talks @@ -33,4 +33,4 @@ July 2013 - South Wales Drupal User Group : An overview of the [Drupal LDAP module](http://www.drupal.org/project/ldap) and how I customised it for a client project. September 2012 - [unified.diff](http://unifieddiff.co.uk) -: [So, what is this Drupal thing?](http://vimeo.com/49827006) - an introduction to Drupal. \ No newline at end of file +: [So, what is this Drupal thing?](http://vimeo.com/49827006) - an introduction to Drupal. From 36e1d2335d40f1141cd2669bbfadf45343a43d91 Mon Sep 17 00:00:00 2001 From: Oliver Davies Date: Wed, 8 Apr 2015 22:52:38 +0100 Subject: [PATCH 07/19] PHPSW is no longer previous --- source/talks.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/source/talks.md b/source/talks.md index 942bba9c..77c23a64 100644 --- a/source/talks.md +++ b/source/talks.md @@ -7,13 +7,13 @@ use: --- # Talks -## Upcoming Talks + + +## Previous Talks April 2015 - [PHPSW](http://phpsw.org.uk/events/221484360-lightning-talks) : [Drupal 8](http://opdavies.github.com/phpsw-drupal8) (lightning talk) -## Previous Talks - February 2015 - [DrupalCamp London](http://2015.drupalcamplondon.co.uk) : Drupal.org in 2015: What's coming next? From cc3201939f50e54cb96b3adf8a1e23527e2b1700 Mon Sep 17 00:00:00 2001 From: Oliver Davies Date: Wed, 8 Apr 2015 22:54:52 +0100 Subject: [PATCH 08/19] Updated slides URL --- source/talks.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/talks.md b/source/talks.md index 77c23a64..ec8658a0 100644 --- a/source/talks.md +++ b/source/talks.md @@ -12,7 +12,7 @@ use: ## Previous Talks April 2015 - [PHPSW](http://phpsw.org.uk/events/221484360-lightning-talks) -: [Drupal 8](http://opdavies.github.com/phpsw-drupal8) (lightning talk) +: [Drupal 8](https://speakerdeck.com/opdavies/drupal-8) (lightning talk) February 2015 - [DrupalCamp London](http://2015.drupalcamplondon.co.uk) : Drupal.org in 2015: What's coming next? From 27ce1433ad6d84926791a7b930946f2e70489608 Mon Sep 17 00:00:00 2001 From: Oliver Davies Date: Wed, 8 Apr 2015 23:43:59 +0100 Subject: [PATCH 09/19] Added build.sh --- .gitignore | 1 + build.sh | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100755 build.sh diff --git a/.gitignore b/.gitignore index 01600603..08c28988 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +/gh-pages-deployment/ /output_*/ /source/components/ /.sculpin/ diff --git a/build.sh b/build.sh new file mode 100755 index 00000000..cae00a49 --- /dev/null +++ b/build.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +set -x + +sculpin='/usr/local/bin/sculpin' +deploy_dir='./gh-pages-deployment' +branch='master' + +rm -rf ./output_prod +${sculpin} generate --env=prod + +rm -rf ${deploy_dir} +git clone git@github.com:opdavies/opdavies.github.io.git ${deploy_dir} + +pushd ${deploy_dir} + +git checkout -B ${branch} + +cp -R ../output_prod/* ./ + +git add -A . +git commit -m "Deploying sculpin-generated pages to \`${branch}\` branch" +git push origin master --force + +popd \ No newline at end of file From 1c4283ba9344f3eb405b9da4f1668527b1e874d6 Mon Sep 17 00:00:00 2001 From: Oliver Davies Date: Wed, 8 Apr 2015 23:53:33 +0100 Subject: [PATCH 10/19] Revert "Added build.sh" This reverts commit 27ce1433ad6d84926791a7b930946f2e70489608. --- .gitignore | 1 - build.sh | 25 ------------------------- 2 files changed, 26 deletions(-) delete mode 100755 build.sh diff --git a/.gitignore b/.gitignore index 08c28988..01600603 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,3 @@ -/gh-pages-deployment/ /output_*/ /source/components/ /.sculpin/ diff --git a/build.sh b/build.sh deleted file mode 100755 index cae00a49..00000000 --- a/build.sh +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/bash - -set -x - -sculpin='/usr/local/bin/sculpin' -deploy_dir='./gh-pages-deployment' -branch='master' - -rm -rf ./output_prod -${sculpin} generate --env=prod - -rm -rf ${deploy_dir} -git clone git@github.com:opdavies/opdavies.github.io.git ${deploy_dir} - -pushd ${deploy_dir} - -git checkout -B ${branch} - -cp -R ../output_prod/* ./ - -git add -A . -git commit -m "Deploying sculpin-generated pages to \`${branch}\` branch" -git push origin master --force - -popd \ No newline at end of file From 8bd10376829dcd91a5932b498ada0d0727248218 Mon Sep 17 00:00:00 2001 From: Oliver Davies Date: Wed, 8 Apr 2015 23:56:02 +0100 Subject: [PATCH 11/19] Added .nojekyll --- source/.nojekyll | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 source/.nojekyll diff --git a/source/.nojekyll b/source/.nojekyll new file mode 100644 index 00000000..e69de29b From 58abcaf49931e9c9f3ceb6496baaf00f91711032 Mon Sep 17 00:00:00 2001 From: Oliver Davies Date: Wed, 8 Apr 2015 23:59:56 +0100 Subject: [PATCH 12/19] Added CNAME --- source/CNAME | 1 + 1 file changed, 1 insertion(+) create mode 100644 source/CNAME diff --git a/source/CNAME b/source/CNAME new file mode 100644 index 00000000..160bfed2 --- /dev/null +++ b/source/CNAME @@ -0,0 +1 @@ +www.oliverdavies.co.uk From 029b31b3b1c01ae4f2314439cd8e0f7369b290ff Mon Sep 17 00:00:00 2001 From: Oliver Davies Date: Thu, 9 Apr 2015 00:00:23 +0100 Subject: [PATCH 13/19] Added build.sh --- .gitignore | 1 + build.sh | 29 +++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100755 build.sh diff --git a/.gitignore b/.gitignore index 01600603..08c28988 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +/gh-pages-deployment/ /output_*/ /source/components/ /.sculpin/ diff --git a/build.sh b/build.sh new file mode 100755 index 00000000..8afd385d --- /dev/null +++ b/build.sh @@ -0,0 +1,29 @@ +#!/bin/bash + +set -x + +SCULPIN='/usr/local/bin/sculpin' +ENV='prod' +REPO='git@github.com:opdavies/opdavies.github.io.git' +DEPLOY_DIR='./gh-pages-deployment' +BRANCH='master' + +rm -rf ./output_${ENV} +${SCULPIN} generate --env=${ENV} + +LOG=$(git log --oneline -n 1) + +rm -rf ${DEPLOY_DIR} +git clone ${REPO} ${DEPLOY_DIR} + +pushd ${DEPLOY_DIR} + +git checkout -B ${BRANCH} + +cp -R ../output_${ENV}/* ./ + +git add -A . +git commit -m "${LOG}" +git push origin ${BRANCH} --force + +popd \ No newline at end of file From 6bcbd86f649246f953345f499f1688accfffd861 Mon Sep 17 00:00:00 2001 From: Oliver Davies Date: Thu, 9 Apr 2015 00:14:08 +0100 Subject: [PATCH 14/19] Updated build.sh --- build.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/build.sh b/build.sh index 8afd385d..271d0ac5 100755 --- a/build.sh +++ b/build.sh @@ -4,9 +4,9 @@ set -x SCULPIN='/usr/local/bin/sculpin' ENV='prod' -REPO='git@github.com:opdavies/opdavies.github.io.git' -DEPLOY_DIR='./gh-pages-deployment' BRANCH='master' +REPO="git@github.com:opdavies/opdavies.github.io.git --branch ${BRANCH}" +DEPLOY_DIR='./gh-pages-deployment' rm -rf ./output_${ENV} ${SCULPIN} generate --env=${ENV} @@ -20,7 +20,7 @@ pushd ${DEPLOY_DIR} git checkout -B ${BRANCH} -cp -R ../output_${ENV}/* ./ +rsync --quiet --archive --delete ../output_${ENV}/ ./ git add -A . git commit -m "${LOG}" From 0bc0f6e95329d5772b476873195f12c8ea0f4a15 Mon Sep 17 00:00:00 2001 From: Oliver Davies Date: Thu, 9 Apr 2015 00:40:48 +0100 Subject: [PATCH 15/19] Updated build.sh --- build.sh | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/build.sh b/build.sh index 271d0ac5..efdfcf96 100755 --- a/build.sh +++ b/build.sh @@ -2,28 +2,23 @@ set -x -SCULPIN='/usr/local/bin/sculpin' -ENV='prod' -BRANCH='master' -REPO="git@github.com:opdavies/opdavies.github.io.git --branch ${BRANCH}" -DEPLOY_DIR='./gh-pages-deployment' - -rm -rf ./output_${ENV} -${SCULPIN} generate --env=${ENV} +rm -rf ./output_prod +/usr/local/bin/sculpin generate --env=prod LOG=$(git log --oneline -n 1) -rm -rf ${DEPLOY_DIR} -git clone ${REPO} ${DEPLOY_DIR} +rm -rf ./gh-pages-deployment/ +git clone git@github.com:opdavies/opdavies.github.io.git ./gh-pages-deployment/ -pushd ${DEPLOY_DIR} +pushd ./gh-pages-deployment/ -git checkout -B ${BRANCH} +git checkout master +git checkout -b master -rsync --quiet --archive --delete ../output_${ENV}/ ./ +rsync --quiet --archive --filter="P .git*" --delete ../output_prod/ ./ git add -A . git commit -m "${LOG}" -git push origin ${BRANCH} --force +git push origin master --force popd \ No newline at end of file From e58eadbfa20151c4c8d5ded69e6bfcaec5f7a076 Mon Sep 17 00:00:00 2001 From: Oliver Davies Date: Thu, 9 Apr 2015 00:54:21 +0100 Subject: [PATCH 16/19] Added .nojekyll --- .nojekyll | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 .nojekyll diff --git a/.nojekyll b/.nojekyll new file mode 100644 index 00000000..e69de29b From c8124beb3fb9fcc03139fdf701be34c1e2d94c9b Mon Sep 17 00:00:00 2001 From: Oliver Davies Date: Thu, 9 Apr 2015 01:57:15 +0100 Subject: [PATCH 17/19] Updated README --- README.md | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index 9a9b4c08..b990739f 100644 --- a/README.md +++ b/README.md @@ -1,20 +1,6 @@ -oliverdavies.co.uk +opdavies.github.io ================== -The source code for . Built with [Sculpin](http://sculpin.io). +The source code for [my personal website and blog](http://www.oliverdavies.co.uk), built with [Sculpin](http://sculpin.io). -Build ------ - -### If You Already Have Sculpin - - sculpin install - sculpin generate --watch --server - -Your newly generated clone of the site is now accessible at `http://localhost:8000/`. - -### If You Need Sculpin - - curl -O https://download.sculpin.io/sculpin.phar - php sculpin.phar install - php sculpin.phar generate --watch --server +Please [create an issue](https://github.com/opdavies/opdavies.github.io/issues) to log any errors or issues with the site or make a suggestion. Pull requests are welcome for suggestions to posts and tutorials. \ No newline at end of file From d19e5abdec08617e655b8a45fb9306a036bfba39 Mon Sep 17 00:00:00 2001 From: Oliver Davies Date: Thu, 9 Apr 2015 01:57:44 +0100 Subject: [PATCH 18/19] Checkout and reset in one command --- build.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/build.sh b/build.sh index efdfcf96..1cb5ab5a 100755 --- a/build.sh +++ b/build.sh @@ -12,8 +12,7 @@ git clone git@github.com:opdavies/opdavies.github.io.git ./gh-pages-deployment/ pushd ./gh-pages-deployment/ -git checkout master -git checkout -b master +git checkout -B master rsync --quiet --archive --filter="P .git*" --delete ../output_prod/ ./ From fd61ca91a20b0c93fa1888d46564232f8f060476 Mon Sep 17 00:00:00 2001 From: Oliver Davies Date: Thu, 9 Apr 2015 01:59:23 +0100 Subject: [PATCH 19/19] Small change --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b990739f..da647e2b 100644 --- a/README.md +++ b/README.md @@ -3,4 +3,4 @@ opdavies.github.io The source code for [my personal website and blog](http://www.oliverdavies.co.uk), built with [Sculpin](http://sculpin.io). -Please [create an issue](https://github.com/opdavies/opdavies.github.io/issues) to log any errors or issues with the site or make a suggestion. Pull requests are welcome for suggestions to posts and tutorials. \ No newline at end of file +Please [create an issue](https://github.com/opdavies/opdavies.github.io/issues) to log any errors or issues with the site or make a suggestion. Pull requests are welcome for improvements to posts and tutorials. \ No newline at end of file