From 5e811636c859eb40487dd95995c329f5d6305e88 Mon Sep 17 00:00:00 2001 From: Simon Lydell Date: Mon, 12 Sep 2016 08:52:59 +0200 Subject: [PATCH] Improve `gB` UX If the page is _not_ blacklisted, everything stays the same. If the page _is_ blacklisted, all matching blacklist patterns are moved first and are delimited from all other patterns with several spaces. There is also a new message for this case. --- extension/lib/commands.coffee | 25 +++++++++++++++++++------ extension/lib/utils.coffee | 11 +++++++++++ extension/locale/de/vimfx.properties | 3 ++- extension/locale/en-US/vimfx.properties | 3 ++- extension/locale/es/vimfx.properties | 3 ++- extension/locale/fr/vimfx.properties | 3 ++- extension/locale/id/vimfx.properties | 3 ++- extension/locale/it/vimfx.properties | 3 ++- extension/locale/ja/vimfx.properties | 3 ++- extension/locale/nl/vimfx.properties | 3 ++- extension/locale/pt-BR/vimfx.properties | 3 ++- extension/locale/ru/vimfx.properties | 3 ++- extension/locale/sv-SE/vimfx.properties | 3 ++- extension/locale/zh-CN/vimfx.properties | 3 ++- extension/locale/zh-TW/vimfx.properties | 3 ++- 15 files changed, 56 insertions(+), 19 deletions(-) diff --git a/extension/lib/commands.coffee b/extension/lib/commands.coffee index 159b27d..a160537 100644 --- a/extension/lib/commands.coffee +++ b/extension/lib/commands.coffee @@ -890,18 +890,31 @@ commands.edit_blacklist = ({vim}) -> location = new vim.window.URL(url) domain = location.host or location.href newPattern = "*#{domain}*" + delimiter = ' ' + blacklistString = prefs.get('blacklist') - blacklist = prefs.get('blacklist') - {parsed} = parsePrefs.parseSpaceDelimitedString(blacklist) - filteredList = parsed.filter((pattern) -> pattern != newPattern) - newBlacklist = [newPattern, filteredList...].join(' ') + if vim._isBlacklisted(url) + blacklist = parsePrefs.parseSpaceDelimitedString(blacklistString).parsed + [matching, nonMatching] = utils.partition(blacklist, (string, index) -> + return vim.options.blacklist[index].test(url) + ) + newBlacklistString = " + #{matching.join(delimiter)}\ + #{delimiter.repeat(7)}\ + #{nonMatching.join(delimiter)} + " + extraMessage = translate('pref.blacklist.extra.is_blacklisted') + else + newBlacklistString = "#{newPattern}#{delimiter}#{blacklistString}" + extraMessage = translate('pref.blacklist.extra.added', newPattern) message = """ #{translate('pref.blacklist.title')}: #{translate('pref.blacklist.desc')} - #{translate('pref.blacklist.extra', newPattern)} + #{extraMessage} """ - vim._modal('prompt', [message, newBlacklist], (input) -> + + vim._modal('prompt', [message, newBlacklistString.trim()], (input) -> return if input == null # Just set the blacklist as if the user had typed it in the Add-ons Manager, # and let the regular pref parsing take care of it. diff --git a/extension/lib/utils.coffee b/extension/lib/utils.coffee index 1ebeb0a..60e3a75 100644 --- a/extension/lib/utils.coffee +++ b/extension/lib/utils.coffee @@ -624,6 +624,16 @@ interval = (window, interval, fn) -> nextTick = (window, fn) -> window.setTimeout((-> fn()) , 0) +partition = (array, fn) -> + matching = [] + nonMatching = [] + for item, index in array + if fn(item, index, array) + matching.push(item) + else + nonMatching.push(item) + return [matching, nonMatching] + regexEscape = (s) -> s.replace(/[|\\{}()[\]^$+*?.]/g, '\\$&') removeDuplicateChars = (string) -> removeDuplicates(string.split('')).join('') @@ -754,6 +764,7 @@ module.exports = { includes interval nextTick + partition regexEscape removeDuplicateChars removeDuplicates diff --git a/extension/locale/de/vimfx.properties b/extension/locale/de/vimfx.properties index cdde918..efd0d16 100644 --- a/extension/locale/de/vimfx.properties +++ b/extension/locale/de/vimfx.properties @@ -169,7 +169,8 @@ pref.ignore_keyboard_layout.desc=So tun, als ob die US-amerikanische QWERTY-Bele pref.blacklist.title=Schwarze Liste pref.blacklist.desc=Liste von URLs, für welche VimFX automatisch in the Ignoriermodus wechseln soll. Benütze Leerstellen as Trennzeichen und * als Platzhalter. The patterns must match the entire URL. -pref.blacklist.extra=%S has been added at the start. +pref.blacklist.extra.added=%S has been added at the start. +pref.blacklist.extra.is_blacklisted=The current URL is blacklisted. Matching patterns come first. pref.hints.chars.title=Zeichen für Hinweise pref.hints.chars.desc= diff --git a/extension/locale/en-US/vimfx.properties b/extension/locale/en-US/vimfx.properties index f0633d3..8bddf64 100644 --- a/extension/locale/en-US/vimfx.properties +++ b/extension/locale/en-US/vimfx.properties @@ -169,7 +169,8 @@ pref.ignore_keyboard_layout.desc=Pretend that the en-US QWERTY layout is always pref.blacklist.title=Blacklist pref.blacklist.desc=List of URL patterns where VimFx should automatically enter Ignore mode. Use spaces as delimiter and * as a wildcard. The patterns must match the entire URL. -pref.blacklist.extra=%S has been added at the start. +pref.blacklist.extra.added=%S has been added at the start. +pref.blacklist.extra.is_blacklisted=The current URL is blacklisted. Matching patterns come first. pref.hints.chars.title=Hint characters pref.hints.chars.desc=The set of characters for hint markers. Some prefer all uppercase, or numbers only. All other characters are used to filter by element text (case insensitively). diff --git a/extension/locale/es/vimfx.properties b/extension/locale/es/vimfx.properties index 56de2a7..7eee750 100644 --- a/extension/locale/es/vimfx.properties +++ b/extension/locale/es/vimfx.properties @@ -169,7 +169,8 @@ pref.ignore_keyboard_layout.desc=Presuponer siempre el uso de teclado QWERTY en- pref.blacklist.title=Lista negra pref.blacklist.desc=Lista de URLs donde VimFx debe entrar automáticamente en modo Ignorar. Use espacios como delimitador y * como comodín. The patterns must match the entire URL. -pref.blacklist.extra=%S has been added at the start. +pref.blacklist.extra.added=%S has been added at the start. +pref.blacklist.extra.is_blacklisted=The current URL is blacklisted. Matching patterns come first. pref.hints.chars.title=Caracteres de indicación pref.hints.chars.desc= diff --git a/extension/locale/fr/vimfx.properties b/extension/locale/fr/vimfx.properties index 12a9194..ecae3c2 100644 --- a/extension/locale/fr/vimfx.properties +++ b/extension/locale/fr/vimfx.properties @@ -169,7 +169,8 @@ pref.ignore_keyboard_layout.desc=Faire comme si le clavier était un clavier QWE pref.blacklist.title=Liste noire pref.blacklist.desc=Liste d'adresses pour lesquelles VimFx doit automatiquement entrer en mode Ignorer. Utilisez les espaces comme séparateurs et « * » comme joker. The patterns must match the entire URL. -pref.blacklist.extra=%S has been added at the start. +pref.blacklist.extra.added=%S has been added at the start. +pref.blacklist.extra.is_blacklisted=The current URL is blacklisted. Matching patterns come first. pref.hints.chars.title=Marqueurs de liens pref.hints.chars.desc= diff --git a/extension/locale/id/vimfx.properties b/extension/locale/id/vimfx.properties index a2982aa..4f0530a 100644 --- a/extension/locale/id/vimfx.properties +++ b/extension/locale/id/vimfx.properties @@ -169,7 +169,8 @@ pref.ignore_keyboard_layout.desc=Anggap layout en-US QWERTY selalu digunakan. pref.blacklist.title=Daftar Hitam pref.blacklist.desc=Daftar URL dimana VimFx harus masuk mode Abai secara otomatis. Gunakan spasi sebagai pemisah dan * sebagai wildcard. The patterns must match the entire URL. -pref.blacklist.extra=%S has been added at the start. +pref.blacklist.extra.added=%S has been added at the start. +pref.blacklist.extra.is_blacklisted=The current URL is blacklisted. Matching patterns come first. pref.hints.chars.title=Karakter Petunjuk pref.hints.chars.desc= diff --git a/extension/locale/it/vimfx.properties b/extension/locale/it/vimfx.properties index 22eee3f..bd76833 100644 --- a/extension/locale/it/vimfx.properties +++ b/extension/locale/it/vimfx.properties @@ -169,7 +169,8 @@ pref.ignore_keyboard_layout.desc=Fai finta che il layout en-US QWERTY sia sempre pref.blacklist.title=Lista nera pref.blacklist.desc=Lista di URL per cui VimFx deve impostare automatica la modalità Ignore. Utilizza gli spazi come delimitatore e il simbolo * come carattere jolly. The patterns must match the entire URL. -pref.blacklist.extra=%S has been added at the start. +pref.blacklist.extra.added=%S has been added at the start. +pref.blacklist.extra.is_blacklisted=The current URL is blacklisted. Matching patterns come first. pref.hints.chars.title=Caratteri di suggerimento pref.hints.chars.desc= diff --git a/extension/locale/ja/vimfx.properties b/extension/locale/ja/vimfx.properties index c86e07b..749aa07 100644 --- a/extension/locale/ja/vimfx.properties +++ b/extension/locale/ja/vimfx.properties @@ -169,7 +169,8 @@ pref.ignore_keyboard_layout.desc=いつもUS-QWERTYキーボードが使われ pref.blacklist.title=ブラックリスト pref.blacklist.desc=VimFxが自動的に無視モードに入るURLのリスト。スペースで区切り、*をワイルドカードに使えます The patterns must match the entire URL. -pref.blacklist.extra=%S has been added at the start. +pref.blacklist.extra.added=%S has been added at the start. +pref.blacklist.extra.is_blacklisted=The current URL is blacklisted. Matching patterns come first. pref.hints.chars.title=ヒント機能で使用する文字 pref.hints.chars.desc= diff --git a/extension/locale/nl/vimfx.properties b/extension/locale/nl/vimfx.properties index 1b1f006..bc648f5 100644 --- a/extension/locale/nl/vimfx.properties +++ b/extension/locale/nl/vimfx.properties @@ -169,7 +169,8 @@ pref.ignore_keyboard_layout.desc=Neem aan dat de toetsenbordindeling altijd en-U pref.blacklist.title=Zwarte lijst pref.blacklist.desc=Lijst van URLS waar VimFx automatisch negeermodus aan moet zetten. Gebruik spatie als scheiding en * als wildcard. The patterns must match the entire URL. -pref.blacklist.extra=%S has been added at the start. +pref.blacklist.extra.added=%S has been added at the start. +pref.blacklist.extra.is_blacklisted=The current URL is blacklisted. Matching patterns come first. pref.hints.chars.title=Gebruikte karakters pref.hints.chars.desc= diff --git a/extension/locale/pt-BR/vimfx.properties b/extension/locale/pt-BR/vimfx.properties index d462836..8dedf30 100644 --- a/extension/locale/pt-BR/vimfx.properties +++ b/extension/locale/pt-BR/vimfx.properties @@ -169,7 +169,8 @@ pref.ignore_keyboard_layout.desc=Simular que a disposição en-US QWERTY é semp pref.blacklist.title=Lista Negra pref.blacklist.desc=Lista de URLs que o VimFx deve automaticamente entrar em modo Ignorar. Use espaço como delimitador e * como curinga. The patterns must match the entire URL. -pref.blacklist.extra=%S has been added at the start. +pref.blacklist.extra.added=%S has been added at the start. +pref.blacklist.extra.is_blacklisted=The current URL is blacklisted. Matching patterns come first. pref.hints.chars.title=Caracteres de Sugestão pref.hints.chars.desc= diff --git a/extension/locale/ru/vimfx.properties b/extension/locale/ru/vimfx.properties index 8f8bd3a..3bec456 100644 --- a/extension/locale/ru/vimfx.properties +++ b/extension/locale/ru/vimfx.properties @@ -169,7 +169,8 @@ pref.ignore_keyboard_layout.desc=Считать, что всегда испол pref.blacklist.title=Стоп список pref.blacklist.desc=Список URL, где VimFx автоматически входит в режим игнорирования. Используйте пробелы в качестве разделителей, а * в качестве символа-джокера. The patterns must match the entire URL. -pref.blacklist.extra=%S has been added at the start. +pref.blacklist.extra.added=%S has been added at the start. +pref.blacklist.extra.is_blacklisted=The current URL is blacklisted. Matching patterns come first. pref.hints.chars.title=Символы на маркерах pref.hints.chars.desc= diff --git a/extension/locale/sv-SE/vimfx.properties b/extension/locale/sv-SE/vimfx.properties index 01f3b6e..610055d 100644 --- a/extension/locale/sv-SE/vimfx.properties +++ b/extension/locale/sv-SE/vimfx.properties @@ -169,7 +169,8 @@ pref.ignore_keyboard_layout.desc=Låtsas att en-US QWERTY-layouten alltid använ pref.blacklist.title=Svartlista pref.blacklist.desc=Lista med URL-mönster där VimFx automatiskt ska gå in i Ignoreringsläge. Använd mellanslag som avgränsare och * som wildcard. Mönstren måste matcha hela URL:en. -pref.blacklist.extra=%S har lagts till i början. +pref.blacklist.extra.added=%S har lagts till i början. +pref.blacklist.extra.is_blacklisted=Nuvarande URL är svartlistad. Matchande mönster kommer först. pref.hints.chars.title=Etikettstecken pref.hints.chars.desc= diff --git a/extension/locale/zh-CN/vimfx.properties b/extension/locale/zh-CN/vimfx.properties index dff1868..cdfdb09 100644 --- a/extension/locale/zh-CN/vimfx.properties +++ b/extension/locale/zh-CN/vimfx.properties @@ -169,7 +169,8 @@ pref.ignore_keyboard_layout.desc=假装总是使用美式标准键盘布局。 pref.blacklist.title=黑名单 pref.blacklist.desc=匹配下列 URL 时 VimFx 将自动进入忽略模式。使用空格作为界定符 * 作为通配符。 The patterns must match the entire URL. -pref.blacklist.extra=%S has been added at the start. +pref.blacklist.extra.added=%S has been added at the start. +pref.blacklist.extra.is_blacklisted=The current URL is blacklisted. Matching patterns come first. pref.hints.chars.title=提示符 pref.hints.chars.desc= diff --git a/extension/locale/zh-TW/vimfx.properties b/extension/locale/zh-TW/vimfx.properties index 06e44c6..be46031 100644 --- a/extension/locale/zh-TW/vimfx.properties +++ b/extension/locale/zh-TW/vimfx.properties @@ -169,7 +169,8 @@ pref.ignore_keyboard_layout.desc=假定總是使用美式 QWERTY 鍵盤佈局 pref.blacklist.title=黑名單 pref.blacklist.desc=在下列 URL 清單中 VimFx 自動進入忽略模式。(以空白分隔, * 作為萬用字元) The patterns must match the entire URL. -pref.blacklist.extra=%S has been added at the start. +pref.blacklist.extra.added=%S has been added at the start. +pref.blacklist.extra.is_blacklisted=The current URL is blacklisted. Matching patterns come first. pref.hints.chars.title=提示字元(Hint Chars) pref.hints.chars.desc=進入 Hints 模式時,用哪些符號進行標記。 -- 2.39.3