From 3f6518ce99de8d8fa330ae551b2dc49b2094c712 Mon Sep 17 00:00:00 2001 From: Luke Granger-Brown Date: Thu, 2 Jul 2020 23:28:39 +0100 Subject: fix(gerrit): return HTML titles in more cases At present, we don't return HTML titles if there's a trailing slash, or a patchset. Instead, just consume the / and anything after it. This also fixes /123, because this is HTTP redirected to the full path *with a trailing slash* which otherwise wouldn't get the title injected. Change-Id: Idfd0e67752880a37dce0b400a3c1cfc53fac2912 Reviewed-on: https://cl.tvl.fyi/c/depot/+/859 Reviewed-by: BuildkiteCI Reviewed-by: tazjin Tested-by: BuildkiteCI --- .../gerrit/0003-Syntax-highlight-rules.pl.patch | 44 ++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 third_party/gerrit/0003-Syntax-highlight-rules.pl.patch (limited to 'third_party/gerrit/0003-Syntax-highlight-rules.pl.patch') diff --git a/third_party/gerrit/0003-Syntax-highlight-rules.pl.patch b/third_party/gerrit/0003-Syntax-highlight-rules.pl.patch new file mode 100644 index 000000000000..e85cbb9db20a --- /dev/null +++ b/third_party/gerrit/0003-Syntax-highlight-rules.pl.patch @@ -0,0 +1,44 @@ +From c3603950e5ae377514febbebf9aa26c31e07cd5d Mon Sep 17 00:00:00 2001 +From: Luke Granger-Brown +Date: Thu, 2 Jul 2020 23:02:43 +0100 +Subject: [PATCH 3/4] Syntax highlight rules.pl + +--- + .../elements/diff/gr-syntax-layer/gr-syntax-layer.js | 10 ++++++++++ + 1 file changed, 10 insertions(+) + +diff --git a/polygerrit-ui/app/elements/diff/gr-syntax-layer/gr-syntax-layer.js b/polygerrit-ui/app/elements/diff/gr-syntax-layer/gr-syntax-layer.js +index cc937cff67..2145bc169b 100644 +--- a/polygerrit-ui/app/elements/diff/gr-syntax-layer/gr-syntax-layer.js ++++ b/polygerrit-ui/app/elements/diff/gr-syntax-layer/gr-syntax-layer.js +@@ -105,6 +105,10 @@ const LANGUAGE_MAP = { + }; + const ASYNC_DELAY = 10; + ++const FILENAME_OVERRIDES = { ++ 'rules.pl': 'prolog', ++}; ++ + const CLASS_WHITELIST = { + 'gr-diff gr-syntax gr-syntax-attr': true, + 'gr-diff gr-syntax gr-syntax-attribute': true, +@@ -236,10 +240,16 @@ class GrSyntaxLayer extends GestureEventListeners( + } + } + ++ _basename(filename) { ++ const pieces = filename.split(/\//); ++ return pieces[pieces.length-1]; ++ } ++ + _getLanguage(diffFileMetaInfo) { + // The Gerrit API provides only content-type, but for other users of + // gr-diff it may be more convenient to specify the language directly. + return diffFileMetaInfo.language || ++ FILENAME_OVERRIDES[this._basename(diffFileMetaInfo.name)] || + LANGUAGE_MAP[diffFileMetaInfo.content_type]; + } + +-- +2.25.1 + -- cgit 1.4.1