This is my first Komodo macro and is for CakePHP 1.2 and greater. The general purpose of the macro is to allow easy navigation between CakePHP model/view/controller files. It should work cross-platform as I did all directory path parsing using 'os.sep'.
It is defaulted to be activated by CTRL+SHIFT+Z
Activating the macro does the following depending on your current open file in Komodo:
I've been using CakePHP for 2 years and these simple navigation shortcuts are something I've always wanted. Thanks to Komodo's great API, this could be easily done.
Please leave any feedback or additional ideas. I enjoyed working on this and would consider adding any features that would be worthwhile.
| Attachment | Size |
|---|---|
| CakePHPToggler_v0_1.kpz | 6.48 KB |
| CakePHPToggler_v0_2.kpz | 6.85 KB |
| CakePHPToggler_v0_3.kpz | 7.52 KB |
I don't have time to look at it tonight, but it sounds really useful and similar to something I've been thinking of lately as I shift from one model to another and first close all the old model's files, then open all the new model's files. Hopefully I'll have time to check it out tomorrow. =)
--
JeffG
http://www.openkomodo.com/blogs/jeffg
I was trying this in one of my cake projects and it reports that it is not cake structure. "You don't seem to be in a cakephp directory structure." Is there a way that the projects need to be added or structured to help with this?
The file you're in when you activate the macro needs to be in a directory path that includes /app/ or else you'll see the error msg you're seeing.
Cake app directory structure assumed as:
./app/controllers/
./app/models/
./app/views/
If your structure is different than this, let me know. It's possible I made a bad assumption as to how the cake apps have to be laid out.
If your directories do look like this, I may have some cross-platform issues going on in regards to file paths. If that is the case, let me know what platform you're running on and I'll take a look.
Thanks for trying this.
So I think it is not a great assumption that the path would begin with /app/ since if you have multiple apps (either in development or deployment) they may have app specific paths /app is only useful if it is the only app in the environment but I may have a dozen or more active projects that are cake apps that look like
and another app in the base directory like
so a directory might look like
you get the idea
Thanks for your feedback, sdevore. I'm glad the issue is as you described because it was easy to fix. If you go to the main post, you'll now see another version for download: 0.2
Please try that if you have a chance and your problems should be resolved.
Thanks!
This fixed it for me, cool nice job
Sam D
I had used something similar when identifying 'Zend Framework' directories in that extension for Komodo. For cake, it might be as easy as looking for paths like:
Yeah?
--
JeffG
http://www.openkomodo.com/blogs/jeffg
I saw your post and the related thread on the CakePHP list as well. Did you get a chance to look at Cakemate? It seems like it might be a good fit for a back-end for Komodo to integrate with.
I finally got a chance to look at cakemate, but I didn't have a lot of luck with it.
It is essentially a cake shell plugin, which allows one to make php commandline calls to the base cake console script and gain info about the project.
However, some of the commands generated errors when I tried to call them, and I was having weird path parsing issues when trying to invoke the console from anywhere except my app root directory, even using the appropriate arguments. This would be a problem for Komodo as it would be invoking the cake shell from outside the app directory. My problems *may* have been because I'm not on the latest version of cake. However, I also don't want to force users to use a certain version of cake just to get the macro to work.
I plan to take some more time to look at it and determine how to get it working on my end. I would like to get it working because a direct link to the cake core allows much more potential in terms of what kind of cool editor tricks could be done.
"This would be a problem for Komodo as it would be invoking the cake shell from outside the app directory."
For Komodo commands, you can specify the directory the command runs in. In a Toolbox Run command, this is especially simple if you assume that the top level directory of the project is the Cake root directory:
The key is the 'Start In' field. For macros, you can supply the directory to run in using a slightly weird syntax:
ko.run.runEncodedCommand(window, '%(ls -lha) {\'cwd\': u\'%p/app\', \'doNotOpenOutputWindow\': True}');...it's the encoded Python dict with 'cwd' as an argument that is the key bit. This causes Komodo run the command or script in the supplied directory.
I added a new version 0.3 available on the root post which fixes some issues related to pluralization of the modelname.
I believe this may be the last version of the macro in this form. I am considering converting the next version to use cake's 'cakemate' plugin since it can make calls directly to cake and handle such issues as pluralization itself.