Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch 'release/v0.3.1'

  • Loading branch information...
commit 3011db4a86d6ec85101e6e158931cffd489e075d 2 parents a0599d4 + 7313af1
@andzdroid authored
View
24 app.js
@@ -12,14 +12,14 @@ var utils = require('./utils');
var mongodb = require('mongodb');
//var cons = require('consolidate');
var swig = require('swig');
-var swig_filters = require('./filters');
+var swigFilters = require('./filters');
var app = express();
//Set up swig
swig.init({
root: __dirname + '/views',
allowErrors: false,
- filters: swig_filters
+ filters: swigFilters
});
/*
@@ -60,7 +60,11 @@ app.configure('development', function(){
var config = require('./config');
var host = config.mongodb.host || 'localhost';
var port = config.mongodb.port || mongodb.Connection.DEFAULT_PORT;
-var db = new mongodb.Db('local', new mongodb.Server(host, port, {auto_reconnect: true}));
+var dbOptions = {
+ auto_reconnect: config.mongodb.autoReconnect,
+ poolSize: config.mongodb.poolSize
+};
+var db = new mongodb.Db('local', new mongodb.Server(host, port, dbOptions));
var connections = {};
@@ -150,7 +154,7 @@ db.open(function(err, db) {
//View helper, sets local variables used in templates
app.locals.use(function(req, res) {
- res.locals.base_href = config.site.base_url;
+ res.locals.baseHref = config.site.baseUrl;
res.locals.databases = databases;
res.locals.collections = collections;
});
@@ -164,8 +168,8 @@ app.param('database', function(req, res, next, id) {
return next('Error!');
}
- req.db_name = id;
- res.locals.db_name = id;
+ req.dbName = id;
+ res.locals.dbName = id;
if (connections[id] !== undefined) {
req.db = connections[id];
@@ -180,15 +184,15 @@ app.param('database', function(req, res, next, id) {
//:collection param MUST be preceded by a :database param
app.param('collection', function(req, res, next, id) {
//Make sure collection exists
- if (!_.include(collections[req.db_name], id)) {
+ if (!_.include(collections[req.dbName], id)) {
//TODO: handle error
return next('Error!');
}
- req.collection_name = id;
- res.locals.collection_name = id;
+ req.collectionName = id;
+ res.locals.collectionName = id;
- connections[req.db_name].collection(id, function(err, coll) {
+ connections[req.dbName].collection(id, function(err, coll) {
if (err) {
//TODO: handle error
return next('Error!');
View
17 config.js
@@ -5,20 +5,23 @@ module.exports = {
//username and password must be for admin account
//leave it empty if no admin account
username: '',
- password: ''
+ password: '',
+ autoReconnect: true,
+ //poolSize: size of connection pool
+ poolSize: 4
},
site: {
- //base_url: the URL that mongo express will be located at
- base_url: 'http://localhost:3000/',
+ //baseUrl: the URL that mongo express will be located at
+ baseUrl: 'http://localhost:3000/',
port: 3000
},
options: {
- //cmd_type: the type of command line you want mongo express to run
+ //cmdType: the type of command line you want mongo express to run
//values: eval, subprocess
// eval - uses db.eval. commands block, so only use this if you have to
// subprocess - spawns a mongo command line as a subprocess and pipes output to mongo express
- cmd_type: 'eval',
- //subprocess_timeout: number of seconds of non-interaction before a subprocess is shut down
- subprocess_timeout: 300
+ cmdType: 'eval',
+ //subprocessTimeout: number of seconds of non-interaction before a subprocess is shut down
+ subprocessTimeout: 300
}
};
View
2  package.json
@@ -2,7 +2,7 @@
"author": "Chun-hao Hu <hu.chunhao@gmail.com> (http://blog.huchunhao.com)",
"name": "mongo-express",
"description": "Web-based admin interface for MongoDB",
- "version": "0.3.0",
+ "version": "0.3.1",
"repository": {
"type": "git",
"url": "git://github.com/andzdroid/mongo-express.git"
View
6 routes/collection.js
@@ -11,7 +11,7 @@ exports.viewCollection = function(req, res, next) {
req.collection.find({}, query_options).toArray(function(err, items) {
req.collection.stats(function(err, stats) {
var ctx = {
- title: 'Viewing Collection: ' + req.collection_name,
+ title: 'Viewing Collection: ' + req.collectionName,
documents: items,
stats: stats
};
@@ -35,13 +35,13 @@ exports.deleteCollection = function(req, res, next) {
//If delete was successful, result === true
- req.updateCollections(req.db, req.db_name, function(err) {
+ req.updateCollections(req.db, req.dbName, function(err) {
if (err) {
//TODO: handle error
console.error(err);
}
- res.redirect('/db/' + req.db_name);
+ res.redirect('/db/' + req.dbName);
});
});
};
View
2  routes/index.js
@@ -25,7 +25,7 @@ exports.index = function(req, res){
//TODO: Move this handler to /db/ URL when implementing REST api, to handle PUT requests
exports.createCollection = function(req, res) {
var db = req.db;
- var name = req.body.collection_name;
+ var name = req.body.collectionName;
if (name === undefined) {
//TODO: handle error
View
6 views/collection.html
@@ -1,6 +1,6 @@
{% extends 'layout.html' %}
-{% block title %}{{ collection_name }}{% endblock %}
+{% block title %}{{ collectionName }}{% endblock %}
{% block content %}
@@ -11,7 +11,7 @@
{% else %}
{% for document in documents %}
<pre class="prettyprint">{{ document|json }}</pre>
- <!--<a href="db/{{ db_name }}/{{ collection_name }}/{{ document._id }}">Edit</a>-->
+ <!--<a href="db/{{ db_name }}/{{ collectionName }}/{{ document._id }}">Edit</a>-->
{% endfor %}
{% endif %}
@@ -37,7 +37,7 @@
#}
<h2>Delete Collection</h2>
-<form method="POST" action="db/{{ db_name }}/{{ collection_name }}" class="well">
+<form method="POST" action="db/{{ dbName }}/{{ collectionName }}" class="well">
<input type="hidden" name="_method" value="delete">
<p>Are you sure you want to delete this collection? All documents will be deleted.</p>
<button type="submit" class="btn btn-danger btn-large">
View
2  views/index.html
@@ -9,7 +9,7 @@
<form class="well form-inline" method="POST">
<div class="input-prepend">
<span class="add-on">{{ database }} . </span>
- <input class="span2" type="text" id="collection_name" name="collection_name" placeholder="Collection Name">
+ <input class="span2" type="text" id="collectionName" name="collectionName" placeholder="Collection Name">
</div>
<button type="submit" class="btn btn-primary">
<i class="icon-folder-open icon-white"></i>
View
8 views/layout.html
@@ -1,7 +1,7 @@
<!DOCTYPE html>
<html lang="en">
<head>
- <base href="{{base_href}}">
+ <base href="{{ baseHref }}">
<meta charset="utf-8">
<title>{% block title %}Index{% endblock %} - Mongo Express</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
@@ -48,14 +48,14 @@
{{ db }}
<i class="icon-chevron-down pull-right"></i>
</li>
- <li><a href="db/{{ db }}"><i class="icon-book"></i> View Database</a></li>
+ <li><a href="db/{{ db }}"><i class="icon-folder-open"></i> View Database</a></li>
<ul class="unstyled collapse nav nav-list
- {%- if db == db_name %} in{% endif -%}
+ {%- if db == dbName %} in{% endif -%}
" id="toggle_{{ db }}">
{% for collection_db in collections -%}
{% if loop.key == db -%}
{% for collection in collection_db -%}
- <li><a href="db/{{ db }}/{{ collection }}"><i class="icon-folder-open"></i> {{ collection }}</a></li>
+ <li><a href="db/{{ db }}/{{ collection }}"><i class="icon-list-alt"></i> {{ collection }}</a></li>
{%- endfor %}
{%- endif %}
{%- endfor %}
Please sign in to comment.
Something went wrong with that request. Please try again.