package ui import ( "fmt" "strings" "charm.land/lipgloss/v2" "github.com/anotherhadi/ilovetui/style" ) type missionCard struct { title string body string } var missionCards = []missionCard{ { title: "The Mission", body: "A centralized repository of factory-set credentials. Built for pentesters and security researchers to identify default access points during engagements or infrastructure audits.", }, { title: "How it Works", body: "Reads structured YAML files (from a local cache or the default-creds API) and performs real-time searches across service names, versions, tags and comments.", }, { title: "Community Driven", body: "Security is a collective effort. Contribute new credentials at github.com/anotherhadi/default-creds.", }, } func (m Model) renderDefaultView(height int) string { if height <= 0 { return "" } cardWidth := max(m.width, 20) var blocks []string blocks = append(blocks, m.renderStatsLine()) blocks = append(blocks, "") for _, c := range missionCards { blocks = append(blocks, renderMissionCard(c, cardWidth), "") } content := strings.TrimRight(strings.Join(blocks, "\n"), "\n") lines := strings.Split(content, "\n") if len(lines) > height { lines = lines[:height] } content = strings.Join(lines, "\n") return lipgloss.Place(m.width, height, lipgloss.Left, lipgloss.Top, content) } func renderMissionCard(c missionCard, width int) string { title := panelTitleStyle.Render(c.title) body := lipgloss.NewStyle().Foreground(style.S.Muted).Width(width - 4).Render(c.body) return style.S.Panel.Width(width).Padding(0, 1).Render(title + "\n" + body) } func (m Model) renderStatsLine() string { if !m.statsLoaded { return mutedStyle.Render(" loading stats…") } text := fmt.Sprintf(" %d manufacturers · %d credentials", m.statsManufacturers, m.statsCredentials) return mutedStyle.Render(text) } func (m Model) sourceLabel() string { switch m.mode { case modeLocal: return "local" default: return "online" } }