Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
experiments
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Monitor
Service Desk
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Christian Boulanger
experiments
Commits
0a1fc8b2
Commit
0a1fc8b2
authored
6 months ago
by
Christian Boulanger
Browse files
Options
Downloads
Patches
Plain Diff
Fix
parent
0f4df798
No related branches found
No related tags found
No related merge requests found
Pipeline
#517188
passed
6 months ago
Stage: deploy
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
hedgedoc/hedgedoc-api.ipynb
+25
-4
25 additions, 4 deletions
hedgedoc/hedgedoc-api.ipynb
with
25 additions
and
4 deletions
hedgedoc/hedgedoc-api.ipynb
+
25
−
4
View file @
0a1fc8b2
...
@@ -89,7 +89,7 @@
...
@@ -89,7 +89,7 @@
},
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count": 1
7
,
"execution_count": 1
8
,
"metadata": {},
"metadata": {},
"outputs": [
"outputs": [
{
{
...
@@ -98,16 +98,16 @@
...
@@ -98,16 +98,16 @@
"text": [
"text": [
"Uploading images:\n",
"Uploading images:\n",
" - https://pad.gwdg.de/uploads/b3dce952-95c4-4143-a09e-a32cddb5168e.png\n",
" - https://pad.gwdg.de/uploads/b3dce952-95c4-4143-a09e-a32cddb5168e.png\n",
" --> http://localhost:3000/uploads/2
b6965db-ffb9-4e9f-b893-3c76a6b522ab
.png\n"
" --> http://localhost:3000/uploads/2
e0afcc6-6c17-49b7-9b0f-075340b76852
.png\n"
]
]
},
},
{
{
"data": {
"data": {
"text/plain": [
"text/plain": [
"'http://localhost:3000/
IWxjqEXJT5SyeQAgX-fEEw
'"
"'http://localhost:3000/
c6tyksPtRrus_iBdLFLX2A
'"
]
]
},
},
"execution_count": 1
7
,
"execution_count": 1
8
,
"metadata": {},
"metadata": {},
"output_type": "execute_result"
"output_type": "execute_result"
}
}
...
@@ -134,6 +134,27 @@
...
@@ -134,6 +134,27 @@
"# uplaod note with new image urls\n",
"# uplaod note with new image urls\n",
"client2.create_note(markdown) "
"client2.create_note(markdown) "
]
]
},
{
"cell_type": "code",
"execution_count": 20,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"'http://localhost:3000/la4abXOCTO2vTTRFwwIHIQ'"
]
},
"execution_count": 20,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# or using the dedicated API method\n",
"client2.import_note(client1, 'wOsgnXCdR9qxkNn1-RyV7g' )"
]
}
}
],
],
"metadata": {
"metadata": {
...
...
%% Cell type:code id: tags:
%% Cell type:code id: tags:
```
python
```
python
%
load_ext
autoreload
%
load_ext
autoreload
%
autoreload
2
%
autoreload
2
```
```
%% Output
%% Output
The autoreload extension is already loaded. To reload it, use:
The autoreload extension is already loaded. To reload it, use:
%reload_ext autoreload
%reload_ext autoreload
%% Cell type:code id: tags:
%% Cell type:code id: tags:
```
python
```
python
from
hedgedoc_api
import
HedgedocClient
from
hedgedoc_api
import
HedgedocClient
client
=
HedgedocClient
(
'
https://pad.gwdg.de
'
)
client
=
HedgedocClient
(
'
https://pad.gwdg.de
'
)
markdown
=
client
.
get_note_content
(
'
wOsgnXCdR9qxkNn1-RyV7g
'
)
markdown
=
client
.
get_note_content
(
'
wOsgnXCdR9qxkNn1-RyV7g
'
)
print
(
markdown
)
print
(
markdown
)
```
```
%% Output
%% Output
# Test
# Test
dies ist ein Test
dies ist ein Test


%% Cell type:code id: tags:
%% Cell type:code id: tags:
```
python
```
python
client2
=
HedgedocClient
(
'
http://localhost:3000
'
)
client2
=
HedgedocClient
(
'
http://localhost:3000
'
)
client2
.
create_note
(
markdown
)
client2
.
create_note
(
markdown
)
```
```
%% Output
%% Output
'http://localhost:3000/WRWm37-BSwSlbsvZv-44DA'
'http://localhost:3000/WRWm37-BSwSlbsvZv-44DA'
%% Cell type:code id: tags:
%% Cell type:code id: tags:
```
python
```
python
from
hedgedoc_api
import
HedgedocClient
,
find_image_urls
from
hedgedoc_api
import
HedgedocClient
,
find_image_urls
client
=
HedgedocClient
(
'
http://localhost:3000
'
)
client
=
HedgedocClient
(
'
http://localhost:3000
'
)
markdown
=
client
.
get_note_content
(
'
Wgn_PaviRj-g6CRnZChkSg
'
)
markdown
=
client
.
get_note_content
(
'
Wgn_PaviRj-g6CRnZChkSg
'
)
print
(
find_image_urls
(
markdown
))
print
(
find_image_urls
(
markdown
))
```
```
%% Output
%% Output
['http://localhost:3000/uploads/4d46ab65-797f-4fde-9329-3859a752d30c.png']
['http://localhost:3000/uploads/4d46ab65-797f-4fde-9329-3859a752d30c.png']
%% Cell type:code id: tags:
%% Cell type:code id: tags:
```
python
```
python
from
hedgedoc_api
import
HedgedocClient
,
find_image_urls
from
hedgedoc_api
import
HedgedocClient
,
find_image_urls
client1
=
HedgedocClient
(
'
https://pad.gwdg.de
'
)
client1
=
HedgedocClient
(
'
https://pad.gwdg.de
'
)
client2
=
HedgedocClient
(
'
http://localhost:3000
'
)
client2
=
HedgedocClient
(
'
http://localhost:3000
'
)
# get content and image urls
# get content and image urls
markdown
=
client1
.
get_note_content
(
'
wOsgnXCdR9qxkNn1-RyV7g
'
)
markdown
=
client1
.
get_note_content
(
'
wOsgnXCdR9qxkNn1-RyV7g
'
)
image_urls
=
find_image_urls
(
markdown
)
image_urls
=
find_image_urls
(
markdown
)
# copy images
# copy images
if
len
(
image_urls
):
if
len
(
image_urls
):
print
(
"
Uploading images:
"
)
print
(
"
Uploading images:
"
)
for
image_url
in
image_urls
:
for
image_url
in
image_urls
:
print
(
f
"
-
{
image_url
}
"
)
print
(
f
"
-
{
image_url
}
"
)
new_image_url
=
client2
.
upload_image_from_url
(
image_url
)
new_image_url
=
client2
.
upload_image_from_url
(
image_url
)
print
(
f
"
-->
{
new_image_url
}
"
)
print
(
f
"
-->
{
new_image_url
}
"
)
markdown
=
markdown
.
replace
(
image_url
,
new_image_url
)
markdown
=
markdown
.
replace
(
image_url
,
new_image_url
)
# uplaod note with new image urls
# uplaod note with new image urls
client2
.
create_note
(
markdown
)
client2
.
create_note
(
markdown
)
```
```
%% Output
%% Output
Uploading images:
Uploading images:
- https://pad.gwdg.de/uploads/b3dce952-95c4-4143-a09e-a32cddb5168e.png
- https://pad.gwdg.de/uploads/b3dce952-95c4-4143-a09e-a32cddb5168e.png
--> http://localhost:3000/uploads/2
b6965db-ffb9-4e9f-b893-3c76a6b522ab
.png
--> http://localhost:3000/uploads/2
e0afcc6-6c17-49b7-9b0f-075340b76852
.png
'http://localhost:3000/IWxjqEXJT5SyeQAgX-fEEw'
'http://localhost:3000/c6tyksPtRrus_iBdLFLX2A'
%% Cell type:code id: tags:
```
python
# or using the dedicated API method
client2
.
import_note
(
client1
,
'
wOsgnXCdR9qxkNn1-RyV7g
'
)
```
%% Output
'http://localhost:3000/la4abXOCTO2vTTRFwwIHIQ'
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment