| 182 | } |
| 183 | |
| 184 | func (p pluginRegistry) WebRequest(r *http.Request) (html string, templateData map[string]any, ok bool) { |
| 185 | |
| 186 | reqPath := filepath.Clean(r.URL.Path) // Example: / or /info/faq |
| 187 | |
| 188 | rootFilePath := `html/public/` |
| 189 | for _, pItem := range p { |
| 190 | |
| 191 | pageData, ok := pItem.Web.pages[reqPath] |
| 192 | if !ok { |
| 193 | continue |
| 194 | } |
| 195 | |
| 196 | b, err := pItem.files.ReadFile(util.FilePath(rootFilePath, pageData.Filepath)) |
| 197 | |
| 198 | if err != nil { |
| 199 | continue |
| 200 | } |
| 201 | |
| 202 | html = string(b) |
| 203 | |
| 204 | if pageData.DataFunction != nil { |
| 205 | templateData = pageData.DataFunction(r) |
| 206 | } |
| 207 | |
| 208 | return html, templateData, true |
| 209 | } |
| 210 | |
| 211 | return html, templateData, false |
| 212 | } |
| 213 | |
| 214 | // Iterator for all plugin file systems. |
| 215 | // This allows you to process each one individually. |