From 2806de2a5dc94047d1483886d2ae7f527f3e54a9 Mon Sep 17 00:00:00 2001 From: Brian Peacock Date: Wed, 7 May 2014 11:27:51 -0500 Subject: [PATCH] Added static resources --- Gruntfile.js | 38 ++++++++++++++++++++++++++++++++++++++ lib/GUI/css/main.less | 3 +++ lib/GUI/index.handlebars | 4 ++++ lib/GUI/js/main.js | 0 lib/index.js | 14 ++++++++++++++ lib/static/main.css | 4 ++++ lib/static/main.js | 3 +++ package.json | 5 +++++ 8 files changed, 71 insertions(+) create mode 100644 Gruntfile.js create mode 100644 lib/GUI/css/main.less create mode 100644 lib/GUI/js/main.js create mode 100644 lib/static/main.css create mode 100644 lib/static/main.js diff --git a/Gruntfile.js b/Gruntfile.js new file mode 100644 index 000000000..fd97aeff1 --- /dev/null +++ b/Gruntfile.js @@ -0,0 +1,38 @@ +module.exports = function(grunt) { + grunt.initConfig({ + pkg: grunt.file.readJSON('package.json'), + browserify: { + dist: { + files: { + 'static/main.js': ['lib/GUI/js/main.js'] + }, + options: { + debug: true + } + } + }, + less: { + dist: { + files: { + 'static/main.css': ['lib/GUI/css/main.less'] + }, + options: { + sourceMap: true + } + } + }, + watch: { + files: [ "lib/GUI/js/**/*", "lib/GUI/css/**/*"], + tasks: [ 'default' ] + } + }); + + grunt.loadNpmTasks('grunt-browserify'); + grunt.loadNpmTasks('grunt-contrib-watch'); + grunt.loadNpmTasks('grunt-contrib-less'); + + grunt.registerTask('default', [ + 'browserify', + 'less' + ]); +}; \ No newline at end of file diff --git a/lib/GUI/css/main.less b/lib/GUI/css/main.less new file mode 100644 index 000000000..a39a29544 --- /dev/null +++ b/lib/GUI/css/main.less @@ -0,0 +1,3 @@ +body { + +} \ No newline at end of file diff --git a/lib/GUI/index.handlebars b/lib/GUI/index.handlebars index 97afde139..0b1f058c6 100644 --- a/lib/GUI/index.handlebars +++ b/lib/GUI/index.handlebars @@ -3,6 +3,8 @@ {{ name }} + +

{{ name }}

@@ -26,5 +28,7 @@

{{ description }}

{{/each}} + + diff --git a/lib/GUI/js/main.js b/lib/GUI/js/main.js new file mode 100644 index 000000000..e69de29bb diff --git a/lib/index.js b/lib/index.js index c2bf39b43..f392a753b 100644 --- a/lib/index.js +++ b/lib/index.js @@ -222,6 +222,20 @@ module.exports = function(config_hash) { }) }) + // Static + app.get('/-/static/:file', function(req, res, next) { + var file = __dirname + '/static/' + req.params.file; + fs.exists(file, function(exists) { + if(exists) { + res.sendfile(file); + } + else { + res.status(404); + res.send("File Not Found"); + } + }); + }); + // tagging a package app.put('/:package/:tag', can('publish'), media('application/json'), function(req, res, next) { if (typeof(req.body) !== 'string') return next('route') diff --git a/lib/static/main.css b/lib/static/main.css new file mode 100644 index 000000000..b8e144189 --- /dev/null +++ b/lib/static/main.css @@ -0,0 +1,4 @@ +body { + background: blue; +} +/*# sourceMappingURL=data:application/json,%7B%22version%22%3A3%2C%22sources%22%3A%5B%22lib%2FGUI%2Fcss%2Fmain.less%22%5D%2C%22names%22%3A%5B%5D%2C%22mappings%22%3A%22AAAA%3BEACC%2CgBAAA%22%7D */ \ No newline at end of file diff --git a/lib/static/main.js b/lib/static/main.js new file mode 100644 index 000000000..8a7bd83c5 --- /dev/null +++ b/lib/static/main.js @@ -0,0 +1,3 @@ +(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o= 0.3.2" }, "devDependencies": { + "browserify": "^3.46.0", "eslint": ">= 0.4.2", + "grunt": "^0.4.4", + "grunt-browserify": "^2.0.8", + "grunt-contrib-less": "^0.11.0", + "grunt-contrib-watch": "^0.6.1", "mocha": ">= 1.17.0", "rimraf": ">= 2.2.5" },