Expand list of forbidden Unicode characters in NewsAPI and refine warning rendering logic in NinaWarnings widget
This commit is contained in:
parent
915087d31a
commit
d4e3b6252b
@ -11,7 +11,16 @@ import (
|
||||
|
||||
const apiBaseURL = "https://newsapi.org/v2/top-headlines"
|
||||
|
||||
var forbiddenStrings = []string{"\r", "\\r", "\ufeff", "\u00A0"}
|
||||
var forbiddenStrings = []string{
|
||||
"\r", "\\r", "\ufeff", "\u00A0", "\u200b", "\u200c",
|
||||
"\u200d", // Zero Width Joiner
|
||||
"\u200e", // Left-to-Right Mark
|
||||
"\u200f", // Right-to-Left Mark
|
||||
"\u2060", // Word Joiner
|
||||
"\ufe0f", // Variation Selector-16
|
||||
"\u2028",
|
||||
"\u2029",
|
||||
}
|
||||
|
||||
type configFile struct {
|
||||
News newsConfig
|
||||
|
||||
@ -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,6 +32,7 @@ func createNinaWarnings(ctx context.Context, _ terminalapi.Terminal, _ interface
|
||||
widget.Reset()
|
||||
for _, warning := range warnings {
|
||||
for _, info := range warning.Info {
|
||||
if info.Language == "de-DE" {
|
||||
var options []cell.Option
|
||||
if info.Severity == "Moderate" {
|
||||
options = append(options, cell.FgColor(cell.ColorRed))
|
||||
@ -43,12 +46,17 @@ func createNinaWarnings(ctx context.Context, _ terminalapi.Terminal, _ interface
|
||||
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 {
|
||||
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
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user