Wiki source code of History

Last modified by Manuel Leduc on 2025/01/28 09:42

Show last authors
1 {{box cssClass="floatinginfobox" title="**Contents**"}}
2 {{toc/}}
3 {{/box}}
4
5
6 = Description =
7
8 The History API provides components that can be used to access and manage the page history for backends that support it. It is required to display the "History" tab on a Cristal page.
9
10 = Details =
11
12 A ##PageRevisionManager## is a component that offers one method:
13
14 {{code language="typescript"}}
15 /**
16 * Returns the revisions for a given page.
17 *
18 * @param pageData - the page for which to get the revisions
19 * @param limit - the number of revisions to fetch
20 * @param offset - the number of revisions to skip
21 * @returns the page revisions
22 */
23 getRevisions(
24 pageData: PageData,
25 limit?: number,
26 offset?: number,
27 ): Promise<Array<PageRevision>>;
28 {{/code}}
29
30 A ##PageRevision## is a simple data structure that stores all the metadata of a specific revision for a given page:
31
32 {{code language="typescript"}}
33 /**
34 * Description of a revision for a given page.
35 */
36 type PageRevision = {
37 version: string;
38 date: Date;
39 user: UserDetails;
40 comment: string;
41 url: string;
42 };
43
44 {{/code}}
45
46 It is expected that any [[backend>>cristal:Backends.WebHome]] supporting versioning should implement their own ##PageRevisionManager##. //E.g.,//
47
48 {{code language="typescript"}}
49 /**
50 * Implementation of PageRevisionManager for the XWiki backend.
51 **/
52 @injectable()
53 class XWikiPageRevisionManager implements PageRevisionManager {
54 // XWiki specific implementation.
55 }
56 {{/code}}
57
58 Each backend-specific implementation should be registered with the name of the backend that they support, and will then be available through ##DefaultPageRevisionManagerProvider.get()## whenever the backend is in use. At the same time, if ##DefaultPageRevisionManagerProvider.has()## returns false for a given backend, some features (such as the "History" tab) will be disabled for this backend.
France 2030 Logo

This project is being financed by the French State as part of the France 2030 program

Ce projet est financé par l’État Français dans le cadre de France 2030

  • Powered by XWiki 18.4.6 - node1. Hosted and managed by XWiki SAS

Get Connected