Skip to content

Commit 81ed8f8

Browse files
committed
guion actions completado
1 parent 3268108 commit 81ed8f8

18 files changed

Lines changed: 838 additions & 1296 deletions

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
env:
1919
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
2020
steps:
21-
- uses: actions/checkout@v5
21+
- uses: actions/checkout@v6
2222
with:
2323
fetch-depth: 0
2424

docs/copy-to-clipboard.js

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
;(function () {
2+
'use strict'
3+
4+
var CMD_RX = /^\$ (\S[^\\\n]*(\\\n(?!\$ )[^\\\n]*)*)(?=\n|$)/gm
5+
var LINE_CONTINUATION_RX = /( ) *\\\n *|\\\n( ?) */g
6+
var TRAILING_SPACE_RX = / +$/gm
7+
8+
var config = (document.getElementById('site-script') || { dataset: {} }).dataset
9+
var uiRootPath = config.uiRootPath == null ? '.' : config.uiRootPath
10+
var svgAs = config.svgAs
11+
var supportsCopy = window.navigator.clipboard
12+
13+
;[].slice.call(document.querySelectorAll('.doc pre.highlight, .doc .literalblock pre')).forEach(function (pre) {
14+
var code, language, lang, copy, toast, toolbox
15+
if (pre.classList.contains('highlight')) {
16+
code = pre.querySelector('code')
17+
if ((language = code.dataset.lang) && language !== 'console') {
18+
;(lang = document.createElement('span')).className = 'source-lang'
19+
lang.appendChild(document.createTextNode(language))
20+
}
21+
} else if (pre.innerText.startsWith('$ ')) {
22+
var block = pre.parentNode.parentNode
23+
block.classList.remove('literalblock')
24+
block.classList.add('listingblock')
25+
pre.classList.add('highlightjs', 'highlight')
26+
;(code = document.createElement('code')).className = 'language-console hljs'
27+
code.dataset.lang = 'console'
28+
code.appendChild(pre.firstChild)
29+
pre.appendChild(code)
30+
} else {
31+
return
32+
}
33+
;(toolbox = document.createElement('div')).className = 'source-toolbox'
34+
if (lang) toolbox.appendChild(lang)
35+
if (supportsCopy) {
36+
;(copy = document.createElement('button')).className = 'copy-button'
37+
copy.setAttribute('title', 'Copy to clipboard')
38+
if (svgAs === 'svg') {
39+
var svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg')
40+
svg.setAttribute('class', 'copy-icon')
41+
var use = document.createElementNS('http://www.w3.org/2000/svg', 'use')
42+
use.setAttribute('href', uiRootPath + '/../images/octicons-16.svg#icon-clippy')
43+
svg.appendChild(use)
44+
copy.appendChild(svg)
45+
} else {
46+
var img = document.createElement('img')
47+
img.src = uiRootPath + '/../images/octicons-16.svg#view-clippy'
48+
img.alt = 'copy icon'
49+
img.className = 'copy-icon'
50+
copy.appendChild(img)
51+
}
52+
;(toast = document.createElement('span')).className = 'copy-toast'
53+
toast.appendChild(document.createTextNode('Copied!'))
54+
copy.appendChild(toast)
55+
toolbox.appendChild(copy)
56+
}
57+
pre.parentNode.appendChild(toolbox)
58+
if (copy) copy.addEventListener('click', writeToClipboard.bind(copy, code))
59+
})
60+
61+
function extractCommands (text) {
62+
var cmds = []
63+
var m
64+
while ((m = CMD_RX.exec(text))) cmds.push(m[1].replace(LINE_CONTINUATION_RX, '$1$2'))
65+
return cmds.join(' && ')
66+
}
67+
68+
function writeToClipboard (code) {
69+
var text = code.innerText.replace(TRAILING_SPACE_RX, '')
70+
if (code.dataset.lang === 'console' && text.startsWith('$ ')) text = extractCommands(text)
71+
window.navigator.clipboard.writeText(text).then(
72+
function () {
73+
this.classList.add('clicked')
74+
this.offsetHeight // eslint-disable-line no-unused-expressions
75+
this.classList.remove('clicked')
76+
}.bind(this),
77+
function () {}
78+
)
79+
}
80+
})()
81+

