-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathprocess-docs.sh
executable file
·57 lines (48 loc) · 1.66 KB
/
process-docs.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/bin/bash
# created by sivagao in 9/9/2017
set -e
replace_dist_html_link() {
local doc_tmp_path=$1
local repo_name=$2
if [ -d "$doc_tmp_path" ];then
for html in "$doc_tmp_path"/*
do
echo "$html"
# [ "$html" = "." -o "$html" = ".." ] && continue
if [ -d "$html" ];then
echo "process sub dir: " $html
replace_dist_html_link "$html" $repo_name
fi
if [[ ! -d "$html" ]] && echo "$html" | grep -E '\.html$' > /dev/null;then
# using double quote to variable, using [\"] to
sed -i -r 's;<img\s*src="([\.\/]*)media/(.*)"\s*(alt=".*?")?\s*/?>;<img src="/images/'"$repo_name"'/\2" \3 />;g' $html
# cat _tmp_out1 > $doc_tmp_path/$html
fi
done
fi
}
cn_tmp_docs_path="dist/docs-cn"
en_tmp_docs_path="dist/docs"
replace_dist_html_link "$cn_tmp_docs_path" docs-cn
replace_dist_html_link "$en_tmp_docs_path" docs
cn_tmp_blogs_path="dist/blog-cn"
en_tmp_blogs_path="dist/blog"
replace_dist_html_link "$cn_tmp_blogs_path" blog-cn
replace_dist_html_link "$en_tmp_blogs_path" blog
replace_dist_html_link "dist/meetup" meetup
replace_dist_html_link "dist/weekly" weekly
parent_dir="`echo $(pwd) | sed 's;/scripts;;g'`/dist"
copy_images_from_media_to_src() {
repo_name=$1
media_path=$(echo $parent_dir/$repo_name/media)
echo $media_path
echo $parent_dir/images/$repo_name
[ -d $media_path ] && mv $media_path $parent_dir/images/$repo_name # cp -R
}
# mv all content in media to src/images
copy_images_from_media_to_src docs
copy_images_from_media_to_src docs-cn
copy_images_from_media_to_src blog-cn
copy_images_from_media_to_src blog
copy_images_from_media_to_src weekly
copy_images_from_media_to_src meetup