nurls 0.1.0-alpha
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.gitattributes +1 -0
- package/.jshintrc +18 -0
- package/.npmignore +7 -0
- package/.travis.yml +6 -0
- package/AUTHORS.md +3 -0
- package/CONTRIBUTING.md +57 -0
- package/Gruntfile.js +34 -0
- package/LICENSE.md +19 -0
- package/README.md +18 -0
- package/lib/index.js +6 -0
- package/lib/view/app.js +90 -0
- package/lib/view/index.js +6 -0
- package/package.json +43 -0
- package/static/.npmignore +0 -0
- package/test/.npmignore +0 -0
- package/views/.npmignore +0 -0
package/.gitattributes
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
* text=auto
|
package/.jshintrc
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"boss": true,
|
|
3
|
+
"camelcase": true,
|
|
4
|
+
"curly": false,
|
|
5
|
+
"eqeqeq": true,
|
|
6
|
+
"immed": true,
|
|
7
|
+
"latedef": true,
|
|
8
|
+
"laxcomma": true,
|
|
9
|
+
"maxlen": 100,
|
|
10
|
+
"newcap": true,
|
|
11
|
+
"noarg": true,
|
|
12
|
+
"node": true,
|
|
13
|
+
"nonew": true,
|
|
14
|
+
"quotmark": "single",
|
|
15
|
+
"strict": true,
|
|
16
|
+
"undef": true,
|
|
17
|
+
"unused": true
|
|
18
|
+
}
|
package/.npmignore
ADDED
package/.travis.yml
ADDED
package/AUTHORS.md
ADDED
package/CONTRIBUTING.md
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# Contributing
|
|
2
|
+
|
|
3
|
+
Here are some guidelines that we'd like contributors to follow so that we can have a chance of
|
|
4
|
+
keeping things right.
|
|
5
|
+
|
|
6
|
+
## Getting Starting
|
|
7
|
+
|
|
8
|
+
* Make sure you have a [GitHub account](https://github.com/signup/free)
|
|
9
|
+
* Submit a ticket for your issue if one does not already exist
|
|
10
|
+
* Clearly describe the issue including steps to reproduce when it is a bug
|
|
11
|
+
* Include the earliest version that you know has the issue
|
|
12
|
+
* Fork the repository on GitHub
|
|
13
|
+
|
|
14
|
+
## Making Changes
|
|
15
|
+
|
|
16
|
+
* Create a topic branch from where you want to base your work
|
|
17
|
+
* This is usually the master branch
|
|
18
|
+
* Only target release branches if you are certain your fix must be on that branch
|
|
19
|
+
* To quickly create a topic branch based on master;
|
|
20
|
+
`git branch fix/master/my_contribution master` then checkout the new branch with
|
|
21
|
+
`git checkout fix/master/my_contribution`
|
|
22
|
+
* Avoid working directly on the `master` branch
|
|
23
|
+
* Make commits of logical units
|
|
24
|
+
* Check for unnecessary whitespace with `git diff --check` before committing
|
|
25
|
+
* Make sure your commit messages are in the proper format
|
|
26
|
+
```
|
|
27
|
+
(#99999) Make the example in CONTRIBUTING imperative and concrete
|
|
28
|
+
|
|
29
|
+
Without this patch applied the example commit message in the CONTRIBUTING document is not a
|
|
30
|
+
concrete example. This is a problem because the contributor is left to imagine what the commit
|
|
31
|
+
message should look like based on a description rather than an example. This patch fixes the
|
|
32
|
+
problem by making the example concrete and imperative.
|
|
33
|
+
|
|
34
|
+
The first line is a real life imperative statement with a ticket number from our issue tracker.
|
|
35
|
+
The body describes the behavior without the patch, why this is a problem, and how the patch
|
|
36
|
+
fixes the problem when applied.
|
|
37
|
+
```
|
|
38
|
+
* Make sure you have added the necessary tests for your changes
|
|
39
|
+
* Run *all* the tests to assure nothing else was accidentally broken
|
|
40
|
+
|
|
41
|
+
## Submitting Changes
|
|
42
|
+
|
|
43
|
+
* Ensure you added your details to `AUTHORS.md` in the correct format
|
|
44
|
+
```
|
|
45
|
+
* Joe Bloggs <joe.bloggs@example.com>
|
|
46
|
+
```
|
|
47
|
+
* Push your changes to a topic branch in your fork of the repository
|
|
48
|
+
* Submit a pull request to NURLS repository
|
|
49
|
+
* Update your issue to mark that you have submitted code and are ready for it to be reviewed
|
|
50
|
+
* Include a link to the pull request in the issue
|
|
51
|
+
|
|
52
|
+
# Additional Resources
|
|
53
|
+
|
|
54
|
+
* [NURLS repository](https://github.com/NURLS/nurls)
|
|
55
|
+
* [Issue tracker](https://github.com/NURLS/nurls/issues)
|
|
56
|
+
* [General GitHub documentation](http://help.github.com)
|
|
57
|
+
* [GitHub pull request documentation](http://help.github.com/send-pull-requests)
|
package/Gruntfile.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
module.exports = function(grunt) {
|
|
2
|
+
|
|
3
|
+
// Configuration
|
|
4
|
+
// -------------
|
|
5
|
+
|
|
6
|
+
grunt.initConfig({
|
|
7
|
+
|
|
8
|
+
jshint: {
|
|
9
|
+
all: [
|
|
10
|
+
'Gruntfile.js'
|
|
11
|
+
, 'lib/**/*.js'
|
|
12
|
+
, '<%= nodeunit.tests %>'
|
|
13
|
+
]
|
|
14
|
+
, options: {
|
|
15
|
+
jshintrc: '.jshintrc'
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
, nodeunit: {
|
|
20
|
+
all: ['test/**/*_test.js']
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
// Tasks
|
|
26
|
+
// -----
|
|
27
|
+
|
|
28
|
+
grunt.loadNpmTasks('grunt-contrib-jshint');
|
|
29
|
+
grunt.loadNpmTasks('grunt-contrib-nodeunit');
|
|
30
|
+
|
|
31
|
+
grunt.registerTask('default', ['jshint', 'test']);
|
|
32
|
+
grunt.registerTask('test', ['nodeunit']);
|
|
33
|
+
|
|
34
|
+
};
|
package/LICENSE.md
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
Copyright (C) 2013 Alasdair Mercer, http://nurls.org
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
5
|
+
in the Software without restriction, including without limitation the rights
|
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
8
|
+
furnished to do so, subject to the following conditions:
|
|
9
|
+
|
|
10
|
+
The above copyright notice and this permission notice shall be included in all
|
|
11
|
+
copies or substantial portions of the Software.
|
|
12
|
+
|
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
19
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
__ __ __ __ ____ __ ____
|
|
2
|
+
/\ \/\ \/\ \/\ \/\ _`\ /\ \ /\ _`\
|
|
3
|
+
\ \ `\\ \ \ \ \ \ \ \L\ \ \ \ \ \,\L\_\
|
|
4
|
+
\ \ , ` \ \ \ \ \ \ , /\ \ \ __\/_\__ \
|
|
5
|
+
\ \ \`\ \ \ \_\ \ \ \\ \\ \ \L\ \ /\ \L\ \
|
|
6
|
+
\ \_\ \_\ \_____\ \_\ \_\ \____/ \ `\____\
|
|
7
|
+
\/_/\/_/\/_____/\/_/\/ /\/___/ \/_____/
|
|
8
|
+
|
|
9
|
+
NURLS: **N**ode **URL** **S**hortener
|
|
10
|
+
[](http://travis-ci.org/NURLS/nurls)
|
|
11
|
+
|
|
12
|
+
> This project is currently a work in progress
|
|
13
|
+
|
|
14
|
+
## Documentation
|
|
15
|
+
|
|
16
|
+
The [nurls.org][] website should have all you need to know.
|
|
17
|
+
|
|
18
|
+
[nurls.org]: http://nurls.org
|
package/lib/index.js
ADDED
package/lib/view/app.js
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
// [NURLS](http://nurls.org)
|
|
2
|
+
// (c) 2013 Alasdair Mercer
|
|
3
|
+
// Freely distributable under the MIT license:
|
|
4
|
+
// <http://nurls.org/license>
|
|
5
|
+
|
|
6
|
+
// Module dependencies
|
|
7
|
+
// -------------------
|
|
8
|
+
|
|
9
|
+
var int17 = require('int17').create('nurls')
|
|
10
|
+
, express = require('express')
|
|
11
|
+
, validator = require('express-validator');
|
|
12
|
+
|
|
13
|
+
// Internationalization
|
|
14
|
+
// --------------------
|
|
15
|
+
|
|
16
|
+
// Initialize the `int17` library.
|
|
17
|
+
// This is done synchronously to avoid wrapping everything else in one big callback.
|
|
18
|
+
int17.initSync();
|
|
19
|
+
|
|
20
|
+
// Express
|
|
21
|
+
// -------
|
|
22
|
+
|
|
23
|
+
// Create the express application.
|
|
24
|
+
var app = module.exports = express();
|
|
25
|
+
|
|
26
|
+
// Configure the application.
|
|
27
|
+
// TODO: session, view engine, authentication/passport
|
|
28
|
+
app.set('views', __dirname + '/../views');
|
|
29
|
+
app.use(express.static(__dirname + '/../static'));
|
|
30
|
+
app.use(express.logger());
|
|
31
|
+
app.use(express.bodyParser());
|
|
32
|
+
app.use(validator);
|
|
33
|
+
app.use(express.methodOverride());
|
|
34
|
+
app.use(express.cookieParser());
|
|
35
|
+
int17.express(app);
|
|
36
|
+
app.use(app.router);
|
|
37
|
+
|
|
38
|
+
// Handle errors correctly (i.e. log -> handle client -> handle server).
|
|
39
|
+
app.use(function (err, req, res, next) {
|
|
40
|
+
console.error(err.stack);
|
|
41
|
+
next(err);
|
|
42
|
+
});
|
|
43
|
+
app.use(function (err, req, res, next) {
|
|
44
|
+
if (req.xhr) {
|
|
45
|
+
res.send(500, { error: int17.get('error_xhr_message') });
|
|
46
|
+
} else {
|
|
47
|
+
next(err);
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
app.use(function (err, req, res, next) {
|
|
51
|
+
res.status(500);
|
|
52
|
+
res.render('error', {
|
|
53
|
+
error: {
|
|
54
|
+
err: err
|
|
55
|
+
, header: int17.get('error_500_header')
|
|
56
|
+
, message: int17.get('error_500_message')
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
// Show *page not found* view when the router found no matching handlers.
|
|
62
|
+
app.use(function (req, res, next) {
|
|
63
|
+
res.status(404);
|
|
64
|
+
res.render('error', {
|
|
65
|
+
error: {
|
|
66
|
+
header: int17.get('error_404_header')
|
|
67
|
+
, message: int17.get('error_404_message', req.url)
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
// Environment-specific support.
|
|
73
|
+
switch (app.get('env')) {
|
|
74
|
+
case 'development':
|
|
75
|
+
app.use(express.errorHandler({
|
|
76
|
+
dumpExceptions: true
|
|
77
|
+
, showStack: true
|
|
78
|
+
}));
|
|
79
|
+
break;
|
|
80
|
+
case 'production':
|
|
81
|
+
app.use(express.errorHandler());
|
|
82
|
+
break;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// Open for business.
|
|
86
|
+
// TODO: Derive port from ENV
|
|
87
|
+
var port = 3000;
|
|
88
|
+
app.listen(port, function () {
|
|
89
|
+
console.log('NURLS listening on port ' + port);
|
|
90
|
+
});
|
package/package.json
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "nurls",
|
|
3
|
+
"description": "Node URL Shortener",
|
|
4
|
+
"version": "0.1.0alpha",
|
|
5
|
+
"homepage": "http://nurls.org",
|
|
6
|
+
"bugs": {
|
|
7
|
+
"url": "https://github.com/NURLS/nurls/issues"
|
|
8
|
+
},
|
|
9
|
+
"author": {
|
|
10
|
+
"name": "Alasdair Mercer",
|
|
11
|
+
"email": "mercer.alasdair@gmail.com",
|
|
12
|
+
"url": "http://neocotic.com"
|
|
13
|
+
},
|
|
14
|
+
"licenses": [
|
|
15
|
+
{
|
|
16
|
+
"type": "MIT",
|
|
17
|
+
"url": "http://nurls.org/license"
|
|
18
|
+
}
|
|
19
|
+
],
|
|
20
|
+
"keywords": [
|
|
21
|
+
"url",
|
|
22
|
+
"shortener"
|
|
23
|
+
],
|
|
24
|
+
"repository": {
|
|
25
|
+
"type": "git",
|
|
26
|
+
"url": "git://github.com/NURLS/nurls.git"
|
|
27
|
+
},
|
|
28
|
+
"dependencies": {
|
|
29
|
+
"express": "~3.2.2",
|
|
30
|
+
"express-validator": "~0.3.2",
|
|
31
|
+
"int17": "~0.2.1",
|
|
32
|
+
"underscore": "~1.4.4"
|
|
33
|
+
},
|
|
34
|
+
"devDependencies": {
|
|
35
|
+
"grunt": "~0.4.1",
|
|
36
|
+
"grunt-contrib-jshint": "~0.4.3",
|
|
37
|
+
"grunt-contrib-nodeunit": "~0.1.2"
|
|
38
|
+
},
|
|
39
|
+
"scripts": {
|
|
40
|
+
"test": "grunt test"
|
|
41
|
+
},
|
|
42
|
+
"main": "lib"
|
|
43
|
+
}
|
|
File without changes
|
package/test/.npmignore
ADDED
|
File without changes
|
package/views/.npmignore
ADDED
|
File without changes
|