-
-
Notifications
You must be signed in to change notification settings - Fork 6.6k
Add Jupyter Notebook (.ipynb) Rendering Support #37433
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
karthikbhandary2
wants to merge
68
commits into
go-gitea:main
Choose a base branch
from
karthikbhandary2:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
68 commits
Select commit
Hold shift + click to select a range
fad641b
added DeleteOrgRepos func
karthikbhandary2 226ace7
Merge branch 'go-gitea:main' into main
karthikbhandary2 acf9dc0
Merge branch 'go-gitea:main' into main
karthikbhandary2 e940dd2
Verified and tested the DeleteRepoOrgs
karthikbhandary2 c319345
ran make generate-swagger
karthikbhandary2 e4c5c38
error handling and swagger updated
karthikbhandary2 ed4b335
Removed additional check for permissions in DeleteOrgRepos
karthikbhandary2 5b819b4
updated DeleteOrgRepos to delete in the background
karthikbhandary2 9f31e6c
Merge branch 'go-gitea:main' into main
karthikbhandary2 a5092e5
added system notice
karthikbhandary2 20e3fe4
added batch processing and other fixes
karthikbhandary2 988ec17
Merge branch 'go-gitea:main' into main
karthikbhandary2 008415e
added retry logic
karthikbhandary2 63f9dbf
reverted back to old logic
karthikbhandary2 204100a
Merge branch 'go-gitea:main' into main
karthikbhandary2 9f7deee
Merge branch 'go-gitea:main' into main
karthikbhandary2 bef6617
Merge branch 'go-gitea:main' into main
karthikbhandary2 ae7b1a1
Merge branch 'go-gitea:main' into main
karthikbhandary2 84e3487
Merge branch 'go-gitea:main' into main
karthikbhandary2 974def8
Merge branch 'go-gitea:main' into main
karthikbhandary2 e29e9bf
Merge branch 'go-gitea:main' into main
karthikbhandary2 ce000b0
Merge branch 'go-gitea:main' into main
karthikbhandary2 95a0d70
Merge branch 'go-gitea:main' into main
karthikbhandary2 cff469d
Merge branch 'go-gitea:main' into main
karthikbhandary2 84ef882
Merge branch 'go-gitea:main' into main
karthikbhandary2 348feff
Merge branch 'go-gitea:main' into main
karthikbhandary2 cfcbdca
updated DeleteOrgRepos to use GetRepositoryByID
a36a3b5
Merge branch 'go-gitea:main' into main
karthikbhandary2 aea3d2b
Merge branch 'go-gitea:main' into main
karthikbhandary2 02343a2
Merge branch 'go-gitea:main' into main
karthikbhandary2 1633be5
Merge branch 'main' into main
karthikbhandary2 53a1aac
merge conflict fix
8b494d6
Merge branch 'go-gitea:main' into main
karthikbhandary2 41a1ed0
Merge branch 'main' into main
karthikbhandary2 35587c0
Merge branch 'go-gitea:main' into main
karthikbhandary2 e402e5f
Merge branch 'go-gitea:main' into main
karthikbhandary2 c8b09c8
Merge branch 'main' into main
karthikbhandary2 88381aa
add test to check if deletes were successful
0f0ec79
Merge branch 'main' into main
karthikbhandary2 41cff2f
refactor
wxiaoguang f723d35
refactor
wxiaoguang 8ed094e
Merge branch 'go-gitea:main' into main
karthikbhandary2 76189cc
tests updated and delete endpoint updated
karthikbhandary2 bc073ce
Merge branch 'main' into main
karthikbhandary2 81fc298
Merge branch 'main' into main
karthikbhandary2 9e71545
clean up AI slop
wxiaoguang 115b582
fine tune
wxiaoguang 8017f5d
fine tune
wxiaoguang bea4c1c
Merge branch 'main' into main
karthikbhandary2 bbc3491
remove unnecessary test
wxiaoguang 7af8f5f
Merge branch 'main' into main
karthikbhandary2 a6bcd02
Merge branch 'go-gitea:main' into main
karthikbhandary2 ea82743
Merge branch 'go-gitea:main' into main
karthikbhandary2 d83c602
feat:Render .ipynb files natively
53cbc73
Add Jupyter Notebook (.ipynb) rendering support
6002070
ran lint and fmt
79d496a
addressed lint issue
40608b2
fix: lint
fa84ca7
fix: removed jupyter.css from index.css
ce940d2
Merge branch 'main' into main
karthikbhandary2 bb0da24
Merge branch 'main' into main
karthikbhandary2 d967030
fix
73ffd64
fix: Moved from custom to using marked for rendering
ab43de0
Merge branch 'main' into main
karthikbhandary2 8563401
fix
55a8bc4
Merge branch 'main' into main
karthikbhandary2 8b912d3
Merge branch 'main' into main
karthikbhandary2 22c4803
Merge branch 'main' into main
karthikbhandary2 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| import {env} from 'node:process'; | ||
| import {expect, test} from '@playwright/test'; | ||
| import {login, apiCreateRepo, apiCreateFile, assertNoJsError, randomString} from './utils.ts'; | ||
|
|
||
| test.describe('jupyter notebook rendering', () => { | ||
| let repoName: string; | ||
| let owner: string; | ||
|
|
||
| test.beforeAll(async ({request}) => { | ||
| repoName = `e2e-jupyter-${randomString(8)}`; | ||
| owner = env.GITEA_TEST_E2E_USER; | ||
|
|
||
| await apiCreateRepo(request, {name: repoName}); | ||
|
|
||
| // Single comprehensive test notebook | ||
| const notebook = JSON.stringify({ | ||
| cells: [ | ||
| {cell_type: 'markdown', source: ['# Header 1\n', '## Header 2\n', '**bold** *italic* `code`\n', '- List item 1\n', '- List item 2\n', '[link](https://example.com)\n', '| Col1 | Col2 |\n', '|------|------|\n', '| A | B |\n', '```python\ncode block\n```\n', '> blockquote\n', '~~strikethrough~~']}, | ||
| {cell_type: 'code', execution_count: 1, source: ['print("Hello")'], outputs: [{output_type: 'stream', name: 'stdout', text: ['Hello\n']}]}, | ||
| {cell_type: 'code', execution_count: 2, source: ['x'], outputs: [{output_type: 'execute_result', data: {'image/png': 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg=='}}]}, | ||
| {cell_type: 'code', source: ['# No output'], outputs: []}, | ||
| {cell_type: 'code', source: ['err'], outputs: [{output_type: 'error', ename: 'ValueError', evalue: 'Test', traceback: ['ValueError: Test']}]}, | ||
| {cell_type: 'code', source: ['mixed'], outputs: [{output_type: 'stream', name: 'stdout', text: ['text\n']}, {output_type: 'execute_result', data: {'text/html': ['<b>HTML</b>']}}]}, | ||
| ], | ||
| metadata: {}, nbformat: 4, nbformat_minor: 5, | ||
| }); | ||
|
|
||
| await apiCreateFile(request, owner, repoName, 'test.ipynb', notebook); | ||
| }); | ||
|
|
||
| test('renders markdown cells', async ({page}) => { | ||
| await login(page); | ||
| await page.goto(`/${owner}/${repoName}/src/branch/main/test.ipynb`); | ||
| await assertNoJsError(page); | ||
| const frame = page.frameLocator('iframe.external-render-iframe'); | ||
| await expect(frame.locator('.cell.markdown h1')).toBeVisible(); | ||
| await expect(frame.locator('.cell.markdown strong')).toBeVisible(); | ||
| await expect(frame.locator('.cell.markdown ul li').first()).toBeVisible(); | ||
| await expect(frame.locator('.cell.markdown table')).toBeVisible(); | ||
| }); | ||
|
|
||
| test('renders code cells with outputs', async ({page}) => { | ||
| await login(page); | ||
| await page.goto(`/${owner}/${repoName}/src/branch/main/test.ipynb`); | ||
| await assertNoJsError(page); | ||
| await expect(page.frameLocator('iframe.external-render-iframe').locator('.cell.code .output pre').first()).toBeVisible(); | ||
| }); | ||
|
|
||
| test('renders image outputs', async ({page}) => { | ||
| await login(page); | ||
| await page.goto(`/${owner}/${repoName}/src/branch/main/test.ipynb`); | ||
| await assertNoJsError(page); | ||
| await expect(page.frameLocator('iframe.external-render-iframe').locator('.cell.code .output img')).toBeVisible(); | ||
| }); | ||
|
|
||
| test('renders error outputs', async ({page}) => { | ||
| await login(page); | ||
| await page.goto(`/${owner}/${repoName}/src/branch/main/test.ipynb`); | ||
| await assertNoJsError(page); | ||
| await expect(page.frameLocator('iframe.external-render-iframe').locator('.error-output')).toBeVisible(); | ||
| }); | ||
| }); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,192 @@ | ||
| /* Gitea styles for Jupyter notebook content */ | ||
| .jupyter-notebook { | ||
| padding: 20px; | ||
| background: var(--color-body); | ||
| color: var(--color-text); | ||
| font-family: inherit; | ||
| } | ||
|
|
||
| /* Cell containers */ | ||
| .jupyter-notebook .cell { | ||
| margin-bottom: 20px; | ||
| } | ||
|
|
||
| /* Markdown cells */ | ||
| .jupyter-notebook .cell.markdown { | ||
| background: var(--color-body); | ||
| border: none; | ||
| } | ||
|
|
||
| .jupyter-notebook .cell.markdown .input { | ||
| padding: 6px 12px; | ||
| line-height: 1.6; | ||
| background: var(--color-body); | ||
| color: var(--color-text); | ||
| margin-left: 110px; | ||
| } | ||
|
|
||
| .jupyter-notebook .cell.markdown h1, | ||
| .jupyter-notebook .cell.markdown h2, | ||
| .jupyter-notebook .cell.markdown h3 { | ||
| margin-top: 24px; | ||
| margin-bottom: 16px; | ||
| font-weight: var(--font-weight-semibold); | ||
| line-height: 1.25; | ||
| color: var(--color-text); | ||
| } | ||
|
|
||
| .jupyter-notebook .cell.markdown h1 { | ||
| font-size: 1.875em; | ||
| border-bottom: 1px solid var(--color-secondary-alpha-20); | ||
| padding-bottom: 0.3em; | ||
| } | ||
|
|
||
| .jupyter-notebook .cell.markdown h2 { | ||
| font-size: 1.5em; | ||
| } | ||
|
|
||
| .jupyter-notebook .cell.markdown h3 { | ||
| font-size: 1.25em; | ||
| } | ||
|
|
||
| .jupyter-notebook .cell.markdown p { | ||
| margin-top: 0; | ||
| margin-bottom: 16px; | ||
| } | ||
|
|
||
| .jupyter-notebook .cell.markdown code { | ||
| padding: 0.2em 0.4em; | ||
| margin: 0; | ||
| font-size: 85%; | ||
| background-color: var(--color-secondary-alpha-20); | ||
| border-radius: 3px; | ||
| font-family: var(--fonts-monospace); | ||
| } | ||
|
|
||
| .jupyter-notebook .cell.markdown table { | ||
| border-collapse: collapse; | ||
| width: 100%; | ||
| margin: 16px 0; | ||
| font-size: 13px; | ||
| } | ||
|
|
||
| .jupyter-notebook .cell.markdown table th, | ||
| .jupyter-notebook .cell.markdown table td { | ||
| border: 1px solid var(--color-secondary); | ||
| padding: 6px 13px; | ||
| text-align: left; | ||
| } | ||
|
|
||
| .jupyter-notebook .cell.markdown table th { | ||
| background: var(--color-secondary-alpha-20); | ||
| font-weight: var(--font-weight-semibold); | ||
| } | ||
|
|
||
| .jupyter-notebook .cell.markdown table tr:nth-child(even) { | ||
| background: var(--color-secondary-alpha-10); | ||
| } | ||
|
|
||
| /* Code cells */ | ||
| .jupyter-notebook .cell.code { | ||
| background: transparent; | ||
| border: none; | ||
| } | ||
|
|
||
| .jupyter-notebook .cell.code .input-wrapper, | ||
| .jupyter-notebook .cell.code .output-wrapper { | ||
| display: flex; | ||
| align-items: flex-start; | ||
| } | ||
|
|
||
| .jupyter-notebook .cell.code .prompt { | ||
| padding: 10px 10px 10px 0; | ||
| color: var(--color-text-light-2); | ||
| font-family: var(--fonts-monospace); | ||
| font-size: 13px; | ||
| white-space: nowrap; | ||
| user-select: none; | ||
| text-align: right; | ||
| width: 100px; | ||
| flex-shrink: 0; | ||
| } | ||
|
|
||
| .jupyter-notebook .cell.code .input { | ||
| flex: 1; | ||
| background-color: var(--color-code-bg, #f6f8fa); | ||
| border: 1px solid var(--color-secondary-alpha-20, #d0d7de); | ||
| border-radius: 4px; | ||
| min-height: 40px; | ||
| } | ||
|
|
||
| .jupyter-notebook .cell.code .input pre { | ||
| margin: 0; | ||
| padding: 10px 16px; | ||
| font-family: var(--fonts-monospace, monospace); | ||
| font-size: 13px; | ||
| line-height: 1.5; | ||
| overflow-x: auto; | ||
| color: var(--color-text); | ||
| background: transparent; | ||
| } | ||
|
|
||
| .jupyter-notebook .cell.code .input code { | ||
| display: block; | ||
| font-family: inherit; | ||
| } | ||
|
|
||
| /* Code outputs */ | ||
| .jupyter-notebook .cell.code .output { | ||
| flex: 1; | ||
| background: var(--color-body); | ||
| color: var(--color-text); | ||
| overflow-x: auto; | ||
| min-width: 0; | ||
| } | ||
|
|
||
| .jupyter-notebook .cell.code .output pre { | ||
| margin: 0; | ||
| padding: 10px 16px; | ||
| font-family: var(--fonts-monospace); | ||
| font-size: 13px; | ||
| line-height: 1.5; | ||
| overflow-x: auto; | ||
| color: var(--color-text); | ||
| background: var(--color-body); | ||
| white-space: pre-wrap; | ||
| overflow-wrap: break-word; | ||
| } | ||
|
|
||
| .jupyter-notebook .cell.code .output table { | ||
| border-collapse: collapse; | ||
| margin: 10px 16px; | ||
| font-size: 13px; | ||
| max-width: 100%; | ||
| } | ||
|
|
||
| .jupyter-notebook .cell.code .output table th, | ||
| .jupyter-notebook .cell.code .output table td { | ||
| border: 1px solid var(--color-secondary); | ||
| padding: 6px 13px; | ||
| text-align: left; | ||
| } | ||
|
|
||
| .jupyter-notebook .cell.code .output table th { | ||
| background: var(--color-secondary-alpha-20); | ||
| font-weight: var(--font-weight-semibold); | ||
| } | ||
|
|
||
| .jupyter-notebook .cell.code .output table tr:nth-child(even) { | ||
| background: var(--color-secondary-alpha-10); | ||
| } | ||
|
|
||
| .jupyter-notebook .cell.code .output img { | ||
| max-width: 90%; | ||
| height: auto; | ||
| display: block; | ||
| margin: 10px 0; | ||
| } | ||
|
|
||
| .jupyter-notebook .cell.code .output table img { | ||
| margin: 0; | ||
| width: auto; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.