Skip to content

Commit 1fbef53

Browse files
committed
--Uploaded to ContentMine's repo--
What's been achieved so far: * Established the application framework (Express.js back-end, Angular.js front-end single-page application). * Designed the page layout with the menus (responsive design, should even look good on mobile devices). * Established a way of actually executing commands in the background. * Set up the basic version of the getpapers user form (based on @tarrow's hand-drawn wireframe google doc).
0 parents  commit 1fbef53

File tree

7,683 files changed

+689719
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

7,683 files changed

+689719
-0
lines changed

.gitignore

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm
2+
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
3+
4+
# User-specific stuff:
5+
.idea/workspace.xml
6+
.idea/tasks.xml
7+
.idea/dictionaries
8+
.idea/vcs.xml
9+
.idea/jsLibraryMappings.xml
10+
11+
# Sensitive or high-churn files:
12+
.idea/dataSources.ids
13+
.idea/dataSources.xml
14+
.idea/dataSources.local.xml
15+
.idea/sqlDataSources.xml
16+
.idea/dynamic.xml
17+
.idea/uiDesigner.xml
18+
19+
# Gradle:
20+
.idea/gradle.xml
21+
.idea/libraries
22+
23+
# Mongo Explorer plugin:
24+
.idea/mongoSettings.xml
25+
26+
## File-based project format:
27+
*.iws
28+
29+
## Plugin-specific files:
30+
31+
# IntelliJ
32+
/out/
33+
34+
# mpeltonen/sbt-idea plugin
35+
.idea_modules/
36+
37+
# JIRA plugin
38+
atlassian-ide-plugin.xml
39+
40+
# Crashlytics plugin (for Android Studio and IntelliJ)
41+
com_crashlytics_export_strings.xml
42+
crashlytics.properties
43+
crashlytics-build.properties
44+
fabric.properties
45+
46+
# EVGENY SAVELIEV CONFIGURED:
47+
.idea
48+
/*.iml

api/api.js

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
* Command execution API.
3+
*/
4+
5+
// The API object.
6+
var api = {};
7+
8+
// Data
9+
var data = {
10+
11+
};
12+
13+
// GET
14+
15+
// [...]
16+
17+
// POST
18+
19+
api.cmd = function (req, res) {
20+
21+
22+
var execCmd = require('../working/exec-cmd');
23+
var dspl = require('../working/display-output').display;
24+
25+
execCmd.exec(req.body.command, function(results) {
26+
//res.json({commandOutput: results});
27+
console.log(results);
28+
res.send(dspl(results));
29+
//next();
30+
});
31+
32+
//console.log("b");
33+
///res = {};
34+
//res.send('done!');
35+
};
36+
37+
// PUT
38+
39+
// [...]
40+
41+
// DELETE
42+
43+
// [...]
44+
45+
module.exports = api;

app.js

+99
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
var express = require('express');
2+
var path = require('path');
3+
var favicon = require('serve-favicon');
4+
var logger = require('morgan');
5+
var cookieParser = require('cookie-parser');
6+
var bodyParser = require('body-parser');
7+
8+
var routes = require('./routes/index');
9+
var partials = require('./routes/partials');
10+
var test = require('./routes/test');
11+
var api = require('./routes/api');
12+
13+
// Custom js files.
14+
var cmdHandler = require('./working/cmd-handler');
15+
16+
var app = express();
17+
18+
// view engine setup
19+
app.set('views', path.join(__dirname, 'views'));
20+
app.set('view engine', 'jade');
21+
22+
// uncomment after placing your favicon in /public
23+
app.use(favicon(path.join(__dirname, 'public/images/favicon/favicon.ico')));
24+
app.use(logger('dev'));
25+
app.use(bodyParser.json());
26+
app.use(bodyParser.urlencoded({ extended: false }));
27+
app.use(cookieParser());
28+
app.use(require('node-sass-middleware')({
29+
src: path.join(__dirname, 'public'),
30+
dest: path.join(__dirname, 'public'),
31+
indentedSyntax: false,
32+
debug: true,
33+
outputStyle: 'compressed',
34+
sourceMap: true
35+
}));
36+
app.use(express.static(path.join(__dirname, 'public')));
37+
38+
// Custom locals.
39+
app.locals.displayOutput = require('./working/display-output');
40+
app.locals.vars =
41+
{
42+
// Global.
43+
title: 'ContentMine',
44+
// Paths.
45+
jsPath: '/javascripts/',
46+
librariesPath: '/javascripts/libraries/',
47+
customJsPath: '/javascripts/custom/',
48+
stylesheetsPath: '/stylesheets/',
49+
imagesPath: '/images/',
50+
faviconPath: '/images/favicon/',
51+
iconsPath: '/images/icons/',
52+
// Content.
53+
outputValue: 'Command output...'
54+
};
55+
56+
// Custom middleware.
57+
//app.use('/', cmdHandler);
58+
59+
// Routes registration.
60+
app.use('/', routes);
61+
app.use('/partials', partials);
62+
app.use('/test', test);
63+
64+
// JSON API.
65+
app.use('/', api);
66+
67+
// catch 404 and forward to error handler
68+
app.use(function(req, res, next) {
69+
var err = new Error('Not Found');
70+
err.status = 404;
71+
next(err);
72+
});
73+
74+
// error handlers
75+
76+
// development error handler
77+
// will print stacktrace
78+
if (app.get('env') === 'development') {
79+
app.use(function(err, req, res, next) {
80+
res.status(err.status || 500);
81+
res.render('error', {
82+
message: err.message,
83+
error: err
84+
});
85+
});
86+
}
87+
88+
// production error handler
89+
// no stacktraces leaked to user
90+
app.use(function(err, req, res, next) {
91+
res.status(err.status || 500);
92+
res.render('error', {
93+
message: err.message,
94+
error: {}
95+
});
96+
});
97+
98+
99+
module.exports = app;

