Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NEW] Package to render issue numbers into links to an issue tracker. #6700

Merged
merged 3 commits into from
Aug 21, 2017
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .meteor/packages
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ rocketchat:importer-slack
rocketchat:integrations
rocketchat:internal-hubot
rocketchat:irc
rocketchat:issuelinks
rocketchat:katex
rocketchat:ldap
rocketchat:lib
Expand Down
1 change: 1 addition & 0 deletions .meteor/versions
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ rocketchat:importer-slack@0.0.1
rocketchat:integrations@0.0.1
rocketchat:internal-hubot@0.0.1
rocketchat:irc@0.0.2
rocketchat:issuelinks@0.0.1
rocketchat:katex@0.0.1
rocketchat:ldap@0.0.1
rocketchat:ldapjs@1.0.0
Expand Down
4 changes: 4 additions & 0 deletions packages/rocketchat-i18n/i18n/en.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -787,6 +787,7 @@
"IRC_Message_Cache_Size": "The cache limit for outbound message handling.",
"IRC_Port": "The port to bind to on the IRC host server.",
"IRC_Quit": "Output upon quitting an IRC session.",
"Issue_Links": "Issue tracker links",
"It_works": "It works",
"italics": "italics",
"Jitsi_Chrome_Extension": "Chrome Extension Id",
Expand Down Expand Up @@ -893,6 +894,9 @@
"Leave_Room_Warning": "Are you sure you want to leave the room \"%s\"?",
"Leave_the_current_channel": "Leave the current channel",
"line": "line",
"IssueLinks_Incompatible": "Warning: do not enable this and the 'Hex Color Preview' at the same time.",
"IssueLinks_LinkTemplate": "Template for issue links",
"IssueLinks_LinkTemplate_Description": "Template for issue links; %s will be replaced by the issue number.",
"List_of_Channels": "List of Channels",
"List_of_Direct_Messages": "List of Direct Messages",
"Livechat_agents": "Livechat agents",
Expand Down
16 changes: 16 additions & 0 deletions packages/rocketchat-issuelinks/client.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//
// IssueLink is a named function that will add issue links
// @param {Object} message - The message object
//

function IssueLink(message) {
if (_.trim(message.html) && RocketChat.settings.get('IssueLinks_Enabled')) {
message.html = message.html.replace(/(?:^|\s|\n)(#[0-9]+)\b/g, function(match, issueNumber) {
const url = RocketChat.settings.get('IssueLinks_Template').replace('%s', issueNumber.substring(1));
return match.replace(issueNumber, `<a href="${ url }" target="_blank">${ issueNumber }</a>`);
});
}
return message;
}

RocketChat.callbacks.add('renderMessage', IssueLink, RocketChat.callbacks.priority.MEDIUM);
14 changes: 14 additions & 0 deletions packages/rocketchat-issuelinks/package.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Package.describe({
name: 'rocketchat:issuelinks',
version: '0.0.1',
summary: 'Message pre-processor that will add links to issue numbers.',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: 'Message pre-processor that adds links to issue numbers.'

git: ''
});

Package.onUse(function(api) {
api.use('rocketchat:lib');
api.use('ecmascript');

api.addFiles('client.js', ['client']);
api.addFiles('settings.js', ['server']);
});
17 changes: 17 additions & 0 deletions packages/rocketchat-issuelinks/settings.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
RocketChat.settings.add('IssueLinks_Enabled', false, {
type: 'boolean',
i18nLabel: 'Enabled',
i18nDescription: 'IssueLinks_Incompatible',
group: 'Message',
section: 'Issue_Links',
public: true
});

RocketChat.settings.add('IssueLinks_Template', '', {
type: 'string',
i18nLabel: 'IssueLinks_LinkTemplate',
i18nDescription: 'IssueLinks_LinkTemplate_Description',
group: 'Message',
section: 'Issue_Links',
public: true
});