mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-27 09:06:15 +01:00
feat: beginnings of the /world route
This commit is contained in:
@@ -1,7 +1,8 @@
|
|||||||
{
|
{
|
||||||
"intro-lead": "What is Federation?",
|
"no-topics": "This forum doesn't know of any other topics yet.",
|
||||||
"intro-body": "NodeBB is able to communicate with other NodeBB instances that support it. This is achieved through a protocol called <a href=\"https://activitypub.rocks/\">ActivityPub</a>. If enabled, NodeBB will also be able to communicate with other apps and websites that use ActivityPub (e.g. Mastodon, Peertube, etc.)",
|
|
||||||
|
|
||||||
"general": "General",
|
"acp.intro-lead": "What is Federation?",
|
||||||
"enabled": "Enable Federation"
|
"acp.intro-body": "NodeBB is able to communicate with other NodeBB instances that support it. This is achieved through a protocol called <a href=\"https://activitypub.rocks/\">ActivityPub</a>. If enabled, NodeBB will also be able to communicate with other apps and websites that use ActivityPub (e.g. Mastodon, Peertube, etc.)",
|
||||||
|
"acp.general": "General",
|
||||||
|
"acp.enabled": "Enable Federation"
|
||||||
}
|
}
|
||||||
@@ -14,7 +14,25 @@ const helpers = require('../helpers');
|
|||||||
|
|
||||||
const controller = module.exports;
|
const controller = module.exports;
|
||||||
|
|
||||||
|
controller.list = async function (req, res, next) {
|
||||||
|
const { topicsPerPage } = await user.getSettings(req.uid);
|
||||||
|
const page = parseInt(req.query.page, 10) || 1;
|
||||||
|
const start = Math.max(0, (page - 1) * topicsPerPage);
|
||||||
|
const stop = start + topicsPerPage - 1;
|
||||||
|
|
||||||
|
const tids = await db.getSortedSetRevRange('cid:-1:tids', start, stop);
|
||||||
|
const topicData = await topics.getTopicsByTids(tids, { uid: req.uid });
|
||||||
|
topics.calculateTopicIndices(topicData, start);
|
||||||
|
res.render('world', {
|
||||||
|
topics: topicData,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
controller.get = async function (req, res, next) {
|
controller.get = async function (req, res, next) {
|
||||||
|
/**
|
||||||
|
* Ideally we would use the existing topicsController.get...
|
||||||
|
* this controller may be a stopgap towards that end goal.
|
||||||
|
*/
|
||||||
const pid = await notes.resolveId(req.uid, req.query.resource);
|
const pid = await notes.resolveId(req.uid, req.query.resource);
|
||||||
if (pid !== req.query.resource) {
|
if (pid !== req.query.resource) {
|
||||||
return helpers.redirect(res, `/topic/remote?resource=${pid}`, true);
|
return helpers.redirect(res, `/topic/remote?resource=${pid}`, true);
|
||||||
|
|||||||
@@ -1,10 +1,14 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
const helpers = require('./helpers');
|
||||||
|
|
||||||
|
module.exports = function (app, middleware, controllers) {
|
||||||
|
helpers.setupPageRoute(app, '/world/:view?', controllers.activitypub.topics.list);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* These controllers only respond if the sender is making an json+activitypub style call (i.e. S2S-only)
|
* These controllers only respond if the sender is making an json+activitypub style call (i.e. S2S-only)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
module.exports = function (app, middleware, controllers) {
|
|
||||||
const middlewares = [middleware.proceedOnActivityPub, middleware.exposeUid];
|
const middlewares = [middleware.proceedOnActivityPub, middleware.exposeUid];
|
||||||
|
|
||||||
app.get('/user/:userslug', middlewares, controllers.activitypub.getActor);
|
app.get('/user/:userslug', middlewares, controllers.activitypub.getActor);
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
const db = require('../database');
|
const db = require('../database');
|
||||||
const plugins = require('../plugins');
|
const plugins = require('../plugins');
|
||||||
const posts = require('../posts');
|
const posts = require('../posts');
|
||||||
|
const activitypub = require('../activitypub');
|
||||||
|
|
||||||
module.exports = function (Topics) {
|
module.exports = function (Topics) {
|
||||||
const terms = {
|
const terms = {
|
||||||
@@ -73,7 +74,8 @@ module.exports = function (Topics) {
|
|||||||
data = await plugins.hooks.fire('filter:topics.updateRecent', { tid: tid, timestamp: timestamp });
|
data = await plugins.hooks.fire('filter:topics.updateRecent', { tid: tid, timestamp: timestamp });
|
||||||
}
|
}
|
||||||
if (data && data.tid && data.timestamp) {
|
if (data && data.tid && data.timestamp) {
|
||||||
await db.sortedSetAdd('topics:recent', data.timestamp, data.tid);
|
const setPrefix = activitypub.helpers.isUri(data.tid) ? 'topicsRemote' : 'topics';
|
||||||
|
await db.sortedSetAdd(`${setPrefix}:recent`, data.timestamp, data.tid);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,18 +1,18 @@
|
|||||||
<div class="acp-page-container">
|
<div class="acp-page-container">
|
||||||
<!-- IMPORT admin/partials/settings/header.tpl -->
|
<!-- IMPORT admin/partials/settings/header.tpl -->
|
||||||
|
|
||||||
<p class="lead">[[admin/settings/activitypub:intro-lead]]</p>
|
<p class="lead">[[admin/settings/activitypub:acp.intro-lead]]</p>
|
||||||
<p>[[admin/settings/activitypub:intro-body]]</p>
|
<p>[[admin/settings/activitypub:acp.intro-body]]</p>
|
||||||
|
|
||||||
<hr />
|
<hr />
|
||||||
|
|
||||||
<div class="row settings m-0">
|
<div class="row settings m-0">
|
||||||
<div class="col-sm-2 col-12 settings-header">[[admin/settings/activitypub:general]]</div>
|
<div class="col-sm-2 col-12 settings-header">[[admin/settings/activitypub:acp.general]]</div>
|
||||||
<div class="col-sm-10 col-12">
|
<div class="col-sm-10 col-12">
|
||||||
<form>
|
<form>
|
||||||
<div class="form-check form-switch mb-3">
|
<div class="form-check form-switch mb-3">
|
||||||
<input class="form-check-input" type="checkbox" data-field="activitypubEnabled">
|
<input class="form-check-input" type="checkbox" data-field="activitypubEnabled">
|
||||||
<label class="form-check-label">[[admin/settings/activitypub:enabled]]</label>
|
<label class="form-check-label">[[admin/settings/activitypub:acp.enabled]]</label>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user