about summary refs log tree commit diff
path: root/config
diff options
context:
space:
mode:
Diffstat (limited to 'config')
-rw-r--r--config/locales/simple_form.en.yml2
-rw-r--r--config/settings.yml1
-rw-r--r--config/webpack/configuration.js28
-rw-r--r--config/webpack/shared.js20
4 files changed, 47 insertions, 4 deletions
diff --git a/config/locales/simple_form.en.yml b/config/locales/simple_form.en.yml
index faf41f316..b9ef21fef 100644
--- a/config/locales/simple_form.en.yml
+++ b/config/locales/simple_form.en.yml
@@ -15,6 +15,7 @@ en:
           other: <span class="note-counter">%{count}</span> characters left
         setting_noindex: Affects your public profile and status pages
         setting_theme: Affects how Mastodon looks when you're logged in from any device.
+        setting_skin: Reskins the selected Mastodon theme
       imports:
         data: CSV file exported from another Mastodon instance
       sessions:
@@ -47,6 +48,7 @@ en:
         setting_reduce_motion: Reduce motion in animations
         setting_system_font_ui: Use system's default font
         setting_theme: Site theme
+        setting_skin: Skin
         setting_unfollow_modal: Show confirmation dialog before unfollowing someone
         severity: Severity
         type: Import type
diff --git a/config/settings.yml b/config/settings.yml
index 6983484d0..5abf647e8 100644
--- a/config/settings.yml
+++ b/config/settings.yml
@@ -26,6 +26,7 @@ defaults: &defaults
   system_font_ui: false
   noindex: false
   theme: 'glitch'
+  skin: 'default'
   notification_emails:
     follow: false
     reblog: false
diff --git a/config/webpack/configuration.js b/config/webpack/configuration.js
index f8741c5d8..cb31c6ab8 100644
--- a/config/webpack/configuration.js
+++ b/config/webpack/configuration.js
@@ -1,15 +1,16 @@
 // Common configuration for webpacker loaded from config/webpacker.yml
 
-const { basename, dirname, join, resolve } = require('path');
+const { basename, dirname, extname, join, resolve } = require('path');
 const { env } = require('process');
 const { safeLoad } = require('js-yaml');
-const { readFileSync } = require('fs');
+const { lstatSync, readFileSync } = require('fs');
 const glob = require('glob');
 
 const configPath = resolve('config', 'webpacker.yml');
 const loadersDir = join(__dirname, 'loaders');
 const settings = safeLoad(readFileSync(configPath), 'utf8')[env.NODE_ENV];
 const themeFiles = glob.sync('app/javascript/themes/*/theme.yml');
+const skinFiles = glob.sync('app/javascript/skins/*/*');
 const themes = {};
 
 const core = function () {
@@ -25,14 +26,35 @@ for (let i = 0; i < themeFiles.length; i++) {
   const themeFile = themeFiles[i];
   const data = safeLoad(readFileSync(themeFile), 'utf8');
   data.name = basename(dirname(themeFile));
+  data.skin = {};
   if (!data.pack_directory) {
     data.pack_directory = dirname(themeFile);
   }
-  if (data.pack && typeof data.pack == 'object') {
+  if (data.pack && typeof data.pack === 'object') {
     themes[data.name] = data;
   }
 }
 
+for (let i = 0; i < skinFiles.length; i++) {
+  const skinFile = skinFiles[i];
+  let skin = basename(skinFile);
+  const name = basename(dirname(skinFile));
+  if (!themes[name]) {
+    continue;
+  }
+  const data = themes[name].skin;
+  if (lstatSync(skinFile).isDirectory()) {
+    data[skin] = {};
+    const skinPacks = glob.sync(skinFile, '*.{css,scss}');
+    for (let j = 0; j < skinPacks.length; j++) {
+      const pack = skinPacks[i];
+      data[skin][basename(pack, extname(pack))] = pack;
+    }
+  } else if ((skin = skin.match(/^(.*)\.s?css$/i))) {
+    data[skin[1]] = { common: skinFile };
+  }
+}
+
 function removeOuterSlashes(string) {
   return string.replace(/^\/*/, '').replace(/\/*$/, '');
 }
diff --git a/config/webpack/shared.js b/config/webpack/shared.js
index 5b90f27fb..a2550bc81 100644
--- a/config/webpack/shared.js
+++ b/config/webpack/shared.js
@@ -1,7 +1,7 @@
 // Note: You must restart bin/webpack-dev-server for changes to take effect
 
 const webpack = require('webpack');
-const { basename, dirname, join, relative, resolve } = require('path');
+const { basename, join, resolve } = require('path');
 const { sync } = require('glob');
 const ExtractTextPlugin = require('extract-text-webpack-plugin');
 const ManifestPlugin = require('webpack-manifest-plugin');
@@ -24,6 +24,24 @@ function reducePacks (data, into = {}) {
     }
     return map;
   }, into);
+  if (data.name) {
+    Object.keys(data.skin).reduce((map, entry) => {
+      const skin = data.skin[entry];
+      const skinName = entry;
+      if (!skin) {
+        return map;
+      }
+      Object.keys(skin).reduce((map, entry) => {
+        const packFile = skin[entry];
+        if (!packFile) {
+          return map;
+        }
+        map[`skins/${data.name}/${skinName}/${entry}`] = resolve(packFile);
+        return map;
+      }, into);
+      return map;
+    }, into);
+  }
   return into;
 }