From 17e80d7757bd0d43f4626963d8527e5cc2349af7 Mon Sep 17 00:00:00 2001 From: Matthew Hodgson Date: Wed, 31 May 2017 11:02:59 +0100 Subject: [PATCH 1/4] i18n welcome --- res/home.html | 58 +++++++++++++-------------- src/components/structures/HomePage.js | 5 +-- 2 files changed, 30 insertions(+), 33 deletions(-) diff --git a/res/home.html b/res/home.html index d199844312..f8c05ea185 100644 --- a/res/home.html +++ b/res/home.html @@ -3,37 +3,37 @@
-

Welcome to Riot.im

-

Decentralised, encrypted chat & collaboration powered by

+

_t("Welcome to Riot.im")

+

_t("Decentralised, encrypted chat & collaboration powered by") [matrix]

-

Search the room directory

+

_t("Search the room directory")

- Lots of rooms already exist in Matrix, linked to existing networks (Slack, IRC, Gitter etc) or independent. - Check out the directory! + _t("Lots of rooms already exist in Matrix, linked to existing networks (Slack, IRC, Gitter etc) or independent. + Check out the directory!")
-

Chat with Riot Bot

+

_t("Chat with Riot Bot")

- Get started with some tips from Riot Bot! + _t("Get started with some tips from Riot Bot!")
-

General discussion about Matrix

+

_t("General discussion about Matrix")

@@ -41,33 +41,33 @@ Matrix HQ - Discussion of all things Matrix! + _t("Discussion of all things Matrix!")
Riot - Riot/Web & Desktop chat + _t("Riot/Web & Desktop chat")
#riot-ios - Riot/iOS & matrix-ios-sdk chat + _t("Riot/iOS & matrix-ios-sdk chat")
#riot-android - Riot/Android & matrix-android-sdk chat + _t("Riot/Android & matrix-android-sdk chat")
-

Matrix technical discussions

-

Running Matrix services

+

_t("Matrix technical discussions")

+

_t("Running Matrix services")

@@ -75,32 +75,32 @@ Synapse Support Community - Community-run support for Synapse + _t("Community-run support for Synapse")
#dendrite:matrix.org - Admin support for Dendrite + _t("Admin support for Dendrite")
Synapse Homeowners - Announcements about Synapse releases + _t("Announcements about Synapse releases")
IRC Matrix Bridges - Support for those using and running matrix-appservice-irc + _t("Support for those using and running matrix-appservice-irc")
-

Building services on Matrix

+

_t("Building services on Matrix")

@@ -108,46 +108,46 @@ #matrix-dev:matrix.org - Support for those using the Matrix spec + _t("Support for those using the Matrix spec")
End-to-end crypto in Matrix - Design and implementation of E2E in Matrix + _t("Design and implementation of E2E in Matrix")
#vr:matrix.org - Implementing VR services with Matrix + _t("Implementing VR services with Matrix")
#webrtc:matrix.org - Implementing VoIP services with Matrix + _t("Implementing VoIP services with Matrix")
Matrix Identity - Discussion of the Identity Service API + _t("Discussion of the Identity Service API")
Matrix Bridging - Support for those using, running and writing other bridges + _t("Support for those using, running and writing other bridges")
-

Contributing code to Matrix and Riot

+

_t("Contributing code to Matrix and Riot")

