Skip to content

Commit

Permalink
update action
Browse files Browse the repository at this point in the history
  • Loading branch information
niqdev committed Jul 31, 2021
1 parent 7c8d035 commit 6bdf0cc
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 9 deletions.
5 changes: 4 additions & 1 deletion .github/scripts/telegram.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 <title> 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 \
Expand All @@ -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 }))
})'
Expand Down Expand Up @@ -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"
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 8 additions & 2 deletions data/telegram.json
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
]
},
Expand All @@ -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": [
{
Expand Down
14 changes: 10 additions & 4 deletions layouts/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down

0 comments on commit 6bdf0cc

Please sign in to comment.