diff --git a/rpg-docs/Model/Character/Characters.js b/rpg-docs/Model/Character/Characters.js index f8a2d33f9..e75430b2b 100644 --- a/rpg-docs/Model/Character/Characters.js +++ b/rpg-docs/Model/Character/Characters.js @@ -4,7 +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}, + 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}, @@ -547,6 +547,9 @@ if (Meteor.isServer){ Characters.update(doc._id, {$set: {urlName}}); } }); + Characters.before.insert(function(userId, doc) { + doc.urlName = getSlug(doc.name, {maintainCase: true}) || "-"; + }); } Characters.allow({ diff --git a/rpg-docs/Routes/Routes.js b/rpg-docs/Routes/Routes.js index 14ac42ff5..90676c79c 100644 --- a/rpg-docs/Routes/Routes.js +++ b/rpg-docs/Routes/Routes.js @@ -43,7 +43,7 @@ Router.map(function() { var _id = this.params._id var character = Characters.findOne(_id); var urlName = character && character.urlName; - var path = `\/character\/${_id}\/${urlName}`; + var path = `\/character\/${_id}\/${urlName || "-"}`; Router.go(path,{},{replaceState:true}); }, }); diff --git a/rpg-docs/client/globalHelpers/characterPath.js b/rpg-docs/client/globalHelpers/characterPath.js new file mode 100644 index 000000000..723ee07b1 --- /dev/null +++ b/rpg-docs/client/globalHelpers/characterPath.js @@ -0,0 +1,3 @@ +Template.registerHelper("characterPath", function(char) { + return `\/character\/${char._id}\/${char.urlName || "-"}`; +}); diff --git a/rpg-docs/client/views/characterList/characterList.html b/rpg-docs/client/views/characterList/characterList.html index 82e12b92c..acde48cb2 100644 --- a/rpg-docs/client/views/characterList/characterList.html +++ b/rpg-docs/client/views/characterList/characterList.html @@ -11,7 +11,7 @@ {{#if characters.count}}
{{# each characters}} - + diff --git a/rpg-docs/client/views/characterList/characterSideList.html b/rpg-docs/client/views/characterList/characterSideList.html index e65d7804c..38a198598 100644 --- a/rpg-docs/client/views/characterList/characterSideList.html +++ b/rpg-docs/client/views/characterList/characterSideList.html @@ -2,7 +2,7 @@ {{#if characters.count}}
{{#each characters}} - +
{{name}}