Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Prod #3812

Merged
merged 11 commits into from
Jul 24, 2024
30 changes: 25 additions & 5 deletions scripts/build/javadoc_modify.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,28 @@ modifyStylesheetFrameless () {
mv newstylesheet.css "$1"
}

modifyStylesheetFramelessSPIAPI () {
# Append extra javadoc styling located in the css direcctory to the stylesheet.css located in the javadoc api/spi subdirectories
cat src/main/content/antora_ui/src/css/javadoc-extended-stylesheet-frameless-api_spi.css >> "$1"

# insert extra import to the beginning of the file
sed '1 i\
@import url("https://fonts.googleapis.com/css?family=Asap:300,400,500");
' "$1" > newstylesheet.css

mv newstylesheet.css "$1"
}

modifySearch () {
# add url support to search
cp src/main/content/_assets/js/javadoc-search.js "$1"
}

modifyFramelessSearch () {
# add url support to frameless javadoc search
cp src/main/content/_assets/js/javadoc-search-frameless.js "$1"
}

modifyRedirect () {
a=$1
cp src/main/content/_assets/js/javadoc-redirect.js "${a/script.js/redirect.js}"
Expand All @@ -38,14 +55,17 @@ modifyRedirect () {

export -f modifyStylesheet
export -f modifyStylesheetFrameless
export -f modifyStylesheetFramelessSPIAPI
export -f modifySearch
export -f modifyFramelessSearch
export -f modifyRedirect

find target/jekyll-webapp/docs -path "*microprofile*/stylesheet.css" -exec bash -c 'modifyStylesheet {}' \;
find target/jekyll-webapp/docs -path "*liberty-*/stylesheet.css" -exec bash -c 'modifyStylesheet {}' \;
find target/jekyll-webapp/docs -path "*io.openliberty*/stylesheet.css" -exec bash -c 'modifyStylesheetFrameless {}' \;
find target/jekyll-webapp/docs -path "*com.ibm.websphere.appserver*/stylesheet.css" -exec bash -c 'modifyStylesheetFrameless {}' \;
find target/jekyll-webapp/docs -name search.js -exec bash -c 'modifySearch {}' \;
find target/jekyll-webapp/docs -path "*liberty-*/stylesheet.css" -exec bash -c 'modifyStylesheetFrameless {}' \;
find target/jekyll-webapp/docs -path "*microprofile*/stylesheet.css" -exec bash -c 'modifyStylesheetFrameless {}' \;
find target/jekyll-webapp/docs -path "*io.openliberty*/stylesheet.css" -exec bash -c 'modifyStylesheetFramelessSPIAPI {}' \;
find target/jekyll-webapp/docs -path "*com.ibm.websphere.appserver*/stylesheet.css" -exec bash -c 'modifyStylesheetFramelessSPIAPI {}' \;
find target/jekyll-webapp/docs -path "*microprofile*" -name search.js -exec bash -c 'modifyFramelessSearch {}' \;
find target/jekyll-webapp/docs -path "*liberty-*" -name search.js -exec bash -c 'modifyFramelessSearch {}' \;
find target/jekyll-webapp/docs -name script.js -exec bash -c 'modifyRedirect {}' \;

timer_end=$(date +%s)
Expand Down
66 changes: 48 additions & 18 deletions src/main/content/_assets/js/javadoc-redirect.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,20 @@ $(function () {
window.top.location.href.includes('/docs/modules/reference/microprofile-')
) {
var jd = window.top.location.href;
var version = jd.substring(
jd.indexOf('microprofile-') + 13,
jd.indexOf('microprofile-') + 16
);
jd = jd.substring(jd.indexOf('microprofile-') + 25);
var ver_start_index= jd.indexOf('microprofile-') + 13;
var ver_string = jd.substring(ver_start_index); // To obtain the last index of version
var ver_end_index = ver_string.indexOf('-');
if(ver_end_index !== -1 ){
var version = ver_string.substring(
0,
ver_end_index
);
var add_index = version.length - 3;
jd = jd.substring(jd.indexOf('microprofile-') + add_index + 25);
}
else{
version = null;
}
javadocRedirect('microprofile-',version,jd);
} else if (
window.top.location.href.includes('/docs/modules/reference/liberty-javaee')
Expand All @@ -23,11 +32,20 @@ $(function () {
window.top.location.href.includes('/docs/modules/reference/liberty-jakartaee')
) {
var jd = window.top.location.href;
var version = jd.substring(
jd.indexOf('liberty-jakartaee') + 17,
jd.indexOf('liberty-jakartaee') + 20
);
jd = jd.substring(jd.indexOf('liberty-jakartaee') + 29);
var ver_start_index= jd.indexOf('liberty-jakartaee') + 17;
var ver_string = jd.substring(ver_start_index); // To obtain the last index of version
var ver_end_index = ver_string.indexOf('-');
if(ver_end_index !== -1 ){
var version = ver_string.substring(
0,
ver_end_index
);
var add_index = version.length - 3;
jd = jd.substring(jd.indexOf('liberty-jakartaee') + add_index + 29);
}
else{
version = null;
}
javadocRedirect('liberty-jakartaee',version,jd);
}
});
Expand All @@ -38,13 +56,25 @@ function javadocRedirect(api,version,jd) {
}
var pack = jd.substring(0, jd.lastIndexOf('/'));
var port = window.top.location.port !== '' ? ':' + window.top.location.port : '';
window.top.location.href =
'https://' +
window.top.location.hostname +
port +
'/docs/latest/reference/javadoc/'+ api +
version +
(pack ? '-javadoc.html?package='+pack+'/package-frame.html&class=': '-javadoc.html?class=') +
jd;
var mainFrame = $('#javadoc_container');
var isFrameless = mainFrame.contents().find('iframe').length === 0;
if(isFrameless){
window.top.location.href =
'https://' +
window.top.location.hostname +
port +
'/docs/latest/reference/javadoc/'+ api +
version + (pack ? '-javadoc.html?path='+api+version+'-javadoc/'+jd: '-javadoc.html');
}
else{
window.top.location.href =
'https://' +
window.top.location.hostname +
port +
'/docs/latest/reference/javadoc/'+ api +
version +
(pack ? '-javadoc.html?package='+pack+'/package-frame.html&class=': '-javadoc.html?class=') +
jd;
}
}

Loading
Loading