diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e920c16 --- /dev/null +++ b/.gitignore @@ -0,0 +1,33 @@ +# Logs +logs +*.log +npm-debug.log* + +# Runtime data +pids +*.pid +*.seed + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage + +# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# node-waf configuration +.lock-wscript + +# Compiled binary addons (http://nodejs.org/api/addons.html) +build/Release + +# Dependency directory +node_modules + +# Optional npm cache directory +.npm + +# Optional REPL history +.node_repl_history diff --git a/Procfile b/Procfile new file mode 100644 index 0000000..a553d73 --- /dev/null +++ b/Procfile @@ -0,0 +1 @@ +web: node ./bin/www diff --git a/README.md b/README.md new file mode 100644 index 0000000..e976735 --- /dev/null +++ b/README.md @@ -0,0 +1,29 @@ +# Developer Tools Gadget +An [OU Campus](https://omniupdate.com/products/oucampus) gadget designed for web developers. + +## Features +- Minify/uglify CSS +- Minify/uglify JavaScript +- Compile SCSS +- Compile LESS + +## OU Campus Installation +Follow the OU Campus [gadget installation instructions](http://support.omniupdate.com/oucampus10/setup/gadgets/new-gadget.html) to install this gadget. When prompted for the gadget URL, enter `https://devtools.gadget.host` + +## Installing and running locally +This gadget requires a NodeJS back-end to handle the core functionality. To install, run +``` +git clone https://github.com/lashkari/gadget-devtools.git + +cd gadget-devtools + +npm install + +npm run dev +``` + +## Reporting issues +This is NOT an official gadget. Please report any issues you find here on GitHub, **do not contact OmniUpdate customer support about this gadget**. + +## Contributing +Contributions (by way of pull requests and reporting issues) are very welcome. I've still got some code cleanup to do and then I'll add some more info on how to contribute code. diff --git a/app.js b/app.js new file mode 100644 index 0000000..a9db3f8 --- /dev/null +++ b/app.js @@ -0,0 +1,61 @@ +var express = require('express'); +var path = require('path'); +var favicon = require('serve-favicon'); +var logger = require('morgan'); +var cookieParser = require('cookie-parser'); +var bodyParser = require('body-parser'); + +var jshint = require('./routes/jshint.js'); +var uglify = require('./routes/uglify.js'); +var sass = require('./routes/sass.js'); +var less = require('./routes/less.js'); + +var app = express(); + +app.use(favicon(path.join(__dirname, 'public', 'favicon.ico'))); +app.use(logger('dev')); +app.use(bodyParser.json({ limit: '1mb' })); +app.use(bodyParser.urlencoded({ extended: false })); +app.use(bodyParser.text()); +app.use(cookieParser()); +app.use(express.static(path.join(__dirname, 'public'))); + +app.use('/', express.static(path.join(__dirname, 'public'))); +app.use('/jshint', jshint); +app.use('/uglify', uglify); +app.use('/sass', sass); +app.use('/less', less); + +// catch 404 and forward to error handler +app.use(function(req, res, next) { + var err = new Error('Not Found'); + err.status = 404; + next(err); +}); + +// error handlers + +// development error handler +// will print stacktrace +if (app.get('env') === 'development') { + app.use(function(err, req, res, next) { + res.status(err.status || 500); + res.render('error', { + message: err.message, + error: err + }); + }); +} + +// production error handler +// no stacktraces leaked to user +app.use(function(err, req, res, next) { + res.status(err.status || 500); + res.render('error', { + message: err.message, + error: {} + }); +}); + + +module.exports = app; diff --git a/bin/www b/bin/www new file mode 100755 index 0000000..a2c8f8d --- /dev/null +++ b/bin/www @@ -0,0 +1,90 @@ +#!/usr/bin/env node + +/** + * Module dependencies. + */ + +var app = require('../app'); +var debug = require('debug')('devtoolsGadget:server'); +var http = require('http'); + +/** + * Get port from environment and store in Express. + */ + +var port = normalizePort(process.env.PORT || '3000'); +app.set('port', port); + +/** + * Create HTTP server. + */ + +var server = http.createServer(app); + +/** + * Listen on provided port, on all network interfaces. + */ + +server.listen(port); +server.on('error', onError); +server.on('listening', onListening); + +/** + * Normalize a port into a number, string, or false. + */ + +function normalizePort(val) { + var port = parseInt(val, 10); + + if (isNaN(port)) { + // named pipe + return val; + } + + if (port >= 0) { + // port number + return port; + } + + return false; +} + +/** + * Event listener for HTTP server "error" event. + */ + +function onError(error) { + if (error.syscall !== 'listen') { + throw error; + } + + var bind = typeof port === 'string' + ? 'Pipe ' + port + : 'Port ' + port; + + // handle specific listen errors with friendly messages + switch (error.code) { + case 'EACCES': + console.error(bind + ' requires elevated privileges'); + process.exit(1); + break; + case 'EADDRINUSE': + console.error(bind + ' is already in use'); + process.exit(1); + break; + default: + throw error; + } +} + +/** + * Event listener for HTTP server "listening" event. + */ + +function onListening() { + var addr = server.address(); + var bind = typeof addr === 'string' + ? 'pipe ' + addr + : 'port ' + addr.port; + debug('Listening on ' + bind); +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..b2821c1 --- /dev/null +++ b/package.json @@ -0,0 +1,31 @@ +{ + "name": "devtoolsGadget", + "version": "1.0.0", + "author": "Shahab Lashkari", + "description":"An OU Campus gadget for web developers", + "license": "ISC", + "scripts": { + "start": "node ./bin/www", + "dev": "nodemon ./bin/www" + }, + "engines": { + "node": "5.4.0" + }, + "dependencies": { + "body-parser": "^1.13.3", + "cookie-parser": "~1.3.5", + "debug": "~2.2.0", + "express": "~4.13.1", + "imagemin": "^4.0.0", + "jshint": "^2.9.1", + "less": "^2.6.0", + "morgan": "~1.6.1", + "node-sass": "^3.4.2", + "serve-favicon": "~2.3.0", + "uglify-js": "^2.6.1", + "uglifycss": "0.0.20" + }, + "devDependencies": { + "nodemon": "^1.9.1" + } +} diff --git a/public/config.xml b/public/config.xml new file mode 100644 index 0000000..d8c1036 --- /dev/null +++ b/public/config.xml @@ -0,0 +1,30 @@ + + + + + Developer Tools + + + https://devtools.gadget.host/favicon.ico + + + Provides useful tools for web developers. Currently supports minification of CSS/JavaScript and CSS pre-processing of SASS and LESS. + + + https://devtools.gadget.host/images/thumbnail.png + + + sidebar + + + view_changed + + + page + + + 80 + + \ No newline at end of file diff --git a/public/favicon.ico b/public/favicon.ico new file mode 100644 index 0000000..a448e4f Binary files /dev/null and b/public/favicon.ico differ diff --git a/public/images/logo.png b/public/images/logo.png new file mode 100644 index 0000000..002fc7b Binary files /dev/null and b/public/images/logo.png differ diff --git a/public/images/thumbnail.png b/public/images/thumbnail.png new file mode 100644 index 0000000..89b5afa Binary files /dev/null and b/public/images/thumbnail.png differ diff --git a/public/index.html b/public/index.html new file mode 100644 index 0000000..a252a51 --- /dev/null +++ b/public/index.html @@ -0,0 +1,282 @@ + + + + + Developer Tools Gadget + + + + + + + +
+ + + + +
+ + + + + + + diff --git a/public/javascripts/gadgetlib.min.js b/public/javascripts/gadgetlib.min.js new file mode 100644 index 0000000..1b86a91 --- /dev/null +++ b/public/javascripts/gadgetlib.min.js @@ -0,0 +1 @@ +!function(){function t(){return a("get-environment")}function e(){var t={},e=location.href.split(/[\?&]/),a=e.splice(1);t.url=e[0];for(var i,o,r,s=0;s