From c85018cdfd1a36e8c33de25c44bf192d53e201c1 Mon Sep 17 00:00:00 2001 From: Dan Ungureanu Date: Wed, 29 Apr 2020 21:40:21 +0300 Subject: [PATCH] Improve support for old browsers (#9515) * FEATURE: Improve crawler view * FIX: Make lazyYT crawler-friendly * DEV: Rename discourse-internet-explorer to discourse-unsupported-browser * DEV: Detect more unsupported browsers Follow-up to 4eebbd221239eaa3fc7e6f1bd6a9dcf0239b8444. * FIX: Hide browser update notice in print view --- .gitignore | 2 +- app/assets/javascripts/browser-detect.js | 9 +++ .../stylesheets/common/base/_topic-list.scss | 6 ++ .../common/base/crawler_layout.scss | 40 +++---------- app/helpers/topics_helper.rb | 4 +- app/views/layouts/crawler.html.erb | 12 ++-- app/views/list/list.erb | 56 ++++++++++++++---- app/views/topics/show.html.erb | 57 +++++++++---------- lib/plugin/metadata.rb | 2 +- .../config/locales/server.en.yml | 4 -- .../config/settings.yml | 6 -- .../discourse-unsupported-browser.js.es6} | 8 +-- .../assets/stylesheets/ie.scss | 0 .../config/locales/client.en.yml | 2 +- .../config/locales/server.en.yml | 4 ++ .../config/settings.yml | 6 ++ .../plugin.rb | 14 ++--- .../public/js/ie.js | 0 .../spec/middleware/anonymous_cache_spec.rb | 0 .../spec/requests/bootstrap_request_spec.rb | 16 +++--- plugins/lazy-yt/plugin.rb | 14 ++++- .../assets/javascripts/browser-update.js.erb | 3 +- 22 files changed, 151 insertions(+), 114 deletions(-) delete mode 100644 plugins/discourse-internet-explorer/config/locales/server.en.yml delete mode 100644 plugins/discourse-internet-explorer/config/settings.yml rename plugins/{discourse-internet-explorer/assets/javascripts/initializers/discourse-internet-explorer.js.es6 => discourse-unsupported-browser/assets/javascripts/initializers/discourse-unsupported-browser.js.es6} (69%) rename plugins/{discourse-internet-explorer => discourse-unsupported-browser}/assets/stylesheets/ie.scss (100%) rename plugins/{discourse-internet-explorer => discourse-unsupported-browser}/config/locales/client.en.yml (78%) create mode 100644 plugins/discourse-unsupported-browser/config/locales/server.en.yml create mode 100644 plugins/discourse-unsupported-browser/config/settings.yml rename plugins/{discourse-internet-explorer => discourse-unsupported-browser}/plugin.rb (76%) rename plugins/{discourse-internet-explorer => discourse-unsupported-browser}/public/js/ie.js (100%) rename plugins/{discourse-internet-explorer => discourse-unsupported-browser}/spec/middleware/anonymous_cache_spec.rb (100%) rename plugins/{discourse-internet-explorer => discourse-unsupported-browser}/spec/requests/bootstrap_request_spec.rb (64%) diff --git a/.gitignore b/.gitignore index bc22f48bbd5..97d1a6b9302 100644 --- a/.gitignore +++ b/.gitignore @@ -54,7 +54,7 @@ bootsnap-compile-cache/ !/plugins/discourse-narrative-bot !/plugins/discourse-presence !/plugins/discourse-local-dates -!/plugins/discourse-internet-explorer +!/plugins/discourse-unsupported-browser /plugins/*/auto_generated/ /spec/fixtures/plugins/my_plugin/auto_generated diff --git a/app/assets/javascripts/browser-detect.js b/app/assets/javascripts/browser-detect.js index bdbbc27b3ef..c13298dbb4f 100644 --- a/app/assets/javascripts/browser-detect.js +++ b/app/assets/javascripts/browser-detect.js @@ -1,3 +1,12 @@ if (!window.WeakMap || !window.Promise) { window.unsupportedBrowser = true; +} else { + // Some implementations of `WeakMap.prototype.has` do not accept false + // values and Ember's `isClassicDecorator` sometimes does that (it only + // checks for `null` and `undefined`). + try { + new WeakMap().has(0); + } catch (err) { + window.unsupportedBrowser = true; + } } diff --git a/app/assets/stylesheets/common/base/_topic-list.scss b/app/assets/stylesheets/common/base/_topic-list.scss index 5b9cff00763..01fc70a2bb2 100644 --- a/app/assets/stylesheets/common/base/_topic-list.scss +++ b/app/assets/stylesheets/common/base/_topic-list.scss @@ -142,6 +142,12 @@ } } + .link-bottom-line { + .category-name { + margin-right: 12px; + } + } + .unread-indicator { &.read { display: none; diff --git a/app/assets/stylesheets/common/base/crawler_layout.scss b/app/assets/stylesheets/common/base/crawler_layout.scss index 8f42f9ae0bd..c0ca9315100 100644 --- a/app/assets/stylesheets/common/base/crawler_layout.scss +++ b/app/assets/stylesheets/common/base/crawler_layout.scss @@ -21,12 +21,6 @@ body.crawler { } } - .raw-topic-link { - display: block; - font-weight: bold; - margin-bottom: 0.25em; - } - .topic-list { margin-bottom: 1em; } @@ -34,6 +28,14 @@ body.crawler { footer { margin-top: 4em; } + + .category-title { + color: $primary; + } + + .discourse-tags { + color: $primary-medium; + } } .noscript-footer-nav { @@ -47,10 +49,7 @@ body.crawler { #noscript-footer { padding: 0 10px; -} - -.crawler-topic-title { - margin-top: 0.5em; + text-align: center; } .crawler-post { @@ -86,27 +85,6 @@ body.crawler { } } -#breadcrumbs { - margin-bottom: 0.5em; - font-size: $font-up-1; - > div { - margin-bottom: 0.15em; - } - .badge-category-bg { - background-color: $secondary-high; - } - .category-title { - color: $primary; - } -} - -.crawler-tags-list { - span { - display: block; - margin-bottom: 0.15em; - } -} - .crawler-linkback-list { margin-top: 1em; a { diff --git a/app/helpers/topics_helper.rb b/app/helpers/topics_helper.rb index 4f4a56b6e7c..00204236218 100644 --- a/app/helpers/topics_helper.rb +++ b/app/helpers/topics_helper.rb @@ -12,9 +12,9 @@ module TopicsHelper category = topic.category if category && !category.uncategorized? - breadcrumb.push(url: category.url, name: category.name) + breadcrumb.push(url: category.url, name: category.name, color: category.color) while category = category.parent_category - breadcrumb.prepend(url: category.url, name: category.name) + breadcrumb.prepend(url: category.url, name: category.name, color: category.color) end end diff --git a/app/views/layouts/crawler.html.erb b/app/views/layouts/crawler.html.erb index e8fc43c0231..b5a83455506 100644 --- a/app/views/layouts/crawler.html.erb +++ b/app/views/layouts/crawler.html.erb @@ -34,13 +34,13 @@ <%= yield %>