@xwiki/cristal-navigation-tree-xwiki 0.10.0 → 0.11.0
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/CHANGELOG.md +13 -0
- package/dist/components/componentsInit.d.ts +0 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.es.js +77 -67
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/index.umd.js.map +1 -1
- package/package.json +6 -5
- package/src/components/componentsInit.ts +81 -48
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# @xwiki/cristal-navigation-tree-xwiki
|
|
2
2
|
|
|
3
|
+
## 0.11.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- d54422d: Cristal 0.11 Release
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies [d54422d]
|
|
12
|
+
- @xwiki/cristal-api@0.11.0
|
|
13
|
+
- @xwiki/cristal-authentication-api@0.11.0
|
|
14
|
+
- @xwiki/cristal-navigation-tree-api@0.11.0
|
|
15
|
+
|
|
3
16
|
## 0.10.0
|
|
4
17
|
|
|
5
18
|
### Minor Changes
|
package/dist/index.d.ts
CHANGED
package/dist/index.es.js
CHANGED
|
@@ -1,88 +1,98 @@
|
|
|
1
|
-
import { injectable as
|
|
2
|
-
import { name as
|
|
3
|
-
var
|
|
4
|
-
for (var t =
|
|
5
|
-
(s =
|
|
6
|
-
return
|
|
7
|
-
},
|
|
8
|
-
let
|
|
9
|
-
constructor(
|
|
10
|
-
this.logger =
|
|
1
|
+
import { injectable as d, inject as c } from "inversify";
|
|
2
|
+
import { name as u } from "@xwiki/cristal-navigation-tree-api";
|
|
3
|
+
var f = Object.defineProperty, m = Object.getOwnPropertyDescriptor, v = (i, e, o, r) => {
|
|
4
|
+
for (var t = r > 1 ? void 0 : r ? m(e, o) : e, n = i.length - 1, s; n >= 0; n--)
|
|
5
|
+
(s = i[n]) && (t = (r ? s(e, o, t) : s(t)) || t);
|
|
6
|
+
return r && t && f(e, o, t), t;
|
|
7
|
+
}, p = (i, e) => (o, r) => e(o, r, i);
|
|
8
|
+
let g = class {
|
|
9
|
+
constructor(i, e, o) {
|
|
10
|
+
this.authenticationManagerProvider = o, this.logger = i, this.logger.setModule(
|
|
11
11
|
"navigation-tree-xwiki.components.XWikiNavigationTreeSource"
|
|
12
12
|
), this.cristalApp = e;
|
|
13
13
|
}
|
|
14
|
-
async getChildNodes(
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
);
|
|
18
|
-
n.search = new URLSearchParams([
|
|
19
|
-
["id", e],
|
|
20
|
-
["outputSyntax", "plain"],
|
|
21
|
-
["sheet", "XWiki.DocumentTree"],
|
|
22
|
-
["data", "children"],
|
|
23
|
-
["compact", "true"]
|
|
24
|
-
]).toString();
|
|
14
|
+
async getChildNodes(i) {
|
|
15
|
+
var r;
|
|
16
|
+
const e = i || "#", o = [];
|
|
25
17
|
try {
|
|
26
|
-
const t = this.
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
(a) => {
|
|
31
|
-
if (!["attachments", "translations"].includes(a.data.type)) {
|
|
32
|
-
const p = decodeURIComponent(
|
|
33
|
-
this.cristalApp.getWikiConfig().storage.getPageFromViewURL(
|
|
34
|
-
`${t}${a.a_attr.href}`
|
|
35
|
-
)
|
|
36
|
-
);
|
|
37
|
-
i.push({
|
|
38
|
-
id: a.id,
|
|
39
|
-
label: a.text,
|
|
40
|
-
location: p.replace(/\.WebHome$/, ""),
|
|
41
|
-
url: this.cristalApp.getRouter().resolve({
|
|
42
|
-
name: "view",
|
|
43
|
-
params: {
|
|
44
|
-
page: p
|
|
45
|
-
}
|
|
46
|
-
}).href,
|
|
47
|
-
has_children: a.children
|
|
48
|
-
//TODO: ignore translations and attachments
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
);
|
|
18
|
+
const t = await ((r = this.authenticationManagerProvider.get()) == null ? void 0 : r.getAuthorizationHeader()), n = {
|
|
19
|
+
Accept: "application/json"
|
|
20
|
+
};
|
|
21
|
+
t && (n.Authorization = t), o.push(...await this.fetchNodes(e, n, 0));
|
|
53
22
|
} catch (t) {
|
|
54
23
|
this.logger.error(t), this.logger.debug("Could not load navigation tree.");
|
|
55
24
|
}
|
|
56
|
-
return
|
|
25
|
+
return o;
|
|
57
26
|
}
|
|
58
|
-
getParentNodesId(
|
|
27
|
+
getParentNodesId(i) {
|
|
59
28
|
const e = [];
|
|
60
|
-
if (
|
|
61
|
-
const
|
|
62
|
-
if (!
|
|
29
|
+
if (i) {
|
|
30
|
+
const o = i.document.getIdentifier();
|
|
31
|
+
if (!o)
|
|
63
32
|
return this.logger.debug(
|
|
64
|
-
`No identifier found for page ${
|
|
33
|
+
`No identifier found for page ${i.name}, cannot resolve parents.`
|
|
65
34
|
), [];
|
|
66
|
-
const
|
|
67
|
-
let t = "",
|
|
68
|
-
for (
|
|
69
|
-
t += n
|
|
70
|
-
e.push(`document:xwiki:${
|
|
35
|
+
const r = o.replace(/\.WebHome$/, "").split(new RegExp("(?<*\\\\)\\."));
|
|
36
|
+
let t = "", n;
|
|
37
|
+
for (n = 0; n < r.length - 1; n++)
|
|
38
|
+
t += r[n], e.push(`document:xwiki:${t}.WebHome`), t += ".";
|
|
39
|
+
e.push(`document:xwiki:${o}`);
|
|
71
40
|
}
|
|
72
41
|
return e;
|
|
73
42
|
}
|
|
43
|
+
async fetchNodes(i, e, o) {
|
|
44
|
+
const r = [], t = this.cristalApp.getWikiConfig().baseURL.replace(/\/[^/]*$/, ""), n = new URL(
|
|
45
|
+
`${this.cristalApp.getWikiConfig().baseURL}/bin/get`
|
|
46
|
+
);
|
|
47
|
+
n.search = new URLSearchParams([
|
|
48
|
+
["id", i],
|
|
49
|
+
["outputSyntax", "plain"],
|
|
50
|
+
["sheet", "XWiki.DocumentTree"],
|
|
51
|
+
["data", "children"],
|
|
52
|
+
["compact", "true"],
|
|
53
|
+
["offset", o.toString()]
|
|
54
|
+
]).toString();
|
|
55
|
+
const h = await (await fetch(n, { headers: e })).json();
|
|
56
|
+
for (const a of h)
|
|
57
|
+
if (a.id == "pagination:wiki:xwiki")
|
|
58
|
+
r.push(
|
|
59
|
+
...await this.fetchNodes(i, e, a.data.offset)
|
|
60
|
+
);
|
|
61
|
+
else if (!["attachments", "translations"].includes(a.data.type) && a.a_attr) {
|
|
62
|
+
const l = decodeURIComponent(
|
|
63
|
+
this.cristalApp.getWikiConfig().storage.getPageFromViewURL(
|
|
64
|
+
`${t}${a.a_attr.href}`
|
|
65
|
+
)
|
|
66
|
+
);
|
|
67
|
+
r.push({
|
|
68
|
+
id: a.id,
|
|
69
|
+
label: a.text,
|
|
70
|
+
location: l.replace(/\.WebHome$/, ""),
|
|
71
|
+
url: this.cristalApp.getRouter().resolve({
|
|
72
|
+
name: "view",
|
|
73
|
+
params: {
|
|
74
|
+
page: l
|
|
75
|
+
}
|
|
76
|
+
}).href,
|
|
77
|
+
has_children: a.children
|
|
78
|
+
//TODO: ignore translations and attachments
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
return r;
|
|
82
|
+
}
|
|
74
83
|
};
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
84
|
+
g = v([
|
|
85
|
+
d(),
|
|
86
|
+
p(0, c("Logger")),
|
|
87
|
+
p(1, c("CristalApp")),
|
|
88
|
+
p(2, c("AuthenticationManagerProvider"))
|
|
89
|
+
], g);
|
|
90
|
+
class P {
|
|
81
91
|
constructor(e) {
|
|
82
|
-
e.bind(
|
|
92
|
+
e.bind(u).to(g).inSingletonScope().whenTargetNamed("XWiki");
|
|
83
93
|
}
|
|
84
94
|
}
|
|
85
95
|
export {
|
|
86
|
-
|
|
96
|
+
P as ComponentInit
|
|
87
97
|
};
|
|
88
98
|
//# sourceMappingURL=index.es.js.map
|
package/dist/index.es.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.es.js","sources":["../src/components/componentsInit.ts"],"sourcesContent":["/*\n * See the LICENSE file distributed with this work for additional\n * information regarding copyright ownership.\n *\n * This is free software; you can redistribute it and/or modify it\n * under the terms of the GNU Lesser General Public License as\n * published by the Free Software Foundation; either version 2.1 of\n * the License, or (at your option) any later version.\n *\n * This software is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public\n * License along with this software; if not, write to the Free\n * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\n * 02110-1301 USA, or see the FSF site: http://www.fsf.org.\n */\n\nimport { Container, inject, injectable } from \"inversify\";\nimport type { CristalApp, Logger, PageData } from \"@xwiki/cristal-api\";\nimport {\n name as NavigationTreeSourceName,\n type NavigationTreeNode,\n type NavigationTreeSource,\n} from \"@xwiki/cristal-navigation-tree-api\";\n\n/**\n * Implementation of NavigationTreeSource for the XWiki backend.\n *\n * @since 0.10\n **/\n@injectable()\nclass XWikiNavigationTreeSource implements NavigationTreeSource {\n private cristalApp: CristalApp;\n public logger: Logger;\n\n constructor(\n @inject<Logger>(\"Logger\") logger: Logger,\n @inject<CristalApp>(\"CristalApp\") cristalApp: CristalApp,\n ) {\n this.logger = logger;\n this.logger.setModule(\n \"navigation-tree-xwiki.components.XWikiNavigationTreeSource\",\n );\n this.cristalApp = cristalApp;\n }\n\n async getChildNodes(id?: string): Promise<Array<NavigationTreeNode>> {\n const currentId = id ? id : \"#\";\n const navigationTree: Array<NavigationTreeNode> = [];\n\n
|
|
1
|
+
{"version":3,"file":"index.es.js","sources":["../src/components/componentsInit.ts"],"sourcesContent":["/*\n * See the LICENSE file distributed with this work for additional\n * information regarding copyright ownership.\n *\n * This is free software; you can redistribute it and/or modify it\n * under the terms of the GNU Lesser General Public License as\n * published by the Free Software Foundation; either version 2.1 of\n * the License, or (at your option) any later version.\n *\n * This software is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public\n * License along with this software; if not, write to the Free\n * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\n * 02110-1301 USA, or see the FSF site: http://www.fsf.org.\n */\n\nimport { Container, inject, injectable } from \"inversify\";\nimport type { CristalApp, Logger, PageData } from \"@xwiki/cristal-api\";\nimport {\n name as NavigationTreeSourceName,\n type NavigationTreeNode,\n type NavigationTreeSource,\n} from \"@xwiki/cristal-navigation-tree-api\";\nimport { type AuthenticationManagerProvider } from \"@xwiki/cristal-authentication-api\";\n\n/**\n * Implementation of NavigationTreeSource for the XWiki backend.\n *\n * @since 0.10\n **/\n@injectable()\nclass XWikiNavigationTreeSource implements NavigationTreeSource {\n private cristalApp: CristalApp;\n public logger: Logger;\n\n constructor(\n @inject<Logger>(\"Logger\") logger: Logger,\n @inject<CristalApp>(\"CristalApp\") cristalApp: CristalApp,\n @inject<AuthenticationManagerProvider>(\"AuthenticationManagerProvider\")\n private authenticationManagerProvider: AuthenticationManagerProvider,\n ) {\n this.logger = logger;\n this.logger.setModule(\n \"navigation-tree-xwiki.components.XWikiNavigationTreeSource\",\n );\n this.cristalApp = cristalApp;\n }\n\n async getChildNodes(id?: string): Promise<Array<NavigationTreeNode>> {\n const currentId = id ? id : \"#\";\n const navigationTree: Array<NavigationTreeNode> = [];\n\n try {\n const authorization = await this.authenticationManagerProvider\n .get()\n ?.getAuthorizationHeader();\n const headers: { Accept: string; Authorization?: string } = {\n Accept: \"application/json\",\n };\n\n if (authorization) {\n headers.Authorization = authorization;\n }\n\n navigationTree.push(...(await this.fetchNodes(currentId, headers, 0)));\n } catch (error) {\n this.logger.error(error);\n this.logger.debug(\"Could not load navigation tree.\");\n }\n return navigationTree;\n }\n\n getParentNodesId(page?: PageData): Array<string> {\n const result = [];\n if (page) {\n const documentId = page.document.getIdentifier();\n if (!documentId) {\n this.logger.debug(\n `No identifier found for page ${page.name}, cannot resolve parents.`,\n );\n return [];\n }\n // TODO: Use a page resolver instead when CRISTAL-234 is fixed.\n const parents = documentId\n .replace(/\\.WebHome$/, \"\")\n .split(/(?<*\\\\)\\./);\n let currentParent = \"\";\n let i;\n for (i = 0; i < parents.length - 1; i++) {\n currentParent += parents[i];\n // TODO: Support subwikis.\n result.push(`document:xwiki:${currentParent}.WebHome`);\n currentParent += \".\";\n }\n result.push(`document:xwiki:${documentId}`);\n }\n return result;\n }\n\n private async fetchNodes(\n currentId: string,\n headers: { Accept: string; Authorization?: string },\n offset: number,\n ): Promise<Array<NavigationTreeNode>> {\n const nodes: Array<NavigationTreeNode> = [];\n const baseXWikiURL = this.cristalApp\n .getWikiConfig()\n .baseURL.replace(/\\/[^/]*$/, \"\");\n\n const navigationTreeRequestUrl = new URL(\n `${this.cristalApp.getWikiConfig().baseURL}/bin/get`,\n );\n navigationTreeRequestUrl.search = new URLSearchParams([\n [\"id\", currentId],\n [\"outputSyntax\", \"plain\"],\n [\"sheet\", \"XWiki.DocumentTree\"],\n [\"data\", \"children\"],\n [\"compact\", \"true\"],\n [\"offset\", offset.toString()],\n ]).toString();\n\n const response = await fetch(navigationTreeRequestUrl, { headers });\n const jsonResponse: [\n {\n id: string;\n text: string;\n children: boolean;\n data: { type: string; offset: number };\n a_attr?: { href: string };\n },\n ] = await response.json();\n for (const treeNode of jsonResponse) {\n if (treeNode.id == \"pagination:wiki:xwiki\") {\n nodes.push(\n ...(await this.fetchNodes(currentId, headers, treeNode.data.offset)),\n );\n } else if (\n ![\"attachments\", \"translations\"].includes(treeNode.data.type) &&\n treeNode.a_attr\n ) {\n const pageId = decodeURIComponent(\n this.cristalApp\n .getWikiConfig()\n .storage.getPageFromViewURL(\n `${baseXWikiURL}${treeNode.a_attr.href}`,\n )!,\n );\n nodes.push({\n id: treeNode.id,\n label: treeNode.text,\n location: pageId.replace(/\\.WebHome$/, \"\"),\n url: this.cristalApp.getRouter().resolve({\n name: \"view\",\n params: {\n page: pageId,\n },\n }).href,\n has_children: treeNode.children, //TODO: ignore translations and attachments\n });\n }\n }\n\n return nodes;\n }\n}\n\nexport class ComponentInit {\n constructor(container: Container) {\n container\n .bind<NavigationTreeSource>(NavigationTreeSourceName)\n .to(XWikiNavigationTreeSource)\n .inSingletonScope()\n .whenTargetNamed(\"XWiki\");\n }\n}\n"],"names":["XWikiNavigationTreeSource","logger","cristalApp","authenticationManagerProvider","id","currentId","navigationTree","authorization","_a","headers","error","page","result","documentId","parents","currentParent","i","offset","nodes","baseXWikiURL","navigationTreeRequestUrl","jsonResponse","treeNode","pageId","__decorateClass","injectable","__decorateParam","ComponentInit","container","NavigationTreeSourceName"],"mappings":"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"}
|
package/dist/index.umd.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
(function(a,s){typeof exports=="object"&&typeof module<"u"?s(exports,require("inversify"),require("@xwiki/cristal-navigation-tree-api")):typeof define=="function"&&define.amd?define(["exports","inversify","@xwiki/cristal-navigation-tree-api"],s):(a=typeof globalThis<"u"?globalThis:a||self,s(a["cristal_navigation-tree-xwiki"]={},a.inversify,a.cristalNavigationTreeApi))})(this,function(a,s,
|
|
1
|
+
(function(a,s){typeof exports=="object"&&typeof module<"u"?s(exports,require("inversify"),require("@xwiki/cristal-navigation-tree-api")):typeof define=="function"&&define.amd?define(["exports","inversify","@xwiki/cristal-navigation-tree-api"],s):(a=typeof globalThis<"u"?globalThis:a||self,s(a["cristal_navigation-tree-xwiki"]={},a.inversify,a.cristalNavigationTreeApi))})(this,function(a,s,g){"use strict";var h=Object.defineProperty,f=Object.getOwnPropertyDescriptor,m=(i,e,n,o)=>{for(var t=o>1?void 0:o?f(e,n):e,r=i.length-1,p;r>=0;r--)(p=i[r])&&(t=(o?p(e,n,t):p(t))||t);return o&&t&&h(e,n,t),t},d=(i,e)=>(n,o)=>e(n,o,i);let l=class{constructor(i,e,n){this.authenticationManagerProvider=n,this.logger=i,this.logger.setModule("navigation-tree-xwiki.components.XWikiNavigationTreeSource"),this.cristalApp=e}async getChildNodes(i){var o;const e=i||"#",n=[];try{const t=await((o=this.authenticationManagerProvider.get())==null?void 0:o.getAuthorizationHeader()),r={Accept:"application/json"};t&&(r.Authorization=t),n.push(...await this.fetchNodes(e,r,0))}catch(t){this.logger.error(t),this.logger.debug("Could not load navigation tree.")}return n}getParentNodesId(i){const e=[];if(i){const n=i.document.getIdentifier();if(!n)return this.logger.debug(`No identifier found for page ${i.name}, cannot resolve parents.`),[];const o=n.replace(/\.WebHome$/,"").split(new RegExp("(?<*\\\\)\\."));let t="",r;for(r=0;r<o.length-1;r++)t+=o[r],e.push(`document:xwiki:${t}.WebHome`),t+=".";e.push(`document:xwiki:${n}`)}return e}async fetchNodes(i,e,n){const o=[],t=this.cristalApp.getWikiConfig().baseURL.replace(/\/[^/]*$/,""),r=new URL(`${this.cristalApp.getWikiConfig().baseURL}/bin/get`);r.search=new URLSearchParams([["id",i],["outputSyntax","plain"],["sheet","XWiki.DocumentTree"],["data","children"],["compact","true"],["offset",n.toString()]]).toString();const w=await(await fetch(r,{headers:e})).json();for(const c of w)if(c.id=="pagination:wiki:xwiki")o.push(...await this.fetchNodes(i,e,c.data.offset));else if(!["attachments","translations"].includes(c.data.type)&&c.a_attr){const u=decodeURIComponent(this.cristalApp.getWikiConfig().storage.getPageFromViewURL(`${t}${c.a_attr.href}`));o.push({id:c.id,label:c.text,location:u.replace(/\.WebHome$/,""),url:this.cristalApp.getRouter().resolve({name:"view",params:{page:u}}).href,has_children:c.children})}return o}};l=m([s.injectable(),d(0,s.inject("Logger")),d(1,s.inject("CristalApp")),d(2,s.inject("AuthenticationManagerProvider"))],l);class v{constructor(e){e.bind(g.name).to(l).inSingletonScope().whenTargetNamed("XWiki")}}a.ComponentInit=v,Object.defineProperty(a,Symbol.toStringTag,{value:"Module"})});
|
|
2
2
|
//# sourceMappingURL=index.umd.js.map
|
package/dist/index.umd.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.umd.js","sources":["../src/components/componentsInit.ts"],"sourcesContent":["/*\n * See the LICENSE file distributed with this work for additional\n * information regarding copyright ownership.\n *\n * This is free software; you can redistribute it and/or modify it\n * under the terms of the GNU Lesser General Public License as\n * published by the Free Software Foundation; either version 2.1 of\n * the License, or (at your option) any later version.\n *\n * This software is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public\n * License along with this software; if not, write to the Free\n * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\n * 02110-1301 USA, or see the FSF site: http://www.fsf.org.\n */\n\nimport { Container, inject, injectable } from \"inversify\";\nimport type { CristalApp, Logger, PageData } from \"@xwiki/cristal-api\";\nimport {\n name as NavigationTreeSourceName,\n type NavigationTreeNode,\n type NavigationTreeSource,\n} from \"@xwiki/cristal-navigation-tree-api\";\n\n/**\n * Implementation of NavigationTreeSource for the XWiki backend.\n *\n * @since 0.10\n **/\n@injectable()\nclass XWikiNavigationTreeSource implements NavigationTreeSource {\n private cristalApp: CristalApp;\n public logger: Logger;\n\n constructor(\n @inject<Logger>(\"Logger\") logger: Logger,\n @inject<CristalApp>(\"CristalApp\") cristalApp: CristalApp,\n ) {\n this.logger = logger;\n this.logger.setModule(\n \"navigation-tree-xwiki.components.XWikiNavigationTreeSource\",\n );\n this.cristalApp = cristalApp;\n }\n\n async getChildNodes(id?: string): Promise<Array<NavigationTreeNode>> {\n const currentId = id ? id : \"#\";\n const navigationTree: Array<NavigationTreeNode> = [];\n\n
|
|
1
|
+
{"version":3,"file":"index.umd.js","sources":["../src/components/componentsInit.ts"],"sourcesContent":["/*\n * See the LICENSE file distributed with this work for additional\n * information regarding copyright ownership.\n *\n * This is free software; you can redistribute it and/or modify it\n * under the terms of the GNU Lesser General Public License as\n * published by the Free Software Foundation; either version 2.1 of\n * the License, or (at your option) any later version.\n *\n * This software is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public\n * License along with this software; if not, write to the Free\n * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\n * 02110-1301 USA, or see the FSF site: http://www.fsf.org.\n */\n\nimport { Container, inject, injectable } from \"inversify\";\nimport type { CristalApp, Logger, PageData } from \"@xwiki/cristal-api\";\nimport {\n name as NavigationTreeSourceName,\n type NavigationTreeNode,\n type NavigationTreeSource,\n} from \"@xwiki/cristal-navigation-tree-api\";\nimport { type AuthenticationManagerProvider } from \"@xwiki/cristal-authentication-api\";\n\n/**\n * Implementation of NavigationTreeSource for the XWiki backend.\n *\n * @since 0.10\n **/\n@injectable()\nclass XWikiNavigationTreeSource implements NavigationTreeSource {\n private cristalApp: CristalApp;\n public logger: Logger;\n\n constructor(\n @inject<Logger>(\"Logger\") logger: Logger,\n @inject<CristalApp>(\"CristalApp\") cristalApp: CristalApp,\n @inject<AuthenticationManagerProvider>(\"AuthenticationManagerProvider\")\n private authenticationManagerProvider: AuthenticationManagerProvider,\n ) {\n this.logger = logger;\n this.logger.setModule(\n \"navigation-tree-xwiki.components.XWikiNavigationTreeSource\",\n );\n this.cristalApp = cristalApp;\n }\n\n async getChildNodes(id?: string): Promise<Array<NavigationTreeNode>> {\n const currentId = id ? id : \"#\";\n const navigationTree: Array<NavigationTreeNode> = [];\n\n try {\n const authorization = await this.authenticationManagerProvider\n .get()\n ?.getAuthorizationHeader();\n const headers: { Accept: string; Authorization?: string } = {\n Accept: \"application/json\",\n };\n\n if (authorization) {\n headers.Authorization = authorization;\n }\n\n navigationTree.push(...(await this.fetchNodes(currentId, headers, 0)));\n } catch (error) {\n this.logger.error(error);\n this.logger.debug(\"Could not load navigation tree.\");\n }\n return navigationTree;\n }\n\n getParentNodesId(page?: PageData): Array<string> {\n const result = [];\n if (page) {\n const documentId = page.document.getIdentifier();\n if (!documentId) {\n this.logger.debug(\n `No identifier found for page ${page.name}, cannot resolve parents.`,\n );\n return [];\n }\n // TODO: Use a page resolver instead when CRISTAL-234 is fixed.\n const parents = documentId\n .replace(/\\.WebHome$/, \"\")\n .split(/(?<*\\\\)\\./);\n let currentParent = \"\";\n let i;\n for (i = 0; i < parents.length - 1; i++) {\n currentParent += parents[i];\n // TODO: Support subwikis.\n result.push(`document:xwiki:${currentParent}.WebHome`);\n currentParent += \".\";\n }\n result.push(`document:xwiki:${documentId}`);\n }\n return result;\n }\n\n private async fetchNodes(\n currentId: string,\n headers: { Accept: string; Authorization?: string },\n offset: number,\n ): Promise<Array<NavigationTreeNode>> {\n const nodes: Array<NavigationTreeNode> = [];\n const baseXWikiURL = this.cristalApp\n .getWikiConfig()\n .baseURL.replace(/\\/[^/]*$/, \"\");\n\n const navigationTreeRequestUrl = new URL(\n `${this.cristalApp.getWikiConfig().baseURL}/bin/get`,\n );\n navigationTreeRequestUrl.search = new URLSearchParams([\n [\"id\", currentId],\n [\"outputSyntax\", \"plain\"],\n [\"sheet\", \"XWiki.DocumentTree\"],\n [\"data\", \"children\"],\n [\"compact\", \"true\"],\n [\"offset\", offset.toString()],\n ]).toString();\n\n const response = await fetch(navigationTreeRequestUrl, { headers });\n const jsonResponse: [\n {\n id: string;\n text: string;\n children: boolean;\n data: { type: string; offset: number };\n a_attr?: { href: string };\n },\n ] = await response.json();\n for (const treeNode of jsonResponse) {\n if (treeNode.id == \"pagination:wiki:xwiki\") {\n nodes.push(\n ...(await this.fetchNodes(currentId, headers, treeNode.data.offset)),\n );\n } else if (\n ![\"attachments\", \"translations\"].includes(treeNode.data.type) &&\n treeNode.a_attr\n ) {\n const pageId = decodeURIComponent(\n this.cristalApp\n .getWikiConfig()\n .storage.getPageFromViewURL(\n `${baseXWikiURL}${treeNode.a_attr.href}`,\n )!,\n );\n nodes.push({\n id: treeNode.id,\n label: treeNode.text,\n location: pageId.replace(/\\.WebHome$/, \"\"),\n url: this.cristalApp.getRouter().resolve({\n name: \"view\",\n params: {\n page: pageId,\n },\n }).href,\n has_children: treeNode.children, //TODO: ignore translations and attachments\n });\n }\n }\n\n return nodes;\n }\n}\n\nexport class ComponentInit {\n constructor(container: Container) {\n container\n .bind<NavigationTreeSource>(NavigationTreeSourceName)\n .to(XWikiNavigationTreeSource)\n .inSingletonScope()\n .whenTargetNamed(\"XWiki\");\n }\n}\n"],"names":["XWikiNavigationTreeSource","logger","cristalApp","authenticationManagerProvider","id","currentId","navigationTree","authorization","_a","headers","error","page","result","documentId","parents","currentParent","i","offset","nodes","baseXWikiURL","navigationTreeRequestUrl","jsonResponse","treeNode","pageId","__decorateClass","injectable","__decorateParam","ComponentInit","container","NavigationTreeSourceName"],"mappings":"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"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xwiki/cristal-navigation-tree-xwiki",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.0",
|
|
4
4
|
"license": "LGPL 2.1",
|
|
5
5
|
"author": "XWiki Org Community <contact@xwiki.org>",
|
|
6
6
|
"homepage": "https://cristal.xwiki.org/",
|
|
@@ -23,12 +23,13 @@
|
|
|
23
23
|
"main": "./dist/index.es.js",
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"inversify": "6.0.2",
|
|
26
|
-
"@xwiki/cristal-api": "0.
|
|
27
|
-
"@xwiki/cristal-
|
|
26
|
+
"@xwiki/cristal-api": "0.11.0",
|
|
27
|
+
"@xwiki/cristal-authentication-api": "0.11.0",
|
|
28
|
+
"@xwiki/cristal-navigation-tree-api": "0.11.0"
|
|
28
29
|
},
|
|
29
30
|
"scripts": {
|
|
30
|
-
"
|
|
31
|
-
"
|
|
31
|
+
"build": "tsc --project tsconfig.json && vite build",
|
|
32
|
+
"clean": "rimraf dist"
|
|
32
33
|
},
|
|
33
34
|
"types": "./dist/index.d.ts"
|
|
34
35
|
}
|
|
@@ -25,6 +25,7 @@ import {
|
|
|
25
25
|
type NavigationTreeNode,
|
|
26
26
|
type NavigationTreeSource,
|
|
27
27
|
} from "@xwiki/cristal-navigation-tree-api";
|
|
28
|
+
import { type AuthenticationManagerProvider } from "@xwiki/cristal-authentication-api";
|
|
28
29
|
|
|
29
30
|
/**
|
|
30
31
|
* Implementation of NavigationTreeSource for the XWiki backend.
|
|
@@ -39,6 +40,8 @@ class XWikiNavigationTreeSource implements NavigationTreeSource {
|
|
|
39
40
|
constructor(
|
|
40
41
|
@inject<Logger>("Logger") logger: Logger,
|
|
41
42
|
@inject<CristalApp>("CristalApp") cristalApp: CristalApp,
|
|
43
|
+
@inject<AuthenticationManagerProvider>("AuthenticationManagerProvider")
|
|
44
|
+
private authenticationManagerProvider: AuthenticationManagerProvider,
|
|
42
45
|
) {
|
|
43
46
|
this.logger = logger;
|
|
44
47
|
this.logger.setModule(
|
|
@@ -51,55 +54,19 @@ class XWikiNavigationTreeSource implements NavigationTreeSource {
|
|
|
51
54
|
const currentId = id ? id : "#";
|
|
52
55
|
const navigationTree: Array<NavigationTreeNode> = [];
|
|
53
56
|
|
|
54
|
-
const navigationTreeRequestUrl = new URL(
|
|
55
|
-
`${this.cristalApp.getWikiConfig().baseURL}/bin/get`,
|
|
56
|
-
);
|
|
57
|
-
navigationTreeRequestUrl.search = new URLSearchParams([
|
|
58
|
-
["id", currentId],
|
|
59
|
-
["outputSyntax", "plain"],
|
|
60
|
-
["sheet", "XWiki.DocumentTree"],
|
|
61
|
-
["data", "children"],
|
|
62
|
-
["compact", "true"],
|
|
63
|
-
]).toString();
|
|
64
57
|
try {
|
|
65
|
-
const
|
|
66
|
-
.
|
|
67
|
-
|
|
68
|
-
const
|
|
69
|
-
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
data: { type: string };
|
|
78
|
-
a_attr: { href: string };
|
|
79
|
-
}) => {
|
|
80
|
-
if (!["attachments", "translations"].includes(treeNode.data.type)) {
|
|
81
|
-
const pageId = decodeURIComponent(
|
|
82
|
-
this.cristalApp
|
|
83
|
-
.getWikiConfig()
|
|
84
|
-
.storage.getPageFromViewURL(
|
|
85
|
-
`${baseXWikiURL}${treeNode.a_attr.href}`,
|
|
86
|
-
)!,
|
|
87
|
-
);
|
|
88
|
-
navigationTree.push({
|
|
89
|
-
id: treeNode.id,
|
|
90
|
-
label: treeNode.text,
|
|
91
|
-
location: pageId.replace(/\.WebHome$/, ""),
|
|
92
|
-
url: this.cristalApp.getRouter().resolve({
|
|
93
|
-
name: "view",
|
|
94
|
-
params: {
|
|
95
|
-
page: pageId,
|
|
96
|
-
},
|
|
97
|
-
}).href,
|
|
98
|
-
has_children: treeNode.children, //TODO: ignore translations and attachments
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
|
-
},
|
|
102
|
-
);
|
|
58
|
+
const authorization = await this.authenticationManagerProvider
|
|
59
|
+
.get()
|
|
60
|
+
?.getAuthorizationHeader();
|
|
61
|
+
const headers: { Accept: string; Authorization?: string } = {
|
|
62
|
+
Accept: "application/json",
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
if (authorization) {
|
|
66
|
+
headers.Authorization = authorization;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
navigationTree.push(...(await this.fetchNodes(currentId, headers, 0)));
|
|
103
70
|
} catch (error) {
|
|
104
71
|
this.logger.error(error);
|
|
105
72
|
this.logger.debug("Could not load navigation tree.");
|
|
@@ -133,6 +100,72 @@ class XWikiNavigationTreeSource implements NavigationTreeSource {
|
|
|
133
100
|
}
|
|
134
101
|
return result;
|
|
135
102
|
}
|
|
103
|
+
|
|
104
|
+
private async fetchNodes(
|
|
105
|
+
currentId: string,
|
|
106
|
+
headers: { Accept: string; Authorization?: string },
|
|
107
|
+
offset: number,
|
|
108
|
+
): Promise<Array<NavigationTreeNode>> {
|
|
109
|
+
const nodes: Array<NavigationTreeNode> = [];
|
|
110
|
+
const baseXWikiURL = this.cristalApp
|
|
111
|
+
.getWikiConfig()
|
|
112
|
+
.baseURL.replace(/\/[^/]*$/, "");
|
|
113
|
+
|
|
114
|
+
const navigationTreeRequestUrl = new URL(
|
|
115
|
+
`${this.cristalApp.getWikiConfig().baseURL}/bin/get`,
|
|
116
|
+
);
|
|
117
|
+
navigationTreeRequestUrl.search = new URLSearchParams([
|
|
118
|
+
["id", currentId],
|
|
119
|
+
["outputSyntax", "plain"],
|
|
120
|
+
["sheet", "XWiki.DocumentTree"],
|
|
121
|
+
["data", "children"],
|
|
122
|
+
["compact", "true"],
|
|
123
|
+
["offset", offset.toString()],
|
|
124
|
+
]).toString();
|
|
125
|
+
|
|
126
|
+
const response = await fetch(navigationTreeRequestUrl, { headers });
|
|
127
|
+
const jsonResponse: [
|
|
128
|
+
{
|
|
129
|
+
id: string;
|
|
130
|
+
text: string;
|
|
131
|
+
children: boolean;
|
|
132
|
+
data: { type: string; offset: number };
|
|
133
|
+
a_attr?: { href: string };
|
|
134
|
+
},
|
|
135
|
+
] = await response.json();
|
|
136
|
+
for (const treeNode of jsonResponse) {
|
|
137
|
+
if (treeNode.id == "pagination:wiki:xwiki") {
|
|
138
|
+
nodes.push(
|
|
139
|
+
...(await this.fetchNodes(currentId, headers, treeNode.data.offset)),
|
|
140
|
+
);
|
|
141
|
+
} else if (
|
|
142
|
+
!["attachments", "translations"].includes(treeNode.data.type) &&
|
|
143
|
+
treeNode.a_attr
|
|
144
|
+
) {
|
|
145
|
+
const pageId = decodeURIComponent(
|
|
146
|
+
this.cristalApp
|
|
147
|
+
.getWikiConfig()
|
|
148
|
+
.storage.getPageFromViewURL(
|
|
149
|
+
`${baseXWikiURL}${treeNode.a_attr.href}`,
|
|
150
|
+
)!,
|
|
151
|
+
);
|
|
152
|
+
nodes.push({
|
|
153
|
+
id: treeNode.id,
|
|
154
|
+
label: treeNode.text,
|
|
155
|
+
location: pageId.replace(/\.WebHome$/, ""),
|
|
156
|
+
url: this.cristalApp.getRouter().resolve({
|
|
157
|
+
name: "view",
|
|
158
|
+
params: {
|
|
159
|
+
page: pageId,
|
|
160
|
+
},
|
|
161
|
+
}).href,
|
|
162
|
+
has_children: treeNode.children, //TODO: ignore translations and attachments
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
return nodes;
|
|
168
|
+
}
|
|
136
169
|
}
|
|
137
170
|
|
|
138
171
|
export class ComponentInit {
|