| 96 | === Adding custom !JavaScript and CSS === |
| 97 | The following example shows how to add some custom !JavaScript and CSS files. Here they all start with a common prefix. The JS files (abc_one.js,abc_two.js,abc_tree.js) are positioned in the `$TRAC_PROJECT_DIR/htdocs/js/` and the CSS files (style_print.css,style_screen.css) `$TRAC_PROJECT_DIR/htdocs/css/` directory. |
| 98 | |
| 99 | {{{ |
| 100 | # in trac.ini |
| 101 | [addheaders] |
| 102 | default_style_base = site/css/ |
| 103 | default_script_base = site/js/ |
| 104 | |
| 105 | add_scripts = abc_one,abc_two,abc_tree |
| 106 | add_styles = style_print,style_screen |
| 107 | }}} |
| 108 | |
| 109 | or, even shorter: |
| 110 | |
| 111 | {{{ |
| 112 | # in trac.ini |
| 113 | [addheaders] |
| 114 | default_style_base = site/css/abc_ |
| 115 | default_script_base = site/js/style_ |
| 116 | |
| 117 | add_scripts = one,two,tree |
| 118 | add_styles = print,screen |
| 119 | }}} |
| 120 | |
| 121 | === Weird filenames === |
| 122 | While the names given by `add_scripts` or `add_styles` is used to build the default filename, it becomes just an arbitrary string when the real filename is set explicitly using ''<name>''`.filename`. |
| 123 | This can be used when the real filename is quit weird, e.g. has commas included or is very long. Make sure to use an UTF-8 capable editor when adding non-ASCII letters. |
| 124 | {{{ |
| 125 | # in trac.ini |
| 126 | [addheaders] |
| 127 | |
| 128 | add_scripts = short |
| 129 | |
| 130 | short.filename = /site/somewhere/Very,weird,filename @;'öäßÖÄß¼€.js |
| 131 | # Also possible to change the MIME-type (default is 'text/javascript') |
| 132 | short.type = text/something |
| 133 | |
| 134 | # Same for style files |
| 135 | # General link files must always be set explicitly |
| 136 | }}} |
| 137 | |