diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 3b2070f39..c4aecb0f3 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -81,6 +81,7 @@ class ApplicationController < ActionController::Base end def pack?(data, pack_name) + return false unless data if data['pack'].is_a?(Hash) && data['pack'].key?(pack_name) return true if data['pack'][pack_name].is_a?(String) || data['pack'][pack_name].is_a?(Hash) end @@ -89,16 +90,17 @@ class ApplicationController < ActionController::Base def nil_pack(data, pack_name, skin = 'default') { - common: pack_name == 'common' ? nil : resolve_pack(data['name'] ? Themes.instance.flavour(current_flavour) : Themes.instance.core, 'common', skin), - flavour: data['name'], + common: pack_name == 'common' ? nil : resolve_pack(!data || data['name'] ? Themes.instance.flavour(current_flavour) : Themes.instance.core, 'common', skin), + flavour: data ? data['name'] : nil, pack: nil, preload: nil, skin: nil, - supported_locales: data['locales'], + supported_locales: data ? data['locales'] : nil, } end def resolve_pack(data, pack_name, skin = 'default') + return nil_pack(data, pack_name, skin) unless data result = pack(data, pack_name, skin) unless result if data['name'] && data.key?('fallback') @@ -154,13 +156,14 @@ class ApplicationController < ActionController::Base end def current_flavour - return Setting.default_settings['flavour'] unless Themes.instance.flavours.include? current_user&.setting_flavour - current_user.setting_flavour + return params[:use_flavour].to_s if Themes.instance.flavours.include? params[:use_flavour].to_s + return current_user.setting_flavour if Themes.instance.flavours.include? current_user&.setting_flavour + Setting.default_settings['flavour'] end def current_skin - return 'default' unless Themes.instance.skins_for(current_flavour).include? current_user&.setting_skin - current_user.setting_skin + return current_user.setting_skin if Themes.instance.skins_for(current_flavour).include? current_user&.setting_skin + 'default' end def cache_collection(raw, klass) diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb index 7437a647e..878f55019 100644 --- a/app/controllers/home_controller.rb +++ b/app/controllers/home_controller.rb @@ -7,6 +7,7 @@ class HomeController < ApplicationController def index @body_classes = 'app-body' + redirect_to "/$#{current_flavour}/#{params[:glob] || ''}" unless Themes.instance.flavours.include?(params[:use_flavour].to_s) or request.path.start_with?("/$#{current_flavour}") end private @@ -58,7 +59,7 @@ class HomeController < ApplicationController end def default_redirect_path - if request.path.start_with?('/web') + if request.path.start_with?('/web') || request.path.match?(/\A\$[\w-]+/) new_user_session_path elsif single_user_mode? short_account_path(Account.first) diff --git a/app/javascript/flavours/glitch/containers/mastodon.js b/app/javascript/flavours/glitch/containers/mastodon.js index 1c98cd5f7..913f64498 100644 --- a/app/javascript/flavours/glitch/containers/mastodon.js +++ b/app/javascript/flavours/glitch/containers/mastodon.js @@ -57,7 +57,7 @@ export default class Mastodon extends React.PureComponent { return ( - + diff --git a/app/javascript/flavours/glitch/service_worker/web_push_notifications.js b/app/javascript/flavours/glitch/service_worker/web_push_notifications.js index f63cff335..4cb744017 100644 --- a/app/javascript/flavours/glitch/service_worker/web_push_notifications.js +++ b/app/javascript/flavours/glitch/service_worker/web_push_notifications.js @@ -17,7 +17,7 @@ const notify = options => icon: '/android-chrome-192x192.png', tag: GROUP_TAG, data: { - url: (new URL('/web/notifications', self.location)).href, + url: (new URL('/$glitch/notifications', self.location)).href, count: notifications.length + 1, message: options.data.message, }, diff --git a/app/javascript/flavours/glitch/util/main.js b/app/javascript/flavours/glitch/util/main.js index fe57fa962..65dab39ed 100644 --- a/app/javascript/flavours/glitch/util/main.js +++ b/app/javascript/flavours/glitch/util/main.js @@ -12,8 +12,8 @@ function main() { if (window.history && history.replaceState) { const { pathname, search, hash } = window.location; const path = pathname + search + hash; - if (!(/^\/web[$/]/).test(path)) { - history.replaceState(null, document.title, `/web${path}`); + if (!(/^\/\$glitch[$/]/).test(path)) { + history.replaceState(null, document.title, `/$glitch${path}`); } } diff --git a/app/javascript/mastodon/containers/mastodon.js b/app/javascript/mastodon/containers/mastodon.js index d1710445b..18de0d7d2 100644 --- a/app/javascript/mastodon/containers/mastodon.js +++ b/app/javascript/mastodon/containers/mastodon.js @@ -57,7 +57,7 @@ export default class Mastodon extends React.PureComponent { return ( - + diff --git a/app/javascript/mastodon/main.js b/app/javascript/mastodon/main.js index 23b6b04fa..4b41206fc 100644 --- a/app/javascript/mastodon/main.js +++ b/app/javascript/mastodon/main.js @@ -12,8 +12,8 @@ function main() { if (window.history && history.replaceState) { const { pathname, search, hash } = window.location; const path = pathname + search + hash; - if (!(/^\/web[$/]/).test(path)) { - history.replaceState(null, document.title, `/web${path}`); + if (!(/^\/\$vanilla[$/]/).test(path)) { + history.replaceState(null, document.title, `/$vanilla${path}`); } } diff --git a/app/javascript/mastodon/service_worker/web_push_notifications.js b/app/javascript/mastodon/service_worker/web_push_notifications.js index f63cff335..44211da31 100644 --- a/app/javascript/mastodon/service_worker/web_push_notifications.js +++ b/app/javascript/mastodon/service_worker/web_push_notifications.js @@ -102,16 +102,16 @@ const findBestClient = clients => { const openUrl = url => self.clients.matchAll({ type: 'window' }).then(clientList => { if (clientList.length !== 0) { - const webClients = clientList.filter(client => /\/web\//.test(client.url)); + const webClients = clientList.filter(client => /\/\$vanilla\//.test(client.url)); if (webClients.length !== 0) { const client = findBestClient(webClients); const { pathname } = new URL(url); - if (pathname.startsWith('/web/')) { + if (pathname.startsWith('/$vanilla/')) { return client.focus().then(client => client.postMessage({ type: 'navigate', - path: pathname.slice('/web/'.length - 1), + path: pathname.slice('/$vanilla/'.length - 1), })); } } else if ('navigate' in clientList[0]) { // Chrome 42-48 does not support navigate diff --git a/app/javascript/styles/win95.scss b/app/javascript/styles/win95.scss index d683218b0..ef37b105d 100644 --- a/app/javascript/styles/win95.scss +++ b/app/javascript/styles/win95.scss @@ -1054,23 +1054,23 @@ body.admin { } } -.column-link[href="/web/timelines/public"] { +.column-link[href="/$vanilla/timelines/public"] { background-image: url("~images/icon_public.png"); &:hover { background-image: url("~images/icon_public.png"); } } -.column-link[href="/web/timelines/public/local"] { +.column-link[href="/$vanilla/timelines/public/local"] { background-image: url("~images/icon_local.png"); &:hover { background-image: url("~images/icon_local.png"); } } -.column-link[href="/web/pinned"] { +.column-link[href="/$vanilla/pinned"] { background-image: url("~images/icon_pin.png"); &:hover { background-image: url("~images/icon_pin.png"); } } -.column-link[href="/web/favourites"] { +.column-link[href="/$vanilla/favourites"] { background-image: url("~images/icon_likes.png"); &:hover { background-image: url("~images/icon_likes.png"); } } -.column-link[href="/web/blocks"] { +.column-link[href="/$vanilla/blocks"] { background-image: url("~images/icon_blocks.png"); &:hover { background-image: url("~images/icon_blocks.png"); } } diff --git a/config/routes.rb b/config/routes.rb index a41e76c2c..459438c94 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -240,7 +240,7 @@ Rails.application.routes.draw do resources :media, only: [:create, :update] resources :blocks, only: [:index] resources :mutes, only: [:index] do - collection do + collection do get 'details' end end @@ -309,7 +309,8 @@ Rails.application.routes.draw do end end - get '/web/(*any)', to: 'home#index', as: :web + get '/web/(*glob)', to: 'home#index', as: :web + get "/$:use_flavour/(*glob)", to: 'home#index', constraints: { flavour: /[\w-]+/ } get '/about', to: 'about#show' get '/about/more', to: 'about#more'