I’d like to customize the way posts are rendered on my hosted Discourse instance. For example, if I wanted to link stock symbols that start with a dollar sign (“cashtags”) like $AAPL, how would I do this?
You would need to write a plugin that would scan the post content for /\$(\w+)\b/ and replace it with a link to the corresponding stock.
Note: if you are hosted with us, we only allow custom plugin on the enterprise data plan.
5 个赞
Where would they link to?
有意思……
最好直接用雅虎财经?
或者 finviz.com 或 barchart.com?
我很想要一个具备此功能的插件。
2 个赞
是否有办法在输入符号后添加实时价格?可能根据涨跌使用绿色或红色的条件格式。
例如
$APPL $148.70
通过使用 Discourse API 中的 decorateCookedElement 自定义主题组件,这是可行的。您需要向第三方服务发起请求以获取股票信息,然后将其引入。
4 个赞
感谢 @awesomerobot,我会就此进行一些研究。
1 个赞
请查看:自定义提及对象 - 插件 - Discourse Meta 作为起点(不过您需要创建该数据集)。
2 个赞