1 |
torben |
2125 |
#!/bin/sh |
2 |
|
|
|
3 |
|
|
cd ../media/src |
4 |
|
|
|
5 |
|
|
# DEFAULTS |
6 |
|
|
CLOSURE="/usr/local/closure_compiler/compiler.jar" |
7 |
|
|
JSDOC="/usr/local/jsdoc/jsdoc" |
8 |
|
|
CMD=$1 |
9 |
|
|
|
10 |
|
|
MAIN_FILE="../js/jquery.dataTables.js" |
11 |
|
|
MIN_FILE="../js/jquery.dataTables.min.js" |
12 |
|
|
VERSION=$(grep " * @version " DataTables.js | awk -F" " '{ print $3 }') |
13 |
|
|
|
14 |
|
|
echo "" |
15 |
|
|
echo " DataTables build ($VERSION)" |
16 |
|
|
echo "" |
17 |
|
|
|
18 |
|
|
|
19 |
|
|
IFS='%' |
20 |
|
|
|
21 |
|
|
cp DataTables.js DataTables.js.build |
22 |
|
|
|
23 |
|
|
echo " Building main script" |
24 |
|
|
grep "require(" DataTables.js.build > /dev/null |
25 |
|
|
while [ $? -eq 0 ]; do |
26 |
|
|
REQUIRE=$(grep "require(" DataTables.js.build | head -n 1) |
27 |
|
|
|
28 |
|
|
SPACER=$(echo ${REQUIRE} | cut -d r -f 1) |
29 |
|
|
FILE=$(echo ${REQUIRE} | sed -e "s#^.*require('##g" -e "s#');##") |
30 |
|
|
DIR=$(echo ${FILE} | cut -d \. -f 1) |
31 |
|
|
|
32 |
|
|
sed "s#^#${SPACER}#" < ${DIR}/${FILE} > ${DIR}/${FILE}.build |
33 |
|
|
|
34 |
|
|
sed -e "/${REQUIRE}/r ${DIR}/${FILE}.build" -e "/${REQUIRE}/d" < DataTables.js.build > DataTables.js.out |
35 |
|
|
mv DataTables.js.out DataTables.js.build |
36 |
|
|
|
37 |
|
|
rm ${DIR}/${FILE}.build |
38 |
|
|
|
39 |
|
|
grep "require(" DataTables.js.build > /dev/null |
40 |
|
|
done |
41 |
|
|
|
42 |
|
|
mv DataTables.js.build $MAIN_FILE |
43 |
|
|
|
44 |
|
|
|
45 |
|
|
if [ "$CMD" != "debug" ]; then |
46 |
|
|
if [ "$CMD" = "jshint" -o "$CMD" = "" -o "$CMD" = "cdn" ]; then |
47 |
|
|
echo " JSHint" |
48 |
|
|
jshint $MAIN_FILE --config ../../scripts/jshint.config |
49 |
|
|
if [ $? -ne 0 ]; then |
50 |
|
|
echo " Errors occured - exiting" |
51 |
|
|
exit 1 |
52 |
|
|
else |
53 |
|
|
echo " Pass" |
54 |
|
|
fi |
55 |
|
|
fi |
56 |
|
|
|
57 |
|
|
if [ "$CMD" = "compress" -o "$CMD" = "" -o "$CMD" = "cdn" ]; then |
58 |
|
|
echo " Minification" |
59 |
|
|
echo "/* |
60 |
|
|
* File: jquery.dataTables.min.js |
61 |
|
|
* Version: $VERSION |
62 |
|
|
* Author: Allan Jardine (www.sprymedia.co.uk) |
63 |
|
|
* Info: www.datatables.net |
64 |
|
|
* |
65 |
|
|
* Copyright 2008-2012 Allan Jardine, all rights reserved. |
66 |
|
|
* |
67 |
|
|
* This source file is free software, under either the GPL v2 license or a |
68 |
|
|
* BSD style license, available at: |
69 |
|
|
* http://datatables.net/license_gpl2 |
70 |
|
|
* http://datatables.net/license_bsd |
71 |
|
|
* |
72 |
|
|
* This source file is distributed in the hope that it will be useful, but |
73 |
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY |
74 |
|
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the license files for details. |
75 |
|
|
*/" > $MIN_FILE |
76 |
|
|
|
77 |
|
|
java -jar $CLOSURE --js $MAIN_FILE >> $MIN_FILE |
78 |
|
|
echo " Min JS file size: $(ls -l $MIN_FILE | awk -F" " '{ print $5 }')" |
79 |
|
|
fi |
80 |
|
|
|
81 |
|
|
if [ "$CMD" = "docs" -o "$CMD" = "" ]; then |
82 |
|
|
echo " Documentation" |
83 |
|
|
$JSDOC -d ../../docs -t JSDoc-DataTables $MAIN_FILE |
84 |
|
|
fi |
85 |
|
|
|
86 |
|
|
if [ "$CMD" = "cdn" ]; then |
87 |
|
|
echo " CDN" |
88 |
|
|
if [ -d ../../cdn ]; then |
89 |
|
|
rm -Rf ../../cdn |
90 |
|
|
fi |
91 |
|
|
mkdir ../../cdn |
92 |
|
|
mkdir ../../cdn/css |
93 |
|
|
cp $MAIN_FILE ../../cdn |
94 |
|
|
cp $MIN_FILE ../../cdn |
95 |
|
|
cp ../css/jquery.dataTables.css ../../cdn/css |
96 |
|
|
cp ../css/jquery.dataTables_themeroller.css ../../cdn/css |
97 |
|
|
cp -r ../images ../../cdn/ |
98 |
|
|
rm ../../cdn/images/Sorting\ icons.psd |
99 |
|
|
fi |
100 |
|
|
fi |
101 |
|
|
|
102 |
|
|
|
103 |
|
|
# Back to DataTables root dir |
104 |
|
|
cd ../.. |
105 |
|
|
|
106 |
|
|
# |
107 |
|
|
# Packaging files |
108 |
|
|
# |
109 |
|
|
cat <<EOF > package.json |
110 |
|
|
{ |
111 |
|
|
"name": "DataTables", |
112 |
|
|
"version": "${VERSION}", |
113 |
|
|
"title": "DataTables", |
114 |
|
|
"author": { |
115 |
|
|
"name": "Allan Jardine", |
116 |
|
|
"url": "http://sprymedia.co.uk" |
117 |
|
|
}, |
118 |
|
|
"licenses": [ |
119 |
|
|
{ |
120 |
|
|
"type": "BSD", |
121 |
|
|
"url": "http://datatables.net/license_bsd" |
122 |
|
|
}, |
123 |
|
|
{ |
124 |
|
|
"type": "GPLv2", |
125 |
|
|
"url": "http://datatables.net/license_gpl2" |
126 |
|
|
} |
127 |
|
|
], |
128 |
|
|
"dependencies": { |
129 |
|
|
"jquery": "1.4 - 1.8" |
130 |
|
|
}, |
131 |
|
|
"description": "DataTables enhances HTML tables with the ability to sort, filter and page the data in the table very easily. It provides a comprehensive API and set of configuration options, allowing you to consume data from virtually any data source.", |
132 |
|
|
"keywords": [ |
133 |
|
|
"DataTables", |
134 |
|
|
"DataTable", |
135 |
|
|
"table", |
136 |
|
|
"grid", |
137 |
|
|
"filter", |
138 |
|
|
"sort", |
139 |
|
|
"page", |
140 |
|
|
"internationalisable" |
141 |
|
|
], |
142 |
|
|
"homepage": "http://datatables.net" |
143 |
|
|
} |
144 |
|
|
EOF |
145 |
|
|
|
146 |
|
|
cat <<EOF > component.json |
147 |
|
|
{ |
148 |
|
|
"name": "DataTables", |
149 |
|
|
"version": "${VERSION}", |
150 |
|
|
"main": [ |
151 |
|
|
"./media/js/jquery.dataTables.js", |
152 |
|
|
"./media/css/jquery.dataTables.css", |
153 |
|
|
], |
154 |
|
|
"dependencies": { |
155 |
|
|
"jquery": "~1.8.0" |
156 |
|
|
} |
157 |
|
|
} |
158 |
|
|
EOF |
159 |
|
|
|
160 |
|
|
|
161 |
|
|
echo " Done\n" |