From 14410b71fbfab6f2980f9d7d532df4a95dbcc8e9 Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Tue, 28 Mar 2017 14:27:54 -0400 Subject: [PATCH] Convert server side paths to use `/u/` --- .../admin/models/admin-user.js.es6 | 3 ++- .../javascripts/discourse/routes/user.js.es6 | 4 ++-- app/controllers/admin/users_controller.rb | 4 +++- app/controllers/list_controller.rb | 4 ++-- app/controllers/posts_controller.rb | 2 +- app/controllers/users_controller.rb | 2 +- app/models/user_action.rb | 2 +- app/views/email/_post.html.erb | 4 ++-- app/views/embed/comments.html.erb | 4 ++-- app/views/list/list.rss.erb | 2 +- app/views/robots_txt/index.erb | 1 + app/views/topics/show.html.erb | 2 +- .../user_notifications/mailing_list.html.erb | 2 +- config/locales/client.en.yml | 2 +- config/locales/server.en.yml | 24 +++++++++---------- config/routes.rb | 2 +- lib/composer_messages_finder.rb | 2 +- lib/system_message.rb | 2 +- lib/tasks/integration.rake | 2 +- script/bench.rb | 2 +- script/import_scripts/mylittleforum.rb | 4 +--- spec/components/post_creator_spec.rb | 6 ++--- spec/components/pretty_text_spec.rb | 4 ++-- spec/integration/users_spec.rb | 8 +++---- spec/models/topic_link_spec.rb | 2 +- .../acceptance/password-reset-test.js.es6 | 2 +- .../plugin-outlet-connector-class-test.js.es6 | 2 +- .../plugin-outlet-multi-template-test.js.es6 | 2 +- .../plugin-outlet-single-template-test.js.es6 | 2 +- .../acceptance/preferences-test.js.es6 | 10 ++++---- .../javascripts/acceptance/search-test.js.es6 | 2 +- .../acceptance/user-anonymous-test.js.es6 | 12 +++++----- test/javascripts/acceptance/user-test.js.es6 | 8 +++---- .../fixtures/group-fixtures.js.es6 | 8 +++---- test/javascripts/lib/computed-test.js.es6 | 6 ++--- test/javascripts/lib/discourse-test.js.es6 | 4 ++-- test/javascripts/lib/pretty-text-test.js.es6 | 4 ++-- .../widgets/poster-name-test.js.es6 | 4 ++-- 38 files changed, 82 insertions(+), 80 deletions(-) diff --git a/app/assets/javascripts/admin/models/admin-user.js.es6 b/app/assets/javascripts/admin/models/admin-user.js.es6 index 48764b671d6..4c952d953f8 100644 --- a/app/assets/javascripts/admin/models/admin-user.js.es6 +++ b/app/assets/javascripts/admin/models/admin-user.js.es6 @@ -5,6 +5,7 @@ import { popupAjaxError } from 'discourse/lib/ajax-error'; import ApiKey from 'admin/models/api-key'; import Group from 'discourse/models/group'; import TL3Requirements from 'admin/models/tl3-requirements'; +import { userPath } from 'discourse/lib/url'; const AdminUser = Discourse.User.extend({ @@ -346,7 +347,7 @@ const AdminUser = Discourse.User.extend({ }, sendActivationEmail() { - return ajax('/users/action/send_activation_email', { + return ajax(userPath('action/send_activation_email'), { type: 'POST', data: { username: this.get('username') } }).then(function() { diff --git a/app/assets/javascripts/discourse/routes/user.js.es6 b/app/assets/javascripts/discourse/routes/user.js.es6 index 936ebadfccb..2ab32969252 100644 --- a/app/assets/javascripts/discourse/routes/user.js.es6 +++ b/app/assets/javascripts/discourse/routes/user.js.es6 @@ -83,14 +83,14 @@ export default Discourse.Route.extend({ activate() { this._super(); const user = this.modelFor('user'); - this.messageBus.subscribe("/users/" + user.get('username_lower'), function(data) { + this.messageBus.subscribe("/u/" + user.get('username_lower'), function(data) { user.loadUserAction(data); }); }, deactivate() { this._super(); - this.messageBus.unsubscribe("/users/" + this.modelFor('user').get('username_lower')); + this.messageBus.unsubscribe("/u/" + this.modelFor('user').get('username_lower')); // Remove the search context this.searchService.set('searchContext', null); diff --git a/app/controllers/admin/users_controller.rb b/app/controllers/admin/users_controller.rb index 8fdd4b95368..c0e97911169 100644 --- a/app/controllers/admin/users_controller.rb +++ b/app/controllers/admin/users_controller.rb @@ -348,7 +348,9 @@ class Admin::UsersController < Admin::AdminController email_token: email_token.token) end - render json: success_json.merge!(password_url: "#{Discourse.base_url}/users/password-reset/#{email_token.token}") + render json: success_json.merge!( + password_url: "#{Discourse.base_url}#{password_reset_token_path(token: email_token.token)}" + ) end diff --git a/app/controllers/list_controller.rb b/app/controllers/list_controller.rb index 69391459d86..b0f9efcf318 100644 --- a/app/controllers/list_controller.rb +++ b/app/controllers/list_controller.rb @@ -192,8 +192,8 @@ class ListController < ApplicationController target_user = fetch_user_from_params @title = "#{SiteSetting.title} - #{I18n.t("rss_description.user_topics", username: target_user.username)}" - @link = "#{Discourse.base_url}/users/#{target_user.username}/activity/topics" - @atom_link = "#{Discourse.base_url}/users/#{target_user.username}/activity/topics.rss" + @link = "#{Discourse.base_url}/u/#{target_user.username}/activity/topics" + @atom_link = "#{Discourse.base_url}/u/#{target_user.username}/activity/topics.rss" @description = I18n.t("rss_description.user_topics", username: target_user.username) @topic_list = TopicQuery.new(nil, order: 'created').send("list_topics_by", target_user) diff --git a/app/controllers/posts_controller.rb b/app/controllers/posts_controller.rb index 225b01f1d61..8531c42e92c 100644 --- a/app/controllers/posts_controller.rb +++ b/app/controllers/posts_controller.rb @@ -103,7 +103,7 @@ class PostsController < ApplicationController @posts = posts @title = "#{SiteSetting.title} - #{I18n.t("rss_description.user_posts", username: user.username)}" - @link = "#{Discourse.base_url}/users/#{user.username}/activity" + @link = "#{Discourse.base_url}/u/#{user.username}/activity" @description = I18n.t("rss_description.user_posts", username: user.username) render 'posts/latest', formats: [:rss] end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 6874fff56d2..13eddab750e 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -189,7 +189,7 @@ class UsersController < ApplicationController cookies[:destination_url] = "/my/#{params[:path]}" redirect_to "/login-preferences" else - redirect_to(path("/users/#{current_user.username}/#{params[:path]}")) + redirect_to(path("/u/#{current_user.username}/#{params[:path]}")) end end diff --git a/app/models/user_action.rb b/app/models/user_action.rb index 13e4dea91a5..5e3599a381b 100644 --- a/app/models/user_action.rb +++ b/app/models/user_action.rb @@ -260,7 +260,7 @@ SQL end if action.user - MessageBus.publish("/users/#{action.user.username.downcase}", action.id, user_ids: [user_id], group_ids: group_ids) + MessageBus.publish("/u/#{action.user.username.downcase}", action.id, user_ids: [user_id], group_ids: group_ids) end action diff --git a/app/views/email/_post.html.erb b/app/views/email/_post.html.erb index 3f0d21580f4..569a12e0582 100644 --- a/app/views/email/_post.html.erb +++ b/app/views/email/_post.html.erb @@ -9,10 +9,10 @@ <%- if show_username_on_post(post) %> - <%= post.user.username %> + <%= post.user.username %> <% end %> <%- if show_name_on_post(post) %> - <%= post.user.name %> + <%= post.user.name %> <% end %> <%- if post.user.title.present? %> <%= post.user.title %> diff --git a/app/views/embed/comments.html.erb b/app/views/embed/comments.html.erb index 29ab2772326..23f69584fed 100644 --- a/app/views/embed/comments.html.erb +++ b/app/views/embed/comments.html.erb @@ -16,11 +16,11 @@ <%- end %>
- +

- <%= post.user.username %> + <%= post.user.username %> <%- if post.user.title.present? %> <%= post.user.title %> <%- end %> diff --git a/app/views/list/list.rss.erb b/app/views/list/list.rss.erb index d0f6c14957c..69799bc5934 100644 --- a/app/views/list/list.rss.erb +++ b/app/views/list/list.rss.erb @@ -20,7 +20,7 @@ <%= topic.category.name %> -

<%= t('author_wrote', author: link_to("@#{username}", "#{Discourse.base_url}/users/#{topic.user.username_lower}")).html_safe %>

+

<%= t('author_wrote', author: link_to("@#{username}", "#{Discourse.base_url}/u/#{topic.user.username_lower}")).html_safe %>

<% end %>
<%= topic.posts.first.cooked.html_safe %> diff --git a/app/views/robots_txt/index.erb b/app/views/robots_txt/index.erb index 8ae193da42b..e4c6a446bc4 100644 --- a/app/views/robots_txt/index.erb +++ b/app/views/robots_txt/index.erb @@ -10,6 +10,7 @@ Disallow: /auth/github/callback Disallow: /auth/cas/callback Disallow: /assets/browser-update*.js Disallow: /users/ +Disallow: /u/ Disallow: /badges/ Disallow: /search Disallow: /search/ diff --git a/app/views/topics/show.html.erb b/app/views/topics/show.html.erb index 73ef1724b60..e24626f2039 100644 --- a/app/views/topics/show.html.erb +++ b/app/views/topics/show.html.erb @@ -46,7 +46,7 @@ <% if (u = post.user) %>
- + <%= "(#{u.name})" if (SiteSetting.display_name_on_posts && SiteSetting.enable_names? && !u.name.blank?) %>