From f548e0ffb9a6b956b9732ae1ceab58a54b03d203 Mon Sep 17 00:00:00 2001 From: =Corey Hulen Date: Wed, 7 Oct 2015 17:13:55 -0700 Subject: PLT-567 auto join open channels --- web/react/utils/markdown.jsx | 10 +++++++++- web/web.go | 19 +++++++++++++++---- 2 files changed, 24 insertions(+), 5 deletions(-) (limited to 'web') diff --git a/web/react/utils/markdown.jsx b/web/react/utils/markdown.jsx index 7e88f8644..074d36b4b 100644 --- a/web/react/utils/markdown.jsx +++ b/web/react/utils/markdown.jsx @@ -2,6 +2,7 @@ // See License.txt for license information. const TextFormatting = require('./text_formatting.jsx'); +const Utils = require('./utils.jsx'); const marked = require('marked'); @@ -39,7 +40,14 @@ export class MattermostMarkdownRenderer extends marked.Renderer { if (title) { output += ' title="' + title + '"'; } - output += ' target="_blank">' + text + ''; + + if (outHref.indexOf(Utils.getTeamURLFromAddressBar()) === 0) { + output += '>'; + } else { + output += ' target="_blank">'; + } + + output += text + ''; return output; } diff --git a/web/web.go b/web/web.go index b87636187..46e8e25a7 100644 --- a/web/web.go +++ b/web/web.go @@ -372,11 +372,22 @@ func getChannel(c *api.Context, w http.ResponseWriter, r *http.Request) { return } - //api.Handle404(w, r) - //Bad channel urls just redirect to the town-square for now + // We will attempt to auto-join open channels + if cr := <-api.Srv.Store.Channel().GetByName(c.Session.TeamId, name); cr.Err != nil { + http.Redirect(w, r, c.GetTeamURL()+"/channels/town-square", http.StatusFound) + } else { + channel := cr.Data.(*model.Channel) + if channel.Type == model.CHANNEL_OPEN { + api.JoinChannel(c, channel.Id, "") + if c.Err != nil { + return + } - http.Redirect(w, r, c.GetTeamURL()+"/channels/town-square", http.StatusFound) - return + channelId = channel.Id + } else { + http.Redirect(w, r, c.GetTeamURL()+"/channels/town-square", http.StatusFound) + } + } } } -- cgit v1.2.3-1-g7c22 From d412144f88a24925af8500d9b1b7535e518a3eb6 Mon Sep 17 00:00:00 2001 From: =Corey Hulen Date: Thu, 8 Oct 2015 09:14:13 -0700 Subject: Adding removing blank target for browser links --- web/react/utils/markdown.jsx | 2 +- web/react/utils/text_formatting.jsx | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) (limited to 'web') diff --git a/web/react/utils/markdown.jsx b/web/react/utils/markdown.jsx index 074d36b4b..78d2b801d 100644 --- a/web/react/utils/markdown.jsx +++ b/web/react/utils/markdown.jsx @@ -41,7 +41,7 @@ export class MattermostMarkdownRenderer extends marked.Renderer { output += ' title="' + title + '"'; } - if (outHref.indexOf(Utils.getTeamURLFromAddressBar()) === 0) { + if (outHref.lastIndexOf(Utils.getTeamURLFromAddressBar()) === 0) { output += '>'; } else { output += ' target="_blank">'; diff --git a/web/react/utils/text_formatting.jsx b/web/react/utils/text_formatting.jsx index 34e42cbae..43b212484 100644 --- a/web/react/utils/text_formatting.jsx +++ b/web/react/utils/text_formatting.jsx @@ -96,8 +96,13 @@ function autolinkUrls(text, tokens) { const index = tokens.size; const alias = `MM_LINK${index}`; + var target = 'target="_blank"'; + if (url.lastIndexOf(Utils.getTeamURLFromAddressBar()) === 0) { + target = ''; + } + tokens.set(alias, { - value: `${linkText}`, + value: '${linkText}', originalText: linkText }); -- cgit v1.2.3-1-g7c22 From e640bf7b6c1f6b3f20db954b27430261c18accda Mon Sep 17 00:00:00 2001 From: =Corey Hulen Date: Thu, 8 Oct 2015 09:34:49 -0700 Subject: Fixing issue with lastIndexOf --- web/react/utils/markdown.jsx | 2 +- web/react/utils/text_formatting.jsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'web') diff --git a/web/react/utils/markdown.jsx b/web/react/utils/markdown.jsx index 78d2b801d..aff776d05 100644 --- a/web/react/utils/markdown.jsx +++ b/web/react/utils/markdown.jsx @@ -41,7 +41,7 @@ export class MattermostMarkdownRenderer extends marked.Renderer { output += ' title="' + title + '"'; } - if (outHref.lastIndexOf(Utils.getTeamURLFromAddressBar()) === 0) { + if (outHref.lastIndexOf(Utils.getTeamURLFromAddressBar(), 0) === 0) { output += '>'; } else { output += ' target="_blank">'; diff --git a/web/react/utils/text_formatting.jsx b/web/react/utils/text_formatting.jsx index 43b212484..b8ed58258 100644 --- a/web/react/utils/text_formatting.jsx +++ b/web/react/utils/text_formatting.jsx @@ -97,7 +97,7 @@ function autolinkUrls(text, tokens) { const alias = `MM_LINK${index}`; var target = 'target="_blank"'; - if (url.lastIndexOf(Utils.getTeamURLFromAddressBar()) === 0) { + if (url.lastIndexOf(Utils.getTeamURLFromAddressBar(), 0) === 0) { target = ''; } -- cgit v1.2.3-1-g7c22