From 5ee19155669c1248d5ea9a2613cbd2eb5e478b3d Mon Sep 17 00:00:00 2001 From: Jochen Topf Date: Sat, 14 Mar 2015 11:07:38 +0100 Subject: Extend "Characters in keys" report. Now has tabs for all classifications. --- web/i18n/de.yml | 80 ++++++++++++++++++++------- web/i18n/en.yml | 74 ++++++++++++++++++------- web/i18n/es.yml | 4 +- web/i18n/fr.yml | 4 +- web/i18n/hu.yml | 4 +- web/i18n/pl.yml | 4 +- web/i18n/pt-BR.yml | 4 +- web/i18n/pt.yml | 4 +- web/i18n/ru.yml | 4 +- web/i18n/uk.yml | 4 +- web/i18n/vi.yml | 4 +- web/lib/api/v4/keys.rb | 8 ++- web/views/reports/characters_in_keys.erb | 51 +++++++++-------- web/viewsjs/reports/characters_in_keys.js.erb | 45 +++------------ 14 files changed, 174 insertions(+), 120 deletions(-) diff --git a/web/i18n/de.yml b/web/i18n/de.yml index 9659510..7060ecd 100644 --- a/web/i18n/de.yml +++ b/web/i18n/de.yml @@ -479,9 +479,11 @@ reports: characters_in_keys: name: Zeichen in Keys intro: | - Alle gültigen Unicode-Zeichen dürfen in OSM-Keys vorkommen. Typischerweise - werden aber nur Kleinbuchstaben (a-z) und der Unterstrich (_) benutzt. Manchmal - kommt dazu der Doppelpunkt (:) als Trennzeichen. + Alle gültigen Unicode-Zeichen dürfen in OSM-Keys vorkommen. + Typischerweise werden aber nur Kleinbuchstaben (a-z) und der + Unterstrich (_) benutzt. Manchmal kommt dazu der Doppelpunkt (:) + als Trennzeichen. Dieser Report teilt alle Keys nach den Zeichen, + die darin benutzt werden, in Kategorien ein. statistics: tab: Statistik title: Statistik-Übersicht @@ -491,32 +493,70 @@ reports: plain: Nur lateinische Kleinbuchstaben (a bis z) und Unterstrich (_), erstes und letztes Zeichen sind Buchstaben. colon: Wie A, aber mit einem oder mehreren Doppelpunkten (:). letters: Wie B, aber mit Großbuchstaben oder Buchstaben aus anderen Alphabeten. - space: Wie C, aber mit mindestens einem Whitespace-Zeichen (Leerzeichen, Tabulator, Neue Zeile, Wagenrücklauf, oder aus anderen Alphabeten) - problem: Wie C, enthält aber die möglicherweise problematischen Zeichen =+/&<>;'"?%#@\,. + space: Key mit mindestens einem Whitespace-Zeichen (Leerzeichen, Tabulator, Neue Zeile, Wagenrücklauf, oder aus anderen Alphabeten). + problem: Key enthält möglicherweise problematische Zeichen =+/&<>;'"?%#@\,. rest: Alles andere. total: Summe - whitespace: + plain: + tab: Einfach + title: Einfache keys + intro: | +

Keys, die nur lateinische Kleinbuchstaben (a bis z) und + den Unterstrich (_) enthalten. Das + erste und letzte Zeichen müssen Buchstaben sein. Die meisten + einfachen Keys sollten in diese Kategorie fallen.

+ colon: + tab: Doppelpunkt + title: Keys mit Doppelpunkt + intro: | +

Keys, die einen oder mehrere Doppelpunkte (:) enthalten zusätzlich zu lateinischen + Kleinbuchstaben (a bis z) und dem Unterstrich (_). Der Doppelpunkt wird oft als + Trennzeichen für eine Hierarchie von "Unter-Keys" verwendet.

+ letters: + tab: Buchstaben + title: Keys mit Großbuchstaben und Buchstaben aus anderen Alphabeten. + intro: | +

