I’m developing a plugin to embed jupyter notebooks into discourse posts. It’s a private jupyter server and the user can only share his notebooks. So i need to verify the user.
-
how to get the current user (and maybe the author of the post or reply) in discourse onebox plugin? i need to get the username (the login name)
-
another question is, there are script tags in notebook html? seems the onebox removes all the script tags. how to make it keep the script tags?
-
one more question, is there any cache in one box? seems there are no more requests when i modify and save the post
below is my test code
Onebox = Onebox
module Onebox
module Engine
class XXXXXXNotebookOnebox
include Engine
include JSON
# include CurrentUser : NameError: uninitialized constant Onebox::Engine::BigQuantNotebookOnebox::CurrentUser
# include CurrentUser
matches_regexp(/^https?:\/\/i\.XXXXXXX\.com\/.+\.ipynb$/)
def placeholder_html
'hello place holder'
end
def to_html
a = 'no user '
if current_user
a = 'has user'
end
"test hello html <iframe src='https://XXXXXX.com/'></iframe> <script>alert('test me');</script> end " + Time.new.inspect + a
end
end
end
end