newsline-cli 0.1.4 → 0.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/fetch.py +15 -2
  2. package/package.json +1 -1
  3. package/refresh.sh +1 -1
package/fetch.py CHANGED
@@ -48,10 +48,14 @@ ICON = "" if _icon.strip().lower() in ("none", "off") else _icon
48
48
  LINKHINT = (os.environ.get("NEWSLINE_LINKHINT") or "").strip().lower() in ("1", "true", "yes", "on")
49
49
  ATOM = "{http://www.w3.org/2005/Atom}"
50
50
  _ws = re.compile(r"\s+")
51
+ # Control chars (incl. ESC) from feed titles would inject terminal escape
52
+ # sequences straight into the status line — strip them before rendering.
53
+ _ctrl = re.compile(r"[\x00-\x1f\x7f]")
51
54
 
52
55
 
53
56
  def clean(title):
54
- return _ws.sub(" ", title).strip()
57
+ # whitespace first (\t\n become spaces), then the remaining control chars
58
+ return _ctrl.sub("", _ws.sub(" ", title)).strip()
55
59
 
56
60
 
57
61
  def parse_items(data):
@@ -111,7 +115,16 @@ def osc8(url, text):
111
115
 
112
116
 
113
117
  def render(title, link, endpoint, lang):
114
- wrapped = endpoint + "?" + urllib.parse.urlencode({"u": link, "c": lang})
118
+ # c/t/v ride along for click analytics (lang / topic pref / client version);
119
+ # the server logs them so vertical-partner pitches can tie clicks to topics.
120
+ q = {"u": link, "c": lang}
121
+ topic = (os.environ.get("NEWSLINE_TOPIC") or "").strip().lower()
122
+ if topic:
123
+ q["t"] = topic
124
+ ver = (os.environ.get("NEWSLINE_VERSION") or "").strip()
125
+ if ver:
126
+ q["v"] = ver
127
+ wrapped = endpoint + "?" + urllib.parse.urlencode(q)
115
128
  if len(title) > MAX_TITLE:
116
129
  title = title[: MAX_TITLE - 1] + "…"
117
130
  label = f"{ICON} {title}" if ICON else title
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "newsline-cli",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "description": "Locale-aware one-line news in your Claude Code status line — local, composes with your existing status line.",
5
5
  "bin": {
6
6
  "newsline": "newsline"
package/refresh.sh CHANGED
@@ -18,7 +18,7 @@ ENDPOINT="${NEWSLINE_ENDPOINT:-https://newsline.thesockerrr.workers.dev/r}"
18
18
  COUNT="${NEWSLINE_COUNT:-15}" # how many headlines to cache for rotation
19
19
  # Client version, sent to /feed as ?v= for the server-side update nudge.
20
20
  # Bump together with package.json when tagging a release.
21
- export NEWSLINE_VERSION="${NEWSLINE_VERSION:-0.1.4}"
21
+ export NEWSLINE_VERSION="${NEWSLINE_VERSION:-0.1.5}"
22
22
  LOCK="$CACHE_DIR/refresh.lock"
23
23
  mkdir -p "$CACHE_DIR" 2>/dev/null
24
24