Skip to content
Snippets Groups Projects
Commit 0a1fc8b2 authored by Christian Boulanger's avatar Christian Boulanger
Browse files

Fix

parent 0f4df798
No related branches found
No related tags found
No related merge requests found
Pipeline #517188 passed
%% 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
![](https://pad.gwdg.de/uploads/b3dce952-95c4-4143-a09e-a32cddb5168e.png) ![](https://pad.gwdg.de/uploads/b3dce952-95c4-4143-a09e-a32cddb5168e.png)
%% 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/2b6965db-ffb9-4e9f-b893-3c76a6b522ab.png --> http://localhost:3000/uploads/2e0afcc6-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'
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment