-
Notifications
You must be signed in to change notification settings - Fork 6
/
app.js
142 lines (119 loc) · 5.69 KB
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
/**
* Module dependencies.
*/
var express = require('express'), routes = require('./routes'), http = require('http'), path = require('path'), fs = require('fs'), autoComplete = require('./aquaria/autocomplete');
var get_matching_structures = require('./aquaria/matching_structures');
var secondary_clustering = require('./aquaria/secondary_clustering');
var metainfo = require('./aquaria/metainfo');
var viewer_format = require('./aquaria/generate_viewer_format');
var viewer = require('./aquaria/viewer');
var snapshot = require('./aquaria/snapshot');
var config = require('./common/config');
var shoe = require('shoe');
var dnode = require('dnode');
//var expiry = require('static-expiry');
var JAR_EXPIRY = 1000 * 60 * 60 * 24 * 7;
//var dark_domains = require ('./aquaria/dark_domains');
//var queryConstraints = require('./aquaria/queryDistanceConstraints');
//var new_sql = require('./aquaria/sql_example');
var app = express();
// http://www.hacksparrow.com/express-js-logging-access-and-errors.html
var access_logfile = fs.createWriteStream('log/access.log', {flags: 'a'});
app.configure(function(){
app.set('port', process.env.PORT || config.get('port'));
app.set('views', __dirname + '/views');
// Switched to EJS engine - see http://stackoverflow.com/questions/4600952/
// Info on EJS ('Embedded JavaScript templates') - https://github.com/visionmedia/ejs
app.set('view engine', 'ejs');
app.use(express.favicon(__dirname + '/public/images/favicon.ico'));
app.use(express.logger('dev'));
app.use(express.bodyParser());
app.use(express.methodOverride());
app.use(express.cookieParser('your secret here'));
app.use(express.session());
// app.use(expiry(app, { dir: path.join(__dirname, 'public') }));
// app.use(expiry(app, { dir: path.join(__dirname, 'public') }));
app.use(app.router);
app.use(express.static(path.join(__dirname, 'public'), { maxAge: 3600000 }));
app.use('/jar', express.static(path.join(__dirname, 'jar'), { maxAge: JAR_EXPIRY}));
app.use(express.logger({stream: access_logfile }));
app.set('views', __dirname + '/views');
});
//app.configure('development', function(){
app.configure('production', function(){
app.use(express.errorHandler());
});
var server = http.createServer(app);
server.listen(app.get('port'), function(){
console.log("Express server listening on port " + app.get('port'));
});
var sock = shoe(function (stream) {
var d = dnode({
transform : function (s, cb) {
var res = s.replace(/[aeiou]{2,}/, 'oo').toUpperCase();
cb(res);
},
queryOrganism : autoComplete.queryOrganism,
queryProtein : autoComplete.queryProtein,
queryProteinWildOrganism: autoComplete.queryProteinWildOrganism,
queryPDB : autoComplete.queryPDB,
loadSnapshot : snapshot.loadSnapshot,
getJNLP : snapshot.getJNLP,
get_matching_structures : matching_structures.get_matching_structures,
getAccessionForPDB: matching_structures.getAccessionForPDBCallback,
get_secondary_clusters : secondary_clustering.get_secondary_clusters,
queryPDBTitle : secondary_clustering.queryPDBTitle,
get_3D_alignment : viewer_format.get_3D_alignment,
getPubMedForPDB : metainfo.getPubMedForPDB,
getOrganismInfo : metainfo.getOrganismInfo,
getProteinSynonyms : metainfo.getProteinSynonyms,
getOrganismSynonyms : metainfo.getOrganismSynonyms,
getOrganismName : metainfo.getOrganismName,
getChainInfo : metainfo.getChainInfo,
getOrganismId : metainfo.getOrganismId,
createAppJNLP : viewer.createJNLP,
createToolkitAppJNLP : viewer.createToolkitJNLP,
get_sequence : matching_structures.get_sequence
});
d.pipe(stream).pipe(d);
});
sock.install(server, '/dnode');
//var everyone = require("now").initialize(server);
//everyone.now.getDarkDomains = dark_domains.getDarkDomains;
//everyone.now.queryConstraints = queryConstraints.queryConstraints;
//everyone.now.sql_query = new_sql.function_name;
// Disable layout - http://stackoverflow.com/questions/4600952/
app.set('view options', {
layout: false
});
app.get('/launch', routes.launchPage);
app.get('/googlehostedservice.html', routes.googleHostedService);
//app.get('/jar/:jarname', routes.jar);
//app.get('/jar/:{jarname}?version-id=:{version}', routes.jar);
//app.post('/jnlp/app/:filename.jnlp', routes.jnlpApp);
app.get('/jnlp/:versionString/:filename.jnlp', routes.jnlp);
app.get('/:id/cluster:clusterId.:format', routes.matchingStructuresExt);
//app.get('/:id/cluster:clusterId.json', routes.matchingStructuresJSON);
//app.get('/:id/cluster:clusterId.txt', routes.matchingStructuresTXT);
//app.get('/:id/cluster:clusterId.csv', routes.matchingStructuresCSV);
app.get('/:id/:pdbid?/:chainid?.:format', routes.matchingStructuresExt);
//app.get('/:id/:pdbid.:ext', routes.matchingStructuresExt);
//app.get('/:id/:pdbid/:chainid.tsv', routes.matchingStructuresTSV);
//app.get('/:id/:pdbid/:chainid.csv', routes.matchingStructuresCSV);
//app.get('/:id/:pdbid/:chainid.txt', routes.matchingStructuresTXT);
//app.get('/:id.:format', routes.matchingStructuresExt);
//app.get('/:id.csv', routes.matchingStructuresCSV);
//app.get('/:id.txt', routes.matchingStructuresTXT);
//app.get('/:id/:pdbid', routes.home_page);
app.get('/:id/:pdbid?/:chainid?', routes.home_page);
//app.get('/leap/:id/:pdbid', routes.home_page);
//app.get('/leap/:id/:pdbid/:chainid', routes.home_page);
app.get('/', routes.home_page);
//app.get('/:id.json', routes.matchingStructuresJSON);
//app.get('/json/:id', routes.matchingStructuresJSON);
//app.get('/pdb/:id', routes.pdb);
//app.get('/:id.pdb:ext?', routes.pdb);
//app.get('/:id', routes.home_page);
//app.get('/leap/:id', routes.home_page);
//app.get('/interactions/:id', routes.interactions);
//app.get('/sean/:id', routes.sean);