Compare commits

...
This repository has been archived on 2023-07-01. You can view files and clone it, but cannot push or open issues or pull requests.

2 Commits

Author SHA1 Message Date
kibigo! f32ef29808 Removed unnecessary constraint 2017-12-11 00:14:00 -08:00
kibigo! a634d3876f Route flavours ~ URLs 2017-12-10 23:59:04 -08:00
10 changed files with 30 additions and 25 deletions

View File

@ -81,6 +81,7 @@ class ApplicationController < ActionController::Base
end end
def pack?(data, pack_name) def pack?(data, pack_name)
return false unless data
if data['pack'].is_a?(Hash) && data['pack'].key?(pack_name) 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) return true if data['pack'][pack_name].is_a?(String) || data['pack'][pack_name].is_a?(Hash)
end end
@ -89,16 +90,17 @@ class ApplicationController < ActionController::Base
def nil_pack(data, pack_name, skin = 'default') 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), common: pack_name == 'common' ? nil : resolve_pack(!data || data['name'] ? Themes.instance.flavour(current_flavour) : Themes.instance.core, 'common', skin),
flavour: data['name'], flavour: data ? data['name'] : nil,
pack: nil, pack: nil,
preload: nil, preload: nil,
skin: nil, skin: nil,
supported_locales: data['locales'], supported_locales: data ? data['locales'] : nil,
} }
end end
def resolve_pack(data, pack_name, skin = 'default') def resolve_pack(data, pack_name, skin = 'default')
return nil_pack(data, pack_name, skin) unless data
result = pack(data, pack_name, skin) result = pack(data, pack_name, skin)
unless result unless result
if data['name'] && data.key?('fallback') if data['name'] && data.key?('fallback')
@ -154,13 +156,14 @@ class ApplicationController < ActionController::Base
end end
def current_flavour def current_flavour
return Setting.default_settings['flavour'] unless Themes.instance.flavours.include? current_user&.setting_flavour return params[:use_flavour].to_s if Themes.instance.flavours.include? params[:use_flavour].to_s
current_user.setting_flavour return current_user.setting_flavour if Themes.instance.flavours.include? current_user&.setting_flavour
Setting.default_settings['flavour']
end end
def current_skin def current_skin
return 'default' unless Themes.instance.skins_for(current_flavour).include? current_user&.setting_skin return current_user.setting_skin if Themes.instance.skins_for(current_flavour).include? current_user&.setting_skin
current_user.setting_skin 'default'
end end
def cache_collection(raw, klass) def cache_collection(raw, klass)

View File

@ -7,6 +7,7 @@ class HomeController < ApplicationController
def index def index
@body_classes = 'app-body' @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 end
private private
@ -58,7 +59,7 @@ class HomeController < ApplicationController
end end
def default_redirect_path 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 new_user_session_path
elsif single_user_mode? elsif single_user_mode?
short_account_path(Account.first) short_account_path(Account.first)

View File

@ -57,7 +57,7 @@ export default class Mastodon extends React.PureComponent {
return ( return (
<IntlProvider locale={locale} messages={messages}> <IntlProvider locale={locale} messages={messages}>
<Provider store={store}> <Provider store={store}>
<BrowserRouter basename='/web'> <BrowserRouter basename='/$glitch'>
<ScrollContext> <ScrollContext>
<Route path='/' component={UI} /> <Route path='/' component={UI} />
</ScrollContext> </ScrollContext>

View File

@ -17,7 +17,7 @@ const notify = options =>
icon: '/android-chrome-192x192.png', icon: '/android-chrome-192x192.png',
tag: GROUP_TAG, tag: GROUP_TAG,
data: { data: {
url: (new URL('/web/notifications', self.location)).href, url: (new URL('/$glitch/notifications', self.location)).href,
count: notifications.length + 1, count: notifications.length + 1,
message: options.data.message, message: options.data.message,
}, },

View File

@ -12,8 +12,8 @@ function main() {
if (window.history && history.replaceState) { if (window.history && history.replaceState) {
const { pathname, search, hash } = window.location; const { pathname, search, hash } = window.location;
const path = pathname + search + hash; const path = pathname + search + hash;
if (!(/^\/web[$/]/).test(path)) { if (!(/^\/\$glitch[$/]/).test(path)) {
history.replaceState(null, document.title, `/web${path}`); history.replaceState(null, document.title, `/$glitch${path}`);
} }
} }

View File

@ -57,7 +57,7 @@ export default class Mastodon extends React.PureComponent {
return ( return (
<IntlProvider locale={locale} messages={messages}> <IntlProvider locale={locale} messages={messages}>
<Provider store={store}> <Provider store={store}>
<BrowserRouter basename='/web'> <BrowserRouter basename='/$vanilla'>
<ScrollContext> <ScrollContext>
<Route path='/' component={UI} /> <Route path='/' component={UI} />
</ScrollContext> </ScrollContext>

View File

@ -12,8 +12,8 @@ function main() {
if (window.history && history.replaceState) { if (window.history && history.replaceState) {
const { pathname, search, hash } = window.location; const { pathname, search, hash } = window.location;
const path = pathname + search + hash; const path = pathname + search + hash;
if (!(/^\/web[$/]/).test(path)) { if (!(/^\/\$vanilla[$/]/).test(path)) {
history.replaceState(null, document.title, `/web${path}`); history.replaceState(null, document.title, `/$vanilla${path}`);
} }
} }

View File

@ -102,16 +102,16 @@ const findBestClient = clients => {
const openUrl = url => const openUrl = url =>
self.clients.matchAll({ type: 'window' }).then(clientList => { self.clients.matchAll({ type: 'window' }).then(clientList => {
if (clientList.length !== 0) { 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) { if (webClients.length !== 0) {
const client = findBestClient(webClients); const client = findBestClient(webClients);
const { pathname } = new URL(url); const { pathname } = new URL(url);
if (pathname.startsWith('/web/')) { if (pathname.startsWith('/$vanilla/')) {
return client.focus().then(client => client.postMessage({ return client.focus().then(client => client.postMessage({
type: 'navigate', 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 } else if ('navigate' in clientList[0]) { // Chrome 42-48 does not support navigate

View File

@ -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"); background-image: url("~images/icon_public.png");
&:hover { 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"); background-image: url("~images/icon_local.png");
&:hover { 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"); background-image: url("~images/icon_pin.png");
&:hover { 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"); background-image: url("~images/icon_likes.png");
&:hover { 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"); background-image: url("~images/icon_blocks.png");
&:hover { background-image: url("~images/icon_blocks.png"); } &:hover { background-image: url("~images/icon_blocks.png"); }
} }

View File

@ -240,7 +240,7 @@ Rails.application.routes.draw do
resources :media, only: [:create, :update] resources :media, only: [:create, :update]
resources :blocks, only: [:index] resources :blocks, only: [:index]
resources :mutes, only: [:index] do resources :mutes, only: [:index] do
collection do collection do
get 'details' get 'details'
end end
end end
@ -309,7 +309,8 @@ Rails.application.routes.draw do
end end
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'
get '/about', to: 'about#show' get '/about', to: 'about#show'
get '/about/more', to: 'about#more' get '/about/more', to: 'about#more'