Fix links and embeds

Disable semi-broken plugins
Lorenz Hübschle-Schneider 11 years ago
parent 4e6cd976e2
commit 9976926c2e
  1. 5
      index.html
  2. 9
      js/filters.js
  3. 10
      js/plugins.js
  4. 6
      test/unit/plugins.js

@ -204,8 +204,7 @@
</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' | 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">
@ -260,7 +259,7 @@
<td class="prefix"><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></td><!-- <td class="prefix"><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></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' | DOMfilter:'irclinky' | DOMfilter:'inlinecolour' | DOMfilter:'mathjax':('.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' | linksForCordova | DOMfilter:'irclinky' | DOMfilter:'inlinecolour' | DOMfilter:'mathjax':('.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">

@ -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 (?:target="_[a-z]+"\s)?href="([^"]+)"/gi, "<a onClick=\"window.open('$1', '_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; }

@ -278,8 +278,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
// TODO strip an existing dl=0 parameter // TODO strip an existing dl=0 parameter
@ -400,6 +400,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) {
var regexp = /^https:\/\/gist\.github.com\/[^.?]+/i; var regexp = /^https:\/\/gist\.github.com\/[^.?]+/i;
@ -421,6 +422,7 @@ plugins.factory('userPlugins', function() {
}; };
} }
}); });
*/
/* match giphy links and display the assocaited gif images /* match giphy links and display the assocaited gif images
* sample input: http://giphy.com/gifs/eyes-shocked-bird-feqkVgjJpYtjy * sample input: http://giphy.com/gifs/eyes-shocked-bird-feqkVgjJpYtjy
@ -445,6 +447,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);
@ -469,6 +472,7 @@ plugins.factory('userPlugins', function() {
}; };
} }
}); });
*/
/* /*
* Vine plugin * Vine plugin
@ -489,7 +493,7 @@ plugins.factory('userPlugins', function() {
}); });
return { return {
plugins: [youtubePlugin, dailymotionPlugin, allocinePlugin, imagePlugin, videoPlugin, spotifyPlugin, cloudmusicPlugin, googlemapPlugin, asciinemaPlugin, yrPlugin, gistPlugin, giphyPlugin, tweetPlugin, vinePlugin] plugins: [youtubePlugin, dailymotionPlugin, allocinePlugin, imagePlugin, videoPlugin, spotifyPlugin, cloudmusicPlugin, googlemapPlugin, asciinemaPlugin, yrPlugin, giphyPlugin, vinePlugin]
}; };

@ -130,6 +130,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',
@ -138,7 +139,7 @@ describe('filter', function() {
'Gist', 'Gist',
plugins); plugins);
})); }));
*/
it('should recognize giphy gifs', inject(function(plugins) { it('should recognize giphy gifs', inject(function(plugins) {
expectTheseMessagesToContain([ expectTheseMessagesToContain([
'https://giphy.com/gifs/eyes-shocked-bird-feqkVgjJpYtjy/', 'https://giphy.com/gifs/eyes-shocked-bird-feqkVgjJpYtjy/',
@ -147,7 +148,7 @@ describe('filter', function() {
'Giphy', 'Giphy',
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',
@ -155,6 +156,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