{"action":"created","issue":{"url":"https://api.github.com/repos/zulip/zulip/issues/2704","repository_url":"https://api.github.com/repos/zulip/zulip","labels_url":"https://api.github.com/repos/zulip/zulip/issues/2704/labels{/name}","comments_url":"https://api.github.com/repos/zulip/zulip/issues/2704/comments","events_url":"https://api.github.com/repos/zulip/zulip/issues/2704/events","html_url":"https://github.com/zulip/zulip/issues/2704","id":195493040,"number":2704,"title":"Custom html based on stream/topic","user":{"login":"xeor","id":682676,"avatar_url":"https://avatars.githubusercontent.com/u/682676?v=3","gravatar_id":"","url":"https://api.github.com/users/xeor","html_url":"https://github.com/xeor","followers_url":"https://api.github.com/users/xeor/followers","following_url":"https://api.github.com/users/xeor/following{/other_user}","gists_url":"https://api.github.com/users/xeor/gists{/gist_id}","starred_url":"https://api.github.com/users/xeor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xeor/subscriptions","organizations_url":"https://api.github.com/users/xeor/orgs","repos_url":"https://api.github.com/users/xeor/repos","events_url":"https://api.github.com/users/xeor/events{/privacy}","received_events_url":"https://api.github.com/users/xeor/received_events","type":"User","site_admin":false},"labels":[{"id":461199252,"url":"https://api.github.com/repos/zulip/zulip/labels/area:%20markdown","name":"area: markdown","color":"bfd4f2","default":false},{"id":408332336,"url":"https://api.github.com/repos/zulip/zulip/labels/feedback%20wanted","name":"feedback wanted","color":"fef2c0","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2016-12-14T10:24:54Z","updated_at":"2016-12-14T20:34:08Z","closed_at":null,"body":"I am experimenting with using zulip with a custom bot that answers based on the stream-name or topic-name. Playing with this, I thought it would be a very nice addition to be able to have custom html either above the message-field, or at the right sidebar.\r\n\r\nI want to use the custom html to have everything from buttons to trigger the bots to do specific things, a list of examples/help, a list of live results from other systems, and so on.\r\n\r\nHave something like this been considered or is in the roadmap?\r\nI know about the dangers of doing this if the people writing the html is not trusted, but adding a this using a django-template lookup would be really nice. Example, if the stream/topic is cases/incidents and custom top-bar/side-bar is enabled. We could look for files; `custom-header-stream-cases.html`, `custom-header-topic-incidents.html`, `custom-sidebar-stream-cases.html`, `custom-sidebar-topic-incidents.html`, and inject them if they are available.\r\n\r\nThoughts?"},"comment":{"url":"https://api.github.com/repos/zulip/zulip/issues/comments/267148512","html_url":"https://github.com/zulip/zulip/issues/2704#issuecomment-267148512","issue_url":"https://api.github.com/repos/zulip/zulip/issues/2704","id":267148512,"user":{"login":"xeor","id":682676,"avatar_url":"https://avatars.githubusercontent.com/u/682676?v=3","gravatar_id":"","url":"https://api.github.com/users/xeor","html_url":"https://github.com/xeor","followers_url":"https://api.github.com/users/xeor/followers","following_url":"https://api.github.com/users/xeor/following{/other_user}","gists_url":"https://api.github.com/users/xeor/gists{/gist_id}","starred_url":"https://api.github.com/users/xeor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xeor/subscriptions","organizations_url":"https://api.github.com/users/xeor/orgs","repos_url":"https://api.github.com/users/xeor/repos","events_url":"https://api.github.com/users/xeor/events{/privacy}","received_events_url":"https://api.github.com/users/xeor/received_events","type":"User","site_admin":false},"created_at":"2016-12-14T20:34:08Z","updated_at":"2016-12-14T20:34:08Z","body":"Thanks for the quick response!\r\n\r\nThis is about the ui itself, not the messages coming from bots.\r\n\r\nI might have time making this into a pr if I know it will get accepted. If not, I will have to maintain a local version of this.\r\n\r\nThe idea, as I am thinking, is for the person that have access to the filesystem, to be able to extend some parts of the ui.\r\nBasically, making django look for extra templates based on stream-name/topic-name and in the same context as the rest of zulip. Something like https://docs.djangoproject.com/en/1.10/ref/templates/builtins/#include, but with graceful fallback if it doesn't exists, a way to turn it off completely, and/or a configurable mapping for which template would be used for different stream/topics. We can discuss implementation-details if a pr is wanted/accepted on this.\r\n\r\nUsecases might be;\r\n  * Displaying help on special-purpose stream/topics.\r\n  * Using javascript in the template with elements that trigger remote actions, which a bot can respond to.\r\n  * Having a generic list of available commands.\r\n  * Administrative commands/buttons to control the bot.\r\n  * Making a list from parts of what the bot have seen. Example to keep track of a todo-list.\r\n\r\nAll these usecases are fictional, and is for advance usecases.\r\n\r\nThe security is important here, so I don't think it is wise, nor easy, to implement this as a configurable from the web-ui. Maybe it should only be able to be set in the django settings.\r\n\r\nSomething like:\r\n\r\n```py\r\ndef get_sidebar_stream_template(streamname):\r\n  if streamname in ['...',]:\r\n    return 'templateforthis.html'\r\n  if re.match(...):\r\n    return 'another-template.html'\r\n\r\nEXTEND_UI = {\r\n  'right-sidebar': {\r\n    'stream': get_sidebar_stream_template\r\n  }\r\n}\r\n```\r\n\r\nYou get the idea.. :)"}}
{"actor":{"display_login":"xeor"}}