Add new icon attribute, add SVG support

main
DaAwesomeP 9 years ago
parent 5fa7da01c5
commit 4fbb767bcc

1
.gitignore vendored

@ -5,6 +5,7 @@ build/*
drivers/npm/node_modules drivers/npm/node_modules
drivers/npm/npm-debug.log drivers/npm/npm-debug.log
package.json
node_modules/ node_modules/
npm-debug.log npm-debug.log

@ -10,7 +10,7 @@ install:
- sudo apt-get update -y - sudo apt-get update -y
- sudo apt-get install -y curl zip sudo -y --force-yes - sudo apt-get install -y curl zip sudo -y --force-yes
- sudo apt-get clean - sudo apt-get clean
- npm install jsonlint jpm imagemin-cli -g - npm install jsonlint jpm imagemin-cli svgo -g
- ln -s docker/node/package.json package.json && npm install - ln -s docker/node/package.json package.json && npm install
- mkdir phantomjs && curl -L https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-1.9.8-linux-x86_64.tar.bz2 | tar xvjC phantomjs && ln -s $WAPPALYZER_ROOT/phantomjs/phantomjs-*-linux-x86_64/bin/phantomjs bin/phantomjs - mkdir phantomjs && curl -L https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-1.9.8-linux-x86_64.tar.bz2 | tar xvjC phantomjs && ln -s $WAPPALYZER_ROOT/phantomjs/phantomjs-*-linux-x86_64/bin/phantomjs bin/phantomjs
script: wappalyzer build script: wappalyzer build

@ -15,10 +15,14 @@ echo "Prettifying apps.json..."
jsonlint -ist $'\t' $WAPPALYZER_ROOT/src/apps.json jsonlint -ist $'\t' $WAPPALYZER_ROOT/src/apps.json
echo "Compressing icons..." echo "Compressing PNG icons..."
imagemin $WAPPALYZER_ROOT/src/icons $WAPPALYZER_ROOT/src/icons -o 3 imagemin $WAPPALYZER_ROOT/src/icons $WAPPALYZER_ROOT/src/icons -o 3
echo "Compressing PNG icons..."
svgo -f $WAPPALYZER_ROOT/src/icons $WAPPALYZER_ROOT/src/icons
wappalyzer links wappalyzer links
# Npm Module # Npm Module

@ -6,23 +6,45 @@ var
fs = require('fs'), fs = require('fs'),
fileType = require(modulesPath + 'file-type'), fileType = require(modulesPath + 'file-type'),
readChunk = require(modulesPath + 'read-chunk') readChunk = require(modulesPath + 'read-chunk')
isSvg = require(modulesPath + 'is-svg')
json = require(process.env.WAPPALYZER_ROOT + '/src/apps.json'); json = require(process.env.WAPPALYZER_ROOT + '/src/apps.json');
for ( app in json.apps ) { for (app in json.apps) {
(function(app) { (function(app) {
var path = process.env.WAPPALYZER_ROOT + '/src/icons/' + app + '.png'; var basePath = process.env.WAPPALYZER_ROOT + '/src/icons/';
var iconPath = json.apps[app].icon;
var path = basePath + iconPath;
var type;
if (path.substr(path.length - 4) === '.png') {
type = "PNG";
}
else if (path.substr(path.length - 4) === '.svg') {
type = "SVG";
}
else {
var err = new Error('Icon file extension specified for app "' + app + '" is not ".png" or ".svg": src/icons/' + iconPath);
throw err;
}
fs.exists(path, function(exists) { fs.exists(path, function(exists) {
var buffer; if (exists) {
if (type === "PNG") {
if ( exists ) { var buffer = fileType(readChunk.sync(path, 0, 262));
buffer = fileType(readChunk.sync(path, 0, 262)); if (buffer.mime !== 'image/png') {
var err = new Error('Incorrect mimetype "' + buffer.mime + '" when expected PNG for app "' + app + '": src/icons/' + iconPath);
if ( buffer.mime !== 'image/png' ) { throw err;
throw new Error('Incorrect mimetype "' + buffer.mime + '": src/icons/' + app + '.png'); }
} }
else if (type === "SVG") {
if (!isSvg(fs.readFileSync(path))) {
var err = new Error('Incorrect mimetype when expected SVG for app "' + app + '": src/icons/' + iconPath);
throw err;
}
}
} else { } else {
throw new Error('Missing file: src/icons/' + app + '.png'); var err = new Error('Missing file for app "' + app + '": src/icons/' + iconPath);
throw err;
} }
}); });
}(app)); }(app));

@ -32,7 +32,7 @@ RUN su wappalyzer -c "mkdir $WAPPALYZER_NODE_PATH"
ADD node/package.json $WAPPALYZER_NODE_PATH/package.json ADD node/package.json $WAPPALYZER_NODE_PATH/package.json
RUN npm install jsonlint jpm imagemin-cli -g && su wappalyzer -c "cd $WAPPALYZER_NODE_PATH && npm install" RUN npm install jsonlint jpm imagemin-cli svgo -g && su wappalyzer -c "cd $WAPPALYZER_NODE_PATH && npm install"
# PhantomJS # PhantomJS

@ -1,6 +1,7 @@
{ {
"devDependencies": { "devDependencies": {
"file-type": "2.2.*", "file-type": "3.1.*",
"is-svg": "1.1.*",
"read-chunk": "1.0.*" "read-chunk": "1.0.*"
} }
} }

@ -74,6 +74,10 @@
"website": { "website": {
"type": "string", "type": "string",
"required": true "required": true
},
"icon": {
"type": "string",
"required": true
} }
} }
} }

File diff suppressed because it is too large Load Diff