Skip to content

Commit

Permalink
[TASK] Recreate integration baseline
Browse files Browse the repository at this point in the history
  • Loading branch information
garvinhicking authored and linawolf committed Nov 4, 2024
1 parent 34b628c commit c0d20ae
Show file tree
Hide file tree
Showing 47 changed files with 290 additions and 48 deletions.
21 changes: 19 additions & 2 deletions packages/typo3-docs-theme/assets/js/link-reference-modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
const SELECTOR_MODAL = '#linkReferenceModal';
const SELECTOR_ALERT_RST_NO_ANCHOR = '.alert-permalink-rst';
const SELECTOR_PERMALINK_URI = '#permalink-uri';
const SELECTOR_SHORTLINK_URI = '#shortlink-uri';
const SELECTOR_PERMALINK_RST = '#permalink-rst';
const SELECTOR_PERMALINK_HTML = '#permalink-html';
const SELECTOR_ALERT_SUCCESS = '#permalink-alert-success';
Expand All @@ -16,6 +17,19 @@
return rstAnchor ? `${window.location.origin}${window.location.pathname}#${rstAnchor}` : `${window.location.origin}${window.location.pathname}#${section?.id || ''}`;
}

function generateShortUri(linkReferenceModal, section, headerText, rstAnchor, filename) {
const urlPrefix = 'https://docs.typo3.org/permalink/';
const interlinkTarget = linkReferenceModal.dataset.interlinkShortcode || 'somemanual';
if (rstAnchor) {
return urlPrefix + `${interlinkTarget}:${rstAnchor}`;
}
if (filename === '') {
return '';
}
// @todo - check how anchor hashes + filenames work with redirects?
return urlPrefix + `${interlinkTarget}:${filename}#${section?.id || ''}`;
}

function generateRstLink(linkReferenceModal, section, headerText, rstAnchor, filename) {
const interlinkTarget = linkReferenceModal.dataset.interlinkShortcode || 'somemanual';
if (rstAnchor) {
Expand All @@ -36,16 +50,18 @@
}
}

function updateInputsAndTextareas(linkReferenceModal, header, headerText, uri, rstLink) {
function updateInputsAndTextareas(linkReferenceModal, header, headerText, uri, rstLink, shortUri) {
if (header) {
linkReferenceModal.querySelector('h5').innerHTML = header;
}
if (uri === null) {
// this can happen when opening a local file
linkReferenceModal.querySelector(SELECTOR_PERMALINK_URI).value = '';
linkReferenceModal.querySelector(SELECTOR_PERMALINK_HTML).value = '';
linkReferenceModal.querySelector(SELECTOR_SHORTLINK_URI).value = '';
} else {
linkReferenceModal.querySelector(SELECTOR_PERMALINK_URI).value = uri;
linkReferenceModal.querySelector(SELECTOR_SHORTLINK_URI).value = shortUri;
linkReferenceModal.querySelector(SELECTOR_PERMALINK_HTML).value = `<a href="${uri}">${headerText}</a>`;
}
const rstInput = linkReferenceModal.querySelector(SELECTOR_PERMALINK_RST);
Expand Down Expand Up @@ -103,8 +119,9 @@
const uri = generateUri(section, rstAnchor);
const filename = linkReferenceModal.dataset.currentFilename;
const rstLink = rstLinkData?rstLinkData:generateRstLink(linkReferenceModal, section, headerText, rstAnchor, filename);
const shortUri = generateShortUri(linkReferenceModal, section, headerText, rstAnchor, filename);

updateInputsAndTextareas(linkReferenceModal, header, headerText, uri, rstLink);
updateInputsAndTextareas(linkReferenceModal, header, headerText, uri, rstLink, shortUri);


handleCopyButtons(linkReferenceModal);
Expand Down
2 changes: 1 addition & 1 deletion packages/typo3-docs-theme/resources/public/js/theme.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@
<input class="form-control code" id="permalink-uri" readonly>
<button type="button" class="btn btn-outline-secondary copy-button" data-target="permalink-uri"><i class="far fa-clone"></i></button>
</div>
<p>Copy and freely share the link</p>
<label for="shortlink-uri" class="col-form-label">Shortlink</label>
<div class="input-group">
<input class="form-control code" id="shortlink-uri" readonly>
<button type="button" class="btn btn-outline-secondary copy-button" data-target="shortlink-uri"><i class="far fa-clone"></i></button>
</div>
<p><em>Copy and freely share the link</em></p>
</div>
<div class="mb-3">
<div class="alert alert-warning alert-permalink-rst" role="alert">
Expand Down
7 changes: 6 additions & 1 deletion tests/Integration/tests-full/breadcrumb/expected/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,12 @@ <h5 class="modal-title" id="linkReferenceModalLabel">Reference to the headline</
<input class="form-control code" id="permalink-uri" readonly>
<button type="button" class="btn btn-outline-secondary copy-button" data-target="permalink-uri"><i class="far fa-clone"></i></button>
</div>
<p>Copy and freely share the link</p>
<label for="shortlink-uri" class="col-form-label">Shortlink</label>
<div class="input-group">
<input class="form-control code" id="shortlink-uri" readonly>
<button type="button" class="btn btn-outline-secondary copy-button" data-target="shortlink-uri"><i class="far fa-clone"></i></button>
</div>
<p><em>Copy and freely share the link</em></p>
</div>
<div class="mb-3">
<div class="alert alert-warning alert-permalink-rst" role="alert">This link target has no permanent anchor assigned.The link below can be used, but is prone to change if the page gets moved.
Expand Down
7 changes: 6 additions & 1 deletion tests/Integration/tests-full/breadcrumb/expected/page.html
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,12 @@ <h5 class="modal-title" id="linkReferenceModalLabel">Reference to the headline</
<input class="form-control code" id="permalink-uri" readonly>
<button type="button" class="btn btn-outline-secondary copy-button" data-target="permalink-uri"><i class="far fa-clone"></i></button>
</div>
<p>Copy and freely share the link</p>
<label for="shortlink-uri" class="col-form-label">Shortlink</label>
<div class="input-group">
<input class="form-control code" id="shortlink-uri" readonly>
<button type="button" class="btn btn-outline-secondary copy-button" data-target="shortlink-uri"><i class="far fa-clone"></i></button>
</div>
<p><em>Copy and freely share the link</em></p>
</div>
<div class="mb-3">
<div class="alert alert-warning alert-permalink-rst" role="alert">This link target has no permanent anchor assigned.The link below can be used, but is prone to change if the page gets moved.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,12 @@ <h5 class="modal-title" id="linkReferenceModalLabel">Reference to the headline</
<input class="form-control code" id="permalink-uri" readonly>
<button type="button" class="btn btn-outline-secondary copy-button" data-target="permalink-uri"><i class="far fa-clone"></i></button>
</div>
<p>Copy and freely share the link</p>
<label for="shortlink-uri" class="col-form-label">Shortlink</label>
<div class="input-group">
<input class="form-control code" id="shortlink-uri" readonly>
<button type="button" class="btn btn-outline-secondary copy-button" data-target="shortlink-uri"><i class="far fa-clone"></i></button>
</div>
<p><em>Copy and freely share the link</em></p>
</div>
<div class="mb-3">
<div class="alert alert-warning alert-permalink-rst" role="alert">This link target has no permanent anchor assigned.The link below can be used, but is prone to change if the page gets moved.
Expand Down
Loading

0 comments on commit c0d20ae

Please sign in to comment.