Wanna hear a story?
Read our tales of web culture, international entrepreneurship, and open software culture. Everyone gets a say so drop a comment!
As promised in my last post, I will present a CoCKTaiL-based code-generator, which accepts CoCKTaiL input and generates php suitable for importing into Drupal via the CCK Content-copy module.
I have submitted a session proposal on Taming CCK configurations with CoCKTail for DrupalCon Boston. Please consider reviewing this and voting for it if you would be interested in seeing CoCKTaiL gain a wider following.
I have made code available via anonymous svn at Raincity's public SVN repository. I encourage anyone interested to have a look at this, take it for a spin, and contribute! But, be warned that this is still very experimental code.
The current version of the code supplies a command-line validator, which checks CoCKTaiL code. The error reporting is extremely naive, still. Also, there is a template-based code generator, which will take CoCKTaiL as input, and generate php code suitable for import into a Drupal application. Both of these are specified as PHP Lemon input files, sharing a common grammar (and Lexer), of course.
The CoCKTaiLcode generator can now generate text fields; support for remaining 'core' fields will be implemented in the next few days. . There is some support for links and noderefs.
In order to write a code generator that generates CCK-import specifications (PHP) from CoCKTaiL input, we will need to:
To do so will require having knowledge of CCK types and fields and their allowed and required attributes.
The output will be a PHP array containing a type specification.
We will supply a template for all default attributes. The values provided by parsing the CoCKTaiL description will be written over the template values, if they have an appropriate value.
There will be a template for each of the following:
Field attributes will have to added for each new field, since CCK is of course extensible.
Because one of the goals of CoCKTaiL is to make life easier for developers, we go a little beyond merely copying in supplied attributes into a template. In particular, the published status, comments, and a few other commonly used attributes for nodes can be supplied as scalar attributes, rather than as array values.
That is, we can write
...
status true;
comment 2;
...
rather than
...
node-options array(
status true;
comment 2;
...
);
...
In addition, templates can contain stubs which are substituted for at code-generation time.
As mentioned, I still need to create the templates for the remaining core CCK fields. I hope that in doing so, I will be able to validate the usefulness of the templating approach to code generation.
Some of the major issues which still need to be addressed are:
© Copyright 2003-2008 Raincity Studios, Inc. All rights reserved. Raincity Studios and the Raincity logo are trademarks of Raincity Studios, Inc
Cocktail Status?
I've been watching this blog for a while, hoping that you'd move forward enough on Cocktail for a relative non-programmer (such as me) to try using it to build a CCK-based module. I downloaded the code from your SVN link, but honestly don't know how I'd use it to make an abstracted description of what I want, and then actually get it implemented on a Drupal website.
Given the whisperings on the wind (that CCK is going to be put in Core, CCK will soon change everything, etc.), having a method for managing CCK-built functionalities would seem to me to be of utmost importance.
Status
Hi, I just wanted to know if there is some update on CoCKTail or it has been just an idea for a hypothetical language?
Thx!