Merge branch 'source' into cv
This commit is contained in:
commit
676f2c54d6
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,3 +1,4 @@
|
|||
/gh-pages-deployment/
|
||||
/output_*/
|
||||
/source/components/
|
||||
/.sculpin/
|
||||
|
|
20
README.md
20
README.md
|
@ -1,20 +1,6 @@
|
|||
oliverdavies.co.uk
|
||||
opdavies.github.io
|
||||
==================
|
||||
|
||||
The source code for <http://www.oliverdavies.co.uk>. 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 improvements to posts and tutorials.
|
23
build.sh
Executable file
23
build.sh
Executable file
|
@ -0,0 +1,23 @@
|
|||
#!/bin/bash
|
||||
|
||||
set -x
|
||||
|
||||
rm -rf ./output_prod
|
||||
/usr/local/bin/sculpin generate --env=prod
|
||||
|
||||
LOG=$(git log --oneline -n 1)
|
||||
|
||||
rm -rf ./gh-pages-deployment/
|
||||
git clone git@github.com:opdavies/opdavies.github.io.git ./gh-pages-deployment/
|
||||
|
||||
pushd ./gh-pages-deployment/
|
||||
|
||||
git checkout -B master
|
||||
|
||||
rsync --quiet --archive --filter="P .git*" --delete ../output_prod/ ./
|
||||
|
||||
git add -A .
|
||||
git commit -m "${LOG}"
|
||||
git push origin master --force
|
||||
|
||||
popd
|
0
source/.nojekyll
Normal file
0
source/.nojekyll
Normal file
1
source/CNAME
Normal file
1
source/CNAME
Normal file
|
@ -0,0 +1 @@
|
|||
www.oliverdavies.co.uk
|
58
source/_posts/2015-04-03-minimum-core-version.md
Normal file
58
source/_posts/2015-04-03-minimum-core-version.md
Normal file
|
@ -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)
|
|
@ -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) 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)
|
||||
|
||||
|
|
|
@ -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).
|
||||
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).
|
||||
|
|
|
@ -7,13 +7,13 @@ use:
|
|||
---
|
||||
# Talks
|
||||
|
||||
## Upcoming Talks
|
||||
|
||||
April 2015 - [PHPSW](http://phpsw.org.uk/events/221484360-lightning-talks)
|
||||
: Drupal 8 (lightning talk)
|
||||
<!-- ## Upcoming Talks -->
|
||||
|
||||
## Previous Talks
|
||||
|
||||
April 2015 - [PHPSW](http://phpsw.org.uk/events/221484360-lightning-talks)
|
||||
: [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?
|
||||
|
||||
|
@ -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.
|
||||
: [So, what is this Drupal thing?](http://vimeo.com/49827006) - an introduction to Drupal.
|
||||
|
|
Loading…
Reference in a new issue