This repository has been archived by the owner on Apr 4, 2019. It is now read-only.
forked from tilemill-project/tilemill
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
First pass, server-side bones stuff only.
- Loading branch information
Young Hahn
committed
May 27, 2011
1 parent
96184e2
commit 05895ec
Showing
34 changed files
with
1,118 additions
and
1,176 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/usr/bin/env node | ||
process.title = 'tilemill'; | ||
require('bones').load(__dirname); | ||
!module.parent && require('bones').start(); |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// Asset | ||
// ----- | ||
// Model. Single external asset, e.g. a shapefile, image, etc. | ||
model = Backbone.Model.extend({ | ||
schema: { | ||
'type': 'object', | ||
'properties': { | ||
'id': { | ||
'type': 'string', | ||
'required': true | ||
}, | ||
'url': { | ||
'type': 'string', | ||
'required': true | ||
}, | ||
'bytes': { | ||
'type': 'string' | ||
} | ||
} | ||
}, | ||
extension: function() { | ||
return this.id.split('.').pop(); | ||
} | ||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// AssetList | ||
// --------- | ||
// Collection. List of all assets for a given Library. Must be given a | ||
// Library model at `options.library` in order to determine its URL endpoint. | ||
// The REST endpoint for a LibraryList collection must return an array of asset | ||
// models, or may optionally return a more complex object suited for handling | ||
// pagination: | ||
// | ||
// { | ||
// page: 0, // The current page number | ||
// pageTotal: 10, // The total number of pages | ||
// models: [] // An array of asset models | ||
// } | ||
model = Backbone.Collection.extend({ | ||
model: models.Asset, | ||
url: function() { | ||
return 'api/Library/' + this.library.id + '/assets/' + this.page; | ||
}, | ||
initialize: function(options) { | ||
this.page = 0; | ||
this.pageTotal = 1; | ||
this.library = options.library; | ||
}, | ||
parse: function(response) { | ||
if (_.isArray(response)) { | ||
return response; | ||
} else { | ||
this.page = response.page; | ||
this.pageTotal = response.pageTotal; | ||
return response.models; | ||
} | ||
}, | ||
hasNext: function() { | ||
return this.page < (this.pageTotal - 1); | ||
}, | ||
hasPrev: function() { | ||
return this.page > 0; | ||
}, | ||
nextPage: function(options) { | ||
if (!this.hasNext()) return; | ||
this.page++; | ||
this.fetch(options); | ||
}, | ||
prevPage: function(options) { | ||
if (!this.hasPrev()) return; | ||
this.page--; | ||
this.fetch(options); | ||
} | ||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// AssetListS3 | ||
// ----------- | ||
// Collection. Override of AssetList for S3 library. S3 uses a marker key | ||
// system for pagination instead of a page # system. | ||
model = models.Assets.extend({ | ||
url: function() { | ||
var url = 'api/Library/' + this.library.id + '/assets'; | ||
if (this.marker()) { | ||
url += '/' + Base64.encodeURI(this.marker()); | ||
} | ||
return url; | ||
}, | ||
initialize: function(options) { | ||
this.markers = []; | ||
this.library = options.library; | ||
}, | ||
marker: function() { | ||
if (this.markers.length) { | ||
return this.markers[this.markers.length - 1]; | ||
} | ||
return false; | ||
}, | ||
parse: function(response) { | ||
if (this.marker() != response.marker) { | ||
this.markers.push(response.marker); | ||
} | ||
return response.models; | ||
}, | ||
hasNext: function() { | ||
return this.marker(); | ||
}, | ||
hasPrev: function() { | ||
return this.markers.length > 1; | ||
}, | ||
nextPage: function(options) { | ||
if (!this.hasNext()) return; | ||
this.fetch(options); | ||
}, | ||
prevPage: function(options) { | ||
if (!this.hasPrev()) return; | ||
this.markers.pop(); | ||
this.markers.pop(); | ||
this.fetch(options); | ||
} | ||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
// Datasource (read-only) | ||
// ---------------------- | ||
// Model. Inspection metadata about a map layer. Use `fetchFeatures()` to do | ||
// a datasource fetch that includes layer feature objects. | ||
model = Backbone.Model.extend({ | ||
// @TODO either as a feature or a bug, object attributes are not set | ||
// automatically when passed to the constructor. We set it manually here. | ||
initialize: function(attributes) { | ||
this.set({'fields': attributes.fields}); | ||
}, | ||
url: function() { | ||
var url = 'api/Datasource'; | ||
this.getFeatures && (url += '/features'); | ||
if (typeof module === 'undefined') { | ||
url += '?' + $.param(this.attributes); | ||
} | ||
return url; | ||
}, | ||
fetchFeatures: function(options) { | ||
this.getFeatures = true; | ||
this.fetch(options); | ||
} | ||
}); | ||
|
||
/* | ||
// FileDatasource (read-only) | ||
// -------------------------- | ||
// Model. Inspection metadata about a map layer. Use `fetchFeatures()` to do | ||
// a datasource fetch that includes layer feature objects. | ||
var FileDatasource = Datasource.extend({ | ||
schema: { | ||
'type': 'object', | ||
'properties': { | ||
'id': { | ||
'type': 'string', | ||
}, | ||
'project': { | ||
'required': true, | ||
'type': 'string', | ||
'description': 'Project to which this datasource belongs.' | ||
}, | ||
'url': { | ||
'type': 'string', | ||
'required': true, | ||
'minLength': 1, | ||
'title': 'URL', | ||
'description': 'URL of the datasource.' | ||
}, | ||
'fields': { | ||
'type': 'object' | ||
}, | ||
'features': { | ||
'type': 'array' | ||
}, | ||
'ds_options': { | ||
'type': 'object' | ||
}, | ||
'ds_type': { | ||
'type': 'string' | ||
}, | ||
'geometry_type': { | ||
'type': 'string', | ||
'enum': ['polygon', 'point', 'linestring', 'raster', 'unknown'] | ||
} | ||
} | ||
} | ||
}); | ||
// PostgisDatasource (read-only) | ||
// ----------------------------- | ||
// Model. Inspection metadata about a map layer. Use `fetchFeatures()` to do | ||
// a datasource fetch that includes layer feature objects. | ||
var PostgisDatasource = Datasource.extend({ | ||
schema: { | ||
'type': 'object', | ||
'properties': { | ||
'id': { | ||
'type': 'string', | ||
}, | ||
'project': { | ||
'required': true, | ||
'type': 'string', | ||
'description': 'Project to which this datasource belongs.' | ||
}, | ||
'dbname': { | ||
'type': 'string', | ||
'required': true, | ||
'minLength': 1, | ||
'title': 'Database', | ||
'description': 'Invalid PostGIS database.' | ||
}, | ||
'table': { | ||
'type': 'string', | ||
'required': true, | ||
'minLength': 1, | ||
'title': 'Query', | ||
'description': 'Invalid PostGIS query.' | ||
}, | ||
'fields': { | ||
'type': 'object' | ||
}, | ||
'features': { | ||
'type': 'array' | ||
}, | ||
'ds_options': { | ||
'type': 'object' | ||
}, | ||
'ds_type': { | ||
'type': 'string' | ||
}, | ||
'geometry_type': { | ||
'type': 'string', | ||
'enum': ['polygon', 'point', 'linestring', 'raster', 'unknown'] | ||
} | ||
} | ||
} | ||
}); | ||
*/ |
Oops, something went wrong.