Fix links and embeds

Disable semi-broken plugins
cordova
Lorenz Hübschle-Schneider 11 years ago
parent d222b8ebc9
commit ebcef891ac
  1. 7
      index.html
  2. 9
      js/filters.js
  3. 12
      js/plugins.js
  4. 4
      test/unit/plugins.js

@ -222,8 +222,7 @@ chown -R <strong>username</strong>:<strong>username</strong> ~<strong>username</
</div> </div>
<div class="title" title="{{activeBuffer().rtitle}}"> <div class="title" title="{{activeBuffer().rtitle}}">
<span class="desktop" ng-repeat="part in activeBuffer().title" ng-class="::part.classes" ng-bind-html="::(part.text | linky:'_blank':{rel:'noopener noreferrer'} | DOMfilter:'irclinky')"></span> <span ng-click="showModal('topicModal')" ng-class="{'active': activeBuffer().active, 'channel': activeBuffer().type === 'channel', 'channel_hash': activeBuffer().prefix === '#', 'channel_plus': activeBuffer().prefix === '+', 'channel_ampersand': activeBuffer().prefix === '&'}">{{ activeBuffer().trimmedName || activeBuffer().fullName }}</span>
<span class="mobile" ng-click="showModal('topicModal')" ng-class="{'active': activeBuffer().active, 'channel': activeBuffer().type === 'channel', 'channel_hash': activeBuffer().prefix === '#', 'channel_plus': activeBuffer().prefix === '+', 'channel_ampersand': activeBuffer().prefix === '&'}">{{ activeBuffer().trimmedName || activeBuffer().fullName }}</span>
</div> </div>
<div class="actions pull-right vertical-line-left"> <div class="actions pull-right vertical-line-left">
@ -288,7 +287,7 @@ chown -R <strong>username</strong>:<strong>username</strong> ~<strong>username</
<td class="prefix"><span ng-class="::{'repeated-prefix': bufferline.prefixtext==bufferlines[$index-1].prefixtext}"><a ng-click="addMention(bufferline.prefix)"><span class="hidden-bracket">&lt;</span><span ng-repeat="part in ::bufferline.prefix" ng-class="::part.classes" ng-bind="::part.text|prefixlimit:25"></span><span class="hidden-bracket">&gt;</span></a></span></td><!-- <td class="prefix"><span ng-class="::{'repeated-prefix': bufferline.prefixtext==bufferlines[$index-1].prefixtext}"><a ng-click="addMention(bufferline.prefix)"><span class="hidden-bracket">&lt;</span><span ng-repeat="part in ::bufferline.prefix" ng-class="::part.classes" ng-bind="::part.text|prefixlimit:25"></span><span class="hidden-bracket">&gt;</span></a></span></td><!--
--><td class="message"><!-- --><td class="message"><!--
--><div ng-repeat="metadata in ::bufferline.metadata" plugin data="::metadata"></div><!-- --><div ng-repeat="metadata in ::bufferline.metadata" plugin data="::metadata"></div><!--
--><span ng-repeat="part in ::bufferline.content" class="text" ng-class="::part.classes.concat(['line-' + part.$$hashKey.replace(':','_')])" ng-bind-html="::part.text | linky:'_blank':{rel:'noopener noreferrer'} | DOMfilter:'irclinky' | DOMfilter:'inlinecolour' | DOMfilter:'latexmath':('.line-' + part.$$hashKey.replace(':','_')):settings.enableMathjax"></span> --><span ng-repeat="part in ::bufferline.content" class="text" ng-class="::part.classes.concat(['line-' + part.$$hashKey.replace(':','_')])" ng-bind-html="::part.text | linky:'_system':{rel:'noopener noreferrer'} | linksForCordova | DOMfilter:'irclinky' | DOMfilter:'inlinecolour' | DOMfilter:'latexmath':('.line-' + part.$$hashKey.replace(':','_')):settings.enableMathjax"></span>
</td> </td>
</tr> </tr>
<tr class="readmarker" ng-if="activeBuffer().lastSeen==$index"> <tr class="readmarker" ng-if="activeBuffer().lastSeen==$index">
@ -452,7 +451,7 @@ chown -R <strong>username</strong>:<strong>username</strong> ~<strong>username</
<div class="modal-header"> <div class="modal-header">
<button type="button" class="close" ng-click="closeModal($event)" aria-hidden="true">&times;</button> <button type="button" class="close" ng-click="closeModal($event)" aria-hidden="true">&times;</button>
<h4 class="modal-title">Channel topic</h4> <h4 class="modal-title">Channel topic</h4>
<p ng-repeat="part in activeBuffer().title" ng-class="::part.classes" ng-bind-html="::(part.text | linky:'_blank':{rel:'noopener noreferrer'} | DOMfilter:'irclinky')"></p> <p ng-repeat="part in activeBuffer().title" ng-class="::part.classes" ng-bind-html="::(part.text | linky:'_system':{rel:'noopener noreferrer'} | linksForCordova | DOMfilter:'irclinky')"></p>
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<button type="button" class="btn btn-primary" ng-click="closeModal($event)">Close</button> <button type="button" class="btn btn-primary" ng-click="closeModal($event)">Close</button>

