From f12a276c78b6175de6e864a9076f16f9ceaeaa7a Mon Sep 17 00:00:00 2001 From: ansuz Date: Fri, 13 Aug 2021 15:18:43 +0530 Subject: [PATCH] correct inconsistent capitalization of 'CryptPad' in markdown files. Add a rule to the translation linter to detect future inconsistencies. --- docs/ARCHITECTURE.md | 8 +- readme.md | 4 +- scripts/find-html-translations.js | 99 ---------------------- scripts/lint-translations.js | 131 ++++++++++++++++++++++++++++-- 4 files changed, 131 insertions(+), 111 deletions(-) delete mode 100644 scripts/find-html-translations.js diff --git a/docs/ARCHITECTURE.md b/docs/ARCHITECTURE.md index 0d1d94873..a4081e568 100644 --- a/docs/ARCHITECTURE.md +++ b/docs/ARCHITECTURE.md @@ -2,7 +2,7 @@ So you want to write a realtime collaborative application? This guide will focus on applications which require **multiple clients** to **collaboratively construct a single authoratative document**. -[XWiki-Labs](https://labs.xwiki.com/) has published an open source suite (called [Cryptpad](https://github.com/xwiki-labs/cryptpad)) of collaborative editors which employ end to end encryption. +[XWiki-Labs](https://labs.xwiki.com/) has published an open source suite (called [CryptPad](https://github.com/xwiki-labs/cryptpad)) of collaborative editors which employ end to end encryption. This guide will refer to the techniques used in the prototypes developed therein. Let's start with an overview of the components involved. @@ -75,7 +75,7 @@ Chainpad can handle out of order messages, but it performs best when its message By architecting your system such that all clients send to a server which then relays to other clients, you guarantee that a particular chain of patches is consistent between the participants of your session. -Cryptpad is capable of using a variety of data stores. +CryptPad is capable of using a variety of data stores. Which data store your instance employs can be [easily configured](https://github.com/xwiki-labs/cryptpad/blob/master/config.example.js). You simply need to write an adaptor which conforms to a simple API. @@ -85,7 +85,7 @@ Whether you decide to use a single server, or distribute messages across a netwo ## Transport -Cryptpad was initially written to use [websockets](https://en.wikipedia.org/wiki/WebSocket) for transportation of messages. +CryptPad was initially written to use [websockets](https://en.wikipedia.org/wiki/WebSocket) for transportation of messages. Since a relay server is indispensable in this model, that server doubles as the **History Keeper**, and implements a datastore. @@ -202,7 +202,7 @@ That isn't to say that there are no tradeoffs when keeping that information from ### Our Encryption Scheme -The encryption scheme employed by Cryptpad is a [symmetric encryption](https://en.wikipedia.org/wiki/Symmetric-key_algorithm) which utilizes a single [pre-shared-key](https://en.wikipedia.org/wiki/Pre-shared_key) known by all participants. +The encryption scheme employed by CryptPad is a [symmetric encryption](https://en.wikipedia.org/wiki/Symmetric-key_algorithm) which utilizes a single [pre-shared-key](https://en.wikipedia.org/wiki/Pre-shared_key) known by all participants. Encryption is complex, and poorly understood by the majority of those who use it on a daily basis. Pre-shared-keys are among the weakest possible cryptographic tools available today, however, few if any other encryption schemes scale to any number of users. diff --git a/readme.md b/readme.md index f4b979bf3..e6982a0fe 100644 --- a/readme.md +++ b/readme.md @@ -20,7 +20,7 @@ The most recent version and all past release notes can be found [here](https://g ## Setup using Docker -See [Cryptpad-Docker](https://github.com/xwiki-labs/cryptpad-docker) repository for details on how to get up-and-running with Cryptpad in Docker. This repository is maintained by the community and not officially supported. +See [CryptPad-Docker](https://github.com/xwiki-labs/cryptpad-docker) repository for details on how to get up-and-running with CryptPad in Docker. This repository is maintained by the community and not officially supported. # Security @@ -72,7 +72,7 @@ CryptPad is actively developed by a team at [XWiki SAS](https://www.xwiki.com), We love Open Source and we love contribution. Learn more about [contributing](https://docs.cryptpad.fr/en/how_to_contribute.html). -If you have any questions or comments, or if you're interested in contributing to Cryptpad, come say hi in our [Matrix channel](https://app.element.io/#/room/#cryptpad:matrix.xwiki.com). +If you have any questions or comments, or if you're interested in contributing to CryptPad, come say hi in our [Matrix channel](https://app.element.io/#/room/#cryptpad:matrix.xwiki.com). # License diff --git a/scripts/find-html-translations.js b/scripts/find-html-translations.js deleted file mode 100644 index 218342137..000000000 --- a/scripts/find-html-translations.js +++ /dev/null @@ -1,99 +0,0 @@ -var EN = require("../www/common/translations/messages.json"); - -var simpleTags = [ - '
', - '', - '', - - // FIXME - "", - '', - '

', - '

', - - // FIXME register_notes - '', - '
  • ', - '
  • ', - '', - '', -]; - -['a', 'b', 'em', 'p', 'i'].forEach(function (tag) { - simpleTags.push('<' + tag + '>'); - simpleTags.push(''); -}); - -// these keys are known to be problematic -var KNOWN_ISSUES = [ // FIXME - //'newVersion', - //'fm_info_anonymous', - //'register_notes', -]; - -var processLang = function (map, lang, primary) { - var announced = false; - var announce = function () { - if (announced) { return; } - announced = true; - console.log("NEXT LANGUAGE: ", lang); - }; - - Object.keys(map).forEach(function (k) { - if (!EN[k]) { return; } - if (KNOWN_ISSUES.indexOf(k) !== -1) { return; } - - var s = map[k]; - if (typeof(s) !== 'string') { return; } - var usesHTML; - - s.replace(/<.*?>/g, function (html) { - if (simpleTags.indexOf(html) !== -1) { return; } - announce(); - usesHTML = true; - if (!primary) { - console.log("{%s}", html); - } - }); - - if (usesHTML) { - announce(); - console.log("%s", s); - console.log("[%s]\n", k); - } - }); -}; - -processLang(EN, 'en', true); - -[ - 'ar', - //'bn_BD', - 'ca', - 'de', - 'es', - 'fi', - 'fr', - 'hi', - 'it', - 'ja', - 'nb', - 'nl', - 'pl', - 'pt-br', - 'ro', - 'ru', - 'sv', - //'te', - 'tr', - 'zh', -].forEach(function (lang) { - try { - var map = require("../www/common/translations/messages." + lang + ".json"); - if (!Object.keys(map).length) { return; } - processLang(map, lang); - } catch (err) { - console.error(err); - } -}); diff --git a/scripts/lint-translations.js b/scripts/lint-translations.js index a38cd615a..bc18dd724 100644 --- a/scripts/lint-translations.js +++ b/scripts/lint-translations.js @@ -1,8 +1,127 @@ -// TODO unify the following scripts - // unused-translations.js - // find-html-translations +var EN = require("../www/common/translations/messages.json"); -// more linting - // Search for 'Cryptpad' string (should be 'CryptPad') - // Search English for -ise\s +var simpleTags = [ + '
    ', + '
    ', + '', + // FIXME + "", + '', + '

    ', + '

    ', + + // FIXME register_notes + '', + '
  • ', + '
  • ', + '', + '', +]; + +['a', 'b', 'em', 'p', 'i'].forEach(function (tag) { + simpleTags.push('<' + tag + '>'); + simpleTags.push(''); +}); + +// these keys are known to be problematic +var KNOWN_ISSUES = [ // FIXME + //'newVersion', + //'fm_info_anonymous', + //'register_notes', +]; + +var special_rules = {}; + +special_rules.en = function (s) { + // Prefer the american -ize suffix for verbs rather than -ise + return /[^w]ise/.test(s); +}; + +special_rules.fr = function (s) { +/* + hacky regexp to check whether there are any instances of ':' + which do not have the preceding space as is expected. + ignore instances where the following character is a '/' + because this is probably a URL (http(s)://) +*/ + return /\S[:;\?\!][^\/]{1,}/.test(s); +}; + +var noop = function () {}; + +var processLang = function (map, lang, primary) { + var announced = false; + var announce = function () { + if (announced) { return; } + announced = true; + console.log("NEXT LANGUAGE: ", lang); + }; + + var special = special_rules[lang] || noop; + Object.keys(map).forEach(function (k) { + if (!EN[k]) { return; } + if (KNOWN_ISSUES.indexOf(k) !== -1) { return; } + + var s = map[k]; + if (typeof(s) !== 'string') { return; } + var usesHTML; + + s.replace(/<.*?>/g, function (html) { + if (simpleTags.indexOf(html) !== -1) { return; } + announce(); + usesHTML = true; + if (!primary) { + console.log("{%s}", html); + } + }); + + var weirdCapitalization; + s.replace(/cryptpad(\.fr)*/gi, function (brand) { + if (['CryptPad', 'cryptpad.fr'].includes(brand)) { return; } + weirdCapitalization = true; + }); + + var specialViolation = special(s); + + if (usesHTML || weirdCapitalization || specialViolation) { + announce(); + console.log("%s", s); + console.log("[%s]\n", k); + } + }); +}; + +processLang(EN, 'en', true); + +[ + 'ar', + //'bn_BD', + 'ca', + 'de', + 'es', + 'fi', + 'fr', + 'hi', + 'it', + 'ja', + 'nb', + 'nl', + 'pl', + 'pt-br', + 'ro', + 'ru', + 'sv', + //'te', + 'tr', + 'zh', +].forEach(function (lang) { + try { + var map = require("../www/common/translations/messages." + lang + ".json"); + if (!Object.keys(map).length) { return; } + processLang(map, lang); + } catch (err) { + console.error(err); + } +});