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?
AI-generated summary
The discussion revolves around automatically linking stock symbols in posts on a Discourse instance. ide proposes customizing post rendering to link “cashtags” like $AAPL. zogstrip suggests creating a plugin to scan and replace these cashtags with links to a corresponding stock page.
Possible link destinations include Yahoo Finance, finviz.com, or barchart.com, as suggested by MarcP. Neildb further proposes adding live prices with conditional formatting for green or red depending on the stock’s movement.
awesomerobot explains that this is possible using a custom theme component with the Discourse API. merefield recommends the Custom Mentionables plugin as a starting point, requiring the creation of a dataset.
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.
Where would they link to?
Интересно..
Лучше всего, наверное, Yahoo Finance?
Возможно, finviz.com или barchart.com?
Мне бы очень понравился плагин с таким функционалом.
Есть ли способ добавлять текущую цену после ввода символа? Возможно, с условным форматированием (зелёный или красный цвет) в зависимости от изменения цены.
Например:
$APPL $148.70
Это возможно с использованием пользовательского компонента темы с помощью decorateCookedElement из API Discourse. Вам потребуется выполнить запрос к стороннему сервису для получения информации о котировках акций, а затем интегрировать её.
Спасибо, @awesomerobot, я проведу исследование по этому вопросу.
Посмотрите: Custom Mentionables - плагин - Discourse Meta в качестве отправной точки (хотя вам всё равно придётся создать набор данных).