@ -135,6 +135,15 @@ weechat.filter('DOMfilter', ['$filter', '$sce', function($filter, $sce) {
}; };
}]); }]);
weechat.filter('linksForCordova', ['$sce', function($sce) {
return function (text) {
// Cordova: need to use window.open instead of href
// XXX TODO this needs to be improved
text = text.replace(/<a (rel="[a-z ]+"\s)?(?:target="_[a-z]+"\s)?href="([^"]+)"/gi, "<a $1 onClick=\"window.open('$2', '_system')\"");
return $sce.trustAsHtml(text);
};
}]);
weechat.filter('getBufferQuickKeys', function () { weechat.filter('getBufferQuickKeys', function () {
return function (obj, $scope) { return function (obj, $scope) {
if (!$scope) { return obj; } if (!$scope) { return obj; }

@ -281,8 +281,8 @@ plugins.factory('userPlugins', function() {
if (url.indexOf("^https?://fukung.net/v/") != -1) { if (url.indexOf("^https?://fukung.net/v/") != -1) {
url = url.replace(/.*\//, "http://media.fukung.net/imgs/"); url = url.replace(/.*\//, "http://media.fukung.net/imgs/");
} else if (url.match(/^http:\/\/(i\.)?imgur\.com\//i)) { } else if (url.match(/^http:\/\/(i\.)?imgur\.com\//i)) {
// remove protocol specification to load over https if used by g-b // always load imgur over https
url = url.replace(/http:/, ""); url = url.replace(/http:/, "https://");
} else if (url.match(/^https:\/\/www\.dropbox\.com\/s\/[a-z0-9]+\//i)) { } else if (url.match(/^https:\/\/www\.dropbox\.com\/s\/[a-z0-9]+\//i)) {
// Dropbox requires a get parameter, dl=1 // Dropbox requires a get parameter, dl=1
var dbox_url = document.createElement("a"); var dbox_url = document.createElement("a");
@ -354,7 +354,7 @@ plugins.factory('userPlugins', function() {
}; };
} }
}); });
/* /*
* Cloud Music Embedded Players * Cloud Music Embedded Players
@ -436,6 +436,7 @@ plugins.factory('userPlugins', function() {
} }
}); });
/*
// Embed GitHub gists // Embed GitHub gists
var gistPlugin = new UrlPlugin('Gist', function(url) { var gistPlugin = new UrlPlugin('Gist', function(url) {
// ignore trailing slashes and anchors // ignore trailing slashes and anchors
@ -458,6 +459,7 @@ plugins.factory('userPlugins', function() {
}; };
} }
}); });
*/
var pastebinPlugin = new UrlPlugin('Pastebin', function(url) { var pastebinPlugin = new UrlPlugin('Pastebin', function(url) {
var regexp = /^https?:\/\/pastebin\.com\/([^.?]+)/i; var regexp = /^https?:\/\/pastebin\.com\/([^.?]+)/i;
@ -496,6 +498,7 @@ plugins.factory('userPlugins', function() {
} }
}); });
/*
var tweetPlugin = new UrlPlugin('Tweet', function(url) { var tweetPlugin = new UrlPlugin('Tweet', function(url) {
var regexp = /^https?:\/\/twitter\.com\/(?:#!\/)?(\w+)\/status(?:es)?\/(\d+)/i; var regexp = /^https?:\/\/twitter\.com\/(?:#!\/)?(\w+)\/status(?:es)?\/(\d+)/i;
var match = url.match(regexp); var match = url.match(regexp);
@ -520,6 +523,7 @@ plugins.factory('userPlugins', function() {
}; };
} }
}); });
*/
/* /*
* Vine plugin * Vine plugin
@ -540,7 +544,7 @@ plugins.factory('userPlugins', function() {
}); });
return { return {
plugins: [youtubePlugin, dailymotionPlugin, allocinePlugin, imagePlugin, videoPlugin, audioPlugin, spotifyPlugin, cloudmusicPlugin, googlemapPlugin, asciinemaPlugin, yrPlugin, gistPlugin, pastebinPlugin, giphyPlugin, tweetPlugin, vinePlugin] plugins: [youtubePlugin, dailymotionPlugin, allocinePlugin, imagePlugin, videoPlugin, audioPlugin, spotifyPlugin, cloudmusicPlugin, googlemapPlugin, asciinemaPlugin, yrPlugin, pastebinPlugin, giphyPlugin, vinePlugin]
}; };

@ -134,6 +134,7 @@ describe('filter', function() {
plugins); plugins);
})); }));
/*
it('should recognize gists', inject(function(plugins) { it('should recognize gists', inject(function(plugins) {
expectTheseMessagesToContain([ expectTheseMessagesToContain([
'https://gist.github.com/lorenzhs/e8c1a7d56fa170320eb8', 'https://gist.github.com/lorenzhs/e8c1a7d56fa170320eb8',
@ -142,6 +143,7 @@ describe('filter', function() {
'Gist', 'Gist',
plugins); plugins);
})); }));
*/
it('should recognize pastebins', inject(function(plugins) { it('should recognize pastebins', inject(function(plugins) {
expectTheseMessagesToContain([ expectTheseMessagesToContain([
@ -160,6 +162,7 @@ describe('filter', function() {
plugins); plugins);
})); }));
/*
it('should recognize tweets', inject(function(plugins) { it('should recognize tweets', inject(function(plugins) {
expectTheseMessagesToContain([ expectTheseMessagesToContain([
'https://twitter.com/DFB_Team_EN/statuses/488436782959448065', 'https://twitter.com/DFB_Team_EN/statuses/488436782959448065',
@ -167,6 +170,7 @@ describe('filter', function() {
'Tweet', 'Tweet',
plugins); plugins);
})); }));
*/
it('should recognize vines', inject(function(plugins) { it('should recognize vines', inject(function(plugins) {
expectTheseMessagesToContain([ expectTheseMessagesToContain([

Loading…
Cancel
Save