Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Revised] Incorporating frontend repo for deployment #59

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/azure-deploy-f24.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ jobs:
"redis:host": "${{ secrets.REDIS_HOST }}",
"redis:port": "6379",
"redis:password": "${{ secrets.REDIS_PASSWORD }}" }'

- name: Incorporate the frontend templates
run: |
npm install

- name: 'Deploy to Azure Web App'
id: deploy-to-webapp
Expand Down
Binary file modified dump.rdb
Binary file not shown.
3 changes: 3 additions & 0 deletions nodebb-frontend-f24-team-wooshiland/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "nodebb"
}
8 changes: 8 additions & 0 deletions nodebb-frontend-f24-team-wooshiland/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
*.css
npm-debug.log
sftp-config.json
*.sublime-project
*.sublime-workspace
.idea
.vscode
node_modules/
5 changes: 5 additions & 0 deletions nodebb-frontend-f24-team-wooshiland/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
*.css
npm-debug.log
sftp-config.json
*.sublime-project
*.sublime-workspace
19 changes: 19 additions & 0 deletions nodebb-frontend-f24-team-wooshiland/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Harmony theme for NodeBB
====================

The Harmony theme is the default theme for NodeBB for versions spanning v3.0.0 onwards.

## Issues

Issues are tracked in [the main project issue tracker](https://github.com/NodeBB/NodeBB/issues?q=is%3Aopen+is%3Aissue+label%3Athemes).

## Screenshots

### Categories
<img height="450" src="screenshots/categories.png">

### Recent
<img height="450" src="screenshots/recent.png">

### Topic
<img height="450" src="screenshots/topic.png">
1 change: 1 addition & 0 deletions nodebb-frontend-f24-team-wooshiland/languages/harmony.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
29 changes: 29 additions & 0 deletions nodebb-frontend-f24-team-wooshiland/lib/controllers.js
Original file line number Diff line number Diff line change
@@ -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/harmony', {
title: '[[themes/harmony:theme-name]]',
});
};

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('../library');
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);
};
190 changes: 190 additions & 0 deletions nodebb-frontend-f24-team-wooshiland/library.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,190 @@
'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('./lib/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/harmony', [], 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/harmony',
icon: 'fa-paint-brush',
name: '[[themes/harmony:theme-name]]',
});
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;
};

library.filterTeasersConfigureStripTags = function (hookData) {
// teasers have a stretched-link to go to last post, the anchors in them are not clickable
hookData.tags.push('a');
return hookData;
};
48 changes: 48 additions & 0 deletions nodebb-frontend-f24-team-wooshiland/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{
"name": "nodebb-theme-harmony",
"version": "1.2.63",
"nbbpm": {
"compatibility": "^3.7.0"
},
"description": "Harmony theme for NodeBB",
"main": "library.js",
"repository": {
"type": "git",
"url": "https://github.com/NodeBB/nodebb-theme-harmony"
},
"scripts": {
"lint": "eslint ."
},
"keywords": [
"nodebb",
"theme",
"forum",
"bootstrap",
"responsive"
],
"contributors": [
{
"name": "Julian Lam",
"email": "[email protected]",
"url": "https://github.com/julianlam"
},
{
"name": "Barış Soner Uşaklı",
"email": "[email protected]",
"url": "https://github.com/barisusakli"
}
],
"license": "MIT",
"bugs": {
"url": "https://github.com/NodeBB/nodebb-theme-harmony/issues"
},
"dependencies": {
"@fontsource/inter": "5.0.15",
"@fontsource/poppins": "5.0.8"
},
"devDependencies": {
"eslint": "^9.0.0",
"eslint-config-nodebb": "^0.2.0",
"eslint-plugin-import": "^2.24.2"
}
}
26 changes: 26 additions & 0 deletions nodebb-frontend-f24-team-wooshiland/plugin.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"id": "nodebb-theme-harmony",
"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" },
{ "hook": "filter:teasers.configureStripTags", "method": "filterTeasersConfigureStripTags"}
],
"scripts": [
"public/harmony.js"
],
"modules": {
"../admin/plugins/harmony.js": "public/admin.js",
"../client/account/theme.js": "public/settings.js"
},
"staticDirs": {
"inter": "node_modules/@fontsource/inter/files",
"poppins": "node_modules/@fontsource/poppins/files"
},
"languages": "languages"
}
3 changes: 3 additions & 0 deletions nodebb-frontend-f24-team-wooshiland/public/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "nodebb/public"
}
15 changes: 15 additions & 0 deletions nodebb-frontend-f24-team-wooshiland/public/admin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
'use strict';

define('admin/plugins/harmony', ['settings'], function (Settings) {
var ACP = {};

ACP.init = function () {
Settings.load('harmony', $('.harmony-settings'));

$('#save').on('click', function () {
Settings.save('harmony', $('.harmony-settings'));
});
};

return ACP;
});
Loading