diff --git a/.github/scripts/telegram.sh b/.github/scripts/telegram.sh index a17843c..fbcd37c 100755 --- a/.github/scripts/telegram.sh +++ b/.github/scripts/telegram.sh @@ -111,6 +111,7 @@ function parse_messages { # - discard messages without text e.g. images: [{"update_id":123,"message_text":[""]}] # - set as "url" only the first item that starts with "http" # - "description" value (url) is just a placeholder, it's replaced with the of the page afterwards with "pup" + # - set as "source" only the first item that starts with "+", default is "unknown" # - set as "path" only the first item that starts with "_", default is "/random" # - set as "tags" all the items that starts with "#" echo $MESSAGES | jq \ @@ -120,7 +121,8 @@ function parse_messages { "timestamp": .timestamp, "url": .message_text[] | select(. | startswith("http")), "description": .message_text[] | select(. | startswith("http")), - "source": "telegram", + "client": "telegram", + "source": ((.message_text | map(select(. | startswith("+")) | gsub("+";"") | ascii_downcase) | first ) // "unknown"), "path": ((.message_text | map(select(. | startswith("_")) | gsub("_";"/") | ascii_downcase) | first ) // "/random"), "tags": (.message_text | map(select(. | startswith("#"))) | map({ "name": . | gsub("#";"") | ascii_downcase, "auto": false })) })' @@ -215,6 +217,7 @@ install_pup # TODO sanitize tags and paths e.g. `[a-zA-Z0-0_\-]` # TODO autogenerated tags from url e.g. github, youtube # TODO gh-action: auto-update workflows to keep in sync with template +# TODO gh-action: create archive (e.g. Wayback Machine) and periodically check broken links and replace them main echo "[-] telegram" diff --git a/README.md b/README.md index 80ff182..2aed211 100644 --- a/README.md +++ b/README.md @@ -19,11 +19,14 @@ Rules: * every multi-line text is evaluated independently * the order of the content doesn't matter * a message must contains a valid **url** or it will be ignored i.e. a word that starts with `http` +* if a line contains a word starting with *plus* it will be used as **source** e.g. `+hackernews` + - optional, default path is `unknown` + - you can define one source: only the first one is used * if a line contains a word starting with *underscore* it will be used as **path** e.g. `_folder_subfolder` - optional, default path is `/random` - - you can define 1 path: only the first one is used + - you can define one path: only the first one is used * if a line contains a word starting with *hash* it will be used as **tag** e.g. `#mytag` - - optional, tags are always converted to lowercase by default + - optional, default is empty - you can define multiple tags ## Setup diff --git a/data/telegram.json b/data/telegram.json index 05ffeda..b01894d 100644 --- a/data/telegram.json +++ b/data/telegram.json @@ -4,12 +4,17 @@ "timestamp": "2021-06-22T09:11:13Z", "url": "https://github.com/niqdev/", "description": "niqdev · GitHub", - "source": "telegram", + "client": "telegram", + "source": "unknown", "path": "/folder/subfolder/nested/", "tags": [ { "name": "github", "auto": true + }, + { + "name": "example", + "auto": false } ] }, @@ -18,7 +23,8 @@ "timestamp": "2021-06-22T09:11:13Z", "url": "https://gohugo.io", "description": "The world’s fastest framework for building websites | Hugo", - "source": "telegram", + "client": "telegram", + "source": "hackernews", "path": "/random", "tags": [ { diff --git a/layouts/index.html b/layouts/index.html index 7629549..2e73c4c 100644 --- a/layouts/index.html +++ b/layouts/index.html @@ -3,10 +3,16 @@ <div>{{ .timestamp }}</div> <div><a href="{{ .url }}" target="_blank">{{ .description }}</a></div> <ul> - <li>{{ .path }}</li> - {{ range .tags }} - <li>{{ .name }} ({{ .auto }})</li> - {{ end }} + <li>client: {{ .client }}</li> + <li>source: {{ .source }}</li> + <li>folder: {{ .path }}</li> + <li>tags: + <ul> + {{ range .tags }} + <li>{{ .name }} (auto={{ .auto }})</li> + {{ end }} + </ul> + </li> </ul> <br> {{ end }}