From a0560ec4e3abf57990d1b1ac71cbd6dc44f35e9d Mon Sep 17 00:00:00 2001 From: Ruba Al Mahmoud Date: Tue, 8 Oct 2024 13:55:24 +0300 Subject: [PATCH 1/3] implemented code for resources button in new theme --- custom_themes/nodebb-theme-testing/.eslintrc | 3 + custom_themes/nodebb-theme-testing/.gitignore | 1 + custom_themes/nodebb-theme-testing/README.md | 43 ++++ .../nodebb-theme-testing/commitlint.config.js | 26 +++ .../nodebb-theme-testing/lib/controllers.js | 29 +++ .../nodebb-theme-testing/lib/theme.js | 185 ++++++++++++++++++ .../nodebb-theme-testing/package.json | 32 +++ .../nodebb-theme-testing/plugin.json | 26 +++ .../nodebb-theme-testing/public/.eslintrc | 3 + .../nodebb-theme-testing/public/client.js | 19 ++ .../nodebb-theme-testing/scss/overrides.scss | 79 ++++++++ .../admin/plugins/theme-quickstart.tpl | 56 ++++++ .../templates/partials/topic-list-bar.tpl | 63 ++++++ .../templates/templates.md | 5 + custom_themes/nodebb-theme-testing/theme.json | 7 + custom_themes/nodebb-theme-testing/theme.scss | 4 + src/controllers/index.js | 2 +- src/controllers/resources-button.js | 12 ++ src/routes/index.js | 2 + src/views/resources-button.tpl | 22 +++ 20 files changed, 618 insertions(+), 1 deletion(-) create mode 100644 custom_themes/nodebb-theme-testing/.eslintrc create mode 100644 custom_themes/nodebb-theme-testing/.gitignore create mode 100644 custom_themes/nodebb-theme-testing/README.md create mode 100644 custom_themes/nodebb-theme-testing/commitlint.config.js create mode 100644 custom_themes/nodebb-theme-testing/lib/controllers.js create mode 100644 custom_themes/nodebb-theme-testing/lib/theme.js create mode 100644 custom_themes/nodebb-theme-testing/package.json create mode 100644 custom_themes/nodebb-theme-testing/plugin.json create mode 100644 custom_themes/nodebb-theme-testing/public/.eslintrc create mode 100644 custom_themes/nodebb-theme-testing/public/client.js create mode 100644 custom_themes/nodebb-theme-testing/scss/overrides.scss create mode 100644 custom_themes/nodebb-theme-testing/templates/admin/plugins/theme-quickstart.tpl create mode 100644 custom_themes/nodebb-theme-testing/templates/partials/topic-list-bar.tpl create mode 100644 custom_themes/nodebb-theme-testing/templates/templates.md create mode 100644 custom_themes/nodebb-theme-testing/theme.json create mode 100644 custom_themes/nodebb-theme-testing/theme.scss create mode 100644 src/controllers/resources-button.js create mode 100644 src/views/resources-button.tpl diff --git a/custom_themes/nodebb-theme-testing/.eslintrc b/custom_themes/nodebb-theme-testing/.eslintrc new file mode 100644 index 0000000000..abd292af1b --- /dev/null +++ b/custom_themes/nodebb-theme-testing/.eslintrc @@ -0,0 +1,3 @@ +{ + "extends": "nodebb" +} diff --git a/custom_themes/nodebb-theme-testing/.gitignore b/custom_themes/nodebb-theme-testing/.gitignore new file mode 100644 index 0000000000..3c3629e647 --- /dev/null +++ b/custom_themes/nodebb-theme-testing/.gitignore @@ -0,0 +1 @@ +node_modules diff --git a/custom_themes/nodebb-theme-testing/README.md b/custom_themes/nodebb-theme-testing/README.md new file mode 100644 index 0000000000..f5cd8425f2 --- /dev/null +++ b/custom_themes/nodebb-theme-testing/README.md @@ -0,0 +1,43 @@ +# Quickstart Theme for NodeBB + +This repository contains all of the preparatory work for a theme based off of the [Harmony theme](https://github.com/NodeBB/nodebb-theme-harmony). If you'd like to base your theme off another supported theme instead, switch to the appropriate branch: + +* [Lavender](https://github.com/NodeBB/nodebb-theme-lavender) + +Fork it to create your own theme based off of it! + +### Some things to change + +* You should rename this theme from `quickstart` to something else. Change all instances of that word in the following files: + * `package.json` + * `plugin.json` + * `theme.json` + +### When you're done... + +Be sure to add some other metadata to the `package.json`, like this: + +``` json +"author": { + "name": "Your Name", + "email": "Your Email", + "url": "Your website" +}, +"repository": { + "type": "git", + "url": "https://github.com/{your-username}/{your-repository}" +}, +"bugs": { + "url": "https://github.com/{your-username}/{your-repository}/issues" +} +``` + +Also, add a screenshot! Take a picture of your theme, and save it as "screenshot.png" in the root of your theme folder, then add this to `theme.json`: + +``` json +"screenshot": "screenshot.png" +``` + +### Credits + +Material theme by [pichalite](https://github.com/pichalite). \ No newline at end of file diff --git a/custom_themes/nodebb-theme-testing/commitlint.config.js b/custom_themes/nodebb-theme-testing/commitlint.config.js new file mode 100644 index 0000000000..062d24b868 --- /dev/null +++ b/custom_themes/nodebb-theme-testing/commitlint.config.js @@ -0,0 +1,26 @@ +'use strict'; + +module.exports = { + extends: ['@commitlint/config-angular'], + rules: { + 'header-max-length': [1, 'always', 72], + 'type-enum': [ + 2, + 'always', + [ + 'breaking', + 'build', + 'chore', + 'ci', + 'docs', + 'feat', + 'fix', + 'perf', + 'refactor', + 'revert', + 'style', + 'test', + ], + ], + }, +}; diff --git a/custom_themes/nodebb-theme-testing/lib/controllers.js b/custom_themes/nodebb-theme-testing/lib/controllers.js new file mode 100644 index 0000000000..542318b3dc --- /dev/null +++ b/custom_themes/nodebb-theme-testing/lib/controllers.js @@ -0,0 +1,29 @@ +'use strict'; + +const Controllers = module.exports; + +const accountHelpers = require.main.require('./src/controllers/accounts/helpers'); +const helpers = require.main.require('./src/controllers/helpers'); + +Controllers.renderAdminPage = (req, res) => { + res.render('admin/plugins/theme-quickstart', { + title: 'Quick Start Theme', + }); +}; + +Controllers.renderThemeSettings = async (req, res, next) => { + const userData = await accountHelpers.getUserDataByUserSlug(req.params.userslug, req.uid, req.query); + if (!userData) { + return next(); + } + const lib = require('./theme'); + userData.theme = await lib.loadThemeConfig(userData.uid); + + userData.title = '[[themes/harmony:settings.title]]'; + userData.breadcrumbs = helpers.buildBreadcrumbs([ + { text: userData.username, url: `/user/${userData.userslug}` }, + { text: '[[themes/harmony:settings.title]]' }, + ]); + + res.render('account/theme', userData); +}; diff --git a/custom_themes/nodebb-theme-testing/lib/theme.js b/custom_themes/nodebb-theme-testing/lib/theme.js new file mode 100644 index 0000000000..ecac49290a --- /dev/null +++ b/custom_themes/nodebb-theme-testing/lib/theme.js @@ -0,0 +1,185 @@ +'use strict'; + +const nconf = require.main.require('nconf'); +const meta = require.main.require('./src/meta'); +const _ = require.main.require('lodash'); +const user = require.main.require('./src/user'); + +const controllers = require('./controllers'); + +const library = module.exports; + +const defaults = { + enableQuickReply: 'on', + enableBreadcrumbs: 'on', + centerHeaderElements: 'off', + mobileTopicTeasers: 'off', + stickyToolbar: 'on', + autohideBottombar: 'on', + openSidebars: 'off', + chatModals: 'off', +}; + +library.init = async function (params) { + const { router, middleware } = params; + const routeHelpers = require.main.require('./src/routes/helpers'); + + routeHelpers.setupAdminPageRoute(router, '/admin/plugins/theme-quickstart', [], controllers.renderAdminPage); + + routeHelpers.setupPageRoute(router, '/user/:userslug/theme', [ + middleware.exposeUid, + middleware.ensureLoggedIn, + middleware.canViewUsers, + middleware.checkAccountPermissions, + ], controllers.renderThemeSettings); + + if (nconf.get('isPrimary') && process.env.NODE_ENV === 'production') { + setTimeout(buildSkins, 0); + } +}; + +async function buildSkins() { + try { + const plugins = require.main.require('./src/plugins'); + await plugins.prepareForBuild(['client side styles']); + for (const skin of meta.css.supportedSkins) { + // eslint-disable-next-line no-await-in-loop + await meta.css.buildBundle(`client-${skin}`, true); + } + require.main.require('./src/meta/minifier').killAll(); + } catch (err) { + console.error(err.stack); + } +} + +library.addAdminNavigation = async function (header) { + header.plugins.push({ + route: '/plugins/theme-quickstart', + icon: 'fa-paint-brush', + name: 'Theme Quick Start', + }); + return header; +}; + +library.addProfileItem = async (data) => { + data.links.push({ + id: 'theme', + route: 'theme', + icon: 'fa-paint-brush', + name: '[[themes/harmony:settings.title]]', + visibility: { + self: true, + other: false, + moderator: false, + globalMod: false, + admin: false, + }, + }); + + return data; +}; + +library.defineWidgetAreas = async function (areas) { + const locations = ['header', 'sidebar', 'footer']; + const templates = [ + 'categories.tpl', 'category.tpl', 'topic.tpl', 'users.tpl', + 'unread.tpl', 'recent.tpl', 'popular.tpl', 'top.tpl', 'tags.tpl', 'tag.tpl', + 'login.tpl', 'register.tpl', + ]; + function capitalizeFirst(str) { + return str.charAt(0).toUpperCase() + str.slice(1); + } + templates.forEach((template) => { + locations.forEach((location) => { + areas.push({ + name: `${capitalizeFirst(template.split('.')[0])} ${capitalizeFirst(location)}`, + template: template, + location: location, + }); + }); + }); + + areas = areas.concat([ + { + name: 'Main post header', + template: 'topic.tpl', + location: 'mainpost-header', + }, + { + name: 'Main post footer', + template: 'topic.tpl', + location: 'mainpost-footer', + }, + { + name: 'Sidebar Footer', + template: 'global', + location: 'sidebar-footer', + }, + { + name: 'Brand Header', + template: 'global', + location: 'brand-header', + }, + { + name: 'About me (before)', + template: 'account/profile.tpl', + location: 'profile-aboutme-before', + }, + { + name: 'About me (after)', + template: 'account/profile.tpl', + location: 'profile-aboutme-after', + }, + ]); + + return areas; +}; + +library.loadThemeConfig = async function (uid) { + const [themeConfig, userConfig] = await Promise.all([ + meta.settings.get('harmony'), + user.getSettings(uid), + ]); + + const config = { ...defaults, ...themeConfig, ...(_.pick(userConfig, Object.keys(defaults))) }; + config.enableQuickReply = config.enableQuickReply === 'on'; + config.enableBreadcrumbs = config.enableBreadcrumbs === 'on'; + config.centerHeaderElements = config.centerHeaderElements === 'on'; + config.mobileTopicTeasers = config.mobileTopicTeasers === 'on'; + config.stickyToolbar = config.stickyToolbar === 'on'; + config.autohideBottombar = config.autohideBottombar === 'on'; + config.openSidebars = config.openSidebars === 'on'; + config.chatModals = config.chatModals === 'on'; + return config; +}; + +library.getThemeConfig = async function (config) { + config.theme = await library.loadThemeConfig(config.uid); + config.openDraftsOnPageLoad = false; + return config; +}; + +library.getAdminSettings = async function (hookData) { + if (hookData.plugin === 'harmony') { + hookData.values = { + ...defaults, + ...hookData.values, + }; + } + return hookData; +}; + +library.saveUserSettings = async function (hookData) { + Object.keys(defaults).forEach((key) => { + if (hookData.data.hasOwnProperty(key)) { + hookData.settings[key] = hookData.data[key] || undefined; + } + }); + return hookData; +}; + +library.filterMiddlewareRenderHeader = async function (hookData) { + hookData.templateData.bootswatchSkinOptions = await meta.css.getSkinSwitcherOptions(hookData.req.uid); + return hookData; +}; + diff --git a/custom_themes/nodebb-theme-testing/package.json b/custom_themes/nodebb-theme-testing/package.json new file mode 100644 index 0000000000..34e100dd53 --- /dev/null +++ b/custom_themes/nodebb-theme-testing/package.json @@ -0,0 +1,32 @@ +{ + "name": "nodebb-theme-testing", + "version": "0.1.0", + "description": "Enter a description here", + "main": "lib/theme.js", + "keywords": [], + "license": "MIT", + "husky": { + "hooks": { + "pre-commit": "npx lint-staged", + "commit-msg": "npx commitlint -E HUSKY_GIT_PARAMS" + } + }, + "lint-staged": { + "*.js": [ + "eslint --fix", + "git add" + ] + }, + "dependencies": { + }, + "devDependencies": { + "@commitlint/cli": "11.0.0", + "@commitlint/config-angular": "11.0.0", + "eslint": "8.x", + "eslint-config-airbnb-base": "14.2.1", + "eslint-config-nodebb": "0.1.1", + "eslint-plugin-import": "2.x", + "husky": "5.0.9", + "lint-staged": "10.5.4" + } +} diff --git a/custom_themes/nodebb-theme-testing/plugin.json b/custom_themes/nodebb-theme-testing/plugin.json new file mode 100644 index 0000000000..62a12b6f6f --- /dev/null +++ b/custom_themes/nodebb-theme-testing/plugin.json @@ -0,0 +1,26 @@ +{ + "id": "nodebb-theme-testing", + "hooks": [ + { "hook": "static:app.load", "method": "init" }, + { "hook": "filter:admin.header.build", "method": "addAdminNavigation" }, + { "hook": "filter:widgets.getAreas", "method": "defineWidgetAreas" }, + { "hook": "filter:config.get", "method": "getThemeConfig" }, + { "hook": "filter:settings.get", "method": "getAdminSettings"}, + { "hook": "filter:user.saveSettings", "method": "saveUserSettings" }, + { "hook": "filter:user.profileMenu", "method": "addProfileItem" }, + { "hook": "filter:middleware.renderHeader", "method": "filterMiddlewareRenderHeader" } + ], + "scripts": [ + "public/client.js", + "../nodebb-theme-harmony/public/harmony.js" + ], + "templates": "templates", + "modules": { + "../admin/plugins/theme-testing.js": "../nodebb-theme-harmony/public/admin.js", + "../client/account/theme.js": "../nodebb-theme-harmony/public/settings.js" + }, + "staticDirs": { + "inter": "node_modules/@fontsource/inter/files", + "poppins": "node_modules/@fontsource/poppins/files" + } +} diff --git a/custom_themes/nodebb-theme-testing/public/.eslintrc b/custom_themes/nodebb-theme-testing/public/.eslintrc new file mode 100644 index 0000000000..a3ce8297a6 --- /dev/null +++ b/custom_themes/nodebb-theme-testing/public/.eslintrc @@ -0,0 +1,3 @@ +{ + "extends": "nodebb/public" +} diff --git a/custom_themes/nodebb-theme-testing/public/client.js b/custom_themes/nodebb-theme-testing/public/client.js new file mode 100644 index 0000000000..c346f0a5c1 --- /dev/null +++ b/custom_themes/nodebb-theme-testing/public/client.js @@ -0,0 +1,19 @@ +'use strict'; + +/* + Hey there! + + This is the client file for your theme. If you need to do any client-side work in javascript, + this is where it needs to go. + + You can listen for page changes by writing something like this: + + $(window).on('action:ajaxify.end', function(ev, data) { + var url = data.url; + console.log('I am now at: ' + url); + }); +*/ + +$(document).ready(function () { + // Your code goes here +}); diff --git a/custom_themes/nodebb-theme-testing/scss/overrides.scss b/custom_themes/nodebb-theme-testing/scss/overrides.scss new file mode 100644 index 0000000000..e3d9d96917 --- /dev/null +++ b/custom_themes/nodebb-theme-testing/scss/overrides.scss @@ -0,0 +1,79 @@ +// only overrides to bs5 variables here + +// below are the default values from harmony theme overrides.scss file +// feel free to change these for your custom theme + +// Harmony colours +$white: #fff !default; +$gray-100: #f8f9fa !default; +$gray-200: #e9ecef !default; +$gray-300: #dee2e6 !default; +$gray-400: #ced4da !default; +$gray-500: #adb5bd !default; +$gray-600: #6c757d !default; +$gray-700: #495057 !default; +$gray-800: #343a40 !default; +$gray-900: #212529 !default; +$black: #000 !default; + +$blue: #0d6efd !default; +$red: #dc3545 !default; +$yellow: #ffc107 !default; +$green: #198754 !default; +$cyan: #0dcaf0 !default; + +$primary: $blue !default; +$secondary: $gray-600 !default; +$success: $green !default; +$info: $cyan !default; +$warning: $yellow !default; +$danger: $red !default; +$light: $gray-100 !default; +$dark: $gray-900 !default; + +$body-color: $gray-800 !default; +$body-bg: $white !default; +$body-tertiary-bg: $gray-200 !default; +$text-muted: $gray-600 !default; +$border-color: $gray-200 !default; +$link-color: shade-color($blue, 20%) !default; + +$btn-ghost-hover-color: mix($light, $dark, 90%); +$btn-ghost-active-color: lighten($btn-ghost-hover-color, 5%); +$btn-ghost-hover-color-dark: mix($dark, $light, 90%); +$btn-ghost-active-color-dark: lighten($btn-ghost-hover-color-dark, 5%); + +:root { + --btn-ghost-hover-color: #{$btn-ghost-hover-color}; + --btn-ghost-active-color: #{$btn-ghost-active-color}; +} +[data-bs-theme="dark"] { + --btn-ghost-hover-color: #{$btn-ghost-hover-color-dark}; + --btn-ghost-active-color: #{$btn-ghost-active-color-dark}; +} + +// no caret on dropdown-toggle +$enable-caret: false; + +// disable smooth scroll, this makes window.scrollTo(0,0) in ajaxify.js take x milliseconds +$enable-smooth-scroll: false; + +$enable-shadows: true; + +$link-decoration: none; +$link-hover-decoration: underline; + +// Custom fonts +$font-family-sans-serif: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans", "Liberation Sans", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"; +$font-family-secondary: "Poppins", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans", "Liberation Sans", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji" !default; +$font-weight-semibold: 500 !default; +$small-font-size: 0.875rem !default; + +$breadcrumb-divider: quote("→"); +$breadcrumb-divider-color: $gray-500 !default; +$breadcrumb-active-color: $body-color !default; +$breadcrumb-item-padding-x: 12px !default; + +.form-control::placeholder, .bootstrap-tagsinput::placeholder { + color: $gray-500 !important; +} diff --git a/custom_themes/nodebb-theme-testing/templates/admin/plugins/theme-quickstart.tpl b/custom_themes/nodebb-theme-testing/templates/admin/plugins/theme-quickstart.tpl new file mode 100644 index 0000000000..289011ad6d --- /dev/null +++ b/custom_themes/nodebb-theme-testing/templates/admin/plugins/theme-quickstart.tpl @@ -0,0 +1,56 @@ +
+ + +
+
+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ +
+ [[themes/harmony:settings.stickyToolbar]] +