docs/docinfo-footer.html

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
<style>
2+
.doc .listingblock > .content {
3+
position: relative;
4+
}
5+
6+
.doc .listingblock code[data-lang]::before {
7+
content: none;
8+
}
9+
10+
.doc .source-toolbox {
11+
display: flex;
12+
position: absolute;
13+
visibility: hidden;
14+
top: 0.25rem;
15+
right: 0.5rem;
16+
color: #808080;
17+
white-space: nowrap;
18+
font-size: 0.85em;
19+
}
20+
21+
.doc .listingblock:hover .source-toolbox {
22+
visibility: visible;
23+
}
24+
25+
.doc .source-toolbox .source-lang {
26+
font-family: "Droid Sans Mono", "DejaVu Sans Mono", monospace;
27+
text-transform: uppercase;
28+
letter-spacing: 0.075em;
29+
}
30+
31+
.doc .source-toolbox > :not(:last-child)::after {
32+
content: "|";
33+
letter-spacing: 0;
34+
padding: 0 1ch;
35+
}
36+
37+
.doc .source-toolbox .copy-button {
38+
cursor: pointer;
39+
display: flex;
40+
flex-direction: column;
41+
align-items: center;
42+
background: none;
43+
border: none;
44+
color: inherit;
45+
outline: none;
46+
padding: 0;
47+
font-family: inherit;
48+
font-size: inherit;
49+
line-height: inherit;
50+
width: 1em;
51+
height: 1em;
52+
}
53+
54+
.doc .source-toolbox .copy-icon {
55+
flex: none;
56+
width: inherit;
57+
height: inherit;
58+
filter: invert(50.2%);
59+
margin-top: 0.05em;
60+
}
61+
62+
.doc .source-toolbox .copy-toast {
63+
flex: none;
64+
position: relative;
65+
display: inline-flex;
66+
justify-content: center;
67+
margin-top: 1em;
68+
border-radius: 0.25em;
69+
padding: 0.5em;
70+
cursor: auto;
71+
opacity: 0;
72+
transition: opacity 0.5s ease 0.75s;
73+
background: rgba(0, 0, 0, 0.8);
74+
color: #fff;
75+
}
76+
77+
.doc .source-toolbox .copy-toast::after {
78+
content: "";
79+
position: absolute;
80+
top: 0;
81+
width: 1em;
82+
height: 1em;
83+
border: 0.55em solid transparent;
84+
border-left-color: rgba(0, 0, 0, 0.8);
85+
transform: rotate(-90deg) translateX(50%) translateY(50%);
86+
transform-origin: left;
87+
}
88+
89+
.doc .source-toolbox .copy-button.clicked .copy-toast {
90+
opacity: 1;
91+
transition: none;
92+
}
93+
94+
.imageblock .title {
95+
text-align: center;
96+
}
97+
</style>
98+
<script src="copy-to-clipboard.js"></script>

docs/index.adoc

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@ Codificación, idioma, tabla de contenidos, tipo de documento
3434
:figure-caption: Fig.
3535
:example-caption!:
3636

37+
////
38+
/// Copy button on code blocks
39+
////
40+
[.doc]
41+
42+
:docinfo: shared-footer
3743

3844
:page-component-display-version: 0.26.1
3945

@@ -48,5 +54,4 @@ include::{sectionPath}/index.adoc[]
4854
:section: first-steps
4955
:sectionPath: modules/{section}/pages
5056
:imagesdir: modules/{section}/images
51-
include::{sectionPath}/index.adoc[]
52-
include::{sectionPath}/first-project.adoc[leveloffset=+1]
57+
include::{sectionPath}/gh-actons-101.adoc[leveloffset=0]

0 commit comments

Comments
 (0)