mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 08:36:12 +01:00
feat: beginnings of the /world route
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
{
|
||||
"intro-lead": "What is Federation?",
|
||||
"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.)",
|
||||
"no-topics": "This forum doesn't know of any other topics yet.",
|
||||
|
||||
"general": "General",
|
||||
"enabled": "Enable Federation"
|
||||
"acp.intro-lead": "What is 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;
|
||||
|
||||
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) {
|
||||
/**
|
||||
* 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);
|
||||
if (pid !== req.query.resource) {
|
||||
return helpers.redirect(res, `/topic/remote?resource=${pid}`, true);
|
||||
|
||||
@@ -1,10 +1,14 @@
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* These controllers only respond if the sender is making an json+activitypub style call (i.e. S2S-only)
|
||||
*/
|
||||
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)
|
||||
*/
|
||||
|
||||
const middlewares = [middleware.proceedOnActivityPub, middleware.exposeUid];
|
||||
|
||||
app.get('/user/:userslug', middlewares, controllers.activitypub.getActor);
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
const db = require('../database');
|
||||
const plugins = require('../plugins');
|
||||
const posts = require('../posts');
|
||||
const activitypub = require('../activitypub');
|
||||
|
||||
module.exports = function (Topics) {
|
||||
const terms = {
|
||||
@@ -73,7 +74,8 @@ module.exports = function (Topics) {
|
||||
data = await plugins.hooks.fire('filter:topics.updateRecent', { tid: tid, timestamp: 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">
|
||||
<!-- IMPORT admin/partials/settings/header.tpl -->
|
||||
|
||||
<p class="lead">[[admin/settings/activitypub:intro-lead]]</p>
|
||||
<p>[[admin/settings/activitypub:intro-body]]</p>
|
||||
<p class="lead">[[admin/settings/activitypub:acp.intro-lead]]</p>
|
||||
<p>[[admin/settings/activitypub:acp.intro-body]]</p>
|
||||
|
||||
<hr />
|
||||
|
||||
<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">
|
||||
<form>
|
||||
<div class="form-check form-switch mb-3">
|
||||
<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>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user