Kleinbuchstaben aus dem lateinischen Alphabet werden für + Keys üblicherweise vorgezogen. Manchmal werden aber auch + Großbuchstaben benutzt (z.B. für bekannte Abkürzungen) oder + Buchstaben aus anderen Alphabeten (z.B. für Keys, die nur in + einem Gebiet relevant sind, wo dieses Alphabet üblicherweise + benutzt wird).

+ space: tab: Leerzeichen title: Keys mit Leerzeichen intro: | -

Keys, die Whitespace-Zeichen (Leerzeichen, Tabulator, Neue Zeile, - Wagenrücklauf, oder aus anderen Alphabeten) enthalten.
- Leerräume in Keys können (da sie nicht sichtbar sind) verwirrend sein, - besonders am Anfang und am Ende der Keys. Normalerweise sollte - stattdessen ein Unterstrich (_) verwenden werden.

- problematic: +

Keys, die Whitespace-Zeichen (Leerzeichen, Tabulator, Neue + Zeile, Wagenrücklauf, oder aus anderen Alphabeten) enthalten. + Leerräume in Keys können (da sie nicht sichtbar sind) + verwirrend sein, besonders am Anfang und am Ende der Keys. + Normalerweise sollte das Whitespace entfernt oder stattdessen + ein Unterstrich (_) verwenden + werden.

+ problem: tab: Problematisch title: Keys mit möglicherweise problematischen Zeichen intro: |

Keys mit möglicherweise problematischen Zeichen: =+/&<>;'"?%#@\, und Control-Zeichen. Diese Zeichen - können problematisch sein, weil sie in verschiedenen Programmiersprachen - zum "Zitieren" von Zeichenketten verwendet werden oder weil sie in - XML, HTML, URLs oder anderen Zusammenhängen besondere Bedeutung - haben. Das Gleichheitszeichen (=) wird bei OSM häufig als Trennzeichen - zwischen Tag Keys und Values benutzt.
- Keys, die in dieser Liste erscheinen, sind nicht unbedingt falsch. In - vielen Fällen sind sie aber das Ergebnis eines Fehlers.

+ class="char">=+/&<>;'"?%#@\, und + Control-Zeichen. Diese Zeichen können problematisch sein, weil + sie in verschiedenen Programmiersprachen zum "Zitieren" von + Zeichenketten verwendet werden oder weil sie in XML, HTML, URLs + oder anderen Zusammenhängen besondere Bedeutung haben. Das + Gleichheitszeichen (=) wird bei OSM + häufig als Trennzeichen zwischen Tag Keys und Values + benutzt.
Keys, die in dieser Liste erscheinen, sind nicht + unbedingt falsch. In vielen Fällen sind sie aber das Ergebnis + eines Fehlers.

+ rest: + tab: Sonstige + title: Alle anderen Keys + intro: | +

Keys, die in keine der anderen Kategorien passen.

database_statistics: name: Datenbank-Statistik objects_in_db: Anzahl Objekte in der Datenbank diff --git a/web/i18n/en.yml b/web/i18n/en.yml index 74d1fee..9536e49 100644 --- a/web/i18n/en.yml +++ b/web/i18n/en.yml @@ -459,9 +459,10 @@ reports: characters_in_keys: name: Characters in keys intro: | - Any valid Unicode character can appear in an OSM key but usually only lower - case latin letters (a-z) and the underscore (_) are used. Sometimes the colon - (:) is added as a separator character. + Any valid Unicode character can appear in an OSM key but usually + only lower case latin letters (a-z) and the underscore (_) are + used. The colon (:) is often used as a separator character. This + report categorizes all keys according the the characters they use. statistics: tab: Statistics title: Statistics overview @@ -471,33 +472,66 @@ reports: plain: Only latin lowercase letters (a to z) and underscore (_), first and last characters are letters. colon: Like A but with one or more colons (:) inside. letters: Like B but with uppercase latin letters or letters from other alphabets. - space: Like C but contains at least one whitespace character (space, tab, new line, carriage return, or from other alphabets). - problem: Like C but contains possibly problematic characters =+/&<>;'"?%#@\,. + space: At least one whitespace character (space, tab, new line, carriage return, or from other alphabets). + problem: Contains possibly problematic characters =+/&<>;'"?%#@\,. rest: Everything else. total: Total - whitespace: + plain: + tab: Plain + title: Plain keys + intro: | +

Keys containing only lowercase latin letters (a to z) and the + underscore (_). First and last + characters must be letters. Most simple keys should fall into + this category.

+ colon: + tab: Colon + title: Keys with colon + intro: | +

Keys that have one or more colon (:) characters inside in addition to the + letters (a to z) and underscores (_). The colon is often used as a hierarchy + separator character.

+ letters: + tab: Letters + title: Keys with uppercase letters or letters from other scripts + intro: | +

Lowercase letters from the latin script are usually + preferred for keys, but sometimes uppercase letters are used + (for instance for known abbreviations) or letters from other + scripts (for instance for keys only relevant to an area where + that script is used predominantly).

+ space: tab: Whitespace title: Keys with whitespace intro: | -

Keys that contain whitespace characters such as space, tab, new - line, carriage return, or whitespace characters from other - alphabets.
- Whitespace in keys can be confusing, especially at the - beginning or end of the key, because they are invisible. Generally - the underscore (_) should be used instead.

- problematic: +

Keys that contain whitespace characters such as space, tab, + new line, carriage return, or whitespace characters from other + alphabets. Whitespace in keys can be confusing, especially at + the beginning or end of the key, because they are invisible. + Generally the whitespace should be removed or the underscore + (_) used instead.

+ problem: tab: Problematic title: Keys with possibly problematic characters intro: |

Keys that contain possibly problematic characters: =+/&<>;'"?%#@\, or control - characters. These characters - can be problematic, because they are used to quote strings in - different programming languages or have special meanings in XML, HTML, - URLs, and other places. The equal sign is used often as separator - between tag keys and values.
- Keys that appear in this list are not necessarily wrong though. But - in many cases they are just results of some error.

+ characters. These characters can be problematic, because they + are used to quote strings in different programming languages or + have special meanings in XML, HTML, URLs, and other places. The + equal sign is used often as separator between tag keys and + values. Keys that appear in this list are not necessarily wrong + though. But in many cases they are just results of some error + and should be fixed.

+ rest: + tab: Rest + title: All other keys + intro: | +

Keys that don't fit in any of the other categories.

database_statistics: name: Database statistics objects_in_db: Number of objects in the database diff --git a/web/i18n/es.yml b/web/i18n/es.yml index 3dc39e7..1faa1ba 100644 --- a/web/i18n/es.yml +++ b/web/i18n/es.yml @@ -465,7 +465,7 @@ reports: problem: Como C pero contiene caracteres posiblemente problemáticos =+/&<>;'"?%#@\,. rest: Todo lo demás. total: Total - whitespace: + space: tab: Whitespace title: Claves con espacios en blanco intro: | @@ -475,7 +475,7 @@ reports: Espacio en blanco en las claves pueden ser confusos, especialmente al principio o al final de la clave, porque son invisibles. Generalmente puede usarse el guión abajo (_) en su lugar.

- problematic: + problem: tab: Problemático title: Claves con caracteres posiblemente problemáticos intro: | diff --git a/web/i18n/fr.yml b/web/i18n/fr.yml index 80b2b3d..48511a6 100644 --- a/web/i18n/fr.yml +++ b/web/i18n/fr.yml @@ -466,7 +466,7 @@ reports: problem: Comme la règle C mais peut contenir des caractères problématiques =+/&<>;'"?%#@\,. rest: Toutes les autres possibilités. total: Total - whitespace: + space: tab: Espaces title: Clés contenant des espaces intro: | @@ -476,7 +476,7 @@ reports: Les espaces dans les clés sont sources d'erreur, en particulier au début ou la fin de la clé, car ils sont invisibles. Généralement le caractère de soulignement (_) devrait être utilisé à la place.

