
**Backport:** https://codeberg.org/forgejo/forgejo/pulls/7337 - Massive replacement of changing `code.gitea.io/gitea` to `forgejo.org`. - Resolves forgejo/discussions#258 Co-authored-by: Gusted <postmaster@gusted.xyz> Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/7354 Reviewed-by: Gusted <gusted@noreply.codeberg.org> Co-authored-by: forgejo-backport-action <forgejo-backport-action@noreply.codeberg.org> Co-committed-by: forgejo-backport-action <forgejo-backport-action@noreply.codeberg.org>
40 lines
1 KiB
Go
40 lines
1 KiB
Go
// Copyright 2020 The Gitea Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package templates
|
|
|
|
import (
|
|
"slices"
|
|
"strings"
|
|
|
|
"forgejo.org/modules/assetfs"
|
|
"forgejo.org/modules/setting"
|
|
)
|
|
|
|
func AssetFS() *assetfs.LayeredFS {
|
|
return assetfs.Layered(CustomAssets(), BuiltinAssets())
|
|
}
|
|
|
|
func CustomAssets() *assetfs.Layer {
|
|
return assetfs.Local("custom", setting.CustomPath, "templates")
|
|
}
|
|
|
|
func ListWebTemplateAssetNames(assets *assetfs.LayeredFS) ([]string, error) {
|
|
files, err := assets.ListAllFiles(".", true)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return slices.DeleteFunc(files, func(file string) bool {
|
|
return strings.HasPrefix(file, "mail/") || !strings.HasSuffix(file, ".tmpl")
|
|
}), nil
|
|
}
|
|
|
|
func ListMailTemplateAssetNames(assets *assetfs.LayeredFS) ([]string, error) {
|
|
files, err := assets.ListAllFiles(".", true)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return slices.DeleteFunc(files, func(file string) bool {
|
|
return !strings.HasPrefix(file, "mail/") || !strings.HasSuffix(file, ".tmpl")
|
|
}), nil
|
|
}
|