Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
sibozhang committed May 6, 2017
1 parent 08754e1 commit d513400
Show file tree
Hide file tree
Showing 3 changed files with 156 additions and 0 deletions.
81 changes: 81 additions & 0 deletions app/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
<!doctype html>
<!-- Declares meanMapApp as the starting Angular module -->
<html class="no-js" ng-app="Geo-tag">
<head>
<meta charset="utf-8">
<title>GeoBurst Demo</title>
<meta name="description" content="Geo-tag Apps">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- CSS -->
<link rel="stylesheet" href="../bower_components/bootstrap/dist/css/bootstrap.css"/>
<link rel="stylesheet" href="style.css"/>
<!-- Holder JS -->
<script src="../bower_components/holderjs/holder.js"></script>
<!-- Google Maps API -->
<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyByhZxu0XT_ILGQCzKI-nc4nOc2Kd0ZmHM"></script>
<!-- Modernizr -->
<script src="../bower_components/modernizr/bin/modernizr"></script>
<!-- JS Source -->
<script src="../bower_components/jquery/jquery.js"></script>
<script src="../bower_components/angular/angular.js"></script>
<script src="../bower_components/angular-route/angular-route.js"></script>
<script src="../bower_components/angularjs-geolocation/dist/angularjs-geolocation.min.js"></script>
<script src="model.js"></script>
</head>
<body>
<div class="container">
<div class="header">
<ul class="nav nav-pills pull-right">
<li active><a href=""></a></li>
<li disabled><a href=""></a></li>
</ul>
<h3 class="text-muted">GeoBurst</h3>
</div>
<!-- Map and Side Panel -->
<div class="row content">
<!-- Google Map -->
<div class="col-md-7">
<div id="map"><img src="holder.js/645x645"></div>
</div>
<!-- Side Panel -->
<div class="col-md-5">
<div class="panel panel-default">
<!-- Panel Title -->
<div class="panel-heading">
<h2 class="panel-title text-center">The Location<span class="glyphicon glyphicon-map-marker"></span></h2>
</div>
<!-- Panel Body -->
<div class="panel-body">
<!-- Creates Form (novalidate disables HTML validation, Angular will control) -->
<form name ="addForm" novalidate>
<div class="form-group">
<label for="language">Search Pattern</label>
<input type="text" class="form-control" id="language" placeholder="Fortran" ng-model="formData.favlang" required>
</div>
<div class="form-group">
<label for="latitude">Latitude</label>
<input type="text" class="form-control" id="latitude" value="39.500" ng-model="formData.latitude" readonly>
</div>
<div class="form-group">
<label for="longitude">Longitude</label>
<input type="text" class="form-control" id="longitude" value="-98.350" ng-model="formData.longitude" readonly>
</div>
<div class="form-group">
<label for="verified">HTML5 Verified Location? <span><button class="btn btn-default btn-xs"><span class="glyphicon glyphicon-refresh"></span></button></span></label>
<input type="text" class="form-control" id="verified" placeholder= "Nope (Thanks for spamming my map...)" ng-model="formData.htmlverified" readonly>
</div>
<button type="submit" class="btn btn-danger btn-block" ng-disabled="addForm.$invalid">Submit</button>
</form>
</div>
</div>
</div>
</div>
<hr/>
<!-- Footer -->
<div class="footer">
<p class="text-center"><span class="glyphicon glyphicon-check"></span>
<a href="https://scotch.io/">GeoBurst</a> | <a href="www.google.com">www.google.com</a></p>
</div>
</div>
</body>
</html>
34 changes: 34 additions & 0 deletions app/model.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// Pulls Mongoose dependency for creating schemas
var mongoose = require('mongoose');
var Schema = mongoose.Schema;

// Creates a User Schema. This will be the basis of how user data is stored in the db
var UserSchema = new Schema({
_id: Number,
querywindowId: Number,
rank: Number,
twitterid: Number,
tag: String, // [Long, Lat]
lat: Number,
lng: Number,
htmlverified: String,
created_at: {type: Date, default: Date.now},
updated_at: {type: Date, default: Date.now}
});


// Sets the created_at parameter equal to the current time
UserSchema.pre('save', function(next){
now = new Date();
this.updated_at = now;
if(!this.created_at) {
this.created_at = now
}
next();
});

// Indexes this schema in 2dsphere format (critical for running proximity searches)
UserSchema.index({location: '2dsphere'});

// Exports the UserSchema for use elsewhere. Sets the MongoDB collection to be used as: "scotch-users"
module.exports = mongoose.model('NewSchema', UserSchema);
41 changes: 41 additions & 0 deletions app/routes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// Dependencies
var mongoose = require('mongoose');
var User = require('./model.js');


// Opens App Routes
module.exports = function(app) {

// GET Routes
// --------------------------------------------------------
// Retrieve records for all users in the db
app.get('/users', function(req, res){

// Uses Mongoose schema to run the search (empty conditions)
var query = User.find({});
query.exec(function(err, users){
if(err)
res.send(err);

// If no errors are found, it responds with a JSON of all users
res.json(users);
});
});

// POST Routes
// --------------------------------------------------------
// Provides method for saving new users in the db
app.post('/users', function(req, res){

// Creates a new User based on the Mongoose schema and the post bo.dy
var newuser = new User(req.body);

// New User is saved in the db.
newuser.save(function(err){
if(err)
res.send(err);

// If no errors are found, it responds with a JSON of the new user
res.json(req.body);
});
});

0 comments on commit d513400

Please sign in to comment.