- problematic: + problem: tab: Problématiques title: Clés avec des caractères potentiellement problématiques intro: | diff --git a/web/i18n/hu.yml b/web/i18n/hu.yml index 4ef92f1..ead6998 100644 --- a/web/i18n/hu.yml +++ b/web/i18n/hu.yml @@ -347,9 +347,9 @@ reports: problem: Mint C, de tartalmaz olyan karaktereket, amik problémát okozhatnak =+/&<>;'"?%#@\,. rest: Bármi más. total: Összes - whitespace: + space: tab: Szököz title: Szóközt tartalmazó kulcsok - problematic: + problem: tab: Problémásak title: Problémás karaktereket tartalmazó kulcsok diff --git a/web/i18n/pl.yml b/web/i18n/pl.yml index d7e78b8..97c5e9c 100644 --- a/web/i18n/pl.yml +++ b/web/i18n/pl.yml @@ -349,13 +349,13 @@ reports: problem: Jak w C, ale zawierające problematyczne znaki =+/&<>;'"?%#@\,. rest: Wszystko pozostałe. total: Razem - whitespace: + space: tab: Znaki niedrukowalne title: Klucze ze znakami niedrukowalnymi intro: |

Klucze zawierające znaki niedrukowalne takie jak spacje, tabulacje, nowe linie, znak powrotu do początku linii, albo z innych alfabetów.
Znaki niedrukowalne w kluczach mogą być dezorientujące, zwłaszcza jeśli znajdują się na początku albo na końcu, gdyż są niewidoczne. Generalnie powinno się używać zamiast nich podkreślnika (_).

- problematic: + problem: tab: Problematyczne title: Klucze z potencjalnie problematycznymi znakami intro: | diff --git a/web/i18n/pt-BR.yml b/web/i18n/pt-BR.yml index f6e0386..e9be434 100644 --- a/web/i18n/pt-BR.yml +++ b/web/i18n/pt-BR.yml @@ -393,10 +393,10 @@ reports: characters_in_keys: rest: Todo o resto. total: Total - whitespace: + space: tab: Espaço em branco title: Chaves com espaços em branco - problematic: + problem: tab: Problemático title: Chaves com caracteres possivelmente problemáticos database_statistics: diff --git a/web/i18n/pt.yml b/web/i18n/pt.yml index 8773cf2..41ccec4 100644 --- a/web/i18n/pt.yml +++ b/web/i18n/pt.yml @@ -393,10 +393,10 @@ reports: characters_in_keys: rest: Todo o resto. total: Total - whitespace: + space: tab: Espaço em branco title: Chaves com espaços em branco - problematic: + problem: tab: Problemático title: Chaves com caracteres possivelmente problemáticos database_statistics: diff --git a/web/i18n/ru.yml b/web/i18n/ru.yml index 97cfbfb..358a377 100644 --- a/web/i18n/ru.yml +++ b/web/i18n/ru.yml @@ -327,7 +327,7 @@ reports: problem: Как в C, но содержит потенциально проблемные символы =+/&<>;'"?%#@\,. rest: Все остальные. total: Всего - whitespace: + space: tab: Пробелы title: Ключи с пробелами и прочим intro: | @@ -336,7 +336,7 @@ reports: Такие разделители могут приводить к путанице, особенно если они находятся в начале или конце ключа и фактически невидимы. Обычно в качестве разделителя используют символ подчёркивания (_).

- problematic: + problem: tab: Проблемные title: Ключи с возможно проблемными символами intro: | diff --git a/web/i18n/uk.yml b/web/i18n/uk.yml index 59b0a31..3e74113 100644 --- a/web/i18n/uk.yml +++ b/web/i18n/uk.yml @@ -327,7 +327,7 @@ reports: problem: Як в C, але містить потенційно проблемні символи =+/&<>;'"?%#@\,. rest: Усі інші. total: Всього - whitespace: + space: tab: Пробіли title: Ключі з пробілами та іншим intro: | @@ -336,7 +336,7 @@ reports: Такі роздільники можуть призводити до плутанини, особливо якщо вони знаходяться на початку або кінці ключа і фактично невидимі. Зазвичай як роздільник використовують символ підкреслення (_).

