mirror of
https://github.com/glitch-soc/mastodon.git
synced 2025-12-14 08:19:05 +00:00
Replace use_pack, layouts/theme and @theme by new helpers
Packs are now loaded from views, just like upstream, and are identified by their filenames. The definition of `theme.yml` has changed as such: - `pack_directory` is now required - `pack` is now unused - `signed_in_preload` has been introduced
This commit is contained in:
@@ -1,36 +1,26 @@
|
||||
// Note: You must restart bin/webpack-dev-server for changes to take effect
|
||||
|
||||
const { resolve } = require('path');
|
||||
const { basename, dirname, join, relative, resolve } = require('path');
|
||||
|
||||
const CircularDependencyPlugin = require('circular-dependency-plugin');
|
||||
const { sync } = require('glob');
|
||||
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
|
||||
const extname = require('path-complete-extname');
|
||||
const webpack = require('webpack');
|
||||
const AssetsManifestPlugin = require('webpack-assets-manifest');
|
||||
|
||||
const { env, settings, flavours, output } = require('./configuration');
|
||||
const rules = require('./rules');
|
||||
|
||||
function reducePacks (data, into = {}) {
|
||||
if (!data.pack) return into;
|
||||
const extensionGlob = `**/*{${settings.extensions.join(',')}}*`;
|
||||
|
||||
for (const entry in data.pack) {
|
||||
const pack = data.pack[entry];
|
||||
if (!pack) continue;
|
||||
function reduceFlavourPacks(data, into = {}) {
|
||||
const packPaths = sync(join(data.pack_directory, extensionGlob));
|
||||
|
||||
let packFiles = [];
|
||||
if (typeof pack === 'string')
|
||||
packFiles = [pack];
|
||||
else if (Array.isArray(pack))
|
||||
packFiles = pack;
|
||||
else
|
||||
packFiles = [pack.filename];
|
||||
|
||||
if (packFiles) {
|
||||
into[`flavours/${data.name}/${entry}`] = packFiles.map(packFile => resolve(data.pack_directory, packFile));
|
||||
}
|
||||
}
|
||||
|
||||
if (!data.name) return into;
|
||||
packPaths.forEach((entry) => {
|
||||
const namespace = relative(join(data.pack_directory), dirname(entry));
|
||||
into[`flavours/${data.name}/${join(namespace, basename(entry, extname(entry)))}`] = resolve(entry);
|
||||
});
|
||||
|
||||
for (const skinName in data.skin) {
|
||||
const skin = data.skin[skinName];
|
||||
@@ -43,7 +33,7 @@ function reducePacks (data, into = {}) {
|
||||
}
|
||||
|
||||
const entries = Object.assign(
|
||||
Object.values(flavours).reduce((map, data) => reducePacks(data, map), {}),
|
||||
Object.values(flavours).reduce((map, data) => reduceFlavourPacks(data, map), {}),
|
||||
);
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user