This repository has been archived by the owner on Jul 5, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 163
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
170 additions
and
133 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 |
---|---|---|
@@ -1 +1 @@ | ||
2.3.1 | ||
2.3.2 |
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
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
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 |
---|---|---|
@@ -1,103 +1,121 @@ | ||
Genghis.Router = Backbone.Router.extend({ | ||
routes: { | ||
'': 'index', | ||
'servers': 'redirectToIndex', | ||
'servers/:server': 'server', | ||
'servers/:server/databases': 'redirectToServer', | ||
'servers/:server/databases/:database': 'database', | ||
'servers/:server/databases/:database/collections': 'redirectToDatabase', | ||
'servers/:server/databases/:database/collections/:collection': 'collection', | ||
'servers/:server/databases/:database/collections/:collection/documents': 'collectionQueryOrRedirect', | ||
'servers/:server/databases/:database/collections/:collection/documents?*query': 'collectionQueryOrRedirect', | ||
'servers/:server/databases/:database/collections/:collection/documents/:documentId': 'document', | ||
'*path': 'notFound' | ||
}, | ||
index: function() { | ||
document.title = 'Genghis'; | ||
app.selection.select(); | ||
app.showSection('servers'); | ||
}, | ||
redirectToIndex: function() { | ||
this.navigate('', true); | ||
}, | ||
server: function(server) { | ||
document.title = this.buildTitle(server); | ||
app.selection.select(server); | ||
app.showSection('databases'); | ||
}, | ||
redirectToServer: function(server) { | ||
this.navigate('servers/'+server, true); | ||
}, | ||
database: function(server, database) { | ||
document.title = this.buildTitle(server, database); | ||
app.selection.select(server, database); | ||
app.showSection('collections'); | ||
}, | ||
redirectToDatabase: function(server, database) { | ||
this.navigate('servers/'+server+'/databases/'+database, true); | ||
}, | ||
collection: function(server, database, collection) { | ||
if (!!window.location.search) { | ||
return this.collectionQueryOrRedirect(server, database, collection); | ||
} | ||
Genghis.Router = (function() { | ||
var e = encodeURIComponent; | ||
|
||
document.title = this.buildTitle(server, database, collection); | ||
app.selection.select(server, database, collection); | ||
app.showSection('documents'); | ||
}, | ||
redirectToCollection: function(server, database, collection) { | ||
this.navigate('servers/'+server+'/databases/'+database+'/collections/'+collection, true); | ||
}, | ||
collectionQueryOrRedirect: function(server, database, collection) { | ||
if (!!window.location.search) { | ||
return this.collectionQuery(server, database, collection, window.location.search.substr(1)); | ||
} else { | ||
this.redirectToCollection(server, database, collection); | ||
} | ||
}, | ||
collectionQuery: function(server, database, collection, query) { | ||
document.title = this.buildTitle(server, database, collection, 'Query results'); | ||
var params = Genghis.Util.parseQuery(query); | ||
app.selection.select(server, database, collection, null, params.q, params.page); | ||
app.showSection('documents'); | ||
}, | ||
redirectToQuery: function(server, database, collection, query) { | ||
this.navigate('servers/'+server+'/databases/'+database+'/collections/'+collection+'/documents?'+Genghis.Util.buildQuery({q: encodeURIComponent(query)}), true); | ||
}, | ||
document: function(server, database, collection, documentId) { | ||
document.title = this.buildTitle(server, database, collection, decodeURIComponent(documentId)); | ||
app.selection.select(server, database, collection, decodeURIComponent(documentId)); | ||
app.showSection('document'); | ||
}, | ||
redirectToDocument: function(server, database, collection, document) { | ||
this.navigate('servers/'+server+'/databases/'+database+'/collections/'+collection+'/documents/'+document, true); | ||
}, | ||
redirectTo: function(server, database, collection, document, query) { | ||
if (!server) return this.redirectToIndex(); | ||
if (!database) return this.redirectToServer(server); | ||
if (!collection) return this.redirectToDatabase(server, database); | ||
|
||
if (!document && !query) { | ||
return this.redirectToCollection(server, database, collection); | ||
} else if (!query) { | ||
return this.redirectToDocument(server, database, collection, document); | ||
} else { | ||
return this.redirectToQuery(server, database, collection, query); | ||
} | ||
}, | ||
notFound: function(path) { | ||
// fix a weird case where the Backbone router won't route if the root url == the current pathname. | ||
if (path.replace(/(^\/|\/$)/g, '') == app.baseUrl.replace(/(^\/|\/$)/g, '')) return this.redirectToIndex(); | ||
|
||
document.title = this.buildTitle('404: Not Found'); | ||
app.showSection(); | ||
app.showMasthead('404: Not Found', "<p>If you think you've reached this message in error, please press <strong>0</strong> to speak with an operator. Otherwise, hang up and try again.</p>", { | ||
error: true, | ||
epic: true | ||
}); | ||
}, | ||
buildTitle: function() { | ||
function setTitle() { | ||
var args = Array.prototype.slice.call(arguments); | ||
return (args.length) ? 'Genghis \u2014 ' + args.join(' \u203A ') : 'Genghis'; | ||
document.title = (args.length) ? 'Genghis \u2014 ' + args.join(' \u203A ') : 'Genghis'; | ||
} | ||
}); | ||
|
||
return Backbone.Router.extend({ | ||
routes: { | ||
'': 'index', | ||
'servers': 'redirectToIndex', | ||
'servers/:server': 'server', | ||
'servers/:server/databases': 'redirectToServer', | ||
'servers/:server/databases/:database': 'database', | ||
'servers/:server/databases/:database/collections': 'redirectToDatabase', | ||
'servers/:server/databases/:database/collections/:collection': 'collection', | ||
'servers/:server/databases/:database/collections/:collection/documents': 'collectionQueryOrRedirect', | ||
'servers/:server/databases/:database/collections/:collection/documents?*query': 'collectionQueryOrRedirect', | ||
'servers/:server/databases/:database/collections/:collection/documents/:documentId': 'document', | ||
'*path': 'notFound' | ||
}, | ||
|
||
index: function() { | ||
setTitle(); | ||
app.selection.select(); | ||
app.showSection('servers'); | ||
}, | ||
|
||
redirectToIndex: function() { | ||
this.navigate('', true); | ||
}, | ||
|
||
server: function(server) { | ||
setTitle(server); | ||
app.selection.select(server); | ||
app.showSection('databases'); | ||
}, | ||
|
||
redirectToServer: function(server) { | ||
this.navigate('servers/' + e(server), true); | ||
}, | ||
|
||
database: function(server, database) { | ||
setTitle(server, database); | ||
app.selection.select(server, database); | ||
app.showSection('collections'); | ||
}, | ||
|
||
redirectToDatabase: function(server, database) { | ||
this.navigate('servers/' + e(server) + '/databases/' + e(database), true); | ||
}, | ||
|
||
collection: function(server, database, collection) { | ||
if (!!window.location.search) { | ||
return this.collectionQueryOrRedirect(server, database, collection); | ||
} | ||
|
||
setTitle(server, database, collection); | ||
app.selection.select(server, database, collection); | ||
app.showSection('documents'); | ||
}, | ||
|
||
redirectToCollection: function(server, database, collection) { | ||
this.navigate('servers/' + e(server) + '/databases/' + e(database) + '/collections/' + e(collection), true); | ||
}, | ||
|
||
collectionQueryOrRedirect: function(server, database, collection) { | ||
if (!!window.location.search) { | ||
return this.collectionQuery(server, database, collection, window.location.search.substr(1)); | ||
} else { | ||
this.redirectToCollection(server, database, collection); | ||
} | ||
}, | ||
|
||
collectionQuery: function(server, database, collection, query) { | ||
setTitle(server, database, collection, 'Query results'); | ||
var params = Genghis.Util.parseQuery(query); | ||
app.selection.select(server, database, collection, null, params.q, params.page); | ||
app.showSection('documents'); | ||
}, | ||
|
||
redirectToQuery: function(server, database, collection, query) { | ||
this.navigate('servers/' + e(server) + '/databases/' + e(database) + '/collections/' + e(collection) + '/documents?' + Genghis.Util.buildQuery({q: e(query)}), true); | ||
}, | ||
|
||
document: function(server, database, collection, documentId) { | ||
setTitle(server, database, collection, Genghis.Util.decodeDocumentId(documentId)); | ||
app.selection.select(server, database, collection, documentId); | ||
app.showSection('document'); | ||
}, | ||
|
||
redirectToDocument: function(server, database, collection, documentId) { | ||
var e = encodeURIComponent; | ||
this.navigate('servers/' + e(server) + '/databases/' + e(database) + '/collections/' + e(collection) + '/documents/' + e(documentId), true); | ||
}, | ||
|
||
redirectTo: function(server, database, collection, documentId, query) { | ||
if (!server) return this.redirectToIndex(); | ||
if (!database) return this.redirectToServer(server); | ||
if (!collection) return this.redirectToDatabase(server, database); | ||
|
||
if (!documentId && !query) { | ||
return this.redirectToCollection(server, database, collection); | ||
} else if (!query) { | ||
return this.redirectToDocument(server, database, collection, documentId); | ||
} else { | ||
return this.redirectToQuery(server, database, collection, query); | ||
} | ||
}, | ||
|
||
notFound: function(path) { | ||
setTitle('404: Not Found'); | ||
app.showSection(); | ||
app.showMasthead('404: Not Found', "<p>If you think you've reached this message in error, please press <strong>0</strong> to speak with an operator. Otherwise, hang up and try again.</p>", { | ||
error: true, | ||
epic: true | ||
}); | ||
} | ||
}); | ||
})(); |
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