├── build.properties ├── build.xml ├── htmlcompressor-1.4.3.jar └── yuicompressor-2.4.6.jar /build.properties: -------------------------------------------------------------------------------- 1 | 2 | base.dir = ../ 3 | 4 | 5 | 6 | build.publishName = Publish 7 | build.dir = ${base.dir}${build.publishName} 8 | 9 | base.js.path = js 10 | base.css.path = css 11 | 12 | js.concat.min = scripts.min.js 13 | css.concat.min = css.min.css -------------------------------------------------------------------------------- /build.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | type = $type; 99 | } 100 | 101 | function setProperty($property) { 102 | $this->property = $property; 103 | } 104 | 105 | function main() { 106 | $this->getFiles(); 107 | 108 | foreach($this->files as $file) { 109 | $links = $this->findLinks($file); 110 | if ( false !== $links ) { 111 | $this->links .= empty($this->links) ? $links : ",$links"; 112 | } 113 | } 114 | 115 | // css/style2.css,css/style.css,css/style3.css,css/style2.css,css/style.css 116 | $this->links = implode(',', array_unique(explode(',', $this->links))); 117 | 118 | $this->project->setProperty($this->property, $this->links); 119 | } 120 | 121 | function getFiles() { 122 | // Get list of all HTML and PHP files in the base directory. 123 | $objects = new RecursiveIteratorIterator(new RecursiveDirectoryIterator('${base.dir}')); 124 | $objects = new RegexIterator($objects, '/\.(?:html|php)$/i', RecursiveRegexIterator::GET_MATCH); 125 | 126 | $files = array(); 127 | foreach($objects as $name => $object) { 128 | $files[] = str_replace('../', '', $name); 129 | } 130 | 131 | $this->files = $files; 132 | } 133 | 134 | function findLinks($file) { 135 | $file = file_get_contents("${base.dir}/$file"); 136 | $this->log("Stripping out the '$this->type' path."); 137 | 138 | $links = trim(preg_replace('/[\s\S]+?([\s\S]+)[\s\S]+/', "$1", $file, -1, $count)); 139 | 140 | 141 | // If the returned val from the preg_replace is the same, there's no match. // Remove this one from the list. It does not have script or link tags. 142 | if ( $count === 0 ) return false; 143 | 144 | if ( $this->type === 'css' ) { 145 | $links = preg_replace("/]+>/i", "$1", $links); 146 | } else if ( $this->type === 'js' ) { 147 | $links = preg_replace("//", "$1", $links); 148 | } 149 | 150 | $links = preg_replace('/\s+/', ',', $links); 151 | return $links; 152 | } 153 | } 154 | ]]> 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | -------------------------------------------------------------------------------- /htmlcompressor-1.4.3.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NETTUTS/Phing-Build-Script-for-Web-Designers/fb0e3cdd62de1d7e7785f49e64b1ed4e389cc970/htmlcompressor-1.4.3.jar -------------------------------------------------------------------------------- /yuicompressor-2.4.6.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NETTUTS/Phing-Build-Script-for-Web-Designers/fb0e3cdd62de1d7e7785f49e64b1ed4e389cc970/yuicompressor-2.4.6.jar --------------------------------------------------------------------------------