Skip to content

Commit fa1e248

Browse files
Merge pull request #38656 from vikram-redhat/pdf
Added icons and pdf
2 parents 8d76680 + dd1dd30 commit fa1e248

File tree

1 file changed

+30
-9
lines changed

1 file changed

+30
-9
lines changed

_templates/_page_openshift.html.erb

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,27 @@
2424
<meta content="#000000" name="msapplication-TileColor">
2525
<meta content="https://assets.openshift.net/content/subdomain/touch-icon-precomposed.png" name="msapplication-TileImage">
2626
<%= render("_templates/_analytics.html.erb", :distro_key => distro_key) %>
27+
<script src="https://cdnjs.cloudflare.com/ajax/libs/html2pdf.js/0.9.3/html2pdf.bundle.min.js"></script>
28+
29+
<link href="https://fonts.googleapis.com/icon?family=Material+Icons+Outlined"
30+
rel="stylesheet">
31+
<script>
32+
33+
function getPDF() {
34+
var element = document.getElementsByClassName('main');
35+
<%
36+
filepath = repo_path[0...-5]
37+
%>
38+
var opt = {
39+
margin: 10,
40+
filename: '<%= "#{filepath}.pdf" %>',
41+
html2canvas: { windowWidth: 650 },
42+
image: { type: 'jpeg', quality: 0.98 }
43+
};
44+
html2pdf().set(opt).from(element[0]).save();
45+
}
46+
</script>
47+
2748
</head>
2849

2950
<body onload="selectVersion('<%= version %>');">
@@ -102,14 +123,14 @@
102123
</li>
103124
<% if (distro_key != "openshift-origin" && distro_key != "openshift-aro") %>
104125
<span text-align="right" style="float: right !important">
105-
<a href="https://github.com/openshift/openshift-docs/commits/<%= (distro_key == "openshift-enterprise") ? "enterprise-#{version}" : "dedicated-4" %>/<%= repo_path %>">Page history</a>
126+
<a href="https://github.com/openshift/openshift-docs/commits/<%= (distro_key == "openshift-enterprise") ? "enterprise-#{version}" : "dedicated-4" %>/<%= repo_path %>"><span class="material-icons-outlined">history</span></a>
106127
<%
107128
unless (unsupported_versions.include? version)
108129
%>
109-
/
110130
<a href="https://github.com/openshift/openshift-docs/issues/new?title=<%= (distro_key == "openshift-enterprise") ? "[enterprise-#{version}] Issue in file #{repo_path}" : ((distro_key=="openshift-dedicated" ) ? "[dedicated] Issue in file #{repo_path}" : "[online] Issue in file #{repo_path}" ) %>">
111-
Open an issue
131+
<span class="material-icons-outlined">bug_report</span>
112132
</a>
133+
<a href="javascript: void(0);" onclick="getPDF();"><span class="material-icons-outlined">picture_as_pdf</span></a>
113134
<% if (version == "4.5") %>
114135
/
115136
<select onchange="selectLang(this);">
@@ -341,7 +362,7 @@
341362
<script type="text/javascript">
342363
window.addEventListener('DOMContentLoaded', () => {
343364
window.addEventListener("wheel", () => {
344-
365+
345366
const ioConfiguration = {
346367
"rootMargin": "-120px 0px -400px 0px",
347368
"threshold": 0
@@ -370,7 +391,7 @@
370391
document.querySelector(`#toc li a[href="#${i.target.id}"]`).classList.add('toc-active')
371392
}
372393
})
373-
}
394+
}
374395
};
375396

376397
//make clicked toc item active and stop IntersectionObserver
@@ -435,7 +456,7 @@
435456
};
436457
};
437458
if(document.documentElement.scrollHeight != window.pageYOffset + window.innerHeight) {
438-
sidebar.style.marginBottom = "0px";
459+
sidebar.style.marginBottom = "0px";
439460
toc.style.bottom = "0px";
440461
}
441462
}
@@ -454,8 +475,8 @@
454475
document.querySelector('#support-alert').style.position = "fixed";
455476
document.querySelector('#support-alert').style.bottom = "0px";
456477
document.querySelector('#support-alert').style.margin = "5px";
457-
document.querySelector('#support-alert').style.zIndex = "9999999";
458-
}
478+
document.querySelector('#support-alert').style.zIndex = "9999999";
479+
}
459480
}
460481
}
461482
});
@@ -465,7 +486,7 @@
465486
document.querySelector('#support-alert').style.removeProperty('position');
466487
document.querySelector('#support-alert').style.removeProperty('bottom');
467488
document.querySelector('#support-alert').style.removeProperty('margin');
468-
document.querySelector('#support-alert').style.removeProperty('zIndex');
489+
document.querySelector('#support-alert').style.removeProperty('zIndex');
469490
}
470491
}
471492
})

0 commit comments

Comments
 (0)