- problematic: + problem: tab: Проблемні title: Ключі з можливо проблемними символами intro: | diff --git a/web/i18n/vi.yml b/web/i18n/vi.yml index 17947a5..a242ec6 100644 --- a/web/i18n/vi.yml +++ b/web/i18n/vi.yml @@ -344,7 +344,7 @@ reports: problem: Giống C nhưng có các ký tự có thể gây vấn đề =+/&<>;'"?%#@\,. rest: Những cái gì khác. total: Tổng số - whitespace: + space: tab: Khoảng cách title: Chìa khóa có khoảng cách intro: | @@ -353,7 +353,7 @@ reports: Khoảng cách trong chìa khóa có thể gây nhầm lẫn, nhất là tại đầu hoặc cuối chìa khóa, vì không nhìn thấy nó được. Nói chung, dấu gạch dưới (_) nên được dùng thay thế.

- problematic: + problem: tab: Gây vấn đề title: Chìa khóa có ký tự có thể gây vấn đề intro: | diff --git a/web/lib/api/v4/keys.rb b/web/lib/api/v4/keys.rb index e4f4c99..f628a5b 100644 --- a/web/lib/api/v4/keys.rb +++ b/web/lib/api/v4/keys.rb @@ -2,8 +2,12 @@ class Taginfo < Sinatra::Base @@filters = { - :characters_space => { :expr => "characters='space'", :doc => 'Only show keys with spaces.' }, - :characters_problematic => { :expr => "characters='problem'", :doc => 'Only show keys with problematic characters.' }, + :characters_plain => { :expr => "characters='plain'", :doc => 'Category A: Only show keys with latin lowercase letters (a to z) or underscore (_), first and last characters must be letters.' }, + :characters_colon => { :expr => "characters='colon'", :doc => 'Category B: Only show keys like category A but with one ore more colons (:) inside.' }, + :characters_letters => { :expr => "characters='letters'", :doc => 'Category C: Only show keys like category B but with uppercase latin letters or letters from other scripts.' }, + :characters_space => { :expr => "characters='space'", :doc => 'Category D: Only show keys with at least one whitespace character (space, tab, new line, carriage return, or from other scripts).' }, + :characters_problem => { :expr => "characters='problem'", :doc => 'Category E: Only show keys with problematic characters.' }, + :characters_rest => { :expr => "characters='rest'", :doc => 'Category F: Only show keys not fitting in category A through E.' }, :in_wiki => { :expr => "in_wiki=1", :doc => 'Only show keys that appear in the wiki.' }, :not_in_db => { :expr => "count_all=0", :doc => 'Only show keys that do not appear in the database.' } } diff --git a/web/views/reports/characters_in_keys.erb b/web/views/reports/characters_in_keys.erb index 7d8eaf3..87349bf 100644 --- a/web/views/reports/characters_in_keys.erb +++ b/web/views/reports/characters_in_keys.erb @@ -1,3 +1,14 @@ +<% +categories = [ + { category: 'A', name: 'plain', color: '#2ca02c' }, + { category: 'B', name: 'colon', color: '#98df8a' }, + { category: 'C', name: 'letters', color: '#dbdb8d' }, + { category: 'D', name: 'space', color: '#d62727' }, + { category: 'E', name: 'problem', color: '#ff9896' }, + { category: 'F', name: 'rest', color: '#aec7e8' }, +] +%> +

<%= h(t.reports.characters_in_keys.name) %>

<%= h(t.reports.characters_in_keys.intro) %>

@@ -5,8 +16,10 @@

<%= h(t.reports.characters_in_keys.statistics.title) %>

