Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
CodiMD export script
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
stgroup
misc
CodiMD export script
Compare revisions
18127bebb27c6feefdeb919f0d904d1fcebd91b3 to 49102d4bc5f5a22132fee1d5f8f934b61b4d6488
Compare revisions
Changes are shown as if the
source
revision was being merged into the
target
revision.
Learn more about comparing revisions.
Source
stgroup/misc/codimd-export-script
Select target project
No results found
49102d4bc5f5a22132fee1d5f8f934b61b4d6488
Select Git revision
Loading items
Swap
Target
stgroup/misc/codimd-export-script
Select target project
stgroup/misc/codimd-export-script
1 result
18127bebb27c6feefdeb919f0d904d1fcebd91b3
Select Git revision
Loading items
Show changes
Only incoming changes from source
Include changes to target since source was created
Compare
Commits on Source
3
Add instructions in stdout
· 127c4906
Andreas Domanowski
authored
Mar 1, 2023
127c4906
Add check whether archive file exists
· 1f7b6fe2
Andreas Domanowski
authored
Mar 1, 2023
1f7b6fe2
Adapt script to our instances
· 49102d4b
Andreas Domanowski
authored
Mar 1, 2023
49102d4b
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
codimd_export.py
+2
-1
2 additions, 1 deletion
codimd_export.py
common.py
+10
-2
10 additions, 2 deletions
common.py
hedgedoc_import.py
+9
-0
9 additions, 0 deletions
hedgedoc_import.py
md-import-export.py
+4
-2
4 additions, 2 deletions
md-import-export.py
with
25 additions
and
5 deletions
codimd_export.py
View file @
49102d4b
...
...
@@ -24,7 +24,8 @@ def prepare_target_dir(pathname):
"""
Create the directory to dump documents to, but refuse to override an existing one.
"""
target_dir
=
Path
(
pathname
)
if
target_dir
.
exists
():
raise
SystemExit
(
f
"
error: the target directory
{
target_dir
}
already exists
"
)
raise
SystemExit
(
f
"
ERROR: the target directory
{
target_dir
}
already exists. Delete it, then re-execute this
"
f
"
script
"
)
target_dir
.
mkdir
()
return
target_dir
...
...
This diff is collapsed.
Click to expand it.
common.py
View file @
49102d4b
...
...
@@ -7,9 +7,17 @@ else:
getpass
=
input
def
get_sessionid
(
cookie_key
):
def
get_sessionid
(
service_name
,
cookie_key
):
"""
Ask the user for the session id, if it
'
s not configured as an envvar.
"""
sid
=
getpass
(
f
"
Please provide your CodiMD session id (
{
cookie_key
}
cookie):
"
)
print
(
f
"
You now will be asked for your session cookie for
{
service_name
}
"
)
print
(
f
"
To extract this cookie, you need to open your browser with an active and logged-in
{
service_name
}
session
"
)
print
(
f
"
In Firefox or Chrome, you can do this by following the following steps:
"
)
print
(
f
"
\t
1. Open the developer tools (Shortcut: F12
"
)
print
(
f
"
\t
2. Select
\"
Storage -> Cookies
\"
(Firefox) or
\"
Application -> Cookies
\"
"
)
print
(
f
"
\t
3. Copy the value for the cookie named
{
cookie_key
}
"
)
print
(
f
"
\t
4. Input it in the prompt
"
)
sid
=
getpass
(
f
"
Please provide your
{
service_name
}
session id (
{
cookie_key
}
cookie):
"
)
if
sid
.
startswith
(
"
s%3A
"
):
return
sid
raise
SystemExit
(
f
"
error: the supplied session id seems to be malformed
"
)
This diff is collapsed.
Click to expand it.
hedgedoc_import.py
View file @
49102d4b
...
...
@@ -33,7 +33,16 @@ def import_single_document(instance_url, hedgedoc_free_url, content, session_id)
return
response
.
url
def
check_archive_exists
(
archive_file
):
if
not
os
.
path
.
exists
(
archive_file
):
raise
SystemExit
(
f
"
ERROR: File
{
archive_file
}
does not exist. Export your data from CodiMD and re-execute this script again!
"
f
"
Aborting...
"
)
def
import_into_hedgedoc
(
instance_url
,
session_id
,
export_folder
,
archive_file
):
print
(
"
Beginning import
"
)
check_archive_exists
(
archive_file
)
check_accessibility
(
instance_url
,
session_id
)
# let user select browser
browser
=
select_browser
()
...
...
This diff is collapsed.
Click to expand it.
md-import-export.py
View file @
49102d4b
...
...
@@ -4,5 +4,7 @@ from hedgedoc_import import import_into_hedgedoc
if
__name__
==
"
__main__
"
:
export_folder
=
"
codimd-documents
"
export_from_codimd
(
"
http://localhost:3001
"
,
get_sessionid
(
"
connect.sid
"
),
export_folder
)
import_into_hedgedoc
(
"
http://hedgedoc:3000
"
,
get_sessionid
(
"
connect.hedgeDoc.sid
"
),
export_folder
,
"
archive.zip
"
)
export_archive
=
"
archive.zip
"
export_from_codimd
(
"
https://md.inf.tu-dresden.de/
"
,
get_sessionid
(
"
CodiMD
"
,
"
connect.sid
"
),
export_folder
)
import_into_hedgedoc
(
"
https://md.inf.tu-dresden.de/notes
"
,
get_sessionid
(
"
HedgeDoc
"
,
"
connect.hedgeDoc.sid
"
),
export_folder
,
export_archive
)
This diff is collapsed.
Click to expand it.