Expand list of forbidden Unicode characters in NewsAPI and refine warning rendering logic in NinaWarnings widget
This commit is contained in:
@@ -17,6 +17,8 @@ import (
|
||||
type NinaWarningsOptions struct {
|
||||
}
|
||||
|
||||
/*dwd.2.49.0.0.276.0.DWD.PVW.1768147140000.877ab163-e3e6-4e9a-8f79-9ffce1a70629.MUL*/
|
||||
|
||||
func NinaWarnings() NinaWarningsOptions {
|
||||
widgetOptions["NinaWarningsOptions"] = createNinaWarnings
|
||||
return NinaWarningsOptions{}
|
||||
@@ -30,24 +32,30 @@ func createNinaWarnings(ctx context.Context, _ terminalapi.Terminal, _ interface
|
||||
widget.Reset()
|
||||
for _, warning := range warnings {
|
||||
for _, info := range warning.Info {
|
||||
var options []cell.Option
|
||||
if info.Severity == "Moderate" {
|
||||
options = append(options, cell.FgColor(cell.ColorRed))
|
||||
} else if info.Severity == "Minor" {
|
||||
options = append(options, cell.FgColor(cell.ColorYellow))
|
||||
} else if info.Severity == "Fine" {
|
||||
options = append(options, cell.FgColor(cell.ColorGray))
|
||||
} else if info.Severity == "Cancel" {
|
||||
options = append(options, cell.FgColor(cell.ColorGreen))
|
||||
} else {
|
||||
options = append(options, cell.FgColor(cell.ColorRed))
|
||||
options = append(options, cell.Blink())
|
||||
}
|
||||
if err := widget.Write(fmt.Sprintf("%s\n\n", info.Headline), text.WriteCellOpts(append(options, cell.Bold())...)); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := widget.Write(fmt.Sprintf("%s\n\n\n", removeElements(info.Description)), text.WriteCellOpts(options...)); err != nil {
|
||||
return err
|
||||
if info.Language == "de-DE" {
|
||||
var options []cell.Option
|
||||
if info.Severity == "Moderate" {
|
||||
options = append(options, cell.FgColor(cell.ColorRed))
|
||||
} else if info.Severity == "Minor" {
|
||||
options = append(options, cell.FgColor(cell.ColorYellow))
|
||||
} else if info.Severity == "Fine" {
|
||||
options = append(options, cell.FgColor(cell.ColorGray))
|
||||
} else if info.Severity == "Cancel" {
|
||||
options = append(options, cell.FgColor(cell.ColorGreen))
|
||||
} else {
|
||||
options = append(options, cell.FgColor(cell.ColorRed))
|
||||
options = append(options, cell.Blink())
|
||||
}
|
||||
if err := widget.Write(fmt.Sprintf("%s\n", info.Headline), text.WriteCellOpts(append(options, cell.Bold())...)); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := widget.Write(fmt.Sprintf("Expires: %s\n\n", info.Expires), text.WriteCellOpts(append(options, cell.Dim())...)); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := widget.Write(fmt.Sprintf("%s\n\n\n", removeElements(info.Description)), text.WriteCellOpts(options...)); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user