@@ -21,11 +21,13 @@ function _change_to_repo_dir {
21
21
}
22
22
23
23
24
- function _recreate_docs_dir {
24
+ function _wipe_and_recreate_docs_dir {
25
+ printf " \e[1m\e[7m %-80s\e[0m\n" ' Wipe and recreate docs/ directory'
25
26
rm -rf docs/*
26
27
cp -a temp_download/* docs/
27
28
touch docs/.nojekyll
28
29
printf ' dev-stateof.creativecommons.org' > docs/CNAME
30
+ echo
29
31
}
30
32
31
33
@@ -92,6 +94,19 @@ function _update_licensebuttons_domain {
92
94
}
93
95
94
96
97
+ function _fix_social_media_links {
98
+ printf " \e[1m\e[7m %-80s\e[0m\n" ' Fix 2017 Social Media links'
99
+ for _file in $( find docs -maxdepth 1 -type f -name ' *.html' )
100
+ do
101
+ ${SED} --regexp-extended \
102
+ -e' s#^(<a.*elementor-social-icon-facebook" href=")[^"]+(" target="_blank">)#\1https://www.facebook.com/creativecommons\2#g' \
103
+ -e' s#^(<a.*elementor-social-icon-twitter" href=")[^"]+(" target="_blank">)#\1https://twitter.com/creativecommons\2#g' \
104
+ --in-place " ${_file} "
105
+ done
106
+ echo
107
+ }
108
+
109
+
95
110
function _replace_full_urls_with_absolute_paths {
96
111
printf " \e[1m\e[7m %-80s\e[0m\n" ' Replace full URLs with absolute paths'
97
112
# Non-escaped URLs with protocol
@@ -102,22 +117,23 @@ function _replace_full_urls_with_absolute_paths {
102
117
for _file in $( grep --files-with-matches --max-count=1 \
103
118
--recursive " ${_pattern} " docs)
104
119
do
105
- ${SED} --in-place - e" s#${_pattern} #/#g" " ${_file} "
120
+ ${SED} -e" s#${_pattern} #/#g" --in-place " ${_file} "
106
121
done
107
122
done
108
123
# Non-escaped URLs without protocol
109
124
_pattern=' //stateof\.creativecommons\.org/'
110
125
for _file in $( grep --files-with-matches --max-count=1 \
111
126
--recursive " ${_pattern} " docs)
112
127
do
113
- ${SED} --in-place - e" s#${_pattern} #/#g" " ${_file} "
128
+ ${SED} -e" s#${_pattern} #/#g" --in-place " ${_file} "
114
129
done
115
130
# Escaped URL
116
131
for _file in $( grep --fixed-strings --files-with-matches --max-count=1 \
117
132
--recursive ' https:\/\/stateof.creativecommons.org\/' docs)
118
133
do
119
- ${SED} --in-place \
120
- -e' s#https:\\/\\/stateof\.creativecommons\.org\\/#\\/#g' " ${_file} "
134
+ ${SED} \
135
+ -e' s#https:\\/\\/stateof\.creativecommons\.org\\/#\\/#g' \
136
+ --in-place " ${_file} "
121
137
done
122
138
echo
123
139
}
@@ -155,7 +171,7 @@ function _cleanup_plaintext_whitespace {
155
171
for _file in $( find docs -type f \
156
172
\( -name ' *.css' -o -name ' *.html' -o -name ' *.js' \) )
157
173
do
158
- ${SED} --in-place - e' s#[ \t]\+$##' " ${_file} "
174
+ ${SED} -e' s#[ \t]\+$##' --in-place " ${_file} "
159
175
done
160
176
echo
161
177
}
@@ -168,10 +184,11 @@ function _cleanup_orig_file_backups {
168
184
169
185
170
186
_change_to_repo_dir # must be called first
171
- _recreate_docs_dir
187
+ _wipe_and_recreate_docs_dir
172
188
_remove_lines_from_html_files
173
189
_restore_query_strings_in_html_files
174
190
_update_licensebuttons_domain
191
+ _fix_social_media_links
175
192
_replace_full_urls_with_absolute_paths
176
193
_revert_non_html_conversions
177
194
_cleanup_plaintext_whitespace
0 commit comments