(section: string, getter: (man: Manifest) => ManifestSection | undefined)
| 87 | } |
| 88 | |
| 89 | load(section: string, getter: (man: Manifest) => ManifestSection | undefined): void { |
| 90 | Object.entries(this.manifests).forEach(([name, manifest]) => { |
| 91 | const manifest_section = getter(manifest) || {}; |
| 92 | Object.entries(manifest_section).forEach(([prop, info]) => { |
| 93 | const item: ManifestItem = { |
| 94 | path: "", // set below |
| 95 | hash: "", // set below |
| 96 | section, |
| 97 | label: info.label ? cockpit.gettext(info.label) : prop, |
| 98 | order: info.order === undefined ? 1000 : info.order, |
| 99 | docs: info.docs, |
| 100 | keywords: info.keywords || [{ matches: [], weight: 3, translate: true, goto: undefined }], |
| 101 | }; |
| 102 | |
| 103 | // Always first keyword should be page name |
| 104 | const page_name = item.label.toLowerCase(); |
| 105 | if (item.keywords[0].matches.indexOf(page_name) < 0) |
| 106 | item.keywords[0].matches.unshift(page_name); |
| 107 | |
| 108 | // Keywords from manifest have different defaults than are usual |
| 109 | item.keywords.forEach(i => { |
| 110 | i.weight = i.weight || 3; |
| 111 | i.translate = i.translate === undefined ? true : i.translate; |
| 112 | }); |
| 113 | |
| 114 | if (info.path) |
| 115 | item.path = info.path.replace(/\.html$/, ""); |
| 116 | else |
| 117 | item.path = name + "/" + prop; |
| 118 | |
| 119 | /* Split out any hash in the path */ |
| 120 | const pos = item.path.indexOf("#"); |
| 121 | if (pos !== -1) { |
| 122 | item.hash = item.path.substring(pos + 1); |
| 123 | item.path = item.path.substring(0, pos); |
| 124 | } |
| 125 | |
| 126 | /* Fix component for compatibility and normalize it */ |
| 127 | if (item.path.indexOf("/") === -1) |
| 128 | item.path = name + "/" + item.path; |
| 129 | if (item.path.slice(-6) == "/index") |
| 130 | item.path = item.path.slice(0, -6); |
| 131 | this.items[item.path] = item; |
| 132 | }); |
| 133 | }); |
| 134 | } |
| 135 | |
| 136 | ordered(section: string): ManifestItem[] { |
| 137 | const list: ManifestItem[] = []; |
no test coverage detected