+ [[themes/harmony:settings.stickyToolbar.help]] +

+
+
+
+ +
+ [[themes/harmony:settings.autohideBottombar]] +

+ [[themes/harmony:settings.autohideBottombar.help]] +

+
+
+
+ + +
+
+ +
+ [[themes/harmony:settings.chatModals]] +
+
+
+
+ + +
+
diff --git a/custom_themes/nodebb-theme-testing/templates/partials/topic-list-bar.tpl b/custom_themes/nodebb-theme-testing/templates/partials/topic-list-bar.tpl new file mode 100644 index 0000000000..16b58d6215 --- /dev/null +++ b/custom_themes/nodebb-theme-testing/templates/partials/topic-list-bar.tpl @@ -0,0 +1,63 @@ +
+ +
diff --git a/custom_themes/nodebb-theme-testing/templates/templates.md b/custom_themes/nodebb-theme-testing/templates/templates.md new file mode 100644 index 0000000000..31a2022077 --- /dev/null +++ b/custom_themes/nodebb-theme-testing/templates/templates.md @@ -0,0 +1,5 @@ +You can override templates from Harmony theme by placing your tpl files in this folder. + +Use the same filename as the file you want to override. For example if you want to override recent.tpl name your file recent.tpl. If you want to override groups/list.tpl name your file groups/list.tpl and so on. + +You can also create entirely new templates and render them in an express route with `res.render('/path/to/yourtemplate', dataToUse);` \ No newline at end of file diff --git a/custom_themes/nodebb-theme-testing/theme.json b/custom_themes/nodebb-theme-testing/theme.json new file mode 100644 index 0000000000..f8eabf99bd --- /dev/null +++ b/custom_themes/nodebb-theme-testing/theme.json @@ -0,0 +1,7 @@ +{ + "id": "nodebb-theme-testing", + "name": "Testing", + "description": "Clone of CMU Quickstart Theme", + "url": "https://github.com/nodebb/nodebb-theme-testing", + "baseTheme": "nodebb-theme-harmony" +} diff --git a/custom_themes/nodebb-theme-testing/theme.scss b/custom_themes/nodebb-theme-testing/theme.scss new file mode 100644 index 0000000000..0205216253 --- /dev/null +++ b/custom_themes/nodebb-theme-testing/theme.scss @@ -0,0 +1,4 @@ +// override harmony font-path +$font-path: "./plugins/nodebb-theme-quickstart"; + +@import "../nodebb-theme-harmony/theme"; diff --git a/src/controllers/index.js b/src/controllers/index.js index 2cf50a7785..fdfc26e9f5 100644 --- a/src/controllers/index.js +++ b/src/controllers/index.js @@ -37,7 +37,7 @@ Controllers.osd = require('./osd'); Controllers['404'] = require('./404'); Controllers.errors = require('./errors'); Controllers.composer = require('./composer'); - +Controllers.resourcesButton = require('./resources-button'); Controllers.write = require('./write'); Controllers.reset = async function (req, res) { diff --git a/src/controllers/resources-button.js b/src/controllers/resources-button.js new file mode 100644 index 0000000000..f3ed5c9af6 --- /dev/null +++ b/src/controllers/resources-button.js @@ -0,0 +1,12 @@ +'use strict'; + +const controllers = {}; + +controllers.getResourcesButtonPage = async (req, res) => { + // Render the resources-button template + res.render('resources-button', { + title: 'Resources Page', // You can customize the title or add more data as needed + }); +}; + +module.exports = controllers; \ No newline at end of file diff --git a/src/routes/index.js b/src/routes/index.js index 4008f1565a..fa44f3ee27 100644 --- a/src/routes/index.js +++ b/src/routes/index.js @@ -7,6 +7,7 @@ const express = require('express'); const meta = require('../meta'); const controllers = require('../controllers'); +const resourcesButtonController = require('../controllers/resources-button'); const controllerHelpers = require('../controllers/helpers'); const plugins = require('../plugins'); @@ -80,6 +81,7 @@ _mounts.categories = (app, name, middleware, controllers) => { setupPageRoute(app, '/recent', [], controllers.recent.get); setupPageRoute(app, '/top', [], controllers.top.get); setupPageRoute(app, '/unread', [middleware.ensureLoggedIn], controllers.unread.get); + setupPageRoute(app, '/resources-button', [], resourcesButtonController.getResourcesButtonPage); }; _mounts.category = (app, name, middleware, controllers) => { diff --git a/src/views/resources-button.tpl b/src/views/resources-button.tpl new file mode 100644 index 0000000000..51ee880762 --- /dev/null +++ b/src/views/resources-button.tpl @@ -0,0 +1,22 @@ + + + + + + {{title}} + + +
+

