ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Coda Comments Plugin

February 22, 2009 3:07pm

Subscribe [10]
  • #1 / Feb 22, 2009 3:07pm

    macigniter

    244 posts

    I just finished a small plug-in that allows to easily add CodeIgniter style comments in Coda. I was inspired by the DevMark Plug-in by Erwan Tossen, yet wanted to add more customization and flexibility.

    After adding the plug-in to Coda you first need to set the preferences in the config file and save it.

    ;    CodeIgniter Comments - Preferences
    ;    ------------------------------------
    ;    This file work like "php.ini" files.
    ;    Don't remove [xxx] lines !
    
    [config]
    
        date = m/d/Y    
        author = title,-,descr,-,license,author,link,email,-,file,version,date,-,copyright
        block = title,-,descr
    
    [author]
    
        descr = Description
        author = Your name    
        link = <a href="http://your-name.com">http://your-name.com</a>
        email = .(JavaScript must be enabled to view this email address)    
        license = GNU General Public License
        version = 1.0
        
    [block]
    
        descr = Description

    Add Author (Ctrl+Shift+A)
    The Add Author function lets you add a comment block like this:

    /**
     * Title
     * 
     * Description
     * 
     * @license     GNU General Public License    
     * @author      Frank Michel
     * @link        <a href="http://frankmichel.com">http://frankmichel.com</a>
     * @email       .(JavaScript must be enabled to view this email address)
     * 
     * @file        test.php
     * @version     1.0
     * @date        02/22/2009
     * 
     * Copyright (c) 2009
     */

    To add a comment block simply select your typed title and add the author block with Ctrl+Shift+A.

    You can easily re-arrange the items of this block by editing the comma separated author line in the [config] section of the preferences. You can use any of the following special items or add a blank line with a dash “-”

    title - the input text from the selection
    descr - the default description placeholder from the preferences
    file - the current file name
    date - the current date in the format you defined in the preferences
    copyright - a copyright notice

    NEW:
    Any other item you add to the preferences file can be supplied with a default value. So if you like to add…

    /**
     * @example   DefaultValue
     */

    ...simply append “example” to the comma separated author line in the [config] section of the preferences file and optionally add the following line to the [author] section:

    example = DefaultValue

    This feature gives you great flexibiliy in adding custom items with default values.

    Add Block (Ctrl+Shift+B)
    The Add Block function lets you add a comment block like this:

    /**
     * Function Name
     * 
     * Description
    */

    Special items are only title and descr. Adding other items is just as easy as described above. Please make sure to put your default values in the [block] section of the preferences file.

    Add Line (Ctrl+Shift+L)
    This function lets you easily add a line like this:

    // --------------------------------------------------------------------------

    Add GPL (Ctrl+Shift+G)
    This function lets you add a GPL license block.

    Add EOF (Ctrl+Shift+E)
    This function lets you add the document footer in a CI style:

    /* End of file test.php */
    /* Location: ./application/libraries/test.php */

    Last but not least there’s an Update Date (Ctrl+Shift+U) function that let’s you automatically update the date in the author block as specified in the preferences file.

    You can download the plug-in here:
    CI Comments Coda Plug-in

    I hope you enjoy it! Happy commenting 😊

  • #2 / Feb 22, 2009 7:12pm

    pistolPete

    1071 posts

    That’s a great plugin!
    I changed one thing:
    The document footer contained the absolute system path:

    /* End of file Layout.php */
    /* Location: ./Volumes/Macintosh HD/Users/[...] */

    So I changed Add EOF to the following to get the relative path:

    #!/usr/bin/php
    <?php
        /**
         * CodeIgniter Comments
         * 
         * @file        Add EOF.php
         * @license        GNU General Public License
         * @author        Frank Michel
         * @link        <a href="http://frankmichel.com">http://frankmichel.com</a>
         * @email        .(JavaScript must be enabled to view this email address)
         * @version        1.0
         * @date        02/21/2009
         * 
         * Copyright (c) 2009
        */
        
        $site_path = getenv('CODA_SITE_LOCAL_PATH');
        $file_path = getenv('CODA_FILEPATH');
        $ending = getenv('CODA_LINE_ENDING');
        
        $file = substr(strrchr($file_path, "/"), 1);
        $extension = substr(strrchr($file, "."), 1);
        
        if(!empty($site_path))
        {
            $file_path = substr($file_path, strlen($site_path));
        }
        
        $output = "/* End of file ".$file." */".$ending;
        $output .= "/* Location: .".$file_path." */";
        
        echo $output;
    ?>
  • #3 / Feb 22, 2009 7:23pm

    macigniter

    244 posts

    Thanks pistolPete!

    I’ll update the plug-in right away.

  • #4 / Feb 22, 2009 8:34pm

    macigniter

    244 posts

    I just added some more flexibility to the plug-in. The new feature (see above) will let you easily add new custom items with default values to the author and block sections.

  • #5 / Feb 22, 2009 9:17pm

    macigniter

    244 posts

    In case you are using my plug-in please let me know if you have some feedback. There’s actually one thing I wasn’t sure what users will prefer:

    In the current version of the plug-in the cursor is positioned right after the comment closing. Would you prefer to have another carriage return, so the cursor is positioned at the beginning of the new line right after the comment block instead?

  • #6 / Mar 01, 2009 6:26pm

    kevinprince

    122 posts

    For some reason the add author option is greyed out after I installed it.

    Any ideas?

    Kevin

  • #7 / Mar 01, 2009 6:28pm

    pistolPete

    1071 posts

    You have to select some text to be able to use it.

    To add a comment block simply select your typed title and add the author block with Ctrl+Shift+A.

  • #8 / Mar 01, 2009 6:28pm

    macigniter

    244 posts

    You need to select some text which will be transformed into the “Title”. As soon as you selected the text, the function will become available.

  • #9 / May 21, 2009 7:43pm

    tdktank59

    322 posts

    So whats coda like? have you ever used zend?

    I took a look at coda and it looks pretty sweet for what it is…

  • #10 / Sep 16, 2009 6:56pm

    chuckleberry13

    43 posts

    coda is a great IDE for mac developers.

    p.s. great plugin!

  • #11 / Sep 16, 2009 7:01pm

    tdktank59

    322 posts

    Yeah I ended up buying it, quite a while ago. Now im working on setting up a local svn to post to!

  • #12 / Sep 16, 2009 7:03pm

    chuckleberry13

    43 posts

    local svn, are you doing that on your mac?

  • #13 / Sep 16, 2009 7:04pm

    tdktank59

    322 posts

    Trying to.
    I want to set it up so when I am offline I can sync to my mac (local dev) and if I am online itll have a hook to update to my web server

  • #14 / Oct 15, 2009 9:35am

    msuess

    1 posts

    Hi macigniter,

    I just registered to thank you for creating this plugin. It is great and I started using it extensively.

    Thanks!

  • #15 / Oct 24, 2009 3:00am

    tdktank59

    322 posts

    Getting a bug with author

    Warning: date(): It is not safe to rely on the system’s timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected ‘America/Los_Angeles’ for ‘PDT/-7.0/DST’ instead in /Users/Trevor/Library/Application Support/Coda/Plug-ins/CI Comments.codaplugin/Contents/Resources/678D6E66-4424-46FC-BE60-39787E3AFC40/Add Author on line 49

    Warning: date(): It is not safe to rely on the system’s timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected ‘America/Los_Angeles’ for ‘PDT/-7.0/DST’ instead in /Users/Trevor/Library/Application Support/Coda/Plug-ins/CI Comments.codaplugin/Contents/Resources/678D6E66-4424-46FC-BE60-39787E3AFC40/Add Author on line 53

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases