Skip to content
This repository was archived by the owner on Jan 2, 2025. It is now read-only.

Replace nodebb profile with catalyst profile #6

Open
wants to merge 1 commit into
base: molecule
Choose a base branch
from
Open
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
22 changes: 22 additions & 0 deletions lib/controllers.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,25 @@ Controllers.renderThemeSettings = async (req, res, next) => {

res.render('account/theme', userData);
};

Controllers.renderProfilePage = (req, res) => {
res.send(`
<html>
<head></head>
<body></body>
<script>
window.onload = function () {
loadPageOutsideIFrame();
}
function loadPageOutsideIFrame() {
if (window !== window.parent) {
console.log('breaking out of iframe')
location.parent.href = '${req.redirectUrl}'
} else {
location.href = '${req.redirectUrl}'
}
}
</script>
</html>`);
res.end();
};
10 changes: 9 additions & 1 deletion library.js
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ const getChatroomForGroup = async (slug) => {
};

library.addChatToCategory = function (data, callback) {
privileges.categories.list(data.category.cid).then((res, err) => {
privileges.categories.list(data.category.cid).then((res) => {
const projectGroup = res.groups.find(group => group.isPrivate && group.name.startsWith('Project '));
if (!projectGroup) {
return callback(null, data);
Expand All @@ -243,3 +243,11 @@ library.addChatToCategory = function (data, callback) {
});
});
};

library.openCatalystProfilePage = async function (data) {
const config = await library.loadThemeConfig(0);
const baseUrl = config.catalystBaseUrl.endsWith('/') ?
config.catalystBaseUrl.replace('https://', '').slice(0, -1) :
config.catalystBaseUrl.replace('https://', '');
controllers.renderProfilePage({ ...data.req, redirectUrl: `https://${baseUrl}/profile/${data.templateData.username}` }, data.res);
};
3 changes: 2 additions & 1 deletion plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
{ "hook": "filter:user.whitelistFields", "method": "whitelistFields" },

{ "hook": "filter:category.get", "method": "addChatToCategory"},
{ "hook": "filter:parse.post", "method": "filterProfileLinks", "priority": 11}
{ "hook": "filter:parse.post", "method": "filterProfileLinks", "priority": 11},
{ "hook": "filter:account/profile.build", "method": "openCatalystProfilePage"}

],
"scripts": [
Expand Down
4 changes: 2 additions & 2 deletions templates/admin/plugins/harmony.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@
</div>
</div>
<div class="mb-3">
<label class="form-label" for="catalystProfileUrl">Catalyst Profile Base URL</label>
<input type="text" id="catalystProfileUrl" name="catalystProfileUrl" title="Catalyst profile URL" class="form-control" placeholder="https://app.catalyst.molecule.xyz/api/nodebb-profile" />
<label class="form-label" for="catalystBaseUrl">Catalyst Base URL</label>
<input type="text" id="catalystBaseUrl" name="catalystBaseUrl" title="Catalyst base URL" class="form-control" placeholder="https://app.catalyst.molecule.xyz/" />
</div>
</form>
</div>
Expand Down
76 changes: 0 additions & 76 deletions templates/partials/chats/message.tpl

This file was deleted.

4 changes: 2 additions & 2 deletions templates/partials/topic/post.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@


<span class="text-nowrap">
<!--a class="fw-bold" href="{{{ if ./user.userslug }}}{config.relative_path}/user/{./user.userslug}{{{ else }}}#{{{ end }}}" data-username="{posts.user.username}" data-uid="{posts.user.uid}" target="_parent">{posts.user.displayname}</a -->
<a class="fw-bold" href="{config.theme.catalystProfileUrl}/{./user.uid}" target="_parent">{posts.user.displayname}</a>
<a class="fw-bold" href="{{{ if ./user.userslug }}}{config.relative_path}/user/{./user.userslug}{{{ else }}}#{{{ end }}}" data-username="{posts.user.username}" data-uid="{posts.user.uid}" target="_blank">{posts.user.displayname}</a>
<!--a class="fw-bold" href="{config.theme.catalystProfileUrl}/{./user.uid}" target="_parent">{posts.user.displayname}</a -->
</span>

{{{ each posts.user.selectedGroups }}}
Expand Down