Resources

+

Welcome to the resources page! Here you can find various links and materials.

+ +

Useful Links

+ + +
+ + \ No newline at end of file From 33324f0d9decbaad2bb5ca21281958f210b28966 Mon Sep 17 00:00:00 2001 From: Ruba Al Mahmoud Date: Tue, 8 Oct 2024 14:04:26 +0300 Subject: [PATCH 2/3] modified the package.json to pick up modded theme from another repo --- src/controllers/resources-button.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/controllers/resources-button.js b/src/controllers/resources-button.js index f3ed5c9af6..e15fd58d25 100644 --- a/src/controllers/resources-button.js +++ b/src/controllers/resources-button.js @@ -9,4 +9,4 @@ controllers.getResourcesButtonPage = async (req, res) => { }); }; -module.exports = controllers; \ No newline at end of file +module.exports = controllers; From b2b22fe2a1a24e872137580f22bb213cee8d2060 Mon Sep 17 00:00:00 2001 From: Ruba Al Mahmoud Date: Tue, 8 Oct 2024 14:26:33 +0300 Subject: [PATCH 3/3] reverted to harmony theme --- custom_themes/nodebb-theme-testing/.eslintrc | 3 - custom_themes/nodebb-theme-testing/.gitignore | 1 - custom_themes/nodebb-theme-testing/README.md | 43 ---- .../nodebb-theme-testing/commitlint.config.js | 26 --- .../nodebb-theme-testing/lib/controllers.js | 29 --- .../nodebb-theme-testing/lib/theme.js | 185 ------------------ .../nodebb-theme-testing/package.json | 32 --- .../nodebb-theme-testing/plugin.json | 26 --- .../nodebb-theme-testing/public/.eslintrc | 3 - .../nodebb-theme-testing/public/client.js | 19 -- .../nodebb-theme-testing/scss/overrides.scss | 79 -------- .../admin/plugins/theme-quickstart.tpl | 56 ------ .../templates/partials/topic-list-bar.tpl | 63 ------ .../templates/templates.md | 5 - custom_themes/nodebb-theme-testing/theme.json | 7 - custom_themes/nodebb-theme-testing/theme.scss | 4 - 16 files changed, 581 deletions(-) delete mode 100644 custom_themes/nodebb-theme-testing/.eslintrc delete mode 100644 custom_themes/nodebb-theme-testing/.gitignore delete mode 100644 custom_themes/nodebb-theme-testing/README.md delete mode 100644 custom_themes/nodebb-theme-testing/commitlint.config.js delete mode 100644 custom_themes/nodebb-theme-testing/lib/controllers.js delete mode 100644 custom_themes/nodebb-theme-testing/lib/theme.js delete mode 100644 custom_themes/nodebb-theme-testing/package.json delete mode 100644 custom_themes/nodebb-theme-testing/plugin.json delete mode 100644 custom_themes/nodebb-theme-testing/public/.eslintrc delete mode 100644 custom_themes/nodebb-theme-testing/public/client.js delete mode 100644 custom_themes/nodebb-theme-testing/scss/overrides.scss delete mode 100644 custom_themes/nodebb-theme-testing/templates/admin/plugins/theme-quickstart.tpl delete mode 100644 custom_themes/nodebb-theme-testing/templates/partials/topic-list-bar.tpl delete mode 100644 custom_themes/nodebb-theme-testing/templates/templates.md delete mode 100644 custom_themes/nodebb-theme-testing/theme.json delete mode 100644 custom_themes/nodebb-theme-testing/theme.scss diff --git a/custom_themes/nodebb-theme-testing/.eslintrc b/custom_themes/nodebb-theme-testing/.eslintrc deleted file mode 100644 index abd292af1b..0000000000 --- a/custom_themes/nodebb-theme-testing/.eslintrc +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "nodebb" -} diff --git a/custom_themes/nodebb-theme-testing/.gitignore b/custom_themes/nodebb-theme-testing/.gitignore deleted file mode 100644 index 3c3629e647..0000000000 --- a/custom_themes/nodebb-theme-testing/.gitignore +++ /dev/null @@ -1 +0,0 @@ -node_modules diff --git a/custom_themes/nodebb-theme-testing/README.md b/custom_themes/nodebb-theme-testing/README.md deleted file mode 100644 index f5cd8425f2..0000000000 --- a/custom_themes/nodebb-theme-testing/README.md +++ /dev/null @@ -1,43 +0,0 @@ -# Quickstart Theme for NodeBB - -This repository contains all of the preparatory work for a theme based off of the [Harmony theme](https://github.com/NodeBB/nodebb-theme-harmony). If you'd like to base your theme off another supported theme instead, switch to the appropriate branch: - -* [Lavender](https://github.com/NodeBB/nodebb-theme-lavender) - -Fork it to create your own theme based off of it! - -### Some things to change - -* You should rename this theme from `quickstart` to something else. Change all instances of that word in the following files: - * `package.json` - * `plugin.json` - * `theme.json` - -### When you're done... - -Be sure to add some other metadata to the `package.json`, like this: - -``` json -"author": { - "name": "Your Name", - "email": "Your Email", - "url": "Your website" -}, -"repository": { - "type": "git", - "url": "https://github.com/{your-username}/{your-repository}" -}, -"bugs": { - "url": "https://github.com/{your-username}/{your-repository}/issues" -} -``` - -Also, add a screenshot! Take a picture of your theme, and save it as "screenshot.png" in the root of your theme folder, then add this to `theme.json`: - -``` json -"screenshot": "screenshot.png" -``` - -### Credits - -Material theme by [pichalite](https://github.com/pichalite). \ No newline at end of file diff --git a/custom_themes/nodebb-theme-testing/commitlint.config.js b/custom_themes/nodebb-theme-testing/commitlint.config.js deleted file mode 100644 index 062d24b868..0000000000 --- a/custom_themes/nodebb-theme-testing/commitlint.config.js +++ /dev/null @@ -1,26 +0,0 @@ -'use strict'; - -module.exports = { - extends: ['@commitlint/config-angular'], - rules: { - 'header-max-length': [1, 'always', 72], - 'type-enum': [ - 2, - 'always', - [ - 'breaking', - 'build', - 'chore', - 'ci', - 'docs', - 'feat', - 'fix', - 'perf', - 'refactor', - 'revert', - 'style', - 'test', - ], - ], - }, -}; diff --git a/custom_themes/nodebb-theme-testing/lib/controllers.js b/custom_themes/nodebb-theme-testing/lib/controllers.js deleted file mode 100644 index 542318b3dc..0000000000 --- a/custom_themes/nodebb-theme-testing/lib/controllers.js +++ /dev/null @@ -1,29 +0,0 @@ -'use strict'; - -const Controllers = module.exports; - -const accountHelpers = require.main.require('./src/controllers/accounts/helpers'); -const helpers = require.main.require('./src/controllers/helpers'); - -Controllers.renderAdminPage = (req, res) => { - res.render('admin/plugins/theme-quickstart', { - title: 'Quick Start Theme', - }); -}; - -Controllers.renderThemeSettings = async (req, res, next) => { - const userData = await accountHelpers.getUserDataByUserSlug(req.params.userslug, req.uid, req.query); - if (!userData) { - return next(); - } - const lib = require('./theme'); - userData.theme = await lib.loadThemeConfig(userData.uid); - - userData.title = '[[themes/harmony:settings.title]]'; - userData.breadcrumbs = helpers.buildBreadcrumbs([ - { text: userData.username, url: `/user/${userData.userslug}` }, - { text: '[[themes/harmony:settings.title]]' }, - ]); - - res.render('account/theme', userData); -}; diff --git a/custom_themes/nodebb-theme-testing/lib/theme.js b/custom_themes/nodebb-theme-testing/lib/theme.js deleted file mode 100644 index ecac49290a..0000000000 --- a/custom_themes/nodebb-theme-testing/lib/theme.js +++ /dev/null @@ -1,185 +0,0 @@ -'use strict'; - -const nconf = require.main.require('nconf'); -const meta = require.main.require('./src/meta'); -const _ = require.main.require('lodash'); -const user = require.main.require('./src/user'); - -const controllers = require('./controllers'); - -const library = module.exports; - -const defaults = { - enableQuickReply: 'on', - enableBreadcrumbs: 'on', - centerHeaderElements: 'off', - mobileTopicTeasers: 'off', - stickyToolbar: 'on', - autohideBottombar: 'on', - openSidebars: 'off', - chatModals: 'off', -}; - -library.init = async function (params) { - const { router, middleware } = params; - const routeHelpers = require.main.require('./src/routes/helpers'); - - routeHelpers.setupAdminPageRoute(router, '/admin/plugins/theme-quickstart', [], controllers.renderAdminPage); - - routeHelpers.setupPageRoute(router, '/user/:userslug/theme', [ - middleware.exposeUid, - middleware.ensureLoggedIn, - middleware.canViewUsers, - middleware.checkAccountPermissions, - ], controllers.renderThemeSettings); - - if (nconf.get('isPrimary') && process.env.NODE_ENV === 'production') { - setTimeout(buildSkins, 0); - } -}; - -async function buildSkins() { - try { - const plugins = require.main.require('./src/plugins'); - await plugins.prepareForBuild(['client side styles']); - for (const skin of meta.css.supportedSkins) { - // eslint-disable-next-line no-await-in-loop - await meta.css.buildBundle(`client-${skin}`, true); - } - require.main.require('./src/meta/minifier').killAll(); - } catch (err) { - console.error(err.stack); - } -} - -library.addAdminNavigation = async function (header) { - header.plugins.push({ - route: '/plugins/theme-quickstart', - icon: 'fa-paint-brush', - name: 'Theme Quick Start', - }); - return header; -}; - -library.addProfileItem = async (data) => { - data.links.push({ - id: 'theme', - route: 'theme', - icon: 'fa-paint-brush', - name: '[[themes/harmony:settings.title]]', - visibility: { - self: true, - other: false, - moderator: false, - globalMod: false, - admin: false, - }, - }); - - return data; -}; - -library.defineWidgetAreas = async function (areas) { - const locations = ['header', 'sidebar', 'footer']; - const templates = [ - 'categories.tpl', 'category.tpl', 'topic.tpl', 'users.tpl', - 'unread.tpl', 'recent.tpl', 'popular.tpl', 'top.tpl', 'tags.tpl', 'tag.tpl', - 'login.tpl', 'register.tpl', - ]; - function capitalizeFirst(str) { - return str.charAt(0).toUpperCase() + str.slice(1); - } - templates.forEach((template) => { - locations.forEach((location) => { - areas.push({ - name: `${capitalizeFirst(template.split('.')[0])} ${capitalizeFirst(location)}`, - template: template, - location: location, - }); - }); - }); - - areas = areas.concat([ - { - name: 'Main post header', - template: 'topic.tpl', - location: 'mainpost-header', - }, - { - name: 'Main post footer', - template: 'topic.tpl', - location: 'mainpost-footer', - }, - { - name: 'Sidebar Footer', - template: 'global', - location: 'sidebar-footer', - }, - { - name: 'Brand Header', - template: 'global', - location: 'brand-header', - }, - { - name: 'About me (before)', - template: 'account/profile.tpl', - location: 'profile-aboutme-before', - }, - { - name: 'About me (after)', - template: 'account/profile.tpl', - location: 'profile-aboutme-after', - }, - ]); - - return areas; -}; - -library.loadThemeConfig = async function (uid) { - const [themeConfig, userConfig] = await Promise.all([ - meta.settings.get('harmony'), - user.getSettings(uid), - ]); - - const config = { ...defaults, ...themeConfig, ...(_.pick(userConfig, Object.keys(defaults))) }; - config.enableQuickReply = config.enableQuickReply === 'on'; - config.enableBreadcrumbs = config.enableBreadcrumbs === 'on'; - config.centerHeaderElements = config.centerHeaderElements === 'on'; - config.mobileTopicTeasers = config.mobileTopicTeasers === 'on'; - config.stickyToolbar = config.stickyToolbar === 'on'; - config.autohideBottombar = config.autohideBottombar === 'on'; - config.openSidebars = config.openSidebars === 'on'; - config.chatModals = config.chatModals === 'on'; - return config; -}; - -library.getThemeConfig = async function (config) { - config.theme = await library.loadThemeConfig(config.uid); - config.openDraftsOnPageLoad = false; - return config; -}; - -library.getAdminSettings = async function (hookData) { - if (hookData.plugin === 'harmony') { - hookData.values = { - ...defaults, - ...hookData.values, - }; - } - return hookData; -}; - -library.saveUserSettings = async function (hookData) { - Object.keys(defaults).forEach((key) => { - if (hookData.data.hasOwnProperty(key)) { - hookData.settings[key] = hookData.data[key] || undefined; - } - }); - return hookData; -}; - -library.filterMiddlewareRenderHeader = async function (hookData) { - hookData.templateData.bootswatchSkinOptions = await meta.css.getSkinSwitcherOptions(hookData.req.uid); - return hookData; -}; - diff --git a/custom_themes/nodebb-theme-testing/package.json b/custom_themes/nodebb-theme-testing/package.json deleted file mode 100644 index 34e100dd53..0000000000 --- a/custom_themes/nodebb-theme-testing/package.json +++ /dev/null @@ -1,32 +0,0 @@ -{ - "name": "nodebb-theme-testing", - "version": "0.1.0", - "description": "Enter a description here", - "main": "lib/theme.js", - "keywords": [], - "license": "MIT", - "husky": { - "hooks": { - "pre-commit": "npx lint-staged", - "commit-msg": "npx commitlint -E HUSKY_GIT_PARAMS" - } - }, - "lint-staged": { - "*.js": [ - "eslint --fix", - "git add" - ] - }, - "dependencies": { - }, - "devDependencies": { - "@commitlint/cli": "11.0.0", - "@commitlint/config-angular": "11.0.0", - "eslint": "8.x", - "eslint-config-airbnb-base": "14.2.1", - "eslint-config-nodebb": "0.1.1", - "eslint-plugin-import": "2.x", - "husky": "5.0.9", - "lint-staged": "10.5.4" - } -} diff --git a/custom_themes/nodebb-theme-testing/plugin.json b/custom_themes/nodebb-theme-testing/plugin.json deleted file mode 100644 index 62a12b6f6f..0000000000 --- a/custom_themes/nodebb-theme-testing/plugin.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "id": "nodebb-theme-testing", - "hooks": [ - { "hook": "static:app.load", "method": "init" }, - { "hook": "filter:admin.header.build", "method": "addAdminNavigation" }, - { "hook": "filter:widgets.getAreas", "method": "defineWidgetAreas" }, - { "hook": "filter:config.get", "method": "getThemeConfig" }, - { "hook": "filter:settings.get", "method": "getAdminSettings"}, - { "hook": "filter:user.saveSettings", "method": "saveUserSettings" }, - { "hook": "filter:user.profileMenu", "method": "addProfileItem" }, - { "hook": "filter:middleware.renderHeader", "method": "filterMiddlewareRenderHeader" } - ], - "scripts": [ - "public/client.js", - "../nodebb-theme-harmony/public/harmony.js" - ], - "templates": "templates", - "modules": { - "../admin/plugins/theme-testing.js": "../nodebb-theme-harmony/public/admin.js", - "../client/account/theme.js": "../nodebb-theme-harmony/public/settings.js" - }, - "staticDirs": { - "inter": "node_modules/@fontsource/inter/files", - "poppins": "node_modules/@fontsource/poppins/files" - } -} diff --git a/custom_themes/nodebb-theme-testing/public/.eslintrc b/custom_themes/nodebb-theme-testing/public/.eslintrc deleted file mode 100644 index a3ce8297a6..0000000000 --- a/custom_themes/nodebb-theme-testing/public/.eslintrc +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "nodebb/public" -} diff --git a/custom_themes/nodebb-theme-testing/public/client.js b/custom_themes/nodebb-theme-testing/public/client.js deleted file mode 100644 index c346f0a5c1..0000000000 --- a/custom_themes/nodebb-theme-testing/public/client.js +++ /dev/null @@ -1,19 +0,0 @@ -'use strict'; - -/* - Hey there! - - This is the client file for your theme. If you need to do any client-side work in javascript, - this is where it needs to go. - - You can listen for page changes by writing something like this: - - $(window).on('action:ajaxify.end', function(ev, data) { - var url = data.url; - console.log('I am now at: ' + url); - }); -*/ - -$(document).ready(function () { - // Your code goes here -}); diff --git a/custom_themes/nodebb-theme-testing/scss/overrides.scss b/custom_themes/nodebb-theme-testing/scss/overrides.scss deleted file mode 100644 index e3d9d96917..0000000000 --- a/custom_themes/nodebb-theme-testing/scss/overrides.scss +++ /dev/null @@ -1,79 +0,0 @@ -// only overrides to bs5 variables here - -// below are the default values from harmony theme overrides.scss file -// feel free to change these for your custom theme - -// Harmony colours -$white: #fff !default; -$gray-100: #f8f9fa !default; -$gray-200: #e9ecef !default; -$gray-300: #dee2e6 !default; -$gray-400: #ced4da !default; -$gray-500: #adb5bd !default; -$gray-600: #6c757d !default; -$gray-700: #495057 !default; -$gray-800: #343a40 !default; -$gray-900: #212529 !default; -$black: #000 !default; - -$blue: #0d6efd !default; -$red: #dc3545 !default; -$yellow: #ffc107 !default; -$green: #198754 !default; -$cyan: #0dcaf0 !default; - -$primary: $blue !default; -$secondary: $gray-600 !default; -$success: $green !default; -$info: $cyan !default; -$warning: $yellow !default; -$danger: $red !default; -$light: $gray-100 !default; -$dark: $gray-900 !default; - -$body-color: $gray-800 !default; -$body-bg: $white !default; -$body-tertiary-bg: $gray-200 !default; -$text-muted: $gray-600 !default; -$border-color: $gray-200 !default; -$link-color: shade-color($blue, 20%) !default; - -$btn-ghost-hover-color: mix($light, $dark, 90%); -$btn-ghost-active-color: lighten($btn-ghost-hover-color, 5%); -$btn-ghost-hover-color-dark: mix($dark, $light, 90%); -$btn-ghost-active-color-dark: lighten($btn-ghost-hover-color-dark, 5%); - -:root { - --btn-ghost-hover-color: #{$btn-ghost-hover-color}; - --btn-ghost-active-color: #{$btn-ghost-active-color}; -} -[data-bs-theme="dark"] { - --btn-ghost-hover-color: #{$btn-ghost-hover-color-dark}; - --btn-ghost-active-color: #{$btn-ghost-active-color-dark}; -} - -// no caret on dropdown-toggle -$enable-caret: false; - -// disable smooth scroll, this makes window.scrollTo(0,0) in ajaxify.js take x milliseconds -$enable-smooth-scroll: false; - -$enable-shadows: true; - -$link-decoration: none; -$link-hover-decoration: underline; - -// Custom fonts -$font-family-sans-serif: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans", "Liberation Sans", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"; -$font-family-secondary: "Poppins", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans", "Liberation Sans", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji" !default; -$font-weight-semibold: 500 !default; -$small-font-size: 0.875rem !default; - -$breadcrumb-divider: quote("→"); -$breadcrumb-divider-color: $gray-500 !default; -$breadcrumb-active-color: $body-color !default; -$breadcrumb-item-padding-x: 12px !default; - -.form-control::placeholder, .bootstrap-tagsinput::placeholder { - color: $gray-500 !important; -} diff --git a/custom_themes/nodebb-theme-testing/templates/admin/plugins/theme-quickstart.tpl b/custom_themes/nodebb-theme-testing/templates/admin/plugins/theme-quickstart.tpl deleted file mode 100644 index 289011ad6d..0000000000 --- a/custom_themes/nodebb-theme-testing/templates/admin/plugins/theme-quickstart.tpl +++ /dev/null @@ -1,56 +0,0 @@ -
- - -
-
-
-
- - -
-
- - -
-
- - -
-
- - -
-
- -
- [[themes/harmony:settings.stickyToolbar]] -

