Skip to content

Commit f53e555

Browse files
committed
add meteor frontend app
1 parent b9cd95b commit f53e555

File tree

233 files changed

+115140
-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.

233 files changed

+115140
-0
lines changed

web-app/.meteor/local/build/README

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
This is a Meteor application bundle. It has only one external dependency:
2+
Node.js 0.10.36 or newer. To run the application:
3+
4+
$ (cd programs/server && npm install)
5+
$ export MONGO_URL='mongodb://user:password@host:port/databasename'
6+
$ export ROOT_URL='http://example.com'
7+
$ export MAIL_URL='smtp://user:password@mailhost:port/'
8+
$ node main.js
9+
10+
Use the PORT environment variable to set the port where the
11+
application will listen. The default is 80, but that will require
12+
root on most systems.
13+
14+
Find out more about Meteor at meteor.com.

web-app/.meteor/local/build/main.js

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
2+
// The debugger pauses here when you run `meteor debug`, because this is
3+
// the very first code to be executed by the server process. If you have
4+
// not already added any `debugger` statements to your code, feel free to
5+
// do so now, wait for the server to restart, then reload this page and
6+
// click the |▶ button to continue.
7+
process.argv.splice(2, 0, 'program.json');
8+
process.chdir(require('path').join(__dirname, 'programs', 'server'));
9+
require('./programs/server/boot.js');
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<html {{htmlAttributes}}>
2+
<head>
3+
{{#each css}} <link rel="stylesheet" type="text/css" class="__meteor-css__" href="{{../bundledJsCssPrefix}}{{url}}">{{/each}}
4+
5+
{{#if inlineScriptsAllowed}}
6+
<script type='text/javascript'>__meteor_runtime_config__ = JSON.parse(decodeURIComponent({{meteorRuntimeConfig}}));</script>
7+
{{else}}
8+
<script type='text/javascript' src='{{rootUrlPathPrefix}}/meteor_runtime_config.js'></script>
9+
{{/if}}
10+
{{#each js}} <script type="text/javascript" src="{{../bundledJsCssPrefix}}{{url}}"></script>
11+
{{/each}}
12+
{{#each additionalStaticJs}}
13+
{{#if ../inlineScriptsAllowed}}
14+
<script type='text/javascript'>
15+
{{contents}}
16+
</script>
17+
{{else}}
18+
<script type='text/javascript'
19+
src='{{rootUrlPathPrefix}}{{pathname}}'></script>
20+
{{/if}}
21+
{{/each}}
22+
23+
{{{head}}}
24+
</head>
25+
<body>
26+
{{{body}}}
27+
</body>
28+
</html>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<html>
2+
<head>
3+
<meta charset="utf-8">
4+
<meta name="format-detection" content="telephone=no">
5+
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height">
6+
<meta name="msapplication-tap-highlight" content="no">
7+
8+
{{#each css}} <link rel="stylesheet" type="text/css" class="__meteor-css__" href="{{../bundledJsCssPrefix}}{{url}}">{{/each}}
9+
10+
<script type='text/javascript'>
11+
__meteor_runtime_config__ = JSON.parse(decodeURIComponent({{meteorRuntimeConfig}}));
12+
13+
if (/Android/i.test(navigator.userAgent)) {
14+
// When Android app is emulated, it cannot connect to localhost,
15+
// instead it should connect to 10.0.2.2
16+
// (unless we're using an http proxy; then it works!)
17+
if (!__meteor_runtime_config__.httpProxyPort) {
18+
__meteor_runtime_config__.ROOT_URL = (__meteor_runtime_config__.ROOT_URL || '').replace(/localhost/i, '10.0.2.2');
19+
__meteor_runtime_config__.DDP_DEFAULT_CONNECTION_URL = (__meteor_runtime_config__.DDP_DEFAULT_CONNECTION_URL || '').replace(/localhost/i, '10.0.2.2');
20+
}
21+
}
22+
</script>
23+
24+
<script type="text/javascript" src="/cordova.js"></script>
25+
{{#each js}} <script type="text/javascript" src="{{../bundledJsCssPrefix}}{{url}}"></script>
26+
{{/each}}
27+
{{#each additionalStaticJs}}
28+
{{#if ../inlineScriptsAllowed}}
29+
<script type='text/javascript'>
30+
{{contents}}
31+
</script>
32+
{{else}}
33+
<script type='text/javascript'
34+
src='{{rootUrlPathPrefix}}{{pathname}}'></script>
35+
{{/if}}
36+
{{/each}}
37+
{{{head}}}
38+
</head>
39+
40+
<body>
41+
{{{body}}}
42+
</body>
43+
</html>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// Separated from boot.js for testing.
2+
3+
// Check that we have a pid that looks like an integer (non-decimal
4+
// integer is okay).
5+
exports.validPid = function (pid) {
6+
return ! isNaN(+pid);
7+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,263 @@
1+
var Fiber = require("fibers");
2+
var fs = require("fs");
3+
var path = require("path");
4+
var Future = require("fibers/future");
5+
var _ = require('underscore');
6+
var sourcemap_support = require('source-map-support');
7+
8+
var bootUtils = require('./boot-utils.js');
9+
var files = require('./mini-files.js');
10+
11+
// This code is duplicated in tools/main.js.
12+
var MIN_NODE_VERSION = 'v0.10.36';
13+
14+
if (require('semver').lt(process.version, MIN_NODE_VERSION)) {
15+
process.stderr.write(
16+
'Meteor requires Node ' + MIN_NODE_VERSION + ' or later.\n');
17+
process.exit(1);
18+
}
19+
20+
// read our control files
21+
var serverJsonPath = path.resolve(process.argv[2]);
22+
var serverDir = path.dirname(serverJsonPath);
23+
var serverJson = JSON.parse(fs.readFileSync(serverJsonPath, 'utf8'));
24+
var configJson =
25+
JSON.parse(fs.readFileSync(path.resolve(serverDir, 'config.json'), 'utf8'));
26+
27+
// Set up environment
28+
__meteor_bootstrap__ = {
29+
startupHooks: [],
30+
serverDir: serverDir,
31+
configJson: configJson };
32+
__meteor_runtime_config__ = { meteorRelease: configJson.meteorRelease };
33+
34+
35+
// connect (and some other NPM modules) use $NODE_ENV to make some decisions;
36+
// eg, if $NODE_ENV is not production, they send stack traces on error. connect
37+
// considers 'development' to be the default mode, but that's less safe than
38+
// assuming 'production' to be the default. If you really want development mode,
39+
// set it in your wrapper script (eg, run-app.js).
40+
if (!process.env.NODE_ENV)
41+
process.env.NODE_ENV = 'production';
42+
43+
// Map from load path to its source map.
44+
var parsedSourceMaps = {};
45+
46+
// Read all the source maps into memory once.
47+
_.each(serverJson.load, function (fileInfo) {
48+
if (fileInfo.sourceMap) {
49+
var rawSourceMap = fs.readFileSync(
50+
path.resolve(serverDir, fileInfo.sourceMap), 'utf8');
51+
// Parse the source map only once, not each time it's needed. Also remove
52+
// the anti-XSSI header if it's there.
53+
var parsedSourceMap = JSON.parse(rawSourceMap.replace(/^\)\]\}'/, ''));
54+
// source-map-support doesn't ever look at the sourcesContent field, so
55+
// there's no point in keeping it in memory.
56+
delete parsedSourceMap.sourcesContent;
57+
var url;
58+
if (fileInfo.sourceMapRoot) {
59+
// Add the specified root to any root that may be in the file.
60+
parsedSourceMap.sourceRoot = path.join(
61+
fileInfo.sourceMapRoot, parsedSourceMap.sourceRoot || '');
62+
}
63+
parsedSourceMaps[path.resolve(__dirname, fileInfo.path)] = parsedSourceMap;
64+
}
65+
});
66+
67+
var retrieveSourceMap = function (pathForSourceMap) {
68+
if (_.has(parsedSourceMaps, pathForSourceMap))
69+
return { map: parsedSourceMaps[pathForSourceMap] };
70+
return null;
71+
};
72+
73+
sourcemap_support.install({
74+
// Use the source maps specified in program.json instead of parsing source
75+
// code for them.
76+
retrieveSourceMap: retrieveSourceMap,
77+
// For now, don't fix the source line in uncaught exceptions, because we
78+
// haven't fixed handleUncaughtExceptions in source-map-support to properly
79+
// locate the source files.
80+
handleUncaughtExceptions: false
81+
});
82+
83+
// Only enabled by default in development.
84+
if (process.env.METEOR_SHELL_DIR) {
85+
require('./shell-server.js').listen(process.env.METEOR_SHELL_DIR);
86+
}
87+
88+
// As a replacement to the old keepalives mechanism, check for a running
89+
// parent every few seconds. Exit if the parent is not running.
90+
//
91+
// Two caveats to this strategy:
92+
// * Doesn't catch the case where the parent is CPU-hogging (but maybe we
93+
// don't want to catch that case anyway, since the bundler not yielding
94+
// is what caused #2536).
95+
// * Could be fooled by pid re-use, i.e. if another process comes up and
96+
// takes the parent process's place before the child process dies.
97+
var startCheckForLiveParent = function (parentPid) {
98+
if (parentPid) {
99+
if (! bootUtils.validPid(parentPid)) {
100+
console.error("METEOR_PARENT_PID must be a valid process ID.");
101+
process.exit(1);
102+
}
103+
104+
setInterval(function () {
105+
try {
106+
process.kill(parentPid, 0);
107+
} catch (err) {
108+
console.error("Parent process is dead! Exiting.");
109+
process.exit(1);
110+
}
111+
}, 3000);
112+
}
113+
};
114+
115+
116+
Fiber(function () {
117+
_.each(serverJson.load, function (fileInfo) {
118+
var code = fs.readFileSync(path.resolve(serverDir, fileInfo.path));
119+
120+
var Npm = {
121+
/**
122+
* @summary Require a package that was specified using
123+
* `Npm.depends()`.
124+
* @param {String} name The name of the package to require.
125+
* @locus Server
126+
* @memberOf Npm
127+
*/
128+
require: function (name) {
129+
if (! fileInfo.node_modules) {
130+
return require(name);
131+
}
132+
133+
var nodeModuleBase = path.resolve(serverDir,
134+
files.convertToOSPath(fileInfo.node_modules));
135+
var nodeModuleDir = path.resolve(nodeModuleBase, name);
136+
137+
// If the user does `Npm.require('foo/bar')`, then we should resolve to
138+
// the package's node modules if `foo` was one of the modules we
139+
// installed. (`foo/bar` might be implemented as `foo/bar.js` so we
140+
// can't just naively see if all of nodeModuleDir exists.
141+
if (fs.existsSync(path.resolve(nodeModuleBase, name.split("/")[0]))) {
142+
return require(nodeModuleDir);
143+
}
144+
145+
try {
146+
return require(name);
147+
} catch (e) {
148+
// Try to guess the package name so we can print a nice
149+
// error message
150+
// fileInfo.path is a standard path, use files.pathSep
151+
var filePathParts = fileInfo.path.split(files.pathSep);
152+
var packageName = filePathParts[1].replace(/\.js$/, '');
153+
154+
// XXX better message
155+
throw new Error(
156+
"Can't find npm module '" + name +
157+
"'. Did you forget to call 'Npm.depends' in package.js " +
158+
"within the '" + packageName + "' package?");
159+
}
160+
}
161+
};
162+
var getAsset = function (assetPath, encoding, callback) {
163+
var fut;
164+
if (! callback) {
165+
fut = new Future();
166+
callback = fut.resolver();
167+
}
168+
// This assumes that we've already loaded the meteor package, so meteor
169+
// itself (and weird special cases like js-analyze) can't call
170+
// Assets.get*. (We could change this function so that it doesn't call
171+
// bindEnvironment if you don't pass a callback if we need to.)
172+
var _callback = Package.meteor.Meteor.bindEnvironment(function (err, result) {
173+
if (result && ! encoding)
174+
// Sadly, this copies in Node 0.10.
175+
result = new Uint8Array(result);
176+
callback(err, result);
177+
}, function (e) {
178+
console.log("Exception in callback of getAsset", e.stack);
179+
});
180+
181+
// Convert a DOS-style path to Unix-style in case the application code was
182+
// written on Windows.
183+
assetPath = files.convertToStandardPath(assetPath);
184+
185+
if (!fileInfo.assets || !_.has(fileInfo.assets, assetPath)) {
186+
_callback(new Error("Unknown asset: " + assetPath));
187+
} else {
188+
var filePath = path.join(serverDir, fileInfo.assets[assetPath]);
189+
fs.readFile(files.convertToOSPath(filePath), encoding, _callback);
190+
}
191+
if (fut)
192+
return fut.wait();
193+
};
194+
195+
var Assets = {
196+
getText: function (assetPath, callback) {
197+
return getAsset(assetPath, "utf8", callback);
198+
},
199+
getBinary: function (assetPath, callback) {
200+
return getAsset(assetPath, undefined, callback);
201+
}
202+
};
203+
204+
// \n is necessary in case final line is a //-comment
205+
var wrapped = "(function(Npm, Assets){" + code + "\n})";
206+
207+
// It is safer to use the absolute path when source map is present as
208+
// different tooling, such as node-inspector, can get confused on relative
209+
// urls.
210+
211+
// fileInfo.path is a standard path, convert it to OS path to join with
212+
// __dirname
213+
var fileInfoOSPath = files.convertToOSPath(fileInfo.path);
214+
var absoluteFilePath = path.resolve(__dirname, fileInfoOSPath);
215+
216+
var scriptPath =
217+
parsedSourceMaps[absoluteFilePath] ? absoluteFilePath : fileInfoOSPath;
218+
// The final 'true' is an undocumented argument to runIn[Foo]Context that
219+
// causes it to print out a descriptive error message on parse error. It's
220+
// what require() uses to generate its errors.
221+
var func = require('vm').runInThisContext(wrapped, scriptPath, true);
222+
func.call(global, Npm, Assets); // Coffeescript
223+
});
224+
225+
// run the user startup hooks. other calls to startup() during this can still
226+
// add hooks to the end.
227+
while (__meteor_bootstrap__.startupHooks.length) {
228+
var hook = __meteor_bootstrap__.startupHooks.shift();
229+
hook();
230+
}
231+
// Setting this to null tells Meteor.startup to call hooks immediately.
232+
__meteor_bootstrap__.startupHooks = null;
233+
234+
// find and run main()
235+
// XXX hack. we should know the package that contains main.
236+
var mains = [];
237+
var globalMain;
238+
if ('main' in global) {
239+
mains.push(main);
240+
globalMain = main;
241+
}
242+
typeof Package !== 'undefined' && _.each(Package, function (p, n) {
243+
if ('main' in p && p.main !== globalMain) {
244+
mains.push(p.main);
245+
}
246+
});
247+
if (! mains.length) {
248+
process.stderr.write("Program has no main() function.\n");
249+
process.exit(1);
250+
}
251+
if (mains.length > 1) {
252+
process.stderr.write("Program has more than one main() function?\n");
253+
process.exit(1);
254+
}
255+
var exitCode = mains[0].call({}, process.argv.slice(3));
256+
// XXX hack, needs a better way to keep alive
257+
if (exitCode !== 'DAEMON')
258+
process.exit(exitCode);
259+
260+
if (process.env.METEOR_PARENT_PID) {
261+
startCheckForLiveParent(process.env.METEOR_PARENT_PID);
262+
}
263+
}).run();
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"meteorRelease": "[email protected]",
3+
"clientPaths": {
4+
"web.browser": "../web.browser/program.json"
5+
}
6+
}

0 commit comments

Comments
 (0)