Convert front end paths from `/users/` to `/u/`

Convert front end paths from /users/ to /u/

diff --git a/app/assets/javascripts/admin/controllers/admin-user-index.js.es6 b/app/assets/javascripts/admin/controllers/admin-user-index.js.es6
index 14bc031..91717cf 100644
--- a/app/assets/javascripts/admin/controllers/admin-user-index.js.es6
+++ b/app/assets/javascripts/admin/controllers/admin-user-index.js.es6
@@ -1,6 +1,7 @@
 import { ajax } from 'discourse/lib/ajax';
 import CanCheckEmails from 'discourse/mixins/can-check-emails';
 import { propertyNotEqual, setting } from 'discourse/lib/computed';
+import { userPath } from 'discourse/lib/url';
 
 export default Ember.Controller.extend(CanCheckEmails, {
   editingTitle: false,
@@ -62,7 +63,7 @@ export default Ember.Controller.extend(CanCheckEmails, {
     saveTitle() {
       const self = this;
 
-      return ajax(`/users/${this.get('model.username').toLowerCase()}.json`, {
+      return ajax(userPath(`${this.get('model.username').toLowerCase()}.json`), {
         data: {title: this.get('userTitleValue')},
         type: 'PUT'
       }).catch(function(e) {
diff --git a/app/assets/javascripts/discourse/components/small-action.js.es6 b/app/assets/javascripts/discourse/components/small-action.js.es6
index 8a17c41..114d358 100644
--- a/app/assets/javascripts/discourse/components/small-action.js.es6
+++ b/app/assets/javascripts/discourse/components/small-action.js.es6
@@ -1,4 +1,5 @@
 import { autoUpdatingRelativeAge } from 'discourse/lib/formatter';
+import { userPath } from 'discourse/lib/url';
 
 export function actionDescriptionHtml(actionCode, createdAt, username) {
   const dt = new Date(createdAt);
@@ -9,7 +10,7 @@ export function actionDescriptionHtml(actionCode, createdAt, username) {
     if (actionCode === "invited_group" || actionCode === "removed_group") {
       who = `<a class="mention-group" href="/groups/${username}">@${username}</a>`;
     } else {
-      who = `<a class="mention" href="/users/${username}">@${username}</a>`;
+      who = `<a class="mention" href="${userPath(username)}">@${username}</a>`;
     }
   }
   return I18n.t(`action_codes.${actionCode}`, { who, when }).htmlSafe();
diff --git a/app/assets/javascripts/discourse/components/user-card-contents.js.es6 b/app/assets/javascripts/discourse/components/user-card-contents.js.es6
index 6aefcaa..969a6a9 100644
--- a/app/assets/javascripts/discourse/components/user-card-contents.js.es6
+++ b/app/assets/javascripts/discourse/components/user-card-contents.js.es6
@@ -5,6 +5,7 @@ import afterTransition from 'discourse/lib/after-transition';
 import { default as computed, observes } from 'ember-addons/ember-computed-decorators';
 import DiscourseURL from 'discourse/lib/url';
 import User from 'discourse/models/user';
+import { userPath } from 'discourse/lib/url';
 
 const clickOutsideEventName = "mousedown.outside-user-card";
 const clickDataExpand = "click.discourse-user-card";
@@ -92,7 +93,7 @@ export default Ember.Component.extend(CleansUp, {
 
     // Don't show on mobile
     if (this.site.mobileView) {
-      DiscourseURL.routeTo(`/users/${username}`);
+      DiscourseURL.routeTo(userPath(username));
       return false;
     }
 
diff --git a/app/assets/javascripts/discourse/components/user-info.js.es6 b/app/assets/javascripts/discourse/components/user-info.js.es6
index 05dde9f..3293e4d 100644
--- a/app/assets/javascripts/discourse/components/user-info.js.es6
+++ b/app/assets/javascripts/discourse/components/user-info.js.es6
@@ -1,5 +1,5 @@
-import { url } from 'discourse/lib/computed';
 import computed from 'ember-addons/ember-computed-decorators';
+import { userPath } from 'discourse/lib/url';
 
 function normalize(name) {
   return name.replace(/[\-\_ \.]/g, '').toLowerCase();
@@ -8,7 +8,11 @@ function normalize(name) {
 export default Ember.Component.extend({
   classNameBindings: [':user-info', 'size'],
   size: 'small',
-  userPath: url('user.username', '/users/%@'),
+
+  @computed('user.username')
+  userPath(username) {
+    return userPath(username);
+  },
 
   // TODO: In later ember releases `hasBlock` works without this
   hasBlock: Ember.computed.alias('template'),
diff --git a/app/assets/javascripts/discourse/controllers/create-account.js.es6 b/app/assets/javascripts/discourse/controllers/create-account.js.es6
index d04a038..d77a4db 100644
--- a/app/assets/javascripts/discourse/controllers/create-account.js.es6
+++ b/app/assets/javascripts/discourse/controllers/create-account.js.es6
@@ -6,6 +6,7 @@ import { emailValid } from 'discourse/lib/utilities';
 import InputValidation from 'discourse/models/input-validation';
 import PasswordValidation from "discourse/mixins/password-validation";
 import UsernameValidation from "discourse/mixins/username-validation";
+import { userPath } from 'discourse/lib/url';
 
 export default Ember.Controller.extend(ModalFunctionality, PasswordValidation, UsernameValidation, {
   login: Ember.inject.controller(),
@@ -164,7 +165,7 @@ export default Ember.Controller.extend(ModalFunctionality, PasswordValidation, U
 
   @on('init')
   fetchConfirmationValue() {
-    return ajax('/users/hp.json').then(json => {
+    return ajax(userPath('hp.json')).then(json => {
       this.set('accountPasswordConfirm', json.value);
       this.set('accountChallenge', json.challenge.split("").reverse().join(""));
     });
@@ -196,7 +197,7 @@ export default Ember.Controller.extend(ModalFunctionality, PasswordValidation, U
           const $hidden_login_form = $('#hidden-login-form');
           $hidden_login_form.find('input[name=username]').val(attrs.accountUsername);
           $hidden_login_form.find('input[name=password]').val(attrs.accountPassword);
-          $hidden_login_form.find('input[name=redirect]').val(Discourse.getURL('/users/account-created'));
+          $hidden_login_form.find('input[name=redirect]').val(userPath('account-created'));
           $hidden_login_form.submit();
         } else {
           self.flash(result.message || I18n.t('create_account.failed'), 'error');
diff --git a/app/assets/javascripts/discourse/controllers/discovery/topics.js.es6 b/app/assets/javascripts/discourse/controllers/discovery/topics.js.es6
index 516c53d..706ee73 100644
--- a/app/assets/javascripts/discourse/controllers/discovery/topics.js.es6
+++ b/app/assets/javascripts/discourse/controllers/discovery/topics.js.es6
@@ -3,6 +3,7 @@ import { queryParams } from 'discourse/controllers/discovery-sortable';
 import BulkTopicSelection from 'discourse/mixins/bulk-topic-selection';
 import { endWith } from 'discourse/lib/computed';
 import showModal from 'discourse/lib/show-modal';
+import { userPath } from 'discourse/lib/url';
 
 const controllerOpts = {
   discovery: Ember.inject.controller(),
@@ -133,14 +134,14 @@ const controllerOpts = {
   }.property('allLoaded', 'model.topics.length'),
 
   footerEducation: function() {
-    if (!this.get('allLoaded') || this.get('model.topics.length') > 0 || !Discourse.User.current()) { return; }
+    if (!this.get('allLoaded') || this.get('model.topics.length') > 0 || !this.currentUser) { return; }
 
     const split = (this.get('model.filter') || '').split('/');
 
     if (split[0] !== 'new' && split[0] !== 'unread') { return; }
 
     return I18n.t("topics.none.educate." + split[0], {
-      userPrefsUrl: Discourse.getURL("/users/") + (Discourse.User.currentProp("username_lower")) + "/preferences"
+      userPrefsUrl: userPath(`${this.currentUser.get('username_lower')}/preferences`)
     });
   }.property('allLoaded', 'model.topics.length')
 
diff --git a/app/assets/javascripts/discourse/controllers/not-activated.js.es6 b/app/assets/javascripts/discourse/controllers/not-activated.js.es6
index 86afe2d..cf0164b 100644
--- a/app/assets/javascripts/discourse/controllers/not-activated.js.es6
+++ b/app/assets/javascripts/discourse/controllers/not-activated.js.es6
@@ -1,6 +1,7 @@
 import { ajax } from 'discourse/lib/ajax';
 import { popupAjaxError } from 'discourse/lib/ajax-error';
 import ModalFunctionality from 'discourse/mixins/modal-functionality';

[... diff too long, it was truncated ...]

GitHub sha: 45a25781

This commit has been mentioned on Discourse Meta. There might be relevant details there:

https://meta.discourse.org/t/was-users-username-deprecated/163284/2