Added static resources

This commit is contained in:
Brian Peacock 2014-05-07 11:27:51 -05:00
parent 27c032d53f
commit 2806de2a5d
8 changed files with 71 additions and 0 deletions

38
Gruntfile.js Normal file
View File

@ -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'
]);
};

3
lib/GUI/css/main.less Normal file
View File

@ -0,0 +1,3 @@
body {
}

View File

@ -3,6 +3,8 @@
<head>
<meta charset="utf-8">
<title>{{ name }}</title>
<link rel="stylesheet" type="text/css" href="/-/static/main.css">
</head>
<body>
<h1><a href='/'>{{ name }}</a></h1>
@ -26,5 +28,7 @@
<p>{{ description }}</p>
</article>
{{/each}}
<script type='text/javascript' src='/-/static/main.js'></script>
</body>
</html>

0
lib/GUI/js/main.js Normal file
View File

View File

@ -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')

4
lib/static/main.css Normal file
View File

@ -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 */

3
lib/static/main.js Normal file
View File

@ -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<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
},{}]},{},[1])

View File

@ -33,7 +33,12 @@
"fs-ext": ">= 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"
},