bin/client-side-launcher.js

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/**
2+
* EVGENY SAVELIEV: CLIENT-SIDE LAUNCHER.
3+
* Requires first argument as the browser launching command (with {port} as the port placeholder), e.g:
4+
* node client-side-launcher "start http://localhost:{port}"
5+
*/
6+
7+
var port = require('../bin/www');
8+
var execCmd = require('../working/exec-cmd.js');
9+
10+
// process.argv[2] is the command passed to the launcher.
11+
// port is the app port as set by /bin/www.
12+
var argProvided = process.argv[2];
13+
if (argProvided !== undefined) {
14+
if (argProvided.indexOf('{port}') !== -1) {
15+
execCmd.exec(argProvided.replace('{port}', port), function(results) { }); // No action.
16+
} else {
17+
console.log('Error: the browser launching command provided as the first argument to the client-side-launcher must contain {port} as the port placeholder.');
18+
}
19+
} else {
20+
console.log('Error: must provide the browser launching command as the first argument to client-side-launcher (with {port} as the port placeholder).');
21+
}

bin/www

+96
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
#!/usr/bin/env node
2+
3+
/**
4+
* Module dependencies.
5+
*/
6+
7+
var app = require('../app');
8+
var debug = require('debug')('contentmine-gui:server');
9+
var http = require('http');
10+
11+
/**
12+
* Get port from environment and store in Express.
13+
*/
14+
15+
var port = normalizePort(process.env.PORT || '3000');
16+
app.set('port', port);
17+
18+
/**
19+
* Create HTTP server.
20+
*/
21+
22+
var server = http.createServer(app);
23+
24+
/**
25+
* Listen on provided port, on all network interfaces.
26+
*/
27+
28+
server.listen(port);
29+
server.on('error', onError);
30+
server.on('listening', onListening);
31+
32+
/**
33+
* Normalize a port into a number, string, or false.
34+
*/
35+
36+
function normalizePort(val) {
37+
var port = parseInt(val, 10);
38+
39+
if (isNaN(port)) {
40+
// named pipe
41+
return val;
42+
}
43+
44+
if (port >= 0) {
45+
// port number
46+
return port;
47+
}
48+
49+
return false;
50+
}
51+
52+
/**
53+
* Event listener for HTTP server "error" event.
54+
*/
55+
56+
function onError(error) {
57+
if (error.syscall !== 'listen') {
58+
throw error;
59+
}
60+
61+
var bind = typeof port === 'string'
62+
? 'Pipe ' + port
63+
: 'Port ' + port;
64+
65+
// handle specific listen errors with friendly messages
66+
switch (error.code) {
67+
case 'EACCES':
68+
console.error(bind + ' requires elevated privileges');
69+
process.exit(1);
70+
break;
71+
case 'EADDRINUSE':
72+
console.error(bind + ' is already in use');
73+
process.exit(1);
74+
break;
75+
default:
76+
throw error;
77+
}
78+
}
79+
80+
/**
81+
* Event listener for HTTP server "listening" event.
82+
*/
83+
84+
function onListening() {
85+
var addr = server.address();
86+
var bind = typeof addr === 'string'
87+
? 'pipe ' + addr
88+
: 'port ' + addr.port;
89+
debug('Listening on ' + bind);
90+
}
91+
92+
/**
93+
* EVGENY SAVELIEV - EXPORT PORT.
94+
*/
95+
96+
module.exports = port;

launchers/linux/ContentMine.sh

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#! /bin/bash
2+
# Launcher NOT TESTED. Evgeny Saveliev.
3+
node ../../bin/client-side-launcher "xdg-open http://localhost:{port}" && node ../../bin/www

launchers/mac/ContentMine.sh

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#! /bin/bash
2+
# Launcher NOT TESTED. Evgeny Saveliev.
3+
node ../../bin/client-side-launcher "open http://localhost:{port}" & node ../../bin/www

launchers/windows/ContentMine.bat

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
@echo off
2+
REM Launcher tested successfully. Evgeny Saveliev.
3+
node ../../bin/client-side-launcher "start http://localhost:{port}" & node ../../bin/www

node_modules/.bin/jade

+15
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/.bin/jade.cmd

+7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/.bin/which

+15
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/.bin/which.cmd

+7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)