Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
blog.funkwhale.audio
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
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
funkwhale
blog.funkwhale.audio
Merge requests
!39
Add a script to import pads into a blogpost
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Add a script to import pads into a blogpost
import-script
into
main
Overview
0
Commits
2
Pipelines
3
Changes
1
Merged
Georg Krause
requested to merge
import-script
into
main
2 years ago
Overview
0
Commits
2
Pipelines
3
Changes
1
Expand
0
0
Merge request reports
Compare
main
version 2
2474b2a7
2 years ago
version 1
89e8b207
2 years ago
main (base)
and
latest version
latest version
50df32af
2 commits,
2 years ago
version 2
2474b2a7
2 commits,
2 years ago
version 1
89e8b207
1 commit,
2 years ago
1 file
+
58
−
0
Side-by-side
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
pad2post.sh
0 → 100755
+
58
−
0
Options
#!/bin/sh
if
[
-z
${
1
+x
}
]
;
then
echo
"Please provide a pad link!"
;
exit
1
;
fi
url
=
"
$(
echo
$1
|
cut
-d
?
-f1
)
"
echo
$url
# Check that file doesn't exist before progressing
while
[[
!
$meta_filename
||
$meta_filename
==
""
]]
do
read
-p
"Filename: "
meta_filename
meta_filename
=
$(
echo
"
${
meta_filename
##*( )
}
"
)
# Trim
meta_filename
=
$(
echo
"
$meta_filename
"
|
cut
-d
.
-f1
)
meta_filename
=
$(
echo
"
$meta_filename
"
|
tr
" "
_
)
filename_ext
=
"
$meta_filename
.md"
if
[
-f
"content/
$filename_ext
"
]
;
then
echo
"File already exists. Please choose another filename."
meta_filename
=
""
else
break
fi
done
meta_date
=
$(
date
+%Y-%m-%d
)
read
-p
"Author: "
meta_author
PS3
=
"Category: "
options
=(
"Announcement"
"Release"
"Community"
)
select
opt
in
"
${
options
[@]
}
"
do
if
[
$opt
]
then
meta_category
=
$opt
break
else
echo
"Please select a valid category"
fi
done
read
-p
"Summary: "
meta_summary
echo
$meta_filename
echo
$meta_date
echo
$meta_author
echo
$meta_category
echo
$meta_summary
echo
"Title:
$(
curl
$url
/download |
head
-n
1
)
"
>>
content/
$filename_ext
echo
"Date:
$meta_date
"
>>
content/
$filename_ext
echo
"Authors:
$meta_author
"
>>
content/
$filename_ext
echo
"Category:
$meta_category
"
>>
content/
$filename_ext
echo
"Slug:
$meta_filename
"
>>
content/
$filename_ext
echo
"Summary:
$meta_summary
"
>>
content/
$filename_ext
# Populate the body with everything that comes after the header
curl
"
$url
/download"
|
#Download the content
sed
-n
'/===/,$p'
|
#Find the header break "===" and take everything after this line. "," = range, "$p" = all lines
tail
-n
+2
>>
content/
$filename_ext
#Print all lines starting at line 2 (after the ===) to the file
Loading