rubric/modules/softmodules/soft_registry.go
2026-07-27 16:45:21 +03:00

75 lines
2 KiB
Go
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package softmodules
import (
"fmt"
"rubric/utils"
"strings"
)
// Module описывает один раздел справочника Soft
type Module struct {
Key string
Aliases []string
Title string
Description string
Run func()
}
// All — список всех модулей в порядке меню
var All = []Module{
ZolaModule,
ForgejoModule,
// сюда будут добавляться новые обзоры софта
}
// Find ищет модуль по ключу или алиасу
func Find(key string) (Module, bool) {
key = strings.ToLower(strings.TrimSpace(key))
for _, m := range All {
if m.Key == key {
return m, true
}
for _, a := range m.Aliases {
if a == key {
return m, true
}
}
}
return Module{}, false
}
// ListModules выводит краткий список модулей
func ListModules() {
fmt.Printf("\n%s%sРазделы справочника Soft:%s\n\n",
utils.ColorBold, utils.ColorCyan, utils.ColorReset)
for i, m := range All {
fmt.Printf(" %s%d.%s %-14s — %s\n",
utils.ColorDim, i+1, utils.ColorReset,
utils.ColorYellow+utils.ColorBold+m.Key+utils.ColorReset,
m.Title,
)
}
fmt.Println()
}
// Keywords возвращает ключевые слова для поиска по модулю
func Keywords(key string) []string {
kw := map[string][]string{
"zola": {
"zola", "статический сайт", "static site", "генератор сайта",
"SSG", "Rust", "шаблоны", "templates", "Tera", "markdown",
"сайт", "rsync", "деплой", "deploy", "front matter",
"content", "themes", "темы",
},
"forgejo": {
"forgejo", "git", "форж", "git forge", "gitea", "self-hosted",
"самохостинг", "репозиторий", "repository", "docker", "sqlite",
"SSH", "issues", "pull request", "CI", "actions", "webhook",
"git-сервер",
},
}
if v, ok := kw[key]; ok {
return v
}
return []string{}
}