Merge branch 'master' into gh-pages

gh-pages
Lorenz Hübschle-Schneider 6 years ago
commit 04bcf37ba0
  1. 6
      css/glowingbear.css
  2. 5
      css/themes/dark.css
  3. 2
      index.html
  4. 26
      js/filters.js
  5. 4
      package.json
  6. 41
      test/unit/filters.js

@ -926,3 +926,9 @@ img.emojione {
[ng\:cloak], [ng-cloak], [data-ng-cloak], [x-ng-cloak], .ng-cloak, .x-ng-cloak { [ng\:cloak], [ng-cloak], [data-ng-cloak], [x-ng-cloak], .ng-cloak, .x-ng-cloak {
display: none !important; display: none !important;
} }
code {
padding: 0px 2px;
color: #444;
border: 1pt solid #444;
}

@ -2114,6 +2114,11 @@ button.close:hover {
font-weight: bold; font-weight: bold;
} }
code {
background-color: #444;
color: #fff;
}
/* */ /* */
/* Mobile layout */ /* Mobile layout */
/* */ /* */

@ -317,7 +317,7 @@ npm run build-electron-{windows, darwin, linux}</pre>
<td class="prefix"><span ng-class="::{'repeated-prefix': bufferline.prefixtext==bufferlines[$index-1].prefixtext}"><a ng-click="addMention(bufferline)"><span class="hidden-bracket" ng-if="::(bufferline.showHiddenBrackets)">&lt;</span><span ng-repeat="part in ::bufferline.prefix" ng-class="::part.classes" ng-bind="::part.text|prefixlimit:25"></span><span class="hidden-bracket" ng-if="::(bufferline.showHiddenBrackets)">&gt;</span></a></span></td><!-- <td class="prefix"><span ng-class="::{'repeated-prefix': bufferline.prefixtext==bufferlines[$index-1].prefixtext}"><a ng-click="addMention(bufferline)"><span class="hidden-bracket" ng-if="::(bufferline.showHiddenBrackets)">&lt;</span><span ng-repeat="part in ::bufferline.prefix" ng-class="::part.classes" ng-bind="::part.text|prefixlimit:25"></span><span class="hidden-bracket" ng-if="::(bufferline.showHiddenBrackets)">&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:'emojify':settings.enableJSEmoji | 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 | conditionalLinkify:part.classes.includes('cof-chat_host') | DOMfilter:'codify' | DOMfilter:'irclinky' | DOMfilter:'emojify':settings.enableJSEmoji | 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">

@ -59,6 +59,17 @@ weechat.filter('inlinecolour', function() {
}; };
}); });
// Calls the 'linky' filter unless the disable flag is set. Useful for things like join/quit messages,
// so you don't accidentally click a mailto: on someone's hostmask.
weechat.filter('conditionalLinkify', ['$filter', function($filter) {
return function(text, disable) {
if (!text || disable) {
return text;
}
return $filter('linky')(text, '_blank', {rel:'noopener noreferrer'});
};
}]);
// apply a filter to an HTML string's text nodes, and do so with not exceedingly terrible performance // apply a filter to an HTML string's text nodes, and do so with not exceedingly terrible performance
weechat.filter('DOMfilter', ['$filter', '$sce', function($filter, $sce) { weechat.filter('DOMfilter', ['$filter', '$sce', function($filter, $sce) {
// To prevent nested anchors, we need to know if a filter is going to create them. // To prevent nested anchors, we need to know if a filter is going to create them.
@ -226,4 +237,19 @@ weechat.filter('prefixlimit', function() {
}; };
}); });
weechat.filter('codify', function() {
return function(text) {
// The groups of this regex are:
// 1. Start of line or space, to prevent codifying weird`stuff` like this
// 2. Opening single or triple backticks (not 2, not more than 3)
// 3. The code block, does not start with another backtick, non-greedy expansion
// 4. The closing backticks, identical to group 2
var re = /(^|\s)(```|`)([^`].*?)\2/g;
return text.replace(re, function(match, ws, open, code) {
var rr = ws + '<span class="hidden-bracket">' + open + '</span><code>' + code + '</code><span class="hidden-bracket">' + open + '</span>';
return rr;
});
};
});
})(); })();

@ -7,12 +7,12 @@
"main": "electron-main.js", "main": "electron-main.js",
"license": "GPLv3", "license": "GPLv3",
"devDependencies": { "devDependencies": {
"bower": "^1.8", "bower": "^1.8.8",
"electron-packager": "^12.2.0", "electron-packager": "^12.2.0",
"http-server": "^0.11", "http-server": "^0.11",
"jasmine-core": "^3.1", "jasmine-core": "^3.1",
"jshint": "^2.9.6", "jshint": "^2.9.6",
"karma": "^3.1.1", "karma": "^4.2.0",
"karma-jasmine": "~1.1", "karma-jasmine": "~1.1",
"karma-junit-reporter": "^1.2", "karma-junit-reporter": "^1.2",
"karma-phantomjs-launcher": "^1.0.0", "karma-phantomjs-launcher": "^1.0.0",

@ -92,4 +92,45 @@ describe('Filters', function() {
// I.e. if we ever got this far, the bug is fixed. // I.e. if we ever got this far, the bug is fixed.
})); }));
}); });
describe('codify', function() {
it('should not mess up text', inject(function(codifyFilter) {
expect(codifyFilter('foo')).toEqual('foo');
}));
it('should codify single snippets', inject(function(codifyFilter) {
expect(codifyFilter('z `foo` z')).toEqual('z <span class="hidden-bracket">`</span><code>foo</code><span class="hidden-bracket">`</span> z');
expect(codifyFilter('z `a` z')).toEqual('z <span class="hidden-bracket">`</span><code>a</code><span class="hidden-bracket">`</span> z');
expect(codifyFilter('z ```foo``` z')).toEqual('z <span class="hidden-bracket">```</span><code>foo</code><span class="hidden-bracket">```</span> z');
}));
it('should codify multiple snippets', inject(function(codifyFilter) {
expect(codifyFilter('z `foo` z `bar` `baz`')).toEqual('z <span class="hidden-bracket">`</span><code>foo</code><span class="hidden-bracket">`</span> z <span class="hidden-bracket">`</span><code>bar</code><span class="hidden-bracket">`</span> <span class="hidden-bracket">`</span><code>baz</code><span class="hidden-bracket">`</span>');
}));
it('should not codify empty snippets', inject(function(codifyFilter) {
expect(codifyFilter('``')).toEqual('``');
}));
it('should not codify single backticks', inject(function(codifyFilter) {
expect(codifyFilter('foo`bar')).toEqual('foo`bar');
}));
it('should not codify double backticks', inject(function(codifyFilter) {
expect(codifyFilter('some ``non-code``')).toEqual('some ``non-code``');
}));
it('should not codify pseudo-fancy quotes', inject(function(codifyFilter) {
expect(codifyFilter('some ``fancy qoutes\'\'')).toEqual('some ``fancy qoutes\'\'');
}));
it('should not codify stuff in the middle of a word or URL', inject(function(codifyFilter) {
expect(codifyFilter('https://foo.bar/`wat`')).toEqual('https://foo.bar/`wat`');
expect(codifyFilter('Weird`ness`')).toEqual('Weird`ness`');
}));
});
}); });

Loading…
Cancel
Save