@@ -18,39 +31,31 @@ <%= h(t.reports.characters_in_keys.statistics.fraction) %> <%= h(t.reports.characters_in_keys.statistics.characters) %> -<% letter='A' - colors = { :A => '#2ca02c', :B => '#98df8a', :C => '#dbdb8d', :D => '#d62728', :E => '#ff9896', :F => '#aec7e8' } - %w(plain colon letters space problem rest).each_with_index do |type, n| c = (n%2!=0) ? ' even' : '' %> +<% categories.each_with_index do |category, n| c = (n%2!=0) ? ' even' : '' %> - <%= letter %> - <%= @db.stats('characters_in_keys_' + type) %> - <%= sprintf '%.2f', @db.stats('characters_in_keys_' + type) * 100.0 / @db.stats('num_keys') %>% - <%= t.reports.characters_in_keys.statistics.characters_in_keys[type] %> + <%= category[:category] %> + <%= @db.stats('characters_in_keys_' + category[:name]) %> + <%= sprintf '%.2f', @db.stats('characters_in_keys_' + category[:name]) * 100.0 / @db.stats('num_keys') %>% + <%= t.reports.characters_in_keys.statistics.characters_in_keys[category[:name]] %> -<% letter = letter.succ; end %> +<% end %> <%= @db.stats('num_keys') %> 100% - <%= t.reports.characters_in_keys.statistics.characters_in_keys.total %> + <%= h(t.reports.characters_in_keys.statistics.characters_in_keys.total) %>
-
-

<%= h(t.reports.characters_in_keys.whitespace.title) %>

+<% categories.map{ |c| c[:name] }.each do |category| %> +
+

<%= h(t.reports.characters_in_keys[category].title) %>

- <%= t.reports.characters_in_keys.whitespace.intro %> + <%= t.reports.characters_in_keys[category].intro %>
- -
-
-
-

<%= h(t.reports.characters_in_keys.problematic.title) %>

-
- <%= t.reports.characters_in_keys.problematic.intro %> -
- +
+<% end %>
<% javascript_for(:d3) %> diff --git a/web/viewsjs/reports/characters_in_keys.js.erb b/web/viewsjs/reports/characters_in_keys.js.erb index 3dbc7c0..4d65201 100644 --- a/web/viewsjs/reports/characters_in_keys.js.erb +++ b/web/viewsjs/reports/characters_in_keys.js.erb @@ -2,41 +2,12 @@ osm = @trans.t.osm misc = @trans.t.misc %> -var create_flexigrid_for = { - whitespace: function() { - create_flexigrid('grid-whitespace', { - url: '/api/4/keys/all?filter=characters_space&include=prevalent_values', - colModel: [ - { display: '<%= h(osm.key) %>', name: 'key', width: 250, sortable: true }, - { display: ' <%= h(osm.objects) %>', name: 'count_all', width: 150, sortable: true, align: 'center' }, - { display: '<%= h(osm.users) %>', name: 'users_all', width: 44, sortable: true, align: 'right' }, - { display: 'Wiki', name: 'in_wiki', width: 20, sortable: true, align: 'center' }, - { display: '<%= h(osm.values) %>', name: 'values_all', width: 70, sortable: true, align: 'right' }, - { display: '<%= h(misc.prevalent_values) %>', name: 'prevalent_values', width: 600, sortable: true } - ], - searchitems: [ - { display: '<%= h(osm.key) %>', name: 'key' } - ], - sortname: 'count_all', - sortorder: 'desc', - preProcess: function(data) { - data.rows = jQuery.map(data.data, function(row, i) { - return { 'cell': [ - link_to_key(row.key), - fmt_value_with_percent(row.count_all, row.count_all_fraction), - fmt_with_ts(row.users_all), - fmt_checkmark(row.in_wiki), - fmt_with_ts(row.values_all), - fmt_prevalent_value_list(row.key, row.prevalent_values) - ] }; - }); - return data; - } - }); - }, - problematic: function() { - create_flexigrid('grid-problematic', { - url: '/api/4/keys/all?filter=characters_problematic&include=prevalent_values', +var create_flexigrid_for = {}; + +['plain', 'colon', 'letters', 'space', 'problem', 'rest'].forEach(function(category) { + create_flexigrid_for[category] = function() { + create_flexigrid('grid-' + category, { + url: '/api/4/keys/all?filter=characters_' + category + '&include=prevalent_values', colModel: [ { display: '<%= h(osm.key) %>', name: 'key', width: 250, sortable: true }, { display: ' <%= h(osm.objects) %>', name: 'count_all', width: 150, sortable: true, align: 'center' }, @@ -64,8 +35,8 @@ var create_flexigrid_for = { return data; } }); - } -}; + }; +}); function page_init() { up = function() { window.location = '/reports'; }; -- cgit v1.2.3