- [[themes/harmony:settings.stickyToolbar.help]] -

-
-
-
- -
- [[themes/harmony:settings.autohideBottombar]] -

- [[themes/harmony:settings.autohideBottombar.help]] -

-
-
-
- - -
-
- -
- [[themes/harmony:settings.chatModals]] -
-
-
-
- - -
-
diff --git a/custom_themes/nodebb-theme-testing/templates/partials/topic-list-bar.tpl b/custom_themes/nodebb-theme-testing/templates/partials/topic-list-bar.tpl deleted file mode 100644 index 16b58d6215..0000000000 --- a/custom_themes/nodebb-theme-testing/templates/partials/topic-list-bar.tpl +++ /dev/null @@ -1,63 +0,0 @@ -
- -
diff --git a/custom_themes/nodebb-theme-testing/templates/templates.md b/custom_themes/nodebb-theme-testing/templates/templates.md deleted file mode 100644 index 31a2022077..0000000000 --- a/custom_themes/nodebb-theme-testing/templates/templates.md +++ /dev/null @@ -1,5 +0,0 @@ -You can override templates from Harmony theme by placing your tpl files in this folder. - -Use the same filename as the file you want to override. For example if you want to override recent.tpl name your file recent.tpl. If you want to override groups/list.tpl name your file groups/list.tpl and so on. - -You can also create entirely new templates and render them in an express route with `res.render('/path/to/yourtemplate', dataToUse);` \ No newline at end of file diff --git a/custom_themes/nodebb-theme-testing/theme.json b/custom_themes/nodebb-theme-testing/theme.json deleted file mode 100644 index f8eabf99bd..0000000000 --- a/custom_themes/nodebb-theme-testing/theme.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "id": "nodebb-theme-testing", - "name": "Testing", - "description": "Clone of CMU Quickstart Theme", - "url": "https://github.com/nodebb/nodebb-theme-testing", - "baseTheme": "nodebb-theme-harmony" -} diff --git a/custom_themes/nodebb-theme-testing/theme.scss b/custom_themes/nodebb-theme-testing/theme.scss deleted file mode 100644 index 0205216253..0000000000 --- a/custom_themes/nodebb-theme-testing/theme.scss +++ /dev/null @@ -1,4 +0,0 @@ -// override harmony font-path -$font-path: "./plugins/nodebb-theme-quickstart"; - -@import "../nodebb-theme-harmony/theme";