Skip to content

Commit 00fcbed

Browse files
Adds 'copy code' functionality to include code module
1 parent ef891ef commit 00fcbed

File tree

6 files changed

+978
-3
lines changed

6 files changed

+978
-3
lines changed

_includes/code.html

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
{% capture samplecode %}{% include_relative {{include.file}} %}{% endcapture %}
2-
{% if include.k8slink %}{% capture ghlink %}https://github.com/kubernetes/kubernetes/blob/{{page.githubbranch}}{{include.k8slink}}{% endcapture %}{% endif %}
3-
{% if include.ghlink %}{% capture ghlink %}https://github.com/kubernetes/kubernetes.github.io/blob/master{{include.ghlink}}{% endcapture %}{% endif %}
2+
{% if include.k8slink %}{% capture ghlink %}https://raw.githubusercontent.com/kubernetes/kubernetes/blob/{{page.githubbranch}}{{include.k8slink}}{% endcapture %}{% endif %}
3+
{% if include.ghlink %}{% capture ghlink %}https://raw.githubusercontent.com/kubernetes/kubernetes.github.io/{{page.docsbranch}}{{include.ghlink}}{% endcapture %}{% endif %}
44
{% capture mysample %}
55
```{{include.language}}
66
{{ samplecode | raw | strip }}
77
```
8+
{: id="{{include.file | handleize}}"}
89
{% endcapture %}
9-
<table class="includecode"><thead><tr><th>{% if ghlink %}<a href="{{ghlink}}">{% endif %}<code>{{include.file}}</code></a></th></tr></thead>
10+
<table class="includecode"><thead><tr><th>{% if ghlink %}<a href="{{ghlink}}" download="{{include.file}}">{% endif %}<code>{{include.file}}</code></a><img src="/images/copycode.svg" style="max-height:24px" onClick="copyCode('{{include.file | handleize}}')" title="Copy {{include.file}} to clipboard"></th></tr></thead>
1011
<tr><td>{{ mysample | markdownify }}</td></tr></table>

_includes/head-header.html

+2
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@
77
<link rel="stylesheet" href='https://fonts.googleapis.com/css?family=Roboto+Mono' type='text/css'>
88
<link rel="stylesheet" href="/css/styles.css"/>
99
<link rel="stylesheet" href="/css/jquery-ui.min.css">
10+
<link rel="stylesheet" href="/css/sweetalert.css">
1011
<script src="/js/jquery-2.2.0.min.js"></script>
1112
<script src="/js/jquery-ui.min.js"></script>
1213
<script src="/js/script.js"></script>
14+
<script src="/js/sweetalert.min.js"></script>
1315
<title>Kubernetes - {{ title }}</title>
1416
</head>
1517
<body>

0 commit comments

Comments
 (0)