{"action":"created","comment":{"url":"https://api.github.com/repos/bokeh/bokeh/pulls/comments/45228122","id":45228122,"diff_hunk":"@@ -400,28 +352,24 @@ def autoload_server(plot_object, app_path=\"/\", session_id=DEFAULT_SESSION_ID, ur\n \n     return encode_utf8(tag)\n \n-def _script_for_render_items(docs_json, render_items, websocket_url,\n-                             custom_models, wrap_script=True):\n-    # this avoids emitting the \"register custom models\" code at all\n-    # just to register an empty set\n-    if (custom_models is not None) and len(custom_models) == 0:\n-        custom_models = None\n-\n-    plot_js = _wrap_in_function(\n-        DOC_JS.render(\n-            custom_models=custom_models,\n-            websocket_url=websocket_url,\n-            docs_json=serialize_json(docs_json),\n-            render_items=serialize_json(render_items)\n+def _script_for_render_items(docs_json, render_items, websocket_url, wrap_script=True):\n+    def plot_js(docs_json):\n+        return _wrap_in_function(\n+            DOC_JS.render(\n+                websocket_url=websocket_url,\n+                docs_json=serialize_json(docs_json),\n+                render_items=serialize_json(render_items),\n+            )\n         )\n-    )\n+\n     if wrap_script:\n-        return SCRIPT_TAG.render(js_code=plot_js)\n+        id = str(uuid.uuid4())\n+        return SCRIPT_TAG.render(docs_json_id=id, docs_json=serialize_json(docs_json), js_code=plot_js(id))\n     else:\n-        return plot_js\n+        return plot_js(docs_json)","path":"bokeh/embed.py","position":126,"original_position":126,"commit_id":"7f69c3ccc4b98d6fd1a261789c332a2f23bf026e","original_commit_id":"7f69c3ccc4b98d6fd1a261789c332a2f23bf026e","user":{"login":"havocp","id":218689,"avatar_url":"https://avatars.githubusercontent.com/u/218689?v=3","gravatar_id":"","url":"https://api.github.com/users/havocp","html_url":"https://github.com/havocp","followers_url":"https://api.github.com/users/havocp/followers","following_url":"https://api.github.com/users/havocp/following{/other_user}","gists_url":"https://api.github.com/users/havocp/gists{/gist_id}","starred_url":"https://api.github.com/users/havocp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/havocp/subscriptions","organizations_url":"https://api.github.com/users/havocp/orgs","repos_url":"https://api.github.com/users/havocp/repos","events_url":"https://api.github.com/users/havocp/events{/privacy}","received_events_url":"https://api.github.com/users/havocp/received_events","type":"User","site_admin":false},"body":"I think this refactor is incomplete and we end up with one function that really does two separate things. As it is, the function is named and expected elsewhere to return one hunk of script, which is optionally wrapped in one `<script>` tag. If we want to change it so that to embed render items, you need N script tags, we should rename the function `_scripts_for_render_items`, return a list, and have all callers handle the list result.\r\n\r\n`wrap_script` should control whether each element is wrapped in a `<script>` tag, not how many elements there are. Though with docs_json in its own tag I think we have to always wrap_script so that parameter would maybe have to go.\r\n\r\nThe simplest thing for this PR is probably to drop the \"externalize docs json into its own <script> tag\" and do that as its own PR, but if you think externalizing the docs json is important to this PR, I think we should finish the refactor - do it always/consistently. There's no value I see to having two ways to do this: either externalize the docs_json into tags, or don't.\r\n\r\nGoing from one script to a list of scripts will break the `components()` API I think. If we don't want to break `components()` I'm not sure we should do this at all, is it really worth two codepaths?\r\n\r\nIf we _do_ have two codepaths, I'd rather not overload `wrap_script` - it refers to whether to wrap the scripts in a script tag, which is separate from whether the docs_json is in its own script tag. Maybe a separate function `_scripts_for_render_items_with_externalized_json` ?\r\n","created_at":"2015-11-18T17:09:12Z","updated_at":"2015-11-18T17:09:12Z","html_url":"https://github.com/bokeh/bokeh/pull/3047#discussion_r45228122","pull_request_url":"https://api.github.com/repos/bokeh/bokeh/pulls/3047","_links":{"self":{"href":"https://api.github.com/repos/bokeh/bokeh/pulls/comments/45228122"},"html":{"href":"https://github.com/bokeh/bokeh/pull/3047#discussion_r45228122"},"pull_request":{"href":"https://api.github.com/repos/bokeh/bokeh/pulls/3047"}}},"pull_request":{"url":"https://api.github.com/repos/bokeh/bokeh/pulls/3047","id":49424960,"html_url":"https://github.com/bokeh/bokeh/pull/3047","diff_url":"https://github.com/bokeh/bokeh/pull/3047.diff","patch_url":"https://github.com/bokeh/bokeh/pull/3047.patch","issue_url":"https://api.github.com/repos/bokeh/bokeh/issues/3047","number":3047,"state":"open","locked":false,"title":"node.js integration and static image generation","user":{"login":"mattpap","id":27475,"avatar_url":"https://avatars.githubusercontent.com/u/27475?v=3","gravatar_id":"","url":"https://api.github.com/users/mattpap","html_url":"https://github.com/mattpap","followers_url":"https://api.github.com/users/mattpap/followers","following_url":"https://api.github.com/users/mattpap/following{/other_user}","gists_url":"https://api.github.com/users/mattpap/gists{/gist_id}","starred_url":"https://api.github.com/users/mattpap/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mattpap/subscriptions","organizations_url":"https://api.github.com/users/mattpap/orgs","repos_url":"https://api.github.com/users/mattpap/repos","events_url":"https://api.github.com/users/mattpap/events{/privacy}","received_events_url":"https://api.github.com/users/mattpap/received_events","type":"User","site_admin":false},"body":"At this point you can convert a `file_html()` generated HTML file into a set of PNG images (one per canvas). For example:\r\n```\r\ncd bokeh/bokehjs\r\n(cd ../examples/plotting/file; python bollinger.py)\r\nnode render.js ../examples/plotting/file/bollinger.html\r\neog ../examples/plotting/file/bollinger-PLOTID.png\r\n```\r\n\r\nCurrently you need to install these manually:\r\n``` \r\nsudo apt-get install libcairo2-dev libpango1.0-dev libjpeg-dev libgif-dev\r\n```\r\n\r\nIssues:\r\n- fonts are messed up very often (when using custom font/size/face)\r\n- several examples are simply broken (histogram, burtin, gears, etc.)\r\n- examples involving maps don't terminate (disabling maps helps)\r\n- examples involving ImageURL, maps and ??? are unreliable (see `render:done`)\r\n- `examples/plotting/file/image.py` (RangeError: Source is too large)\r\n- `examples/plotting/file/image_rgba.py` (TypeError: Image or Canvas expected)\r\n\r\nTODO:\r\n- [x] add direct support for image generation from bokeh\r\n- [ ] use separate `package.json` for node.js integration tools\r\n- [x] add support for custom models\r\n- [ ] make `render:done` event reliable","created_at":"2015-11-02T12:16:17Z","updated_at":"2015-11-18T17:09:12Z","closed_at":null,"merged_at":null,"merge_commit_sha":"256d0bd492df67a6891b7ea128706a396b468900","assignee":{"login":"mattpap","id":27475,"avatar_url":"https://avatars.githubusercontent.com/u/27475?v=3","gravatar_id":"","url":"https://api.github.com/users/mattpap","html_url":"https://github.com/mattpap","followers_url":"https://api.github.com/users/mattpap/followers","following_url":"https://api.github.com/users/mattpap/following{/other_user}","gists_url":"https://api.github.com/users/mattpap/gists{/gist_id}","starred_url":"https://api.github.com/users/mattpap/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mattpap/subscriptions","organizations_url":"https://api.github.com/users/mattpap/orgs","repos_url":"https://api.github.com/users/mattpap/repos","events_url":"https://api.github.com/users/mattpap/events{/privacy}","received_events_url":"https://api.github.com/users/mattpap/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/bokeh/bokeh/milestones/22","html_url":"https://github.com/bokeh/bokeh/milestones/0.11.0","labels_url":"https://api.github.com/repos/bokeh/bokeh/milestones/22/labels","id":1320524,"number":22,"title":"0.11.0","description":"","creator":{"login":"mattpap","id":27475,"avatar_url":"https://avatars.githubusercontent.com/u/27475?v=3","gravatar_id":"","url":"https://api.github.com/users/mattpap","html_url":"https://github.com/mattpap","followers_url":"https://api.github.com/users/mattpap/followers","following_url":"https://api.github.com/users/mattpap/following{/other_user}","gists_url":"https://api.github.com/users/mattpap/gists{/gist_id}","starred_url":"https://api.github.com/users/mattpap/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mattpap/subscriptions","organizations_url":"https://api.github.com/users/mattpap/orgs","repos_url":"https://api.github.com/users/mattpap/repos","events_url":"https://api.github.com/users/mattpap/events{/privacy}","received_events_url":"https://api.github.com/users/mattpap/received_events","type":"User","site_admin":false},"open_issues":78,"closed_issues":82,"state":"open","created_at":"2015-09-23T15:04:43Z","updated_at":"2015-11-18T15:32:37Z","due_on":"2015-12-07T23:00:00Z","closed_at":null},"commits_url":"https://api.github.com/repos/bokeh/bokeh/pulls/3047/commits","review_comments_url":"https://api.github.com/repos/bokeh/bokeh/pulls/3047/comments","review_comment_url":"https://api.github.com/repos/bokeh/bokeh/pulls/comments{/number}","comments_url":"https://api.github.com/repos/bokeh/bokeh/issues/3047/comments","statuses_url":"https://api.github.com/repos/bokeh/bokeh/statuses/7f69c3ccc4b98d6fd1a261789c332a2f23bf026e","head":{"label":"bokeh:mattpap/1589_nodejs","ref":"mattpap/1589_nodejs","sha":"7f69c3ccc4b98d6fd1a261789c332a2f23bf026e","user":{"login":"bokeh","id":8440965,"avatar_url":"https://avatars.githubusercontent.com/u/8440965?v=3","gravatar_id":"","url":"https://api.github.com/users/bokeh","html_url":"https://github.com/bokeh","followers_url":"https://api.github.com/users/bokeh/followers","following_url":"https://api.github.com/users/bokeh/following{/other_user}","gists_url":"https://api.github.com/users/bokeh/gists{/gist_id}","starred_url":"https://api.github.com/users/bokeh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bokeh/subscriptions","organizations_url":"https://api.github.com/users/bokeh/orgs","repos_url":"https://api.github.com/users/bokeh/repos","events_url":"https://api.github.com/users/bokeh/events{/privacy}","received_events_url":"https://api.github.com/users/bokeh/received_events","type":"Organization","site_admin":false},"repo":{"id":3834332,"name":"bokeh","full_name":"bokeh/bokeh","owner":{"login":"bokeh","id":8440965,"avatar_url":"https://avatars.githubusercontent.com/u/8440965?v=3","gravatar_id":"","url":"https://api.github.com/users/bokeh","html_url":"https://github.com/bokeh","followers_url":"https://api.github.com/users/bokeh/followers","following_url":"https://api.github.com/users/bokeh/following{/other_user}","gists_url":"https://api.github.com/users/bokeh/gists{/gist_id}","starred_url":"https://api.github.com/users/bokeh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bokeh/subscriptions","organizations_url":"https://api.github.com/users/bokeh/orgs","repos_url":"https://api.github.com/users/bokeh/repos","events_url":"https://api.github.com/users/bokeh/events{/privacy}","received_events_url":"https://api.github.com/users/bokeh/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/bokeh/bokeh","description":"Interactive Web Plotting for Python","fork":false,"url":"https://api.github.com/repos/bokeh/bokeh","forks_url":"https://api.github.com/repos/bokeh/bokeh/forks","keys_url":"https://api.github.com/repos/bokeh/bokeh/keys{/key_id}","collaborators_url":"https://api.github.com/repos/bokeh/bokeh/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/bokeh/bokeh/teams","hooks_url":"https://api.github.com/repos/bokeh/bokeh/hooks","issue_events_url":"https://api.github.com/repos/bokeh/bokeh/issues/events{/number}","events_url":"https://api.github.com/repos/bokeh/bokeh/events","assignees_url":"https://api.github.com/repos/bokeh/bokeh/assignees{/user}","branches_url":"https://api.github.com/repos/bokeh/bokeh/branches{/branch}","tags_url":"https://api.github.com/repos/bokeh/bokeh/tags","blobs_url":"https://api.github.com/repos/bokeh/bokeh/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/bokeh/bokeh/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/bokeh/bokeh/git/refs{/sha}","trees_url":"https://api.github.com/repos/bokeh/bokeh/git/trees{/sha}","statuses_url":"https://api.github.com/repos/bokeh/bokeh/statuses/{sha}","languages_url":"https://api.github.com/repos/bokeh/bokeh/languages","stargazers_url":"https://api.github.com/repos/bokeh/bokeh/stargazers","contributors_url":"https://api.github.com/repos/bokeh/bokeh/contributors","subscribers_url":"https://api.github.com/repos/bokeh/bokeh/subscribers","subscription_url":"https://api.github.com/repos/bokeh/bokeh/subscription","commits_url":"https://api.github.com/repos/bokeh/bokeh/commits{/sha}","git_commits_url":"https://api.github.com/repos/bokeh/bokeh/git/commits{/sha}","comments_url":"https://api.github.com/repos/bokeh/bokeh/comments{/number}","issue_comment_url":"https://api.github.com/repos/bokeh/bokeh/issues/comments{/number}","contents_url":"https://api.github.com/repos/bokeh/bokeh/contents/{+path}","compare_url":"https://api.github.com/repos/bokeh/bokeh/compare/{base}...{head}","merges_url":"https://api.github.com/repos/bokeh/bokeh/merges","archive_url":"https://api.github.com/repos/bokeh/bokeh/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/bokeh/bokeh/downloads","issues_url":"https://api.github.com/repos/bokeh/bokeh/issues{/number}","pulls_url":"https://api.github.com/repos/bokeh/bokeh/pulls{/number}","milestones_url":"https://api.github.com/repos/bokeh/bokeh/milestones{/number}","notifications_url":"https://api.github.com/repos/bokeh/bokeh/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/bokeh/bokeh/labels{/name}","releases_url":"https://api.github.com/repos/bokeh/bokeh/releases{/id}","created_at":"2012-03-26T15:40:01Z","updated_at":"2015-11-18T12:19:34Z","pushed_at":"2015-11-18T16:15:06Z","git_url":"git://github.com/bokeh/bokeh.git","ssh_url":"git@github.com:bokeh/bokeh.git","clone_url":"https://github.com/bokeh/bokeh.git","svn_url":"https://github.com/bokeh/bokeh","homepage":"http://bokeh.pydata.org/en/latest/","size":130618,"stargazers_count":3427,"watchers_count":3427,"language":"CoffeeScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":657,"mirror_url":null,"open_issues_count":613,"forks":657,"open_issues":613,"watchers":3427,"default_branch":"master"}},"base":{"label":"bokeh:master","ref":"master","sha":"172da20f3e1d8cdc39f971c968965230f7e0e730","user":{"login":"bokeh","id":8440965,"avatar_url":"https://avatars.githubusercontent.com/u/8440965?v=3","gravatar_id":"","url":"https://api.github.com/users/bokeh","html_url":"https://github.com/bokeh","followers_url":"https://api.github.com/users/bokeh/followers","following_url":"https://api.github.com/users/bokeh/following{/other_user}","gists_url":"https://api.github.com/users/bokeh/gists{/gist_id}","starred_url":"https://api.github.com/users/bokeh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bokeh/subscriptions","organizations_url":"https://api.github.com/users/bokeh/orgs","repos_url":"https://api.github.com/users/bokeh/repos","events_url":"https://api.github.com/users/bokeh/events{/privacy}","received_events_url":"https://api.github.com/users/bokeh/received_events","type":"Organization","site_admin":false},"repo":{"id":3834332,"name":"bokeh","full_name":"bokeh/bokeh","owner":{"login":"bokeh","id":8440965,"avatar_url":"https://avatars.githubusercontent.com/u/8440965?v=3","gravatar_id":"","url":"https://api.github.com/users/bokeh","html_url":"https://github.com/bokeh","followers_url":"https://api.github.com/users/bokeh/followers","following_url":"https://api.github.com/users/bokeh/following{/other_user}","gists_url":"https://api.github.com/users/bokeh/gists{/gist_id}","starred_url":"https://api.github.com/users/bokeh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bokeh/subscriptions","organizations_url":"https://api.github.com/users/bokeh/orgs","repos_url":"https://api.github.com/users/bokeh/repos","events_url":"https://api.github.com/users/bokeh/events{/privacy}","received_events_url":"https://api.github.com/users/bokeh/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/bokeh/bokeh","description":"Interactive Web Plotting for Python","fork":false,"url":"https://api.github.com/repos/bokeh/bokeh","forks_url":"https://api.github.com/repos/bokeh/bokeh/forks","keys_url":"https://api.github.com/repos/bokeh/bokeh/keys{/key_id}","collaborators_url":"https://api.github.com/repos/bokeh/bokeh/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/bokeh/bokeh/teams","hooks_url":"https://api.github.com/repos/bokeh/bokeh/hooks","issue_events_url":"https://api.github.com/repos/bokeh/bokeh/issues/events{/number}","events_url":"https://api.github.com/repos/bokeh/bokeh/events","assignees_url":"https://api.github.com/repos/bokeh/bokeh/assignees{/user}","branches_url":"https://api.github.com/repos/bokeh/bokeh/branches{/branch}","tags_url":"https://api.github.com/repos/bokeh/bokeh/tags","blobs_url":"https://api.github.com/repos/bokeh/bokeh/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/bokeh/bokeh/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/bokeh/bokeh/git/refs{/sha}","trees_url":"https://api.github.com/repos/bokeh/bokeh/git/trees{/sha}","statuses_url":"https://api.github.com/repos/bokeh/bokeh/statuses/{sha}","languages_url":"https://api.github.com/repos/bokeh/bokeh/languages","stargazers_url":"https://api.github.com/repos/bokeh/bokeh/stargazers","contributors_url":"https://api.github.com/repos/bokeh/bokeh/contributors","subscribers_url":"https://api.github.com/repos/bokeh/bokeh/subscribers","subscription_url":"https://api.github.com/repos/bokeh/bokeh/subscription","commits_url":"https://api.github.com/repos/bokeh/bokeh/commits{/sha}","git_commits_url":"https://api.github.com/repos/bokeh/bokeh/git/commits{/sha}","comments_url":"https://api.github.com/repos/bokeh/bokeh/comments{/number}","issue_comment_url":"https://api.github.com/repos/bokeh/bokeh/issues/comments{/number}","contents_url":"https://api.github.com/repos/bokeh/bokeh/contents/{+path}","compare_url":"https://api.github.com/repos/bokeh/bokeh/compare/{base}...{head}","merges_url":"https://api.github.com/repos/bokeh/bokeh/merges","archive_url":"https://api.github.com/repos/bokeh/bokeh/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/bokeh/bokeh/downloads","issues_url":"https://api.github.com/repos/bokeh/bokeh/issues{/number}","pulls_url":"https://api.github.com/repos/bokeh/bokeh/pulls{/number}","milestones_url":"https://api.github.com/repos/bokeh/bokeh/milestones{/number}","notifications_url":"https://api.github.com/repos/bokeh/bokeh/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/bokeh/bokeh/labels{/name}","releases_url":"https://api.github.com/repos/bokeh/bokeh/releases{/id}","created_at":"2012-03-26T15:40:01Z","updated_at":"2015-11-18T12:19:34Z","pushed_at":"2015-11-18T16:15:06Z","git_url":"git://github.com/bokeh/bokeh.git","ssh_url":"git@github.com:bokeh/bokeh.git","clone_url":"https://github.com/bokeh/bokeh.git","svn_url":"https://github.com/bokeh/bokeh","homepage":"http://bokeh.pydata.org/en/latest/","size":130618,"stargazers_count":3427,"watchers_count":3427,"language":"CoffeeScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":657,"mirror_url":null,"open_issues_count":613,"forks":657,"open_issues":613,"watchers":3427,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/bokeh/bokeh/pulls/3047"},"html":{"href":"https://github.com/bokeh/bokeh/pull/3047"},"issue":{"href":"https://api.github.com/repos/bokeh/bokeh/issues/3047"},"comments":{"href":"https://api.github.com/repos/bokeh/bokeh/issues/3047/comments"},"review_comments":{"href":"https://api.github.com/repos/bokeh/bokeh/pulls/3047/comments"},"review_comment":{"href":"https://api.github.com/repos/bokeh/bokeh/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/bokeh/bokeh/pulls/3047/commits"},"statuses":{"href":"https://api.github.com/repos/bokeh/bokeh/statuses/7f69c3ccc4b98d6fd1a261789c332a2f23bf026e"}}}}