diff --git a/rpg-docs/.meteor/packages b/rpg-docs/.meteor/packages index 0928a7e4..89495d83 100644 --- a/rpg-docs/.meteor/packages +++ b/rpg-docs/.meteor/packages @@ -48,3 +48,4 @@ es5-shim@4.6.15 differential:vulcanize reactive-dict percolate:synced-cron +ongoworks:speakingurl diff --git a/rpg-docs/.meteor/versions b/rpg-docs/.meteor/versions index 04f53178..c2254df9 100644 --- a/rpg-docs/.meteor/versions +++ b/rpg-docs/.meteor/versions @@ -85,6 +85,7 @@ npm-mongo@2.2.16_1 oauth@1.1.12 oauth2@1.1.11 observe-sequence@1.0.14 +ongoworks:speakingurl@9.0.0 ordered-dict@1.0.9 percolate:migrations@0.9.8 percolate:synced-cron@1.3.2 diff --git a/rpg-docs/Model/Character/Characters.js b/rpg-docs/Model/Character/Characters.js index 88fbc911..b16e3324 100644 --- a/rpg-docs/Model/Character/Characters.js +++ b/rpg-docs/Model/Character/Characters.js @@ -4,6 +4,7 @@ Characters = new Mongo.Collection("characters"); Schemas.Character = new SimpleSchema({ //strings name: {type: String, defaultValue: "", trim: false, optional: true}, + urlName: {type: String, defaultValue: "", trim: false, optional: true}, alignment: {type: String, defaultValue: "", trim: false, optional: true}, gender: {type: String, defaultValue: "", trim: false, optional: true}, race: {type: String, defaultValue: "", trim: false, optional: true}, @@ -540,6 +541,12 @@ if (Meteor.isServer){ Items .remove({charId: character._id}); Containers .remove({charId: character._id}); }); + Characters.after.update(function(userId, doc, fieldNames, modifier, options) { + if (_.contains(fieldNames, "name")){ + var urlName = getSlug(doc.name, {maintainCase: true}); + Characters.update(doc._id, {$set: {urlName}}); + } + }); } Characters.allow({ diff --git a/rpg-docs/Routes/Routes.js b/rpg-docs/Routes/Routes.js index 5f2906c2..14ac42ff 100644 --- a/rpg-docs/Routes/Routes.js +++ b/rpg-docs/Routes/Routes.js @@ -24,7 +24,7 @@ Router.map(function() { this.route("characterList", { path: "/characterList", waitOn: function(){ - return subsManager.subscribe("characterList", Meteor.userId()); + return subsManager.subscribe("characterList"); }, onAfterAction: function() { document.title = appName + " - Characters"; @@ -32,11 +32,27 @@ Router.map(function() { fastRender: true, }); - this.route("characterSheet", { - path: "/character/:_id", + this.route("characterSheetNaked", { + path: "/character/:_id/", waitOn: function(){ return [ - subsManager.subscribe("singleCharacter", this.params._id, Meteor.userId()), + subsManager.subscribe("singleCharacter", this.params._id), + ]; + }, + action: function(){ + var _id = this.params._id + var character = Characters.findOne(_id); + var urlName = character && character.urlName; + var path = `\/character\/${_id}\/${urlName}`; + Router.go(path,{},{replaceState:true}); + }, + }); + + this.route("characterSheet", { + path: "/character/:_id/:urlName", + waitOn: function(){ + return [ + subsManager.subscribe("singleCharacter", this.params._id), ]; }, data: function() { diff --git a/rpg-docs/client/views/characterList/characterList.html b/rpg-docs/client/views/characterList/characterList.html index 1603eaa5..82e12b92 100644 --- a/rpg-docs/client/views/characterList/characterList.html +++ b/rpg-docs/client/views/characterList/characterList.html @@ -11,7 +11,7 @@ {{#if characters.count}}