cointop-sh / cointop

A fast and lightweight interactive terminal based UI application for tracking cryptocurrencies 🚀
https://cointop.sh
Apache License 2.0
3.94k stars 309 forks source link

Implement alt-link and bind it to ^o #284

Closed lyricnz closed 2 years ago

lyricnz commented 2 years ago

Add support for an "alternate link" for a coin, to a user-defined target. This is expressed in a code snippet, defined in the config.toml file. The code has access to sprintf and a coin object with [ID, Name, Symbol, Rank, Slug] available.

alt_link_code = "sprintf(\"https://www.tradingview.com/chart/?symbol=%sUSDT\", coin.Symbol)"

Per #283

lyricnz commented 2 years ago

Thoughts:

lyricnz commented 2 years ago

The config is a little codey. Might be easier to explain with simple tokens.

miguelmota commented 2 years ago

(copying my comment from discord):

This format makes it very specific to Go but the config file should be generalized. I think something like alt_link_code = "https://www.tradingview.com/chart/?symbol=:SYMBOL:" would be better and we can offer :SYMBOL:, :NAME, :ID: , etc as variables

miguelmota commented 2 years ago

Merging this with some changes

I updated it to use template tags and simplified the link generation by not passing the alt coin link code to each coin api class

Example link

alt_coin_link = "https://www.tradingview.com/symbols/{{SYMBOL}}USD/"

Available tags:

Thanks @lyricnz!