| 1 | 2005-04-15 |
|---|
| 2 | |
|---|
| 3 | Xinha Unified Backend Branch |
|---|
| 4 | Development Info |
|---|
| 5 | |
|---|
| 6 | by: Yermo Lamers of DTLink Software |
|---|
| 7 | http://www.formvista.com |
|---|
| 8 | |
|---|
| 9 | ---------------------------------------------------------- |
|---|
| 10 | Configure.php |
|---|
| 11 | ---------------------------------------------------------- |
|---|
| 12 | |
|---|
| 13 | To avoid hard coding paths, I've hacked together a small |
|---|
| 14 | Configure.php system which will generate various scripts |
|---|
| 15 | and set directory permissions based on conf files in ./conf. |
|---|
| 16 | |
|---|
| 17 | Configure.php must be called from the command line using the |
|---|
| 18 | full path to command line PHP. This script must be run first |
|---|
| 19 | before any other development scripts can be run. |
|---|
| 20 | |
|---|
| 21 | ---------------------------------------------------------- |
|---|
| 22 | Dev Environment Scripts |
|---|
| 23 | ---------------------------------------------------------- |
|---|
| 24 | |
|---|
| 25 | These scripts assume the availability command line PHP and Perl. |
|---|
| 26 | |
|---|
| 27 | These script have not been tested under Windows. If there is sufficient |
|---|
| 28 | interest, I can make them portable to Windows. |
|---|
| 29 | |
|---|
| 30 | The devutil scripts are located on ./devutils and they include: |
|---|
| 31 | |
|---|
| 32 | svn_commit.php |
|---|
| 33 | |
|---|
| 34 | preprocessor to "svn commit" command that updates the |
|---|
| 35 | popups/about.html file so that it always includes the current |
|---|
| 36 | revision info. |
|---|
| 37 | |
|---|
| 38 | Requires command line "svn" command to be in $PATH |
|---|
| 39 | |
|---|
| 40 | buildruntime.php: - not done |
|---|
| 41 | |
|---|
| 42 | generates a "runtime" version of xinha_ub with all comments |
|---|
| 43 | and debug trace messages stripped out. It also does |
|---|
| 44 | in-line text replacement for some specific tags. |
|---|
| 45 | |
|---|
| 46 | ddtpreproc.php |
|---|
| 47 | |
|---|
| 48 | Javascript does not seem to have a version of PHP's |
|---|
| 49 | __LINE__ and __FILE__ constants so there is no clean way of |
|---|
| 50 | including file and line numbers in ddt trace messages; at least |
|---|
| 51 | none that I've been able to find. This script preprocesses the |
|---|
| 52 | javascript source files to patch in file and line numbers to |
|---|
| 53 | every _ddt() call. |
|---|
| 54 | |
|---|
| 55 | If you are working on the source files and add or delete lines just |
|---|
| 56 | rerun the ddtpreproc.php script from the xinha_ub root directory. It |
|---|
| 57 | will recurse through all the .js files in the directory tree. |
|---|
| 58 | |
|---|
| 59 | makedocs.pl |
|---|
| 60 | |
|---|
| 61 | Calls JSDoc with some arguments to generate the class documentation |
|---|
| 62 | from the source javascript files. Requires Perl, JSDoc and PHPDoc |
|---|
| 63 | to run. |
|---|
| 64 | |
|---|
| 65 | NOTE: Under RedHat 9, JSDoc will cause perl to dump core when running |
|---|
| 66 | on htmlarea.js. Upgrading Perl to 5.8.6(from source) fixed the |
|---|
| 67 | problem for me). |
|---|
| 68 | |
|---|
| 69 | IMPORTANT: |
|---|
| 70 | |
|---|
| 71 | DO NOT FIELD THESE SCRIPTS ON A LIVE SITE. |
|---|
| 72 | |
|---|
| 73 | I have added "deny from all" .htaccess files and each scripts |
|---|
| 74 | checks it's environment in an attempt to avoid being run from |
|---|
| 75 | a webserver. |
|---|
| 76 | |
|---|
| 77 | If you are not running Apache or aren't permitted to do overrides |
|---|
| 78 | in .htaccess, you may want to move the ./devutils directory |
|---|
| 79 | somewhere outside of DOCUMENT_ROOT. |
|---|
| 80 | |
|---|
| 81 | ---------------------------------------------------------- |
|---|
| 82 | Code Re-Org |
|---|
| 83 | ---------------------------------------------------------- |
|---|
| 84 | |
|---|
| 85 | In an attempt to make the codebase more manageable I've |
|---|
| 86 | reorganized htmlarea.js to group related items together. |
|---|
| 87 | |
|---|
| 88 | The file is now broken into five sections: |
|---|
| 89 | |
|---|
| 90 | 1. Initial Setup |
|---|
| 91 | 2. HTMLArea.Config Class |
|---|
| 92 | 3. HTMLArea class methods |
|---|
| 93 | 4. HTMLArea Class |
|---|
| 94 | 5. Misc Support overrides and functions |
|---|
| 95 | |
|---|
| 96 | ---------------------------------------------------------- |
|---|
| 97 | JSDoc and PHPDoc. |
|---|
| 98 | ---------------------------------------------------------- |
|---|
| 99 | |
|---|
| 100 | I found a perl script that implements a JavaDoc style system |
|---|
| 101 | for JavaScript. See http://jsdoc.sourceforge.net/. |
|---|
| 102 | |
|---|
| 103 | JSDoc is very sensitive to the order of tags in the headers. |
|---|
| 104 | If you try to add doc headers and they are not showing up |
|---|
| 105 | correctly compare with the test.js file distributed with JSDoc. |
|---|
| 106 | |
|---|
| 107 | JSDoc seems to lack the ability to link to the actual source |
|---|
| 108 | code definition of a given class or method. |
|---|
| 109 | |
|---|
| 110 | I've added JSDoc headers to just about everything I've touched. |
|---|
| 111 | |
|---|
| 112 | For the PHP scripts that I touch, I'm adding PHPDoc headers. |
|---|
| 113 | |
|---|
| 114 | There is a ./utils/makedocs.pl shell script. |
|---|
| 115 | |
|---|
| 116 | ---------------------------------------------------------- |
|---|
| 117 | Debugging Trace Messages |
|---|
| 118 | ---------------------------------------------------------- |
|---|
| 119 | |
|---|
| 120 | To further make my life easier and come up to speed, I've added |
|---|
| 121 | trace messages to virtually every method using a contributed version |
|---|
| 122 | of my DDT debug-trace-message-to-popup window class. |
|---|
| 123 | |
|---|
| 124 | You will need to turn off any popup blockers in order to see the debugging |
|---|
| 125 | trace messages. |
|---|
| 126 | |
|---|
| 127 | These messages can be turned on and off on a per-class basis using the ddtOn() method. |
|---|
| 128 | (See examples/simple_example.html) |
|---|
| 129 | |
|---|
| 130 | What's nice is you can quickly get a feel for the order in which things happen |
|---|
| 131 | and which methods are invoked for what events. |
|---|
| 132 | |
|---|
| 133 | The concept is to do development on the trace enabled version of the code and then |
|---|
| 134 | generate a stripped "runtime" version using the provided ./utils/make_runtime.sh |
|---|
| 135 | script. make_runtime strips all debugging code out of the .js files. It also removes |
|---|
| 136 | almost all comments to reduce file size. I am envisioning having two distributions |
|---|
| 137 | of Xinha .. a development version with all debugging intact and a runtime version |
|---|
| 138 | that has been stripped. (this has served me extremely well in formVista development) |
|---|
| 139 | |
|---|
| 140 | It's important to note that each domain Xinha is run on will open it's own |
|---|
| 141 | debugging trace window. (for instance, if you are working on two copies on different |
|---|
| 142 | servers they will not be able to share a single debugging window. This is because |
|---|
| 143 | a script in one domain cannot write into a window opened by another domain). |
|---|
| 144 | |
|---|
| 145 | You should be aware that Xinha intecepts some events on reload or page change |
|---|
| 146 | which means that there are debugging messages that are output by the currently |
|---|
| 147 | loaded script on the page when you click reload or change pages. (This took me |
|---|
| 148 | a while to track down). Often times I would close the trace window and then |
|---|
| 149 | do a reload noticing exceptions listed in the javascript console. Took forever |
|---|
| 150 | to figure out these exceptions were not being generated by the new page but |
|---|
| 151 | instead by the old page. See DDT.prototype._ddt() in ddt.js for more insights. |
|---|
| 152 | |
|---|
| 153 | ---------------------------------------------------------- |
|---|
| 154 | Coding Style |
|---|
| 155 | ---------------------------------------------------------- |
|---|
| 156 | |
|---|
| 157 | The original coding style guidelines included in the code were: |
|---|
| 158 | |
|---|
| 159 | --------------------------------------------------- |
|---|
| 160 | Developers - Xinha main branch Coding Style by Gogo: |
|---|
| 161 | |
|---|
| 162 | For the sake of not committing needlessly conflicting changes, |
|---|
| 163 | |
|---|
| 164 | - New code to be indented with 2 spaces ("soft tab"). |
|---|
| 165 | - New code preferably uses BSD-Style Bracing |
|---|
| 166 | if(foo) |
|---|
| 167 | { |
|---|
| 168 | bar(); |
|---|
| 169 | } |
|---|
| 170 | |
|---|
| 171 | Don't change brace styles unless you're working on the non BSD-Style |
|---|
| 172 | area (so we don't get spurious changes in line numbering). |
|---|
| 173 | |
|---|
| 174 | Don't change indentation unless you're working on the badly indented |
|---|
| 175 | area (so we don't get spurious changes of large blocks of code). |
|---|
| 176 | |
|---|
| 177 | Jedit is the recommended editor, a comment of this format should be |
|---|
| 178 | included in the top 10 lines of the file (see the embedded edit mode) |
|---|
| 179 | --------------------------------------------------- |
|---|
| 180 | |
|---|
| 181 | Unfortunately, given the endless nested "using dynamic function |
|---|
| 182 | definitions as method arguments" the BSD bracing style makes the code |
|---|
| 183 | impossible to read, IHMO. |
|---|
| 184 | |
|---|
| 185 | To make my life easier I've gone through and changed the style to: |
|---|
| 186 | |
|---|
| 187 | if (foo) |
|---|
| 188 | { |
|---|
| 189 | bar(); |
|---|
| 190 | } |
|---|
| 191 | |
|---|
| 192 | So if you have a function definition as an argument as in: |
|---|
| 193 | |
|---|
| 194 | class.method( "foo", |
|---|
| 195 | function() |
|---|
| 196 | { |
|---|
| 197 | return bar; |
|---|
| 198 | }); |
|---|
| 199 | |
|---|
| 200 | Which to my eye is alot easier to follow and less error prone. |
|---|
| 201 | |
|---|
| 202 | I tried Jedit. I can't stand Java apps and the editor is simply too |
|---|
| 203 | slow. I use CRISP which unfortunately has some serious issues with |
|---|
| 204 | tab to space conversions. |
|---|