-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8db12f8
commit 5d82a39
Showing
4 changed files
with
28,416 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,200 @@ | ||
define(['require', './normalize'], function(req, normalize) { | ||
var cssAPI = {}; | ||
|
||
var isWindows = !!process.platform.match(/^win/); | ||
|
||
function compress(css) { | ||
if (config.optimizeCss == 'none') { | ||
return css; | ||
} | ||
if (typeof process !== "undefined" && process.versions && !!process.versions.node && require.nodeRequire) { | ||
try { | ||
var csso = require.nodeRequire('csso'); | ||
} | ||
catch(e) { | ||
console.log('Compression module not installed. Use "npm install csso -g" to enable.'); | ||
return css; | ||
} | ||
var csslen = css.length; | ||
try { | ||
css = csso.justDoIt(css); | ||
} | ||
catch(e) { | ||
console.log('Compression failed due to a CSS syntax error.'); | ||
return css; | ||
} | ||
console.log('Compressed CSS output to ' + Math.round(css.length / csslen * 100) + '%.'); | ||
return css; | ||
} | ||
console.log('Compression not supported outside of nodejs environments.'); | ||
return css; | ||
} | ||
|
||
//load file code - stolen from text plugin | ||
function loadFile(path) { | ||
if (typeof process !== "undefined" && process.versions && !!process.versions.node && require.nodeRequire) { | ||
var fs = require.nodeRequire('fs'); | ||
var file = fs.readFileSync(path, 'utf8'); | ||
if (file.indexOf('\uFEFF') === 0) | ||
return file.substring(1); | ||
return file; | ||
} | ||
else { | ||
var file = new java.io.File(path), | ||
lineSeparator = java.lang.System.getProperty("line.separator"), | ||
input = new java.io.BufferedReader(new java.io.InputStreamReader(new java.io.FileInputStream(file), 'utf-8')), | ||
stringBuffer, line; | ||
try { | ||
stringBuffer = new java.lang.StringBuffer(); | ||
line = input.readLine(); | ||
if (line && line.length() && line.charAt(0) === 0xfeff) | ||
line = line.substring(1); | ||
stringBuffer.append(line); | ||
while ((line = input.readLine()) !== null) { | ||
stringBuffer.append(lineSeparator).append(line); | ||
} | ||
return String(stringBuffer.toString()); | ||
} | ||
finally { | ||
input.close(); | ||
} | ||
} | ||
} | ||
|
||
|
||
function saveFile(path, data) { | ||
if (typeof process !== "undefined" && process.versions && !!process.versions.node && require.nodeRequire) { | ||
var fs = require.nodeRequire('fs'); | ||
fs.writeFileSync(path, data, 'utf8'); | ||
} | ||
else { | ||
var content = new java.lang.String(data); | ||
var output = new java.io.BufferedWriter(new java.io.OutputStreamWriter(new java.io.FileOutputStream(path), 'utf-8')); | ||
|
||
try { | ||
output.write(content, 0, content.length()); | ||
output.flush(); | ||
} | ||
finally { | ||
output.close(); | ||
} | ||
} | ||
} | ||
|
||
//when adding to the link buffer, paths are normalised to the baseUrl | ||
//when removing from the link buffer, paths are normalised to the output file path | ||
function escape(content) { | ||
return content.replace(/(["'\\])/g, '\\$1') | ||
.replace(/[\f]/g, "\\f") | ||
.replace(/[\b]/g, "\\b") | ||
.replace(/[\n]/g, "\\n") | ||
.replace(/[\t]/g, "\\t") | ||
.replace(/[\r]/g, "\\r"); | ||
} | ||
|
||
// NB add @media query support for media imports | ||
var importRegEx = /@import\s*(url)?\s*(('([^']*)'|"([^"]*)")|\(('([^']*)'|"([^"]*)"|([^\)]*))\))\s*;?/g; | ||
var absUrlRegEx = /^([^\:\/]+:\/)?\//; | ||
|
||
|
||
var siteRoot; | ||
|
||
var baseParts = req.toUrl('base_url').split('/'); | ||
baseParts[baseParts.length - 1] = ''; | ||
var baseUrl = baseParts.join('/'); | ||
|
||
var curModule = 0; | ||
var config; | ||
|
||
var layerBuffer = []; | ||
var cssBuffer = {}; | ||
|
||
cssAPI.load = function(name, req, load, _config) { | ||
|
||
//store config | ||
config = config || _config; | ||
|
||
if (!siteRoot) { | ||
siteRoot = path.resolve(config.dir || path.dirname(config.out), config.siteRoot || '.') + '/'; | ||
if (isWindows) | ||
siteRoot = siteRoot.replace(/\\/g, '/'); | ||
} | ||
|
||
//external URLS don't get added (just like JS requires) | ||
if (name.match(absUrlRegEx)) | ||
return load(); | ||
|
||
var fileUrl = req.toUrl(name + '.css'); | ||
if (isWindows) | ||
fileUrl = fileUrl.replace(/\\/g, '/'); | ||
|
||
// rebase to the output directory if based on the source directory; | ||
// baseUrl points always to the output directory, fileUrl only if | ||
// it is not prefixed by a computed path (relative too) | ||
var fileSiteUrl = fileUrl; | ||
if (fileSiteUrl.indexOf(baseUrl) < 0) { | ||
var appRoot = req.toUrl(config.appDir); | ||
if (isWindows) | ||
appRoot = appRoot.replace(/\\/g, '/'); | ||
if (fileSiteUrl.indexOf(appRoot) == 0) | ||
fileSiteUrl = siteRoot + fileSiteUrl.substring(appRoot.length); | ||
} | ||
|
||
//add to the buffer | ||
cssBuffer[name] = normalize(loadFile(fileUrl), fileSiteUrl, siteRoot); | ||
|
||
load(); | ||
} | ||
|
||
cssAPI.normalize = function(name, normalize) { | ||
if (name.substr(name.length - 4, 4) == '.css') | ||
name = name.substr(0, name.length - 4); | ||
return normalize(name); | ||
} | ||
|
||
cssAPI.write = function(pluginName, moduleName, write, parse) { | ||
//external URLS don't get added (just like JS requires) | ||
if (moduleName.match(absUrlRegEx)) | ||
return; | ||
|
||
layerBuffer.push(cssBuffer[moduleName]); | ||
|
||
if (config.buildCSS != false) | ||
write.asModule(pluginName + '!' + moduleName, 'define(function(){})'); | ||
} | ||
|
||
cssAPI.onLayerEnd = function(write, data) { | ||
if (config.separateCSS && config.IESelectorLimit) | ||
throw 'RequireCSS: separateCSS option is not compatible with ensuring the IE selector limit'; | ||
|
||
if (config.separateCSS) { | ||
var outPath = data.path.replace(/(\.js)?$/, '.css'); | ||
console.log('Writing CSS! file: ' + outPath + '\n'); | ||
|
||
var css = layerBuffer.join(''); | ||
|
||
process.nextTick(function() { | ||
if (fs.existsSync(outPath)) { | ||
css = css + fs.readFileSync(outPath, {encoding: 'utf8'}); | ||
} | ||
saveFile(outPath, compress(css)); | ||
}); | ||
|
||
} | ||
else if (config.buildCSS != false) { | ||
var styles = config.IESelectorLimit ? layerBuffer : [layerBuffer.join('')]; | ||
for (var i = 0; i < styles.length; i++) { | ||
if (styles[i] == '') | ||
return; | ||
write( | ||
"(function(c){var d=document,a='appendChild',i='styleSheet',s=d.createElement('style');s.type='text/css';d.getElementsByTagName('head')[0][a](s);s[i]?s[i].cssText=c:s[a](d.createTextNode(c));})\n" | ||
+ "('" + escape(compress(styles[i])) + "');\n" | ||
); | ||
} | ||
} | ||
//clear layer buffer for next layer | ||
layerBuffer = []; | ||
} | ||
|
||
return cssAPI; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
#!/bin/bash | ||
|
||
VERSION="$1" | ||
USER="$2" | ||
PASS="$3" | ||
|
||
if [[ -z $PASS ]]; then | ||
echo "Call script with the new version name as parameter like | ||
$0 \"1.2.3\" \"MySVNUserName\" \"MySVNPass\" [-dry]" | ||
exit | ||
fi | ||
|
||
RELEASE_DIR="release_$VERSION" | ||
SVN_CMD="svn --username $USER --password $PASS" | ||
|
||
if [ x"$4" = "x-dry" ]; then | ||
echo "Dry run!" | ||
SVN_CMD="echo svn" | ||
fi | ||
|
||
echo "Creating Release: '$VERSION' in '$RELEASE_DIR'" | ||
|
||
# Make sure we start at the location of this script | ||
# NOTE: the script assumes to live at .../CometVisu/_support | ||
cd "$( dirname "${BASH_SOURCE[0]}" )" | ||
|
||
$SVN_CMD copy -m "Creating release branch $VERSION" \ | ||
"svn+ssh://$USER@svn.code.sf.net/p/openautomation/code/CometVisu/trunk" \ | ||
"svn+ssh://$USER@svn.code.sf.net/p/openautomation/code/CometVisu/branches/$RELEASE_DIR" | ||
|
||
# NOTE: the script assumes that the branches live at .../CometVisu/branches | ||
cd ../branches | ||
|
||
if [ x"$4" = "x-dry" ]; then | ||
# dry run? Then fake copy in /tmp/branches | ||
if [ -e /tmp/branches ]; then | ||
echo "/tmp/branches does already exist - deleting it..." | ||
rm -rf /tmp/branches | ||
fi | ||
mkdir /tmp/branches | ||
mkdir /tmp/_support | ||
cp ../_support/* /tmp/_support | ||
cp -r ../trunk /tmp/branches/$RELEASE_DIR | ||
cd /tmp/branches | ||
fi | ||
|
||
$SVN_CMD up | ||
echo $VERSION > $RELEASE_DIR/VERSION | ||
echo $VERSION > $RELEASE_DIR/src/version | ||
sed -i "s/Version: SVN/Version: $VERSION/" $RELEASE_DIR/src/config/visu_config.xml | ||
sed -i "s/Version: SVN/Version: $VERSION/" $RELEASE_DIR/src/config/demo/visu_config_demo.xml | ||
sed -i "s/comet_16x16_000000.png/comet_16x16_ff8000.png/" $RELEASE_DIR/src/index.html | ||
cd $RELEASE_DIR | ||
|
||
#make | ||
JS_ENGINE=`which node nodejs 2>/dev/null | head -n 1` | ||
TIMESTAMP=`date +%Y%m%d-%H%M%S` | ||
STATIC_FILES_PRE=$(cat src/cometvisu.appcache | sed '0,/T MODIFY!$/{//!b};d') | ||
STATIC_FILES_POST=$(cat src/cometvisu.appcache | sed '/^NETWORK:$/,/^$/{//!b};d') | ||
PLUGIN_FILES=$(find src | grep plugins | grep -E "structure_plugin.js|\.css" | sed 's%src/%%') | ||
DESIGN_FILES=$(find src | grep designs | grep -E "\.js|\.css|\.ttf" | grep -v "custom.css" | sed 's%src/%%') | ||
mkdir -p ./release | ||
$JS_ENGINE ../../_support/r.js -o build.js | ||
find release -path "*/.svn" -exec rm -rf {} + | ||
echo -e "$STATIC_FILES_PRE\n$DESIGN_FILES\n$PLUGIN_FILES\n\nNETWORK:\n$STATIC_FILES_POST" | \ | ||
sed "s/# Version.*/# Version $VERSION:$TIMESTAMP/" \ | ||
> release/cometvisu.appcache | ||
rm release/build.txt | ||
|
||
chmod -R a+w src/config | ||
chmod -R a+w release/config | ||
# why do I need this?!? I'd expect r.js to create that dir already... | ||
mkdir -p release/config/backup | ||
chmod -R a+w release/config/backup | ||
cd .. | ||
$SVN_CMD propdel svn:ignore $RELEASE_DIR | ||
$SVN_CMD add $RELEASE_DIR/docs --depth infinity | ||
$SVN_CMD add $RELEASE_DIR/release --depth infinity | ||
$SVN_CMD ci -m "New release: $VERSION" | ||
|
||
tar -cjp --exclude-vcs -f CometVisu_$VERSION.tar.bz2 $RELEASE_DIR | ||
|
Oops, something went wrong.