Skip to content

Commit 6324ec2

Browse files
authored
move custom.css from css to config (#4020)
This is another change to cleanup structure, already mentioned in #4019 (comment) After separating default and 3rd-party modules this PR moves the `custom.css` from the mm-owned directory `css` into user owned directory `config`. It has a built-in function which moves the `css/custom.css` to the new location `config/custom.css` (if the target not exists). Let me know if there's a majority in favor of this change.
1 parent 43503e8 commit 6324ec2

File tree

8 files changed

+23
-18
lines changed

8 files changed

+23
-18
lines changed

.github/workflows/automated-tests.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ jobs:
6969
sudo chmod 4755 ./node_modules/electron/dist/chrome-sandbox
7070
# Start labwc
7171
WLR_BACKENDS=headless WLR_LIBINPUT_NO_DEVICES=1 WLR_RENDERER=pixman labwc &
72-
touch css/custom.css
72+
touch config/custom.css
7373
- name: "Run tests"
7474
run: |
7575
export WAYLAND_DISPLAY=wayland-0

.gitignore

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,16 +57,10 @@ Temporary Items
5757
# Ignore all modules
5858
/modules/*
5959

60-
# Ignore changes to the custom css files but keep the sample and main.
61-
/css/*
62-
!/css/custom.css.sample
63-
!/css/font-awesome.css
64-
!/css/main.css
65-
!/css/roboto.css
66-
67-
# Ignore users config file but keep the sample.
60+
# Ignore users config file but keep the samples.
6861
config
6962
!config/config.js.sample
63+
!config/custom.css.sample
7064

7165
# Vim
7266
## swap

js/app.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ function App () {
5757
let nodeHelpers = [];
5858
let httpServer;
5959
let defaultModules;
60+
let env;
6061

6162
/**
6263
* Loads the config file. Combines it with the defaults and returns the config
@@ -181,7 +182,6 @@ function App () {
181182
function loadModule (module) {
182183
const elements = module.split("/");
183184
const moduleName = elements[elements.length - 1];
184-
const env = getEnvVarsAsObj();
185185
let moduleFolder = path.resolve(`${global.root_path}/${env.modulesDir}`, module);
186186

187187
if (defaultModules.includes(moduleName)) {
@@ -296,6 +296,17 @@ function App () {
296296

297297
Log.setLogLevel(config.logLevel);
298298

299+
env = getEnvVarsAsObj();
300+
// check for deprecated css/custom.css and move it to new location
301+
if ((!fs.existsSync(`${global.root_path}/${env.customCss}`)) && (fs.existsSync(`${global.root_path}/css/custom.css`))) {
302+
try {
303+
fs.renameSync(`${global.root_path}/css/custom.css`, `${global.root_path}/${env.customCss}`);
304+
Log.warn(`WARNING! Your custom css file was moved from ${global.root_path}/css/custom.css to ${global.root_path}/${env.customCss}`);
305+
} catch (err) {
306+
Log.warn("WARNING! Your custom css file is currently located in the css folder. Please move it to the config folder!");
307+
}
308+
}
309+
299310
// get the used module positions
300311
Utils.getModulePositions();
301312

js/defaults.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const defaults = {
1818
timeFormat: 24,
1919
units: "metric",
2020
zoom: 1,
21-
customCss: "css/custom.css",
21+
customCss: "config/custom.css",
2222
foreignModulesDir: "modules",
2323
defaultModulesDir: "defaultmodules",
2424
// httpHeaders used by helmet, see https://helmetjs.github.io/. You can add other/more object values by overriding this in config.js,

js/loader.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const Loader = (function () {
1818
return {
1919
modulesDir: config.foreignModulesDir || "modules",
2020
defaultModulesDir: config.defaultModulesDir || "defaultmodules",
21-
customCss: config.customCss || "css/custom.css"
21+
customCss: config.customCss || "config/custom.css"
2222
};
2323
};
2424

@@ -262,7 +262,7 @@ const Loader = (function () {
262262

263263
/**
264264
* Load a file (script or stylesheet).
265-
* Prevent double loading and search for files in the vendor folder.
265+
* Prevent double loading and search for files defined in js/vendor.js.
266266
* @param {string} fileName Path of the file we want to load.
267267
* @param {Module} module The module that calls the loadFile function.
268268
* @returns {Promise} resolved when the file is loaded
@@ -281,8 +281,8 @@ const Loader = (function () {
281281
}
282282

283283
if (vendor[fileName] !== undefined) {
284-
// This file is available in the vendor folder.
285-
// Load it from this vendor folder.
284+
// This file is defined in js/vendor.js.
285+
// Load it from its location.
286286
loadedFiles.push(fileName.toLowerCase());
287287
return loadFile(`${vendor[fileName]}`);
288288
}

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
"postinstall": "git clean -df fonts vendor modules/default",
4444
"install-mm": "npm install --no-audit --no-fund --no-update-notifier --only=prod --omit=dev",
4545
"install-mm:dev": "npm install --no-audit --no-fund --no-update-notifier && npx playwright install chromium",
46-
"lint:css": "stylelint 'css/main.css' 'css/roboto.css' 'css/font-awesome.css' 'defaultmodules/**/*.css' --fix",
46+
"lint:css": "stylelint 'css/**/*.css' 'defaultmodules/**/*.css' --fix",
4747
"lint:js": "eslint --fix",
4848
"lint:markdown": "markdownlint-cli2 . --fix",
4949
"lint:prettier": "prettier . --write",
@@ -61,7 +61,7 @@
6161
"test": "vitest run",
6262
"test:calendar": "node ./defaultmodules/calendar/debug.js",
6363
"test:coverage": "vitest run --coverage",
64-
"test:css": "stylelint 'css/main.css' 'css/roboto.css' 'css/font-awesome.css' 'defaultmodules/**/*.css'",
64+
"test:css": "stylelint 'css/**/*.css' 'defaultmodules/**/*.css'",
6565
"test:e2e": "vitest run tests/e2e",
6666
"test:electron": "vitest run tests/electron",
6767
"test:js": "eslint",

tests/e2e/helpers/global-setup.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const { chromium } = require("playwright");
77
global.root_path = path.resolve(`${__dirname}/../../../`);
88

99
const indexFile = `${global.root_path}/index.html`;
10-
const cssFile = `${global.root_path}/css/custom.css`;
10+
const cssFile = `${global.root_path}/config/custom.css`;
1111
const sampleCss = [
1212
".region.row3 {",
1313
" top: 0;",

0 commit comments

Comments
 (0)