Hi everyone,
This module provides an interface to create multiple 'switcher rules' to allow your Drupal site to change themes or redirect to another webpage depending on what kind of device it using the site. We have submitted a module before but withdrew it after deciding the interface wasn't up to scratch. Device detection is provided by the 51Degrees.mobi PHP detector. There are many device properties available to check a device against, starting simply with if the device is mobile, moving onto more advanced data such as the browser being used or the screen size.
The detector itself (look in the 51Degrees folder for the code) is far more complicated than simply looking for common strings in the useragent, so there is a large amount of code that has optimised for speed rather than readability. That said, we think it still follows most of Drupals code standards and uses the fiftyone_degrees_ prefix for its functions. It has been available for sometime on Sourceforge and has already been deployed to a number of servers - http://sourceforge.net/projects/fiftyone/?source=directory .
The module installs a new menu where new rules can be created (represented by a tab) in which conditions are selected and an action chosen.
A word about the code structure chosen: we eventually want to port this module to other CMSs. To help with this we have a logic and constants file which (we hope) are platform independent and a platform functions and constants file which contain calls to Drupal. I've tried to keep those files a Druponic as possible but the whole project follows Drupal guidelines and has the fiftyone_degrees prefix.
This modules is intended for Drupal 7.x
Sandbox page : http://drupal.org/sandbox/51Degrees/1841688
I had orginally posted the wrong sandbox page, the above page goes to the right one.
Comments
Comment #1
nesta_ commentedchange text
Issue Summary
-description-
attachments
your url
git clone http://git.drupal.org/sandbox/user/.git name_project
Drupal 7
Attachment Size
Web oficial xxx.xx KB
And
README.txt is missing, see the guidelines for in-project documentation.
You can check here: http://ventral.org/pareview/httpgitdrupalorgsandbox51degrees1629098git
Comment #2
nesta_ commentedComment #3
51Degrees.mobi commentedSorry nguerrero, I had originally posted the wrong sandbox address. The project has a readme as well as addressing other faults that report came up with.
Comment #4
gazoakley commentedHi 51Degrees.mobi,
There's still a few outstanding PAReview issues:
http://ventral.org/pareview/httpgitdrupalorgsandbox51degrees1841688git
Your repository contains a master branch which should be deleted and a 7.x-1.0 branch which should be renamed to 7.x-1.x . The most direct documentation on this is Moving from a master branch to a version branch. For additional resources please see the documentation about release naming conventions and creating a branch in git.
Also, whilst possibly created by you the 51Degrees directory contains code that is not licensed under the GPL. All code hosted on Drupal.org must be GPL licensed: http://drupal.org/node/422996 . The Libraries API module is a recommended method for adding 3rd party dependencies without directly including the code on Drupal.org.
Comment #5
51Degrees.mobi commentedI've changed the branches to meet with convention.
We have also changed the license of our detector so it is dual licensed under MPLv2 and GPLv2 (as can been seen from 51Degrees/License.txt) and the file headers. I hope this will allows our plugin to be hosted.
Thanks,
Tom
Comment #6
gazoakley commentedHi Tom,
I feel I'd need to refer to an administrator such as Klausi on this issue. Whilst I know you've written the shared library in general 3rd party libraries shouldn't be hosted here - it means that project administrators such as yourselves would have to try and keep the drupal.org copy up to date at all times:
http://drupal.org/node/422996
I think the preferred solution would be for you to remove the shared library and ask users to copy it themselves from a location specified in your readme to sites/all/libraries. You can then use the Libraries API Module to load it. It also removes any need for your module hosted here on drupal.org to contain license information.
I'll ask for a second opinion here:
http://groups.drupal.org/node/157669
Comment #7
gazoakley commented*accidental double post*
Comment #8
gazoakley commentedManual review:
The list looks a lot, but you have a reasonably large module for review so it's likely for us to find a few problems. If you need a hand with the fixes let us know - we'll try and help when we can :-).
Can you please check\fix the above and set the status to 'needs review' once done.
Comment #9
gazoakley commentedComment #10
51Degrees.mobi commentedHi,
Thanks again for reviewing. I've addressed most of the points you have made, but there a few things I'm not clear on.
The first is using tpl for html. Initially I tried to use them but all the documentation I could find focused on theme developing that made lots of use of overriding rather than creating a one off control that I can't image anyone ever wanting to retheme. I've used theme() wherever I could (usually by putting a wrapper around it). Do you know of any guide or example that deals with this kind of use case?
As for fiftyone_degrees_write_text() - the plan was that using a wrapper like this would allow us to reuse code for other CMSs. I also couldn't find any instance of it not being used with a non-literal string.
Finally, is Drupal unable to host the detection library? Following the discussion it seemed like opinion was divided and other plugins were mentioned that do host their libraries here.
Thanks,
Tom
Comment #11
51Degrees.mobi commentedComment #12
gazoakley commentedHi Tom,
You can then create a fiftyone_degrees_admin.tpl.php file for your module:
To use it, call theme():
Which should output your template. There's probably an argument for using the Forms API for outputting the form in your admin area - you might want to try that as an alternative. See here and here.
You also do pass non-string literals to fiftyone_degrees_write_text() - fiftyone_degrees_logic.php:515 contains "$options[$value] = fiftyone_degrees_write_text($value);" - you should use check_plain() for non-literals.
It's better :-). In general you're mixing a lot of generation of presentation level output with logic though - this makes it more difficult for people with design skills to contribute to your module either through updating templates or altering CSS. It's also not great to wrap calls to the Drupal API that don't add anything extra - other developers are used to seeing calls to the API rather than your wrappers and if they try and work with you they'll have to keep looking up what your functions really do.
As for bundling libraries unfortunately no clear answer ever came out, though I'd argue all but one reviewer said they felt code that is available elsewhere and that isn't Drupal specific shouldn't really be on d.o. Lots of modules do use the Libraries API - it also means if another module wants to use your shared library it's a simple case for them of calling library_load('fiftyone_degrees'). The bit of added pain for users installing your module by having to download and unzip an extra file can also be mitigated for drush users if you provide a .make file - they can just drush en fiftyone_degrees and have the required library downloaded automatically. Take a look again - if you get stuck I'd be happy to help you.
Could any other reviewers have a look at this? I'd also certainly appreciate some feedback on my reviews.
Comment #13
51Degrees.mobi commentedHi,
Thank you for your help so far, it has been very appreciated. However, as I've alluded to before, we're planning on creating a version of this plugin for several CMSs, so we were trying as much as possible to separate Drupal code and the logic. Not being able to do this isn't in itself a massive problem, but the possibility that we may need to take the detector from the plugin make users download it later making us think we'd be better off putting the plugin as it currently is as a download from our site and host it ourselves.
I'll be postponing the project until we're sure we want to follow this route.
Again, thanks a lot for reviewing the project so far.
Tom
Comment #14
klausiClosing due to lack of activity. Feel free to reopen if you are still working on this application.
If you reopen this please keep in mind that we are currently quite busy with all the project applications and I can only review projects with a review bonus. Please help me reviewing and I'll take a look at your project right away :-)
Comment #14.0
klausiChanged sandbox address
Comment #15
avpadernoComment #16
avpaderno