@teleporthq/teleport-project-generator-next 0.45.21 → 0.45.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/__tests__/code-copy-runtime.test.ts +31 -24
- package/__tests__/forum-files-route.test.ts +147 -0
- package/__tests__/forum-markdown.test.ts +136 -0
- package/__tests__/forum-page-data.test.ts +1329 -0
- package/__tests__/forum-project-plugin.test.ts +789 -0
- package/__tests__/forum-replies-route.test.ts +82 -0
- package/__tests__/forum-topics-only-end2end.test.ts +124 -0
- package/__tests__/i18n-app-runtime.test.ts +187 -0
- package/__tests__/page-revalidate-plugin.test.ts +111 -0
- package/__tests__/rich-text-editor-frame.test.ts +25 -0
- package/dist/cjs/forum/files-route.d.ts +26 -0
- package/dist/cjs/forum/files-route.d.ts.map +1 -0
- package/dist/cjs/forum/files-route.js +42 -0
- package/dist/cjs/forum/files-route.js.map +1 -0
- package/dist/cjs/forum/markdown-source.d.ts +17 -0
- package/dist/cjs/forum/markdown-source.d.ts.map +1 -0
- package/dist/cjs/forum/markdown-source.js +23 -0
- package/dist/cjs/forum/markdown-source.js.map +1 -0
- package/dist/cjs/forum/notifications-route.d.ts +17 -0
- package/dist/cjs/forum/notifications-route.d.ts.map +1 -0
- package/dist/cjs/forum/notifications-route.js +30 -0
- package/dist/cjs/forum/notifications-route.js.map +1 -0
- package/dist/cjs/forum/page-data-source.d.ts +58 -0
- package/dist/cjs/forum/page-data-source.d.ts.map +1 -0
- package/dist/cjs/forum/page-data-source.js +168 -0
- package/dist/cjs/forum/page-data-source.js.map +1 -0
- package/dist/cjs/forum/page-rewrite.d.ts +50 -0
- package/dist/cjs/forum/page-rewrite.d.ts.map +1 -0
- package/dist/cjs/forum/page-rewrite.js +473 -0
- package/dist/cjs/forum/page-rewrite.js.map +1 -0
- package/dist/cjs/forum/project-plugin.d.ts +34 -0
- package/dist/cjs/forum/project-plugin.d.ts.map +1 -0
- package/dist/cjs/forum/project-plugin.js +272 -0
- package/dist/cjs/forum/project-plugin.js.map +1 -0
- package/dist/cjs/forum/replies-route.d.ts +21 -0
- package/dist/cjs/forum/replies-route.d.ts.map +1 -0
- package/dist/cjs/forum/replies-route.js +33 -0
- package/dist/cjs/forum/replies-route.js.map +1 -0
- package/dist/cjs/forum/seo.d.ts +29 -0
- package/dist/cjs/forum/seo.d.ts.map +1 -0
- package/dist/cjs/forum/seo.js +61 -0
- package/dist/cjs/forum/seo.js.map +1 -0
- package/dist/cjs/forum/settings.d.ts +97 -0
- package/dist/cjs/forum/settings.d.ts.map +1 -0
- package/dist/cjs/forum/settings.js +162 -0
- package/dist/cjs/forum/settings.js.map +1 -0
- package/dist/cjs/index.d.ts +1 -0
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +87 -80
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/instant-search/sections.d.ts.map +1 -1
- package/dist/cjs/instant-search/sections.js +18 -0
- package/dist/cjs/instant-search/sections.js.map +1 -1
- package/dist/cjs/instant-search/settings.d.ts +1 -1
- package/dist/cjs/instant-search/settings.d.ts.map +1 -1
- package/dist/cjs/instant-search/settings.js +2 -0
- package/dist/cjs/instant-search/settings.js.map +1 -1
- package/dist/cjs/internationalization/app-i18n-runtime.d.ts +39 -0
- package/dist/cjs/internationalization/app-i18n-runtime.d.ts.map +1 -0
- package/dist/cjs/internationalization/app-i18n-runtime.js +126 -0
- package/dist/cjs/internationalization/app-i18n-runtime.js.map +1 -0
- package/dist/cjs/internationalization/project.d.ts.map +1 -1
- package/dist/cjs/internationalization/project.js +6 -0
- package/dist/cjs/internationalization/project.js.map +1 -1
- package/dist/cjs/page-revalidate/project-plugin.d.ts.map +1 -1
- package/dist/cjs/page-revalidate/project-plugin.js +5 -1
- package/dist/cjs/page-revalidate/project-plugin.js.map +1 -1
- package/dist/cjs/rich-text-editor/content-support-source.d.ts +2 -1
- package/dist/cjs/rich-text-editor/content-support-source.d.ts.map +1 -1
- package/dist/cjs/rich-text-editor/content-support-source.js +9 -2
- package/dist/cjs/rich-text-editor/content-support-source.js.map +1 -1
- package/dist/cjs/tsconfig.tsbuildinfo +1 -1
- package/dist/esm/forum/files-route.d.ts +26 -0
- package/dist/esm/forum/files-route.d.ts.map +1 -0
- package/dist/esm/forum/files-route.js +38 -0
- package/dist/esm/forum/files-route.js.map +1 -0
- package/dist/esm/forum/markdown-source.d.ts +17 -0
- package/dist/esm/forum/markdown-source.d.ts.map +1 -0
- package/dist/esm/forum/markdown-source.js +19 -0
- package/dist/esm/forum/markdown-source.js.map +1 -0
- package/dist/esm/forum/notifications-route.d.ts +17 -0
- package/dist/esm/forum/notifications-route.d.ts.map +1 -0
- package/dist/esm/forum/notifications-route.js +26 -0
- package/dist/esm/forum/notifications-route.js.map +1 -0
- package/dist/esm/forum/page-data-source.d.ts +58 -0
- package/dist/esm/forum/page-data-source.d.ts.map +1 -0
- package/dist/esm/forum/page-data-source.js +164 -0
- package/dist/esm/forum/page-data-source.js.map +1 -0
- package/dist/esm/forum/page-rewrite.d.ts +50 -0
- package/dist/esm/forum/page-rewrite.d.ts.map +1 -0
- package/dist/esm/forum/page-rewrite.js +446 -0
- package/dist/esm/forum/page-rewrite.js.map +1 -0
- package/dist/esm/forum/project-plugin.d.ts +34 -0
- package/dist/esm/forum/project-plugin.d.ts.map +1 -0
- package/dist/esm/forum/project-plugin.js +269 -0
- package/dist/esm/forum/project-plugin.js.map +1 -0
- package/dist/esm/forum/replies-route.d.ts +21 -0
- package/dist/esm/forum/replies-route.d.ts.map +1 -0
- package/dist/esm/forum/replies-route.js +29 -0
- package/dist/esm/forum/replies-route.js.map +1 -0
- package/dist/esm/forum/seo.d.ts +29 -0
- package/dist/esm/forum/seo.d.ts.map +1 -0
- package/dist/esm/forum/seo.js +56 -0
- package/dist/esm/forum/seo.js.map +1 -0
- package/dist/esm/forum/settings.d.ts +97 -0
- package/dist/esm/forum/settings.d.ts.map +1 -0
- package/dist/esm/forum/settings.js +158 -0
- package/dist/esm/forum/settings.js.map +1 -0
- package/dist/esm/index.d.ts +1 -0
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +6 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/instant-search/sections.d.ts.map +1 -1
- package/dist/esm/instant-search/sections.js +18 -0
- package/dist/esm/instant-search/sections.js.map +1 -1
- package/dist/esm/instant-search/settings.d.ts +1 -1
- package/dist/esm/instant-search/settings.d.ts.map +1 -1
- package/dist/esm/instant-search/settings.js +2 -0
- package/dist/esm/instant-search/settings.js.map +1 -1
- package/dist/esm/internationalization/app-i18n-runtime.d.ts +39 -0
- package/dist/esm/internationalization/app-i18n-runtime.d.ts.map +1 -0
- package/dist/esm/internationalization/app-i18n-runtime.js +120 -0
- package/dist/esm/internationalization/app-i18n-runtime.js.map +1 -0
- package/dist/esm/internationalization/project.d.ts.map +1 -1
- package/dist/esm/internationalization/project.js +6 -0
- package/dist/esm/internationalization/project.js.map +1 -1
- package/dist/esm/page-revalidate/project-plugin.d.ts.map +1 -1
- package/dist/esm/page-revalidate/project-plugin.js +5 -1
- package/dist/esm/page-revalidate/project-plugin.js.map +1 -1
- package/dist/esm/rich-text-editor/content-support-source.d.ts +2 -1
- package/dist/esm/rich-text-editor/content-support-source.d.ts.map +1 -1
- package/dist/esm/rich-text-editor/content-support-source.js +9 -2
- package/dist/esm/rich-text-editor/content-support-source.js.map +1 -1
- package/dist/esm/tsconfig.tsbuildinfo +1 -1
- package/package.json +19 -19
- package/src/forum/files-route.ts +133 -0
- package/src/forum/markdown-source.ts +177 -0
- package/src/forum/notifications-route.ts +87 -0
- package/src/forum/page-data-source.ts +810 -0
- package/src/forum/page-rewrite.ts +567 -0
- package/src/forum/project-plugin.ts +328 -0
- package/src/forum/replies-route.ts +91 -0
- package/src/forum/seo.ts +245 -0
- package/src/forum/settings.ts +261 -0
- package/src/index.ts +6 -0
- package/src/instant-search/sections.ts +20 -0
- package/src/instant-search/settings.ts +2 -0
- package/src/internationalization/app-i18n-runtime.ts +165 -0
- package/src/internationalization/project.ts +7 -0
- package/src/page-revalidate/project-plugin.ts +5 -1
- package/src/rich-text-editor/content-support-source.ts +14 -2
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
16
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
17
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
18
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
19
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
24
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
|
+
function step(op) {
|
|
27
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
29
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
30
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
+
switch (op[0]) {
|
|
32
|
+
case 0: case 1: t = op; break;
|
|
33
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
+
default:
|
|
37
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
+
if (t[2]) _.ops.pop();
|
|
42
|
+
_.trys.pop(); continue;
|
|
43
|
+
}
|
|
44
|
+
op = body.call(thisArg, _);
|
|
45
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
50
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
51
|
+
if (ar || !(i in from)) {
|
|
52
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
53
|
+
ar[i] = from[i];
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
57
|
+
};
|
|
58
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
59
|
+
exports.NextForumProjectPlugin = exports.FORUM_FILE_KEYS = void 0;
|
|
60
|
+
var teleport_types_1 = require("@teleporthq/teleport-types");
|
|
61
|
+
var teleport_shared_1 = require("@teleporthq/teleport-shared");
|
|
62
|
+
var teleport_plugin_next_workflows_1 = require("@teleporthq/teleport-plugin-next-workflows");
|
|
63
|
+
var locales_1 = require("../pwa/locales");
|
|
64
|
+
var settings_1 = require("./settings");
|
|
65
|
+
var markdown_source_1 = require("./markdown-source");
|
|
66
|
+
var page_data_source_1 = require("./page-data-source");
|
|
67
|
+
var replies_route_1 = require("./replies-route");
|
|
68
|
+
var files_route_1 = require("./files-route");
|
|
69
|
+
var notifications_route_1 = require("./notifications-route");
|
|
70
|
+
var seo_1 = require("./seo");
|
|
71
|
+
var page_rewrite_1 = require("./page-rewrite");
|
|
72
|
+
exports.FORUM_FILE_KEYS = {
|
|
73
|
+
markdown: 'forum-markdown',
|
|
74
|
+
pageData: 'forum-page-data',
|
|
75
|
+
repliesRoute: 'forum-replies-route',
|
|
76
|
+
filesRoute: 'forum-files-route',
|
|
77
|
+
notificationsRoute: 'forum-notifications-route',
|
|
78
|
+
sitemap: 'forum-sitemap',
|
|
79
|
+
llms: 'forum-llms',
|
|
80
|
+
pageArrival: "resource-".concat(teleport_shared_1.PageArrival.PAGE_ARRIVAL_DIR.join('/'), "/").concat(teleport_shared_1.PageArrival.PAGE_ARRIVAL_FILE_NAME),
|
|
81
|
+
};
|
|
82
|
+
/** `/api/plugins/forum/replies` → `pages/api/plugins/forum` + `replies`. */
|
|
83
|
+
var routeFile = function (route) {
|
|
84
|
+
var segments = route.split('/').filter(Boolean);
|
|
85
|
+
return { path: __spreadArray(['pages'], segments.slice(0, -1), true), name: segments[segments.length - 1] };
|
|
86
|
+
};
|
|
87
|
+
var setJsFile = function (structure, key, path, name, content) {
|
|
88
|
+
structure.files.set(key, { path: path, files: [{ name: name, fileType: teleport_types_1.FileType.JS, content: content }] });
|
|
89
|
+
};
|
|
90
|
+
var hasFile = function (files, path, name) {
|
|
91
|
+
var found = false;
|
|
92
|
+
files.forEach(function (record) {
|
|
93
|
+
var _a;
|
|
94
|
+
if (!found && ((_a = record === null || record === void 0 ? void 0 : record.path) === null || _a === void 0 ? void 0 : _a.join('/')) === path.join('/')) {
|
|
95
|
+
found = (record.files || []).some(function (file) { return (file === null || file === void 0 ? void 0 : file.name) === name; });
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
return found;
|
|
99
|
+
};
|
|
100
|
+
var segmentsOf = function (route) { return route.split('/').filter(Boolean); };
|
|
101
|
+
/** A details page is written under its column: `/forum/t/[slug]` at `pages/forum/t/[slug].js`. */
|
|
102
|
+
var detailsPageFile = function (route) { return ({
|
|
103
|
+
folder: __spreadArray(['pages'], segmentsOf(route.staticBase), true),
|
|
104
|
+
name: "[".concat(route.column, "]"),
|
|
105
|
+
}); };
|
|
106
|
+
/** A static page is written under its last segment: `/forum/new` at `pages/forum/new.js`. */
|
|
107
|
+
var staticPageFile = function (route) {
|
|
108
|
+
var _a;
|
|
109
|
+
var segments = segmentsOf(route);
|
|
110
|
+
var name = (_a = segments.pop()) !== null && _a !== void 0 ? _a : 'index';
|
|
111
|
+
return { folder: __spreadArray(['pages'], segments, true), name: name };
|
|
112
|
+
};
|
|
113
|
+
/** The generated page at `address`, as `files` keeps it. */
|
|
114
|
+
var findPageFile = function (files, address) {
|
|
115
|
+
var folder = address.folder.join('/');
|
|
116
|
+
var name = address.name;
|
|
117
|
+
var found = null;
|
|
118
|
+
files.forEach(function (record) {
|
|
119
|
+
var _a;
|
|
120
|
+
if (found || ((_a = record === null || record === void 0 ? void 0 : record.path) === null || _a === void 0 ? void 0 : _a.join('/')) !== folder) {
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
var file = (record.files || []).find(function (candidate) {
|
|
124
|
+
return (candidate === null || candidate === void 0 ? void 0 : candidate.name) === name &&
|
|
125
|
+
typeof candidate.content === 'string' &&
|
|
126
|
+
candidate.fileType === teleport_types_1.FileType.JS;
|
|
127
|
+
});
|
|
128
|
+
if (file) {
|
|
129
|
+
found = { record: record, file: file };
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
return found;
|
|
133
|
+
};
|
|
134
|
+
/** What the page reads its row as (`initialPropsData.exposeAs.name`), from the project's routes. */
|
|
135
|
+
var exposeAsOf = function (uidl, route) {
|
|
136
|
+
var _a, _b, _c, _d;
|
|
137
|
+
var values = (_c = (_b = (_a = uidl.root) === null || _a === void 0 ? void 0 : _a.stateDefinitions) === null || _b === void 0 ? void 0 : _b.route) === null || _c === void 0 ? void 0 : _c.values;
|
|
138
|
+
var navLink = "".concat(route.staticBase, "/[").concat(route.column, "]");
|
|
139
|
+
for (var _i = 0, _e = Array.isArray(values) ? values : []; _i < _e.length; _i++) {
|
|
140
|
+
var value = _e[_i];
|
|
141
|
+
var pageOptions = value === null || value === void 0 ? void 0 : value.pageOptions;
|
|
142
|
+
if ((pageOptions === null || pageOptions === void 0 ? void 0 : pageOptions.navLink) !== navLink) {
|
|
143
|
+
continue;
|
|
144
|
+
}
|
|
145
|
+
var exposeAs = (_d = pageOptions.initialPropsData) === null || _d === void 0 ? void 0 : _d.exposeAs;
|
|
146
|
+
return typeof (exposeAs === null || exposeAs === void 0 ? void 0 : exposeAs.name) === 'string' && exposeAs.name ? exposeAs.name : null;
|
|
147
|
+
}
|
|
148
|
+
return null;
|
|
149
|
+
};
|
|
150
|
+
var DETAILS_PAGES = ['topic', 'community', 'manage', 'newTopic'];
|
|
151
|
+
/**
|
|
152
|
+
* The pages the project has, of the ones served per request: its details
|
|
153
|
+
* pages, each about the record its address names, and — in a forum without
|
|
154
|
+
* communities — the static New topic page, always about the main community
|
|
155
|
+
* (no route column, no record prop).
|
|
156
|
+
*/
|
|
157
|
+
var forumPageTargets = function (uidl, config) {
|
|
158
|
+
var targets = [];
|
|
159
|
+
for (var _i = 0, DETAILS_PAGES_1 = DETAILS_PAGES; _i < DETAILS_PAGES_1.length; _i++) {
|
|
160
|
+
var kind = DETAILS_PAGES_1[_i];
|
|
161
|
+
var route = config.routes[kind];
|
|
162
|
+
if (route) {
|
|
163
|
+
targets.push({
|
|
164
|
+
kind: kind,
|
|
165
|
+
file: detailsPageFile(route),
|
|
166
|
+
record: { column: route.column },
|
|
167
|
+
exposeAs: exposeAsOf(uidl, route),
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
if (config.composerPath) {
|
|
172
|
+
targets.push({
|
|
173
|
+
kind: 'newTopic',
|
|
174
|
+
file: staticPageFile(config.composerPath),
|
|
175
|
+
record: { slug: settings_1.FORUM_MAIN_COMMUNITY_SLUG },
|
|
176
|
+
exposeAs: null,
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
return targets;
|
|
180
|
+
};
|
|
181
|
+
/**
|
|
182
|
+
* The Forum plugin on the published site (plan §12): the read side only, since
|
|
183
|
+
* every write is an editor-built workflow. Emits the Markdown renderer and the
|
|
184
|
+
* forum data module, the replies and notifications routes, the forum's own
|
|
185
|
+
* sitemap and llms file, and rewrites the four details pages to render per
|
|
186
|
+
* request through the module (`page-rewrite.ts`): the session decides what is
|
|
187
|
+
* shown. To a non-member, a private community's topic answers `notFound` and
|
|
188
|
+
* its own page shows the About side only (`viewer.can_read` false, no
|
|
189
|
+
* topics). Anonymous answers of the topic and community pages are cached 30 s
|
|
190
|
+
* at the edge, signed-in ones never. A community's Manage and New topic pages
|
|
191
|
+
* are served to who moderates it and to a signed-in viewer who can read it,
|
|
192
|
+
* `notFound` to anyone else, and are never cached nor indexed. A forum without
|
|
193
|
+
* communities (`settings.structure`) has the topic page and a static New topic
|
|
194
|
+
* page, served through the same gate for its main community; no community is
|
|
195
|
+
* named, linked or listed there. A project without the plugin comes out
|
|
196
|
+
* exactly as before.
|
|
197
|
+
*/
|
|
198
|
+
var NextForumProjectPlugin = /** @class */ (function () {
|
|
199
|
+
function NextForumProjectPlugin() {
|
|
200
|
+
}
|
|
201
|
+
NextForumProjectPlugin.prototype.runBefore = function (structure) {
|
|
202
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
203
|
+
return __generator(this, function (_a) {
|
|
204
|
+
return [2 /*return*/, structure];
|
|
205
|
+
});
|
|
206
|
+
});
|
|
207
|
+
};
|
|
208
|
+
NextForumProjectPlugin.prototype.runAfter = function (structure) {
|
|
209
|
+
var _a;
|
|
210
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
211
|
+
var uidl, dependencies, config, withSessionRevocation, replies, files, notifications, _i, _b, _c, name_1, version;
|
|
212
|
+
return __generator(this, function (_d) {
|
|
213
|
+
uidl = structure.uidl, dependencies = structure.dependencies;
|
|
214
|
+
config = (0, settings_1.resolveForumConfig)(uidl);
|
|
215
|
+
if (!config) {
|
|
216
|
+
return [2 /*return*/, structure];
|
|
217
|
+
}
|
|
218
|
+
withSessionRevocation = ((_a = uidl.authentication) === null || _a === void 0 ? void 0 : _a.enabled) === true;
|
|
219
|
+
setJsFile(structure, exports.FORUM_FILE_KEYS.markdown, markdown_source_1.FORUM_MARKDOWN_MODULE_PATH, markdown_source_1.FORUM_MARKDOWN_MODULE_NAME, (0, markdown_source_1.buildForumMarkdownSource)());
|
|
220
|
+
setJsFile(structure, exports.FORUM_FILE_KEYS.pageData, page_data_source_1.FORUM_PAGE_DATA_MODULE_PATH, page_data_source_1.FORUM_PAGE_DATA_MODULE_NAME, (0, page_data_source_1.buildForumPageDataSource)(config, { withSessionRevocation: withSessionRevocation }));
|
|
221
|
+
replies = routeFile(replies_route_1.FORUM_REPLIES_ROUTE);
|
|
222
|
+
setJsFile(structure, exports.FORUM_FILE_KEYS.repliesRoute, replies.path, replies.name, (0, replies_route_1.buildForumRepliesRouteSource)({ withSessionRevocation: withSessionRevocation }));
|
|
223
|
+
files = routeFile(files_route_1.FORUM_FILES_ROUTE);
|
|
224
|
+
setJsFile(structure, exports.FORUM_FILE_KEYS.filesRoute, files.path, files.name, (0, files_route_1.buildForumFilesRouteSource)({ withSessionRevocation: withSessionRevocation }));
|
|
225
|
+
if (config.settings.notifications) {
|
|
226
|
+
notifications = routeFile(notifications_route_1.FORUM_NOTIFICATIONS_ROUTE);
|
|
227
|
+
setJsFile(structure, exports.FORUM_FILE_KEYS.notificationsRoute, notifications.path, notifications.name, (0, notifications_route_1.buildForumNotificationsRouteSource)({ withSessionRevocation: withSessionRevocation }));
|
|
228
|
+
}
|
|
229
|
+
setJsFile(structure, exports.FORUM_FILE_KEYS.sitemap, ['pages'], seo_1.FORUM_SITEMAP_PATH.slice(1), (0, seo_1.buildForumSitemapPageSource)(config, {
|
|
230
|
+
multilingual: Boolean(uidl.internationalization) && (0, locales_1.resolveAppLocales)(uidl).locales.length > 1,
|
|
231
|
+
}));
|
|
232
|
+
setJsFile(structure, exports.FORUM_FILE_KEYS.llms, ['pages'], seo_1.FORUM_LLMS_PATH.slice(1), (0, seo_1.buildForumLlmsPageSource)(config));
|
|
233
|
+
// The routes count their visitors through the shared security runtime; the
|
|
234
|
+
// module reads the database through the same driver as the data API.
|
|
235
|
+
(0, teleport_plugin_next_workflows_1.ensureSecurityRuntimeModule)(structure);
|
|
236
|
+
for (_i = 0, _b = Object.entries((0, teleport_plugin_next_workflows_1.getDatabaseDriverDependencies)('teleport')); _i < _b.length; _i++) {
|
|
237
|
+
_c = _b[_i], name_1 = _c[0], version = _c[1];
|
|
238
|
+
if (!dependencies[name_1]) {
|
|
239
|
+
dependencies[name_1] = version;
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
this.rewritePages(structure, config);
|
|
243
|
+
return [2 /*return*/, structure];
|
|
244
|
+
});
|
|
245
|
+
});
|
|
246
|
+
};
|
|
247
|
+
NextForumProjectPlugin.prototype.rewritePages = function (structure, config) {
|
|
248
|
+
var uidl = structure.uidl, files = structure.files;
|
|
249
|
+
var remounts = false;
|
|
250
|
+
for (var _i = 0, _a = forumPageTargets(uidl, config); _i < _a.length; _i++) {
|
|
251
|
+
var target = _a[_i];
|
|
252
|
+
var page = findPageFile(files, target.file);
|
|
253
|
+
if (!page) {
|
|
254
|
+
continue;
|
|
255
|
+
}
|
|
256
|
+
var rootPrefix = page.record.path.map(function () { return '..'; }).join('/') + '/';
|
|
257
|
+
var result = (0, page_rewrite_1.rewriteForumPage)(page.file.content, __assign(__assign({}, target.record), { kind: target.kind, exposeAs: target.exposeAs, rootPrefix: rootPrefix, dataModulePath: __spreadArray(__spreadArray([], page_data_source_1.FORUM_PAGE_DATA_MODULE_PATH, true), [page_data_source_1.FORUM_PAGE_DATA_MODULE_NAME], false).join('/'), pageArrivalPath: __spreadArray(__spreadArray([], teleport_shared_1.PageArrival.PAGE_ARRIVAL_DIR, true), [teleport_shared_1.PageArrival.PAGE_ARRIVAL_FILE_NAME], false).join('/') }));
|
|
258
|
+
if (!result) {
|
|
259
|
+
continue;
|
|
260
|
+
}
|
|
261
|
+
page.file.content = result.content;
|
|
262
|
+
remounts = remounts || result.remounts;
|
|
263
|
+
}
|
|
264
|
+
if (remounts &&
|
|
265
|
+
!hasFile(files, teleport_shared_1.PageArrival.PAGE_ARRIVAL_DIR, teleport_shared_1.PageArrival.PAGE_ARRIVAL_FILE_NAME)) {
|
|
266
|
+
setJsFile(structure, exports.FORUM_FILE_KEYS.pageArrival, __spreadArray([], teleport_shared_1.PageArrival.PAGE_ARRIVAL_DIR, true), teleport_shared_1.PageArrival.PAGE_ARRIVAL_FILE_NAME, teleport_shared_1.PageArrival.generatePageArrivalRuntime());
|
|
267
|
+
}
|
|
268
|
+
};
|
|
269
|
+
return NextForumProjectPlugin;
|
|
270
|
+
}());
|
|
271
|
+
exports.NextForumProjectPlugin = NextForumProjectPlugin;
|
|
272
|
+
//# sourceMappingURL=project-plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project-plugin.js","sourceRoot":"","sources":["../../../src/forum/project-plugin.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6DAOmC;AACnC,+DAAyD;AACzD,6FAGmD;AAEnD,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ACA,SAAS,CACP,SAAS,EACT,uBAAe,CAAC,WAAW,oBACvB,6BAAW,CAAC,gBAAgB,SAChC,6BAAW,CAAC,sBAAsB,EAClC,6BAAW,CAAC,0BAA0B,EAAE,CACzC,CAAA;SACF;IACH,CAAC;IACH,6BAAC;AAAD,CAAC,AA1HD,IA0HC;AA1HY,wDAAsB"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export declare const FORUM_REPLIES_ROUTE = "/api/plugins/forum/replies";
|
|
2
|
+
/** From `pages/api/plugins/forum/<route>.js` to the project root. */
|
|
3
|
+
export declare const FORUM_ROUTE_ROOT = "../../../..";
|
|
4
|
+
export declare const UUID_PATTERN = "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$";
|
|
5
|
+
/**
|
|
6
|
+
* `pages/api/plugins/forum/replies.js`: "Load more" and the reply sort on a
|
|
7
|
+
* topic page (plan D15). `?topic=<id>&root=<reply id>&sort=best|new|old&after=<n>`
|
|
8
|
+
* answers the next page of the tree through the data module, as the viewer
|
|
9
|
+
* the session cookie names: the same visibility rules as the page itself,
|
|
10
|
+
* never `readAsVisitor` (the replies table is bound by no public page). A
|
|
11
|
+
* visitor may ask 120 times per 10 minutes, counted by the shared security
|
|
12
|
+
* runtime. A topic the viewer may not read answers 404, like its page.
|
|
13
|
+
* Only a request that carries no credentials at all (no cookie, no
|
|
14
|
+
* authorization) may be cached: a member's list right after their own reply
|
|
15
|
+
* must never come from a cache, even when their session could not be read.
|
|
16
|
+
* `replyCount` is the topic's count of published replies.
|
|
17
|
+
*/
|
|
18
|
+
export declare const buildForumRepliesRouteSource: (options?: {
|
|
19
|
+
withSessionRevocation?: boolean;
|
|
20
|
+
}) => string;
|
|
21
|
+
//# sourceMappingURL=replies-route.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"replies-route.d.ts","sourceRoot":"","sources":["../../../src/forum/replies-route.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,mBAAmB,+BAA+B,CAAA;AAE/D,qEAAqE;AACrE,eAAO,MAAM,gBAAgB,gBAAgB,CAAA;AAK7C,eAAO,MAAM,YAAY,mEAAmE,CAAA;AAE5F;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,4BAA4B,aAC9B;IAAE,qBAAqB,CAAC,EAAE,OAAO,CAAA;CAAE,KAC3C,MA4DF,CAAA"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.buildForumRepliesRouteSource = exports.UUID_PATTERN = exports.FORUM_ROUTE_ROOT = exports.FORUM_REPLIES_ROUTE = void 0;
|
|
4
|
+
var teleport_shared_1 = require("@teleporthq/teleport-shared");
|
|
5
|
+
var teleport_plugin_next_workflows_1 = require("@teleporthq/teleport-plugin-next-workflows");
|
|
6
|
+
var source_literals_1 = require("../pwa/source-literals");
|
|
7
|
+
var page_data_source_1 = require("./page-data-source");
|
|
8
|
+
exports.FORUM_REPLIES_ROUTE = '/api/plugins/forum/replies';
|
|
9
|
+
/** From `pages/api/plugins/forum/<route>.js` to the project root. */
|
|
10
|
+
exports.FORUM_ROUTE_ROOT = '../../../..';
|
|
11
|
+
var DATA_MODULE_IMPORT = "".concat(exports.FORUM_ROUTE_ROOT, "/").concat(page_data_source_1.FORUM_PAGE_DATA_MODULE_PATH.join('/'), "/").concat(page_data_source_1.FORUM_PAGE_DATA_MODULE_NAME);
|
|
12
|
+
exports.UUID_PATTERN = '^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$';
|
|
13
|
+
/**
|
|
14
|
+
* `pages/api/plugins/forum/replies.js`: "Load more" and the reply sort on a
|
|
15
|
+
* topic page (plan D15). `?topic=<id>&root=<reply id>&sort=best|new|old&after=<n>`
|
|
16
|
+
* answers the next page of the tree through the data module, as the viewer
|
|
17
|
+
* the session cookie names: the same visibility rules as the page itself,
|
|
18
|
+
* never `readAsVisitor` (the replies table is bound by no public page). A
|
|
19
|
+
* visitor may ask 120 times per 10 minutes, counted by the shared security
|
|
20
|
+
* runtime. A topic the viewer may not read answers 404, like its page.
|
|
21
|
+
* Only a request that carries no credentials at all (no cookie, no
|
|
22
|
+
* authorization) may be cached: a member's list right after their own reply
|
|
23
|
+
* must never come from a cache, even when their session could not be read.
|
|
24
|
+
* `replyCount` is the topic's count of published replies.
|
|
25
|
+
*/
|
|
26
|
+
var buildForumRepliesRouteSource = function (options) {
|
|
27
|
+
if (options === void 0) { options = {}; }
|
|
28
|
+
return "var forum = require(".concat((0, source_literals_1.toJsLiteral)(DATA_MODULE_IMPORT), ");\nvar security = require(").concat((0, source_literals_1.toJsLiteral)((0, teleport_plugin_next_workflows_1.securityRuntimeSpecifier)(exports.FORUM_ROUTE_ROOT)), ");\n\n").concat(teleport_shared_1.SessionCookieResolver.generateCommonJsSessionTokenResolverCode(exports.FORUM_ROUTE_ROOT, {
|
|
29
|
+
withRevocation: options.withSessionRevocation !== false,
|
|
30
|
+
}), "\n\nvar UUID = new RegExp(").concat((0, source_literals_1.toJsLiteral)(exports.UUID_PATTERN), ", 'i');\nvar RATE_LIMIT = { scope: 'forum-replies', limit: 120, windowSeconds: 600 };\n\nfunction carriesCredentials(req) {\n var headers = (req && req.headers) || {};\n return !!(headers.cookie || headers.authorization);\n}\n\nfunction one(value) {\n return String(Array.isArray(value) ? value[0] : value == null ? '' : value).trim();\n}\n\nasync function sessionOf(req) {\n try {\n return await __tqSessionToken(req);\n } catch (error) {\n return null;\n }\n}\n\nexport default async function handler(req, res) {\n if (req.method !== 'GET') {\n res.setHeader('Allow', 'GET');\n return res.status(405).json({ success: false, error: 'Method not allowed' });\n }\n if (!(await security.rateLimitRequest(req, res, RATE_LIMIT))) {\n return;\n }\n var topicId = one(req.query.topic);\n var rootReplyId = one(req.query.root);\n if (!UUID.test(topicId) || (rootReplyId && !UUID.test(rootReplyId))) {\n return res.status(400).json({ success: false, error: 'This is not a topic.' });\n }\n var session = await sessionOf(req);\n res.setHeader('Cache-Control', session || carriesCredentials(req) ? 'private, no-store' : 'public, s-maxage=30, stale-while-revalidate=300');\n try {\n var result = await forum.loadReplies({\n topicId: topicId,\n rootReplyId: rootReplyId || null,\n sort: one(req.query.sort),\n after: parseInt(one(req.query.after), 10) || 0,\n session: session,\n });\n if (!result) {\n return res.status(404).json({ success: false, error: 'This topic is no longer available.' });\n }\n return res.status(200).json({ success: true, replies: result.replies, hasMore: result.hasMore, nextOffset: result.nextOffset, replyCount: result.replyCount });\n } catch (error) {\n console.error('[forum] replies could not be read:', error && error.message);\n res.setHeader('Cache-Control', 'no-store');\n return res.status(500).json({ success: false, error: 'The replies could not be loaded.' });\n }\n}\n");
|
|
31
|
+
};
|
|
32
|
+
exports.buildForumRepliesRouteSource = buildForumRepliesRouteSource;
|
|
33
|
+
//# sourceMappingURL=replies-route.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"replies-route.js","sourceRoot":"","sources":["../../../src/forum/replies-route.ts"],"names":[],"mappings":";;;AAAA,+DAAmE;AACnE,6FAAqF;AACrF,0DAAoD;AACpD,uDAA6F;AAEhF,QAAA,mBAAmB,GAAG,4BAA4B,CAAA;AAE/D,qEAAqE;AACxD,QAAA,gBAAgB,GAAG,aAAa,CAAA;AAC7C,IAAM,kBAAkB,GAAG,UAAG,wBAAgB,cAAI,8CAA2B,CAAC,IAAI,CAChF,GAAG,CACJ,cAAI,8CAA2B,CAAE,CAAA;AAErB,QAAA,YAAY,GAAG,gEAAgE,CAAA;AAE5F;;;;;;;;;;;;GAYG;AACI,IAAM,4BAA4B,GAAG,UAC1C,OAAiD;IAAjD,wBAAA,EAAA,YAAiD;IACtC,OAAA,8BAAuB,IAAA,6BAAW,EAAC,kBAAkB,CAAC,wCAC1C,IAAA,6BAAW,EAAC,IAAA,yDAAwB,EAAC,wBAAgB,CAAC,CAAC,mBAE9E,uCAAqB,CAAC,wCAAwC,CAAC,wBAAgB,EAAE;QACjF,cAAc,EAAE,OAAO,CAAC,qBAAqB,KAAK,KAAK;KACxD,CAAC,uCAEsB,IAAA,6BAAW,EAAC,oBAAY,CAAC,08DAqDhD;AA5DY,CA4DZ,CAAA;AA9DY,QAAA,4BAA4B,gCA8DxC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { ForumConfig } from './settings';
|
|
2
|
+
export declare const FORUM_SITEMAP_PATH = "/sitemap-forum.xml";
|
|
3
|
+
export declare const FORUM_LLMS_PATH = "/llms-forum.txt";
|
|
4
|
+
/**
|
|
5
|
+
* The forum's search-engine side, as JavaScript the data module carries:
|
|
6
|
+
*
|
|
7
|
+
* - `topicNoIndex(topic, community)`: a pending or removed topic, one in a
|
|
8
|
+
* private community or one not yet approved in a restricted one is kept out
|
|
9
|
+
* of search engines (plan 8.3);
|
|
10
|
+
* - `topicJsonLd(topic, community, replies, url)`: `DiscussionForumPosting`,
|
|
11
|
+
* and `QAPage` when the community takes questions and an answer is accepted.
|
|
12
|
+
*
|
|
13
|
+
* The page writes the JSON-LD into its head (see `page-rewrite.ts`).
|
|
14
|
+
*/
|
|
15
|
+
export declare const FORUM_SEO_RUNTIME = "// --- search engines --------------------------------------------------------\nfunction topicNoIndex(topic, community) {\n if (!topic || topic.status !== 'published') return true;\n if (!community || community.status !== 'active') return true;\n return community.visibility === 'private';\n}\n\nfunction personOf(row) {\n return row && row.author_name ? { '@type': 'Person', name: row.author_name } : undefined;\n}\n\nfunction postingOf(row, url) {\n return {\n '@type': 'Comment',\n text: row.body_text || '',\n url: url,\n author: personOf(row),\n datePublished: row.created_at || undefined,\n upvoteCount: typeof row.upvotes === 'number' ? row.upvotes : undefined,\n };\n}\n\nfunction topicJsonLd(topic, community, replies, url) {\n var answers = (replies || []).filter(function (reply) { return reply.is_accepted; });\n var isQuestion = community && community.kind === 'questions' && answers.length > 0;\n var posting = {\n '@type': 'DiscussionForumPosting',\n '@id': url,\n url: url,\n headline: topic.title,\n text: topic.body_text || '',\n author: personOf(topic),\n datePublished: topic.created_at || undefined,\n dateModified: topic.edited_at || topic.updated_at || undefined,\n interactionStatistic: [\n { '@type': 'InteractionCounter', interactionType: 'https://schema.org/CommentAction', userInteractionCount: topic.reply_count || 0 },\n { '@type': 'InteractionCounter', interactionType: 'https://schema.org/LikeAction', userInteractionCount: topic.upvotes || 0 },\n ],\n comment: (replies || []).slice(0, 20).map(function (reply) { return postingOf(reply, url + '#reply-' + reply.id); }),\n };\n if (!isQuestion) {\n posting['@context'] = 'https://schema.org';\n return posting;\n }\n return {\n '@context': 'https://schema.org',\n '@type': 'QAPage',\n mainEntity: {\n '@type': 'Question',\n name: topic.title,\n text: topic.body_text || '',\n author: personOf(topic),\n dateCreated: topic.created_at || undefined,\n answerCount: topic.reply_count || 0,\n upvoteCount: topic.upvotes || 0,\n acceptedAnswer: Object.assign(postingOf(answers[0], url + '#reply-' + answers[0].id), { '@type': 'Answer' }),\n },\n };\n}\n";
|
|
16
|
+
/**
|
|
17
|
+
* `pages/sitemap-forum.xml.js` and `pages/llms-forum.txt.js`: every public
|
|
18
|
+
* topic and every active community that is not private, read on request
|
|
19
|
+
* through the data module (`listPublicIndex`), as the content presets' live
|
|
20
|
+
* sitemap does (`blog/content-site-index.ts`). The forum's entries are kept
|
|
21
|
+
* in files of their own because the editor's `/llms.txt` page lists the
|
|
22
|
+
* presets' posts and is written by the blog plugin alone. A forum without
|
|
23
|
+
* communities lists its topics only.
|
|
24
|
+
*/
|
|
25
|
+
export declare const buildForumSitemapPageSource: (config: ForumConfig, options?: {
|
|
26
|
+
multilingual?: boolean;
|
|
27
|
+
}) => string;
|
|
28
|
+
export declare const buildForumLlmsPageSource: (config: ForumConfig) => string;
|
|
29
|
+
//# sourceMappingURL=seo.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"seo.d.ts","sourceRoot":"","sources":["../../../src/forum/seo.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AAExC,eAAO,MAAM,kBAAkB,uBAAuB,CAAA;AACtD,eAAO,MAAM,eAAe,oBAAoB,CAAA;AAEhD;;;;;;;;;;GAUG;AACH,eAAO,MAAM,iBAAiB,2tEA2D7B,CAAA;AAmDD;;;;;;;;GAQG;AACH,eAAO,MAAM,2BAA2B,WAC9B,WAAW,YACV;IAAE,YAAY,CAAC,EAAE,OAAO,CAAA;CAAE,KAClC,MAqDF,CAAA;AAED,eAAO,MAAM,wBAAwB,WAAY,WAAW,KAAG,MAkD9D,CAAA"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.buildForumLlmsPageSource = exports.buildForumSitemapPageSource = exports.FORUM_SEO_RUNTIME = exports.FORUM_LLMS_PATH = exports.FORUM_SITEMAP_PATH = void 0;
|
|
4
|
+
var source_literals_1 = require("../pwa/source-literals");
|
|
5
|
+
exports.FORUM_SITEMAP_PATH = '/sitemap-forum.xml';
|
|
6
|
+
exports.FORUM_LLMS_PATH = '/llms-forum.txt';
|
|
7
|
+
/**
|
|
8
|
+
* The forum's search-engine side, as JavaScript the data module carries:
|
|
9
|
+
*
|
|
10
|
+
* - `topicNoIndex(topic, community)`: a pending or removed topic, one in a
|
|
11
|
+
* private community or one not yet approved in a restricted one is kept out
|
|
12
|
+
* of search engines (plan 8.3);
|
|
13
|
+
* - `topicJsonLd(topic, community, replies, url)`: `DiscussionForumPosting`,
|
|
14
|
+
* and `QAPage` when the community takes questions and an answer is accepted.
|
|
15
|
+
*
|
|
16
|
+
* The page writes the JSON-LD into its head (see `page-rewrite.ts`).
|
|
17
|
+
*/
|
|
18
|
+
exports.FORUM_SEO_RUNTIME = "// --- search engines --------------------------------------------------------\nfunction topicNoIndex(topic, community) {\n if (!topic || topic.status !== 'published') return true;\n if (!community || community.status !== 'active') return true;\n return community.visibility === 'private';\n}\n\nfunction personOf(row) {\n return row && row.author_name ? { '@type': 'Person', name: row.author_name } : undefined;\n}\n\nfunction postingOf(row, url) {\n return {\n '@type': 'Comment',\n text: row.body_text || '',\n url: url,\n author: personOf(row),\n datePublished: row.created_at || undefined,\n upvoteCount: typeof row.upvotes === 'number' ? row.upvotes : undefined,\n };\n}\n\nfunction topicJsonLd(topic, community, replies, url) {\n var answers = (replies || []).filter(function (reply) { return reply.is_accepted; });\n var isQuestion = community && community.kind === 'questions' && answers.length > 0;\n var posting = {\n '@type': 'DiscussionForumPosting',\n '@id': url,\n url: url,\n headline: topic.title,\n text: topic.body_text || '',\n author: personOf(topic),\n datePublished: topic.created_at || undefined,\n dateModified: topic.edited_at || topic.updated_at || undefined,\n interactionStatistic: [\n { '@type': 'InteractionCounter', interactionType: 'https://schema.org/CommentAction', userInteractionCount: topic.reply_count || 0 },\n { '@type': 'InteractionCounter', interactionType: 'https://schema.org/LikeAction', userInteractionCount: topic.upvotes || 0 },\n ],\n comment: (replies || []).slice(0, 20).map(function (reply) { return postingOf(reply, url + '#reply-' + reply.id); }),\n };\n if (!isQuestion) {\n posting['@context'] = 'https://schema.org';\n return posting;\n }\n return {\n '@context': 'https://schema.org',\n '@type': 'QAPage',\n mainEntity: {\n '@type': 'Question',\n name: topic.title,\n text: topic.body_text || '',\n author: personOf(topic),\n dateCreated: topic.created_at || undefined,\n answerCount: topic.reply_count || 0,\n upvoteCount: topic.upvotes || 0,\n acceptedAnswer: Object.assign(postingOf(answers[0], url + '#reply-' + answers[0].id), { '@type': 'Answer' }),\n },\n };\n}\n";
|
|
19
|
+
var SINGLE_LANGUAGE_ENTRIES_SOURCE = " var base = origin(context.req)\n var lines = ['<?xml version=\"1.0\" encoding=\"UTF-8\"?>', '<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">']\n var entry = function (path, at) {\n lines.push(' <url>')\n lines.push(' <loc>' + xmlText(base + path) + '</loc>')\n if (at) lines.push(' <lastmod>' + xmlText(at) + '</lastmod>')\n lines.push(' </url>')\n }\n";
|
|
20
|
+
/**
|
|
21
|
+
* A site in several languages: each page once per language (the default
|
|
22
|
+
* unprefixed, the others under `/<locale>`), each naming every language's
|
|
23
|
+
* address and the default one as `x-default` — as the editor's static
|
|
24
|
+
* sitemap and the content presets' live one write theirs.
|
|
25
|
+
*/
|
|
26
|
+
var MULTILINGUAL_ENTRIES_SOURCE = " var base = origin(context.req)\n var main = context.defaultLocale || null\n var locales = [main].concat((Array.isArray(context.locales) ? context.locales : []).filter(function (locale) {\n return locale && locale !== main\n }))\n var lines = ['<?xml version=\"1.0\" encoding=\"UTF-8\"?>', '<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\" xmlns:xhtml=\"http://www.w3.org/1999/xhtml\">']\n var entry = function (path, at) {\n var addresses = locales.map(function (locale) {\n return { lang: locale, url: base + (locale && locale !== main ? '/' + locale : '') + path }\n })\n var alternates = addresses.length > 1 ? addresses.concat([{ lang: 'x-default', url: base + path }]) : []\n addresses.forEach(function (address) {\n lines.push(' <url>')\n lines.push(' <loc>' + xmlText(address.url) + '</loc>')\n if (at) lines.push(' <lastmod>' + xmlText(at) + '</lastmod>')\n alternates.forEach(function (alternate) {\n lines.push(' <xhtml:link rel=\"alternate\" hreflang=\"' + xmlText(alternate.lang) + '\" href=\"' + xmlText(alternate.url) + '\" />')\n })\n lines.push(' </url>')\n })\n }\n";
|
|
27
|
+
/** Source only a forum with communities gets: one without them names, links and lists none. */
|
|
28
|
+
var withCommunities = function (config, source) {
|
|
29
|
+
return config.settings.structure === 'communities' ? source : '';
|
|
30
|
+
};
|
|
31
|
+
var communityBaseSource = function (config) {
|
|
32
|
+
var _a, _b;
|
|
33
|
+
return withCommunities(config, "var COMMUNITY_BASE = ".concat((0, source_literals_1.toJsLiteral)((_b = (_a = config.routes.community) === null || _a === void 0 ? void 0 : _a.staticBase) !== null && _b !== void 0 ? _b : '/forum/c'), "\n"));
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* `pages/sitemap-forum.xml.js` and `pages/llms-forum.txt.js`: every public
|
|
37
|
+
* topic and every active community that is not private, read on request
|
|
38
|
+
* through the data module (`listPublicIndex`), as the content presets' live
|
|
39
|
+
* sitemap does (`blog/content-site-index.ts`). The forum's entries are kept
|
|
40
|
+
* in files of their own because the editor's `/llms.txt` page lists the
|
|
41
|
+
* presets' posts and is written by the blog plugin alone. A forum without
|
|
42
|
+
* communities lists its topics only.
|
|
43
|
+
*/
|
|
44
|
+
var buildForumSitemapPageSource = function (config, options) {
|
|
45
|
+
var _a, _b;
|
|
46
|
+
if (options === void 0) { options = {}; }
|
|
47
|
+
var topicBase = (_b = (_a = config.routes.topic) === null || _a === void 0 ? void 0 : _a.staticBase) !== null && _b !== void 0 ? _b : '/forum/t';
|
|
48
|
+
var communityEntries = withCommunities(config, " index.communities.forEach(function (row) { entry(COMMUNITY_BASE + '/' + encodeURIComponent(row.slug), row.updated_at) })\n");
|
|
49
|
+
return "import { listPublicIndex } from '../utils/forum-page-data'\n\nvar TOPIC_BASE = ".concat((0, source_literals_1.toJsLiteral)(topicBase), "\n").concat(communityBaseSource(config), "\nfunction xmlText(value) {\n return String(value == null ? '' : value)\n .replace(/[^\\x09\\x0a\\x0d\\x20-\\uD7FF\\uE000-\\uFFFD]/g, '')\n .replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/\"/g, '"').replace(/'/g, ''')\n}\n\nfunction origin(req) {\n var host = String((req && req.headers && req.headers.host) || '')\n if (!/^[a-z0-9.-]+(:\\d+)?$/i.test(host)) return ''\n var proto = String(req.headers['x-forwarded-proto'] || '').split(',')[0].trim()\n var local = /^(localhost|127\\.0\\.0\\.1)(:\\d+)?$/.test(host)\n return (proto === 'http' || proto === 'https' ? proto : local ? 'http' : 'https') + '://' + host\n}\n\n// ").concat(exports.FORUM_SITEMAP_PATH, ", read on request. Generated from the Forum plugin.\nexport async function getServerSideProps(context) {\n var res = context.res\n var index\n try {\n index = await listPublicIndex()\n } catch (error) {\n console.error('[forum] the sitemap could not be read: ' + (error && error.message ? error.message : String(error)))\n res.statusCode = 503\n res.setHeader('Retry-After', '300')\n res.setHeader('Cache-Control', 'no-store')\n res.end('This file is unavailable right now. Try again in a few minutes.')\n return { props: {} }\n }\n").concat(options.multilingual ? MULTILINGUAL_ENTRIES_SOURCE : SINGLE_LANGUAGE_ENTRIES_SOURCE).concat(communityEntries, " index.topics.forEach(function (row) { entry(TOPIC_BASE + '/' + encodeURIComponent(row.slug), row.updated_at) })\n lines.push('</urlset>')\n res.statusCode = 200\n res.setHeader('Content-Type', 'application/xml; charset=utf-8')\n res.setHeader('Cache-Control', 'public, s-maxage=600, stale-while-revalidate=3600')\n res.end(lines.join('\\n'))\n return { props: {} }\n}\n\nexport default function ForumSitemap() {\n return null\n}\n");
|
|
50
|
+
};
|
|
51
|
+
exports.buildForumSitemapPageSource = buildForumSitemapPageSource;
|
|
52
|
+
var buildForumLlmsPageSource = function (config) {
|
|
53
|
+
var _a, _b;
|
|
54
|
+
var topicBase = (_b = (_a = config.routes.topic) === null || _a === void 0 ? void 0 : _a.staticBase) !== null && _b !== void 0 ? _b : '/forum/t';
|
|
55
|
+
var communityWords = withCommunities(config, 'communities and ');
|
|
56
|
+
var communityHeading = withCommunities(config, ", '', '## Communities', ''");
|
|
57
|
+
var communityLinks = withCommunities(config, " index.communities.forEach(function (row) {\n lines.push('- [' + linkText(row.name) + '](' + base + COMMUNITY_BASE + '/' + encodeURIComponent(row.slug) + ')' + (row.description ? ': ' + linkText(row.description).slice(0, 200) : ''))\n })\n");
|
|
58
|
+
return "import { listPublicIndex } from '../utils/forum-page-data'\n\nvar TOPIC_BASE = ".concat((0, source_literals_1.toJsLiteral)(topicBase), "\n").concat(communityBaseSource(config), "\nfunction linkText(value) {\n return String(value == null ? '' : value).replace(/\\s+/g, ' ').replace(/[\\[\\]]/g, '\\\\$&').trim()\n}\n\n// ").concat(exports.FORUM_LLMS_PATH, ": the forum's ").concat(communityWords, "public topics, for language models.\nexport async function getServerSideProps(context) {\n var res = context.res\n var index\n try {\n index = await listPublicIndex()\n } catch (error) {\n res.statusCode = 503\n res.setHeader('Retry-After', '300')\n res.setHeader('Cache-Control', 'no-store')\n res.end('This file is unavailable right now. Try again in a few minutes.')\n return { props: {} }\n }\n var host = String((context.req && context.req.headers && context.req.headers.host) || '')\n var base = /^[a-z0-9.-]+(:\\d+)?$/i.test(host) ? 'https://' + host : ''\n var lines = ['# Forum'").concat(communityHeading, "]\n").concat(communityLinks, " lines.push('', '## Topics', '')\n index.topics.forEach(function (row) {\n lines.push('- [' + linkText(row.title) + '](' + base + TOPIC_BASE + '/' + encodeURIComponent(row.slug) + ')' + (row.excerpt ? ': ' + linkText(row.excerpt) : ''))\n })\n res.statusCode = 200\n res.setHeader('Content-Type', 'text/plain; charset=utf-8')\n res.setHeader('Cache-Control', 'public, s-maxage=600, stale-while-revalidate=3600')\n res.end(lines.join('\\n') + '\\n')\n return { props: {} }\n}\n\nexport default function ForumLlms() {\n return null\n}\n");
|
|
59
|
+
};
|
|
60
|
+
exports.buildForumLlmsPageSource = buildForumLlmsPageSource;
|
|
61
|
+
//# sourceMappingURL=seo.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"seo.js","sourceRoot":"","sources":["../../../src/forum/seo.ts"],"names":[],"mappings":";;;AAAA,0DAAoD;AAGvC,QAAA,kBAAkB,GAAG,oBAAoB,CAAA;AACzC,QAAA,eAAe,GAAG,iBAAiB,CAAA;AAEhD;;;;;;;;;;GAUG;AACU,QAAA,iBAAiB,GAAG,wtEA2DhC,CAAA;AAED,IAAM,8BAA8B,GAAG,0YAQtC,CAAA;AAED;;;;;GAKG;AACH,IAAM,2BAA2B,GAAG,wpCAqBnC,CAAA;AAED,+FAA+F;AAC/F,IAAM,eAAe,GAAG,UAAC,MAAmB,EAAE,MAAc;IAC1D,OAAA,MAAM,CAAC,QAAQ,CAAC,SAAS,KAAK,aAAa,CAAC,CAAC,CAAC,MAAM,CA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cAAc,knBAezB,gBAAgB,gBACxC,cAAc,uiBAcf,CAAA;AACD,CAAC,CAAA;AAlDY,QAAA,wBAAwB,4BAkDpC"}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { ProjectUIDL } from '@teleporthq/teleport-types';
|
|
2
|
+
import { DetailsRoute } from '../instant-search/sections';
|
|
3
|
+
/**
|
|
4
|
+
* The Forum plugin's settings as the editor stores them
|
|
5
|
+
* (`features/plugins/registry/definitions/forum.ts` there), its pages' routes
|
|
6
|
+
* (`uidl.plugins.forum.pages`, by page type) and the data source its tables
|
|
7
|
+
* live in. Every value is checked: the published site bakes them into the
|
|
8
|
+
* forum data module and its routes.
|
|
9
|
+
*/
|
|
10
|
+
export declare const FORUM_PLUGIN_KEY = "forum";
|
|
11
|
+
export declare const FORUM_TABLES: {
|
|
12
|
+
readonly communities: "teleport_forum_communities";
|
|
13
|
+
readonly memberships: "teleport_forum_memberships";
|
|
14
|
+
readonly topics: "teleport_forum_topics";
|
|
15
|
+
readonly replies: "teleport_forum_replies";
|
|
16
|
+
readonly votes: "teleport_forum_votes";
|
|
17
|
+
readonly reactions: "teleport_forum_reactions";
|
|
18
|
+
readonly reports: "teleport_forum_reports";
|
|
19
|
+
readonly subscriptions: "teleport_forum_subscriptions";
|
|
20
|
+
readonly profiles: "teleport_forum_profiles";
|
|
21
|
+
readonly notifications: "teleport_forum_notifications";
|
|
22
|
+
readonly topicViews: "teleport_forum_topic_views";
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* How the forum is organised: in communities members join, or as one list of
|
|
26
|
+
* topics. A topic is always stored in a community, so a forum without
|
|
27
|
+
* communities keeps every topic in one of its own — the main community —
|
|
28
|
+
* which the published site reads for the rights and never shows.
|
|
29
|
+
*/
|
|
30
|
+
export type ForumStructure = 'communities' | 'topics';
|
|
31
|
+
/**
|
|
32
|
+
* The slug of the main community. MUST stay in step with
|
|
33
|
+
* `FORUM_MAIN_COMMUNITY_SLUG` in the editor's
|
|
34
|
+
* `apps/gui/app/project-page/features/forum/constants/forum-structure.ts`.
|
|
35
|
+
*/
|
|
36
|
+
export declare const FORUM_MAIN_COMMUNITY_SLUG = "main";
|
|
37
|
+
export interface ForumSettings {
|
|
38
|
+
structure: ForumStructure;
|
|
39
|
+
membersCreateCommunities: boolean;
|
|
40
|
+
communityApproval: 'none' | 'owner';
|
|
41
|
+
maxCommunitiesPerMember: number;
|
|
42
|
+
defaultVisibility: 'public' | 'restricted' | 'private';
|
|
43
|
+
attachments: boolean;
|
|
44
|
+
maxAttachments: number;
|
|
45
|
+
tags: boolean;
|
|
46
|
+
editWindowMinutes: number;
|
|
47
|
+
replyNesting: 'nested' | 'flat';
|
|
48
|
+
topicsPerDay: number;
|
|
49
|
+
votes: 'updown' | 'up' | 'off';
|
|
50
|
+
reactions: boolean;
|
|
51
|
+
acceptedAnswers: 'questions' | 'all' | 'off';
|
|
52
|
+
reputation: boolean;
|
|
53
|
+
badges: boolean;
|
|
54
|
+
moderation: 'none' | 'newMembers' | 'all';
|
|
55
|
+
newMemberPosts: number;
|
|
56
|
+
holdLinks: boolean;
|
|
57
|
+
notifications: boolean;
|
|
58
|
+
emailOnReply: boolean;
|
|
59
|
+
}
|
|
60
|
+
/** A page of a community's topic list: what a project that never set it gets, and the most it may hold. */
|
|
61
|
+
export declare const FORUM_COMMUNITY_TOPICS_PER_PAGE = 20;
|
|
62
|
+
export declare const FORUM_COMMUNITY_TOPICS_PER_PAGE_MAX = 50;
|
|
63
|
+
/** The page types the editor's plugin record names (`forum-markers.ts` there). */
|
|
64
|
+
export type ForumPageType = 'home' | 'communities' | 'community' | 'topic' | 'new-topic' | 'manage';
|
|
65
|
+
/**
|
|
66
|
+
* The pages served per record. Three of them are pages of a community: its
|
|
67
|
+
* own, Manage and New topic. A forum without communities has the topic page
|
|
68
|
+
* and New topic only, the latter a static page (`ForumConfig.composerPath`).
|
|
69
|
+
*/
|
|
70
|
+
export type ForumDetailsPage = 'topic' | 'community' | 'manage' | 'newTopic';
|
|
71
|
+
export interface ForumConfig {
|
|
72
|
+
settings: ForumSettings;
|
|
73
|
+
/**
|
|
74
|
+
* The route of each page a forum of this structure has, as the editor
|
|
75
|
+
* resolved it; a details page is `<base>` (`/forum/t`), without its `[slug]`.
|
|
76
|
+
*/
|
|
77
|
+
pages: Partial<Record<ForumPageType, string>>;
|
|
78
|
+
/** Where each details page is served: `<staticBase>/[column]`. */
|
|
79
|
+
routes: Record<ForumDetailsPage, DetailsRoute | null>;
|
|
80
|
+
/**
|
|
81
|
+
* The New topic page of a forum without communities: a static page
|
|
82
|
+
* (`/forum/new`) that always writes in the main community. Null in a forum
|
|
83
|
+
* with communities, where it is a community's details page (`routes.newTopic`).
|
|
84
|
+
*/
|
|
85
|
+
composerPath: string | null;
|
|
86
|
+
/** How many topics a page of a community's list holds (the community page's own setting in the editor). */
|
|
87
|
+
communityTopicsPerPage: number;
|
|
88
|
+
/** The data source the forum tables are read through (the project's TeleportHQ one). */
|
|
89
|
+
dataSource: {
|
|
90
|
+
dataSourceId: string;
|
|
91
|
+
dataSourceType: string;
|
|
92
|
+
} | null;
|
|
93
|
+
}
|
|
94
|
+
export declare const FORUM_DEFAULTS: ForumSettings;
|
|
95
|
+
/** The plugin's configuration when the project has it on; null otherwise. */
|
|
96
|
+
export declare const resolveForumConfig: (uidl: ProjectUIDL) => ForumConfig | null;
|
|
97
|
+
//# sourceMappingURL=settings.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"settings.d.ts","sourceRoot":"","sources":["../../../src/forum/settings.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAA0B,MAAM,4BAA4B,CAAA;AAEhF,OAAO,EAAE,YAAY,EAA0B,MAAM,4BAA4B,CAAA;AAEjF;;;;;;GAMG;AAEH,eAAO,MAAM,gBAAgB,UAAU,CAAA;AACvC,eAAO,MAAM,YAAY;;;;;;;;;;;;CAA6B,CAAA;AAEtD;;;;;GAKG;AACH,MAAM,MAAM,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