A platform for community discussion. Free, open, simple.
DEV: Drop empty core mobile/desktop stylesheets (#41988)
David Taylord2dc8d4f22ab
diff --git a/app/assets/stylesheets/desktop.scss b/app/assets/stylesheets/desktop.scssdeleted file mode 100644index 566f6f39081..00000000000--- a/app/assets/stylesheets/desktop.scss+++ /dev/null@@ -1,3 +0,0 @@-// This file intentionally left blank — the stylesheet compiler generates `@import "desktop"`-// Plugins and themes can still add desktop styles for import-// Instead of authoring desktop-specific styles, use media queries in the common stylesheetsdiff --git a/app/assets/stylesheets/desktop_rtl.scss b/app/assets/stylesheets/desktop_rtl.scssdeleted file mode 100644index cddb8710acb..00000000000--- a/app/assets/stylesheets/desktop_rtl.scss+++ /dev/null@@ -1,2 +0,0 @@-// stub file used to clean up asset precompilation process-@import "desktop";diff --git a/app/assets/stylesheets/mobile.scss b/app/assets/stylesheets/mobile.scssdeleted file mode 100644index d88bbbc645d..00000000000--- a/app/assets/stylesheets/mobile.scss+++ /dev/null@@ -1,3 +0,0 @@-// This file intentionally left blank — the stylesheet compiler generates `@import "mobile"`-// Plugins and themes can still add mobile styles for import-// Instead of authoring mobile-specific styles, use media queries in the common stylesheetsdiff --git a/app/assets/stylesheets/mobile_rtl.scss b/app/assets/stylesheets/mobile_rtl.scssdeleted file mode 100644index 861812af904..00000000000--- a/app/assets/stylesheets/mobile_rtl.scss+++ /dev/null@@ -1,2 +0,0 @@-// stub file used to clean up asset precompilation process-@import "mobile";diff --git a/app/models/theme.rb b/app/models/theme.rbindex ae11bc28991..2584624925f 100644--- a/app/models/theme.rb+++ b/app/models/theme.rb@@ -542,7 +542,7 @@ class Theme < ActiveRecord::Basetargets = %i[common_theme mobile_theme desktop_theme]if with_scheme- targets.prepend(:common, :desktop, :mobile, :admin)+ targets.prepend(:common, :admin)targets.append(*Discourse.find_plugin_css_assets(mobile_view: true,diff --git a/app/views/common/_discourse_preload_stylesheet.html.erb b/app/views/common/_discourse_preload_stylesheet.html.erbindex e050c0d1e53..5025ee34a75 100644--- a/app/views/common/_discourse_preload_stylesheet.html.erb+++ b/app/views/common/_discourse_preload_stylesheet.html.erb@@ -2,10 +2,8 @@<%- if rtl? %><%= discourse_stylesheet_preload_tag(:common_rtl) %>- <%= discourse_stylesheet_preload_tag(mobile_device? ? :mobile_rtl : :desktop_rtl) %><%- else %><%= discourse_stylesheet_preload_tag(:common) %>- <%= discourse_stylesheet_preload_tag(mobile_device? ? :mobile : :desktop) %><%- end %><%- if staff? %>diff --git a/app/views/common/_discourse_stylesheet.html.erb b/app/views/common/_discourse_stylesheet.html.erbindex 7c12e85aed9..35bd7b3afb5 100644--- a/app/views/common/_discourse_stylesheet.html.erb+++ b/app/views/common/_discourse_stylesheet.html.erb@@ -2,9 +2,6 @@<%= discourse_stylesheet_link_tag(:common, supports_rtl: true) %>-<%= discourse_stylesheet_link_tag(:mobile, supports_rtl: true, media: "(width < 40rem)") %>-<%= discourse_stylesheet_link_tag(:desktop, supports_rtl: true, media: "(width >= 40rem)") %>-<%- if staff? %><%= discourse_stylesheet_link_tag(:admin, supports_rtl: true) %><%- end %>diff --git a/app/views/qunit/qunit.html.erb b/app/views/qunit/qunit.html.erbindex 8ffff4025a8..332618ad608 100644--- a/app/views/qunit/qunit.html.erb+++ b/app/views/qunit/qunit.html.erb@@ -70,7 +70,6 @@</style><%= discourse_stylesheet_link_tag(:common, theme_id: nil) %>- <%= discourse_stylesheet_link_tag(:desktop, theme_id: nil) %><%= discourse_stylesheet_link_tag(:admin) %><%= discourse_stylesheet_link_tag(:wizard) %>diff --git a/lib/stylesheet/manager.rb b/lib/stylesheet/manager.rbindex 825c5dd9d25..96abefbb7d5 100644--- a/lib/stylesheet/manager.rb+++ b/lib/stylesheet/manager.rb@@ -49,7 +49,7 @@ class Stylesheet::Managerenddef self.precompile_css- targets = %i[common desktop mobile admin wizard]+ targets = %i[common admin wizard]targets += targets.map { |t| :"#{t}_rtl" }targets +=@@ -267,11 +267,11 @@ class Stylesheet::Managerthemesend- def stylesheet_data(target = :desktop)+ def stylesheet_data(target)stylesheet_details(target, "all")end- def stylesheet_preload_tag(target = :desktop, media = "all")+ def stylesheet_preload_tag(target, media = "all")stylesheets = stylesheet_details(target, media)stylesheets.map do |stylesheet|@@ -282,7 +282,7 @@ class Stylesheet::Manager.html_safeend- def stylesheet_link_tag(target = :desktop, media = "all", preload_callback = nil)+ def stylesheet_link_tag(target, media = "all", preload_callback = nil)stylesheets = stylesheet_details(target, media)stylesheets.map do |stylesheet|@@ -298,7 +298,7 @@ class Stylesheet::Manager.html_safeend- def stylesheet_details(target = :desktop, media = "all")+ def stylesheet_details(target, media = "all")target = target.to_symcurrent_hostname = Discourse.current_hostnamerelative_url_root = GlobalSetting.relative_url_rootdiff --git a/lib/stylesheet/manager/builder.rb b/lib/stylesheet/manager/builder.rbindex 9b71967bc6c..57d2be21848 100644--- a/lib/stylesheet/manager/builder.rb+++ b/lib/stylesheet/manager/builder.rb@@ -3,7 +3,7 @@class Stylesheet::Manager::Builderattr_reader :theme- def initialize(target: :desktop, theme: nil, color_scheme: nil, manager:)+ def initialize(target:, theme: nil, color_scheme: nil, manager:)@target = target@theme = theme@color_scheme = color_schemediff --git a/lib/stylesheet/watcher.rb b/lib/stylesheet/watcher.rbindex 79217dca23e..49d142d5b57 100644--- a/lib/stylesheet/watcher.rb+++ b/lib/stylesheet/watcher.rb@@ -4,7 +4,7 @@ require "listen"module Stylesheetclass Watcher- CORE_TARGETS = %w[admin desktop mobile publish wizard wcag]+ CORE_TARGETS = %w[admin publish wizard wcag]SPECIAL_CORE_TARGETS = %w[color_definitions]def self.watch(paths = nil)@@ -115,7 +115,7 @@ module Stylesheetreturnend- targets = target ? [target] : %w[admin common desktop mobile]+ targets = target ? [target] : %w[admin common]Stylesheet::Manager.clear_core_cache!(targets)message =targets.map! { |name| Stylesheet::Manager.new.stylesheet_data(name.to_sym) }.flatten!diff --git a/spec/helpers/application_helper_spec.rb b/spec/helpers/application_helper_spec.rbindex f4674420299..fd98488d396 100644--- a/spec/helpers/application_helper_spec.rb+++ b/spec/helpers/application_helper_spec.rb@@ -224,13 +224,13 @@ RSpec.describe ApplicationHelper doendit "adds resources to the preload list when discourse_stylesheet_link_tag is called" do- helper.discourse_stylesheet_link_tag(:desktop)+ helper.discourse_stylesheet_link_tag(:common)expect(controller.instance_variable_get(:@asset_preload_links).size).to eq(1)endit "adds resources as the correct type" do- helper.discourse_stylesheet_link_tag(:desktop)+ helper.discourse_stylesheet_link_tag(:common)helper.preload_script("discourse")expect(controller.instance_variable_get(:@asset_preload_links)[0]).to match(/as="style"/)diff --git a/spec/lib/stylesheet/manager_spec.rb b/spec/lib/stylesheet/manager_spec.rbindex 048292b738d..f7308b0bdf6 100644--- a/spec/lib/stylesheet/manager_spec.rb+++ b/spec/lib/stylesheet/manager_spec.rb@@ -14,7 +14,7 @@ RSpec.describe Stylesheet::Manager doendit "still returns something for no themes" do- link = manager.stylesheet_link_tag(:desktop, "all")+ link = manager.stylesheet_link_tag(:common, "all")expect(link).not_to eq("")end@@ -58,7 +58,7 @@ RSpec.describe Stylesheet::Manager doit "generates the right links for non-theme targets" domanager = manager(nil)- hrefs = manager.stylesheet_details(:desktop, "all")+ hrefs = manager.stylesheet_details(:common, "all")expect(hrefs.length).to eq(1)end@@ -254,9 +254,9 @@ RSpec.describe Stylesheet::Manager doit "outputs tags for non-theme targets for theme component" dochild_theme = Fabricate(:theme, component: true)- hrefs = manager(child_theme.id).stylesheet_details(:desktop, "all")+ hrefs = manager(child_theme.id).stylesheet_details(:common, "all")- expect(hrefs.count).to eq(1) # desktop+ expect(hrefs.count).to eq(1) # commonendit "does not output tags for component targets with no styles" do@@ -298,7 +298,7 @@ RSpec.describe Stylesheet::Manager dohrefs = manager.stylesheet_details(:admin, "all")expect(hrefs.count).to eq(1)- hrefs = manager.stylesheet_details(:mobile, "all")+ hrefs = manager.stylesheet_details(:common, "all")expect(hrefs.count).to eq(1)endend@@ -307,11 +307,11 @@ RSpec.describe Stylesheet::Manager doafter { DiscoursePluginRegistry.reset! }it "can correctly account for plugins in default digest" do- builder = Stylesheet::Manager::Builder.new(target: :desktop, manager: manager)+ builder = Stylesheet::Manager::Builder.new(target: :common, manager: manager)digest1 = builder.digestDiscoursePluginRegistry.stylesheets["fake"] = Set.new(["fake_file"])- builder = Stylesheet::Manager::Builder.new(target: :desktop, manager: manager)+ builder = Stylesheet::Manager::Builder.new(target: :common, manager: manager)digest2 = builder.digestexpect(digest1).not_to eq(digest2)@@ -449,9 +449,6 @@ RSpec.describe Stylesheet::Manager dobuilder = Stylesheet::Manager::Builder.new(target: :admin, manager: manager)expect(builder.digest).to eq(builder.default_digest)-- builder = Stylesheet::Manager::Builder.new(target: :desktop, manager: manager)- expect(builder.digest).to eq(builder.default_digest)endit "returns different digest based on hostname" do@@ -467,7 +464,7 @@ RSpec.describe Stylesheet::Manager doinitial_color_scheme_digest =Stylesheet::Manager::Builder.new(target: :color_definitions, manager: manager).digestinitial_default_digest =- Stylesheet::Manager::Builder.new(target: :desktop, manager: manager).digest+ Stylesheet::Manager::Builder.new(target: :common, manager: manager).digestSiteSetting.force_hostname = "host2.example.com"new_theme_digest =@@ -479,7 +476,7 @@ RSpec.describe Stylesheet::Manager donew_color_scheme_digest =Stylesheet::Manager::Builder.new(target: :color_definitions, manager: manager).digestnew_default_digest =- Stylesheet::Manager::Builder.new(target: :desktop, manager: manager).digest+ Stylesheet::Manager::Builder.new(target: :common, manager: manager).digestexpect(initial_theme_digest).not_to eq(new_theme_digest)expect(initial_color_scheme_digest).not_to eq(new_color_scheme_digest)@@ -870,9 +867,7 @@ RSpec.describe Stylesheet::Manager doenddescribe ".precompile_css" do- let(:core_targets) do- %w[common desktop mobile admin wizard common_rtl desktop_rtl mobile_rtl admin_rtl wizard_rtl]- end+ let(:core_targets) { %w[common admin wizard common_rtl admin_rtl wizard_rtl] }let(:theme_targets) do%i[@@ -962,7 +957,7 @@ RSpec.describe Stylesheet::Manager doStylesheet::Manager.precompile_theme_cssresults = StylesheetCache.pluck(:target)- expect(results.size).to eq(16) # 10 core targets + 2 theme (ltr/rtl) + 4 color schemes+ expect(results.size).to eq(12) # 6 core targets + 2 theme (ltr/rtl) + 4 color schemesexpect(results.count { |target| target =~ /^common_theme_/ }).to eq(2) # ltr/rtlend@@ -974,7 +969,7 @@ RSpec.describe Stylesheet::Manager doStylesheet::Manager.precompile_theme_cssresults = StylesheetCache.pluck(:target)- expect(results.size).to eq(18) # 10 core targets + 2 theme rtl/ltr + 6 color schemes+ expect(results.size).to eq(14) # 6 core targets + 2 theme rtl/ltr + 6 color schemesexpect(results).to include("color_definitions_#{scheme1.name}_#{scheme1.id}_#{user_theme.id}")expect(results).to include(diff --git a/spec/lib/stylesheet/watcher_spec.rb b/spec/lib/stylesheet/watcher_spec.rbindex 4a4f7e149fd..c3845265c39 100644--- a/spec/lib/stylesheet/watcher_spec.rb+++ b/spec/lib/stylesheet/watcher_spec.rb@@ -20,9 +20,9 @@ RSpec.describe Stylesheet::Watcher doendit "infers core targets from top-level stylesheet filenames" do- path = Rails.root.join("app/assets/stylesheets/mobile.scss")+ path = Rails.root.join("app/assets/stylesheets/wizard.scss")- expect(watcher.path_data(path.to_s, [])).to include(target: "mobile", plugin_name: nil)+ expect(watcher.path_data(path.to_s, [])).to include(target: "wizard", plugin_name: nil)endit "infers special core targets from top-level filenames" dodiff --git a/spec/models/theme_spec.rb b/spec/models/theme_spec.rbindex bc8144c4ce8..cf99b16bcfc 100644--- a/spec/models/theme_spec.rb+++ b/spec/models/theme_spec.rb@@ -520,8 +520,6 @@ RSpec.describe Theme doexpect(messages.first.data.map { |d| d[:target] }).to contain_exactly(:common,:admin,- :desktop,- :mobile,:common_theme,)enddiff --git a/spec/requests/stylesheets_controller_spec.rb b/spec/requests/stylesheets_controller_spec.rbindex 3f5e5c5dbcf..dd21ee822ce 100644--- a/spec/requests/stylesheets_controller_spec.rb+++ b/spec/requests/stylesheets_controller_spec.rb@@ -4,23 +4,23 @@ RSpec.describe StylesheetsController doit "can survive cache miss" doStylesheetCache.destroy_allmanager = Stylesheet::Manager.new(theme_id: nil)- builder = Stylesheet::Manager::Builder.new(target: "desktop_rtl", manager: manager, theme: nil)+ builder = Stylesheet::Manager::Builder.new(target: "common_rtl", manager: manager, theme: nil)builder.compiledigest = StylesheetCache.first.digestStylesheetCache.destroy_all- get "/stylesheets/desktop_rtl_#{digest}.css"+ get "/stylesheets/common_rtl_#{digest}.css"expect(response.status).to eq(200)cached = StylesheetCache.first- expect(cached.target).to eq "desktop_rtl"+ expect(cached.target).to eq "common_rtl"expect(cached.digest).to eq digest# tmp folder destruction and cachedStylesheet::Manager.rm_cache_folder- get "/stylesheets/desktop_rtl_#{digest}.css"+ get "/stylesheets/common_rtl_#{digest}.css"expect(response.status).to eq(200)# there is an edge case which is ... disk and db cache is nuked, very unlikely to happen@@ -32,7 +32,7 @@ RSpec.describe StylesheetsController domanager = Stylesheet::Manager.new(theme_id: theme.id)- builder = Stylesheet::Manager::Builder.new(target: :desktop, theme: theme, manager: manager)+ builder = Stylesheet::Manager::Builder.new(target: :common, theme: theme, manager: manager)builder.compileStylesheet::Manager.rm_cache_folder@@ -174,22 +174,22 @@ RSpec.describe StylesheetsController doit "ignores Accept header and does not include Vary header" doStylesheetCache.destroy_allmanager = Stylesheet::Manager.new(theme_id: nil)- builder = Stylesheet::Manager::Builder.new(target: "desktop", manager: manager, theme: nil)+ builder = Stylesheet::Manager::Builder.new(target: "common", manager: manager, theme: nil)builder.compiledigest = StylesheetCache.first.digest- get "/stylesheets/desktop_#{digest}.css"+ get "/stylesheets/common_#{digest}.css"expect(response.status).to eq(200)expect(response.headers["Content-Type"]).to eq("text/css")expect(response.headers["Vary"]).to eq(nil)- get "/stylesheets/desktop_#{digest}.css", headers: { "Accept" => "text/html" }+ get "/stylesheets/common_#{digest}.css", headers: { "Accept" => "text/html" }expect(response.status).to eq(200)expect(response.headers["Content-Type"]).to eq("text/css")expect(response.headers["Vary"]).to eq(nil)- get "/stylesheets/desktop_#{digest}.css", headers: { "Accept" => "invalidcontenttype" }+ get "/stylesheets/common_#{digest}.css", headers: { "Accept" => "invalidcontenttype" }expect(response.status).to eq(200)expect(response.headers["Content-Type"]).to eq("text/css")expect(response.headers["Vary"]).to eq(nil)diff --git a/spec/system/mobile_mode_spec.rb b/spec/system/mobile_mode_spec.rbindex 09634274123..8e71d3078af 100644--- a/spec/system/mobile_mode_spec.rb+++ b/spec/system/mobile_mode_spec.rb@@ -1,15 +1,9 @@# frozen_string_literal: trueRSpec.describe "Viewport-based mobile mode" do- it "has both stylesheets, and updates classes at runtime" do+ it "updates classes at runtime" dovisit "/"- mobile_stylesheet = find("link[rel=stylesheet][href*='stylesheets/mobile']", visible: false)- desktop_stylesheet = find("link[rel=stylesheet][href*='stylesheets/desktop']", visible: false)-- expect(mobile_stylesheet["media"]).to include("width < 40rem")- expect(desktop_stylesheet["media"]).to include("width >= 40rem")-expect(page).to have_css("html.desktop-view")expect(page).not_to have_css("html.mobile-view")