@@ -155,21 +155,21 @@ #riot-dev - Dev chat for the Riot/Web dev team + _t("Dev chat for the Riot/Web dev team")
#dendrite-dev - Dev chat for the Dendrite dev team + _t("Dev chat for the Dendrite dev team")
Riot-Web Translations - Co-ordination for Riot/Web translators + _t("Co-ordination for Riot/Web translators")
diff --git a/src/components/structures/HomePage.js b/src/components/structures/HomePage.js index 8b5b2f3c41..bdd4874df3 100644 --- a/src/components/structures/HomePage.js +++ b/src/components/structures/HomePage.js @@ -61,10 +61,7 @@ module.exports = React.createClass({ this.setState({ page: "Couldn't load home page" }); } - // We parse the JSON ourselves rather than use the JSON - // parameter, since this throws a parse error on empty - // which breaks if there's no config.json and we're - // loading from the filesystem (see above). + body.replaceAll(/_t\(['"](.*?)['"]\)/, (match)=>{ return sanitizehtml_t(match[1]) }); this.setState({ page: body }); } ); From a21c77f4ddc4556d226273db086eb54e0580f574 Mon Sep 17 00:00:00 2001 From: Matthew Hodgson Date: Thu, 1 Jun 2017 00:07:47 +0100 Subject: [PATCH 2/4] make it work --- src/components/structures/HomePage.js | 4 +++- src/i18n/strings/en_EN.json | 29 ++++++++++++++++++++++++++- 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/src/components/structures/HomePage.js b/src/components/structures/HomePage.js index bdd4874df3..ff61e51c2f 100644 --- a/src/components/structures/HomePage.js +++ b/src/components/structures/HomePage.js @@ -22,6 +22,8 @@ import MatrixClientPeg from 'matrix-react-sdk/lib/MatrixClientPeg'; import sdk from 'matrix-react-sdk'; import GeminiScrollbar from 'react-gemini-scrollbar'; import request from 'browser-request'; +import { _t } from 'matrix-react-sdk/lib/languageHandler'; +import sanitizeHtml from 'sanitize-html'; module.exports = React.createClass({ displayName: 'HomePage', @@ -61,7 +63,7 @@ module.exports = React.createClass({ this.setState({ page: "Couldn't load home page" }); } - body.replaceAll(/_t\(['"](.*?)['"]\)/, (match)=>{ return sanitizehtml_t(match[1]) }); + body = body.replace(/_t\(['"]([\s\S]*?)['"]\)/mg, (match, g1)=>{ return sanitizeHtml(_t(g1)) }); this.setState({ page: body }); } ); diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index eded26bdc9..bf4ecfcd16 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -128,5 +128,32 @@ "Today": "Today", "Yesterday": "Yesterday", "Welcome page": "Welcome page", - "With your current browser, the look and feel of the application may be completely incorrect, and some or all features may not function. If you want to try it anyway you can continue, but you are on your own in terms of any issues you may encounter!": "With your current browser, the look and feel of the application may be completely incorrect, and some or all features may not function. If you want to try it anyway you can continue, but you are on your own in terms of any issues you may encounter!" + "With your current browser, the look and feel of the application may be completely incorrect, and some or all features may not function. If you want to try it anyway you can continue, but you are on your own in terms of any issues you may encounter!": "With your current browser, the look and feel of the application may be completely incorrect, and some or all features may not function. If you want to try it anyway you can continue, but you are on your own in terms of any issues you may encounter!", + "Welcome to Riot.im": "Welcome to Riot.im", + "Decentralised, encrypted chat & collaboration powered by": "Decentralised, encrypted chat & collaboration powered by", + "Search the room directory": "Search the room directory", + "Chat with Riot Bot": "Chat with Riot Bot", + "Get started with some tips from Riot Bot!": "Get started with some tips from Riot Bot!", + "General discussion about Matrix": "General discussion about Matrix", + "Discussion of all things Matrix!": "Discussion of all things Matrix!", + "Riot/Web & Desktop chat": "Riot/Web & Desktop chat", + "Riot/iOS & matrix-ios-sdk chat": "Riot/iOS & matrix-ios-sdk chat", + "Riot/Android & matrix-android-sdk chat": "Riot/Android & matrix-android-sdk chat", + "Matrix technical discussions": "Matrix technical discussions", + "Running Matrix services": "Running Matrix services", + "Community-run support for Synapse": "Community-run support for Synapse", + "Admin support for Dendrite": "Admin support for Dendrite", + "Announcements about Synapse releases": "Announcements about Synapse releases", + "Support for those using and running matrix-appservice-irc": "Support for those using and running matrix-appservice-irc", + "Building services on Matrix": "Building services on Matrix", + "Support for those using the Matrix spec": "Support for those using the Matrix spec", + "Design and implementation of E2E in Matrix": "Design and implementation of E2E in Matrix", + "Implementing VR services with Matrix": "Implementing VR services with Matrix", + "Implementing VoIP services with Matrix": "Implementing VoIP services with Matrix", + "Discussion of the Identity Service API": "Discussion of the Identity Service API", + "Support for those using, running and writing other bridges": "Support for those using, running and writing other bridges", + "Contributing code to Matrix and Riot": "Contributing code to Matrix and Riot", + "Dev chat for the Riot/Web dev team": "Dev chat for the Riot/Web dev team", + "Dev chat for the Dendrite dev team": "Dev chat for the Dendrite dev team", + "Co-ordination for Riot/Web translators": "Co-ordination for Riot/Web translators" } From 4805bcf3640e1fc8ec2a6260020618bb48b7a7f2 Mon Sep 17 00:00:00 2001 From: Matthew Hodgson Date: Thu, 1 Jun 2017 10:50:47 +0100 Subject: [PATCH 3/4] outline font correctly in svg --- res/home/images/logo.svg | 77 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 76 insertions(+), 1 deletion(-) diff --git a/res/home/images/logo.svg b/res/home/images/logo.svg index 49f1186ffc..a5f70e5e4c 100644 --- a/res/home/images/logo.svg +++ b/res/home/images/logo.svg @@ -1 +1,76 @@ -New_logoI M. \ No newline at end of file + + + + +New_logo + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 623f9959349da0446eb9a409a536aa707bab63f3 Mon Sep 17 00:00:00 2001 From: Matthew Hodgson Date: Thu, 1 Jun 2017 11:13:04 +0100 Subject: [PATCH 4/4] fix untested stuff with iframe homepages --- src/components/structures/HomePage.js | 45 +++++++++++++-------------- 1 file changed, 22 insertions(+), 23 deletions(-) diff --git a/src/components/structures/HomePage.js b/src/components/structures/HomePage.js index 8b5b2f3c41..05bfc0da1b 100644 --- a/src/components/structures/HomePage.js +++ b/src/components/structures/HomePage.js @@ -38,44 +38,43 @@ module.exports = React.createClass({ getInitialState: function() { return { - page: "" + iframeSrc: '', + page: '', }; }, componentWillMount: function() { if (this.props.teamToken && this.props.teamServerUrl) { - return; + this.setState({ + iframeSrc: `${this.props.teamServerUrl}/static/${this.props.teamToken}/home.html` + }); } + else { + // we use request() to inline the homepage into the react component + // so that it can inherit CSS and theming easily rather than mess around + // with iframes and trying to synchronise document.stylesheets. - // we use request() to inline the homepage into the react component - // so that it can inherit CSS and theming easily rather than mess around - // with iframes and trying to synchronise document.stylesheets. + let src = this.props.homePageUrl || '/home.html'; - let src = this.props.homePageUrl || '/home.html'; + request( + { method: "GET", url: src }, + (err, response, body) => { + if (err || response.status < 200 || response.status >= 300) { + console.log(error); + this.setState({ page: "Couldn't load home page" }); + } - request( - { method: "GET", url: src }, - (err, response, body) => { - if (err || response.status < 200 || response.status >= 300) { - console.log(error); - this.setState({ page: "Couldn't load home page" }); + this.setState({ page: body }); } - - // We parse the JSON ourselves rather than use the JSON - // parameter, since this throws a parse error on empty - // which breaks if there's no config.json and we're - // loading from the filesystem (see above). - this.setState({ page: body }); - } - ); + ); + } }, render: function() { - if (this.props.teamToken && this.props.teamServerUrl) { - src = `${this.props.teamServerUrl}/static/${this.props.teamToken}/home.html`; + if (this.state.iframeSrc) { return (
-