Skip to content

Commit

Permalink
finish removing jupyter classic in an iframe
Browse files Browse the repository at this point in the history
  • Loading branch information
williamstein committed Oct 9, 2024
1 parent 234f5ec commit 571779f
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 2,236 deletions.
14 changes: 0 additions & 14 deletions src/packages/frontend/account/editor-settings/checkboxes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,10 @@
*/

import { defineMessage, useIntl } from "react-intl";

import { Checkbox } from "@cocalc/frontend/antd-bootstrap";
import { Rendered } from "@cocalc/frontend/app-framework";
import { A } from "@cocalc/frontend/components";
import { IntlMessage, isIntlMessage } from "@cocalc/frontend/i18n";
import { capitalize, keys } from "@cocalc/util/misc";
import { JUPYTER_CLASSIC_MODERN } from "@cocalc/util/theme";

const EDITOR_SETTINGS_CHECKBOXES: {
[setting: string]: IntlMessage | Rendered;
Expand Down Expand Up @@ -93,17 +90,6 @@ const EDITOR_SETTINGS_CHECKBOXES: {
defaultMessage:
"render entire Jupyter Notebook instead of just visible part (slower and not recommended)",
}),
jupyter_classic: (
<span>
<A href="https://github.com/sagemathinc/cocalc/issues/7706">
<b>DEPRECATED -- will to be removed after Aug 2024</b>
</A>{" "}
(see <A href={JUPYTER_CLASSIC_MODERN}>the docs</A>).
</span>
),
/* commented out since we are never using this.
disable_jupyter_windowing:
"never use windowing with Jupyter notebooks (windowing is sometimes used on the Chrome browser to make very large notebooks render quickly, but can lead to trouble)",*/
} as const;

interface Props {
Expand Down
4 changes: 2 additions & 2 deletions src/packages/frontend/components/link-retry.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,6 @@ const LinkRetry: React.FC<Props> = ({
return btn;
}
case "link":
default:
console.warn(`LinkRetry: invalid mode "${mode}"`);
const aLink = (
<a onClick={click} style={{ cursor: "pointer" }}>
{children}
Expand All @@ -148,6 +146,8 @@ const LinkRetry: React.FC<Props> = ({
{renderError()}
</span>
);
default:
console.warn(`LinkRetry: invalid mode "${mode}"`);
}
};

Expand Down
73 changes: 0 additions & 73 deletions src/packages/frontend/editor.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ $ = window.$
templates_html = \
require("./console.html").default +
require("./editor.html").default +
require("./jupyter.html").default +
require("./sagews/interact.html").default +
require("./sagews/3d.html").default +
require("./sagews/d3.html").default;
Expand Down Expand Up @@ -1749,75 +1748,6 @@ class FileEditorWrapper extends FileEditor
@wrapped?.hide?()


###
# Jupyter notebook
###
jupyter = require('./editor_jupyter')

class JupyterNotebook extends FileEditorWrapper
init_wrapped: () =>
@element = $("<div><span>&nbsp;&nbsp;Loading...</span></div>")
require.ensure [], =>
@init_font_size() # get the @default_font_size
# console.log("JupyterNotebook@default_font_size: #{@default_font_size}")
@opts.default_font_size = @default_font_size
@element = jupyter.jupyter_notebook(@, @filename, @opts)
@wrapped = @element.data('jupyter_notebook')

mount: () =>
if not @mounted
$(document.body).append(@element)
@mounted = true
return @mounted

class JupyterNBViewer extends FileEditorWrapper
init_wrapped: () ->
@element = jupyter.jupyter_nbviewer(@project_id, @filename, @content, @opts)
@wrapped = @element.data('jupyter_nbviewer')

class JupyterNBViewerEmbedded extends FileEditor
# this is like JupyterNBViewer but https://nbviewer.jupyter.org in an iframe
# it's only used for public files and when not part of the project or anonymous
constructor: (project_id, filename, content, opts) ->
super(project_id, filename)
@content = content
@element = $(".smc-jupyter-templates .smc-jupyter-nbviewer").clone()
@init_buttons()

init_buttons: () =>
# code duplication from editor_jupyter/JupyterNBViewer
@element.find('a[href="#copy"]').click () =>
actions = redux.getProjectActions(@project_id)
actions.load_target('files')
actions.set_all_files_unchecked()
actions.set_file_checked(@filename, true)
actions.set_file_action('copy')
return false

@element.find('a[href="#download"]').click () =>
actions = redux.getProjectActions(@project_id)
actions.load_target('files')
actions.set_all_files_unchecked()
actions.set_file_checked(@filename, true)
actions.set_file_action('download')
return false

show: () =>
if not @is_active()
return
if not @iframe?
@iframe = @element.find(".smc-jupyter-nbviewer-content").find('iframe')
{join} = require('path')
ipynb_src = join(window.location.hostname,
appBasePath,
@project_id,
'raw',
@filename)
# for testing, set it to a src like this: (smc-in-smc doesn't work for published files, since it
# still requires the user to be logged in with access to the host project)
#ipynb_src = 'cocalc.com/14eed217-2d3c-4975-a381-b69edcb40e0e/raw/scratch/1_notmnist.ipynb'
@iframe.attr('src', "//nbviewer.jupyter.org/urls/#{ipynb_src}")
@element.show()

exports.register_nonreact_editors = ->

Expand All @@ -1840,9 +1770,6 @@ exports.register_nonreact_editors = ->
if feature.IS_TOUCH
register(false, Terminal, ['term', 'sage-term'])

exports.switch_to_ipynb_classic = ->
register(false, JupyterNotebook, ['ipynb'])

# Editing Sage worksheets
reg
ext : 'sagews'
Expand Down
Loading

0 comments on commit 571779f

Please sign in to comment.