Skip to content

Commit 85c13d6

Browse files
committed
[BUGFIX] Fix the asset paths in single HTMl
And add an integration test for single HTML. It was until now not possible testing it. There are still open issues with single HTMl, but I would suggest to solve them in follow-ups. - #238 - #239 Resolves #233
1 parent d368a1d commit 85c13d6

File tree

8 files changed

+242
-13
lines changed

8 files changed

+242
-13
lines changed

packages/typo3-docs-theme/resources/template/structure/singlepage.html.twig

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
{% block body %}
44
<!-- content start -->
55
{% for document in documents -%}
6-
{{ renderNode(document) }}
6+
<article>
7+
{{ renderNode(document) }}
8+
</article>
79
{%~ endfor -%}
810
<!-- content end -->
911
{% endblock %}

packages/typo3-docs-theme/src/Twig/TwigExtension.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ public function getCurrentFilename(array $context): string
103103
*/
104104
public function getRelativePath(array $context, string $path): string
105105
{
106+
$renderContext = $this->getRenderContext($context);
106107
if ($this->typo3AzureEdgeURI !== '') {
107108
// CI (GitHub Actions) gets special treatment, then we use a fixed URI for assets.
108109
// TODO: Fixate the "_resources" string as a class/config constant, not hardcoded

packages/typo3-guides-extension/src/Renderer/SinglePageRenderer.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ public function render(RenderCommand $renderCommand): void
2222
$renderCommand->getDestination(),
2323
$renderCommand->getDestinationPath(),
2424
'singlepage',
25-
)->withIterator($renderCommand->getDocumentIterator());
25+
)->withIterator($renderCommand->getDocumentIterator())
26+
->withOutputFilePath('singlehtml/Index.html');
2627

2728
$context->getDestination()->put(
2829
$renderCommand->getDestinationPath() . '/singlehtml/Index.html',

tests/ApplicationTestCase.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
use Symfony\Component\DependencyInjection\Container;
1313
use Symfony\Component\DependencyInjection\Extension\ExtensionInterface;
1414
use T3Docs\GuidesExtension\DependencyInjection\TestExtension;
15+
use T3Docs\GuidesExtension\DependencyInjection\Typo3GuidesExtension;
1516
use T3Docs\GuidesPhpDomain\DependencyInjection\GuidesPhpDomainExtension;
1617
use T3Docs\Typo3DocsTheme\DependencyInjection\Typo3DocsThemeExtension;
1718

@@ -42,6 +43,7 @@ protected function prepareContainer(string|null $configurationFile = null, array
4243
new MarkdownExtension(),
4344
new BootstrapExtension(),
4445
new Typo3DocsThemeExtension(),
46+
new Typo3GuidesExtension(),
4547
new GuidesPhpDomainExtension(),
4648
...$extraExtensions,
4749
]);
Lines changed: 198 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,198 @@
1+
<!DOCTYPE html>
2+
<html class="no-js" lang="en">
3+
<head>
4+
<meta charset="utf-8">
5+
<meta content="width=device-width, initial-scale=1.0" name="viewport">
6+
<meta content="phpdocumentor/guides" name="generator">
7+
<meta content="" name="docsearch:name">
8+
<meta content="" name="docsearch:package_type">
9+
<meta content="" name="docsearch:release">
10+
<meta content="" name="docsearch:version">
11+
<meta content="2023-01-01T12:00:00+00:00" name="docsearch:modified">
12+
<link href="http://purl.org/dc/elements/1.1/" rel="schema.dc">
13+
<meta content="2023-01-01T12:00:00+00:00" name="dc.modified">
14+
<meta content="2023-01-01T12:00:00+00:00" property="article:modified_time">
15+
<title> documentation</title>
16+
17+
<link href="../_resources/css/theme.css" rel="stylesheet">
18+
<link href="https://docs.typo3.org/search/" rel="search" title="Search">
19+
<!-- extrahead --><!-- /extrahead -->
20+
<!-- UNIVERSE BAR START -->
21+
<script src="https://typo3.azureedge.net/typo3infrastructure/universe/dist/webcomponents-loader.js"></script>
22+
<script src="https://typo3.azureedge.net/typo3infrastructure/universe/dist/typo3-universe.js" type="module"></script>
23+
<!-- UNIVERSE BAR END -->
24+
</head>
25+
<body cz-shortcut-listen="true">
26+
<div class="page">
27+
<header>
28+
<div class="page-topbar">
29+
<div class="page-topbar-inner">
30+
<!-- UNIVERSE BAR START -->
31+
<typo3-universe active="documentation">
32+
<div style="display: block; height: 44px; background-color: #313131;"></div>
33+
</typo3-universe>
34+
<!-- UNIVERSE BAR END -->
35+
</div>
36+
</div>
37+
<div class="page-header">
38+
<div class="page-header-inner">
39+
<!-- pageheader -->
40+
<a class="logo" href="https://docs.typo3.org/" title="TYPO3 Documentation">
41+
<img alt="TYPO3 Logo" class="logo-image" src="../_resources/img/typo3-logo.svg" width="484" height="130">
42+
</a>
43+
<!-- /pageheader -->
44+
</div>
45+
</div>
46+
</header>
47+
48+
<main class="page-main">
49+
<div class="page-main-inner">
50+
<div class="page-main-navigation">
51+
<nav>
52+
<input class="toc-checkbox" id="toggleToc" type="checkbox">
53+
<div class="toc-header">
54+
<div class="toc-title">
55+
<a class="toc-title-project" href="/"></a>
56+
</div>
57+
<div class="toc-actions">
58+
<label class="toc-toggle" for="toggleToc">
59+
Menu
60+
</label>
61+
</div>
62+
</div>
63+
<div class="toc-collapse">
64+
<div aria-label="main navigation" class="toc" role="navigation">
65+
<!-- menu -->
66+
<!-- /menu -->
67+
</div>
68+
</div>
69+
</nav>
70+
</div>
71+
<div class="page-main-content">
72+
<div class="rst-content"> <!-- content start -->
73+
<article>
74+
<section class="section" id="root-index">
75+
<h1>Root index<a class="headerlink" href="#root-index" data-bs-toggle="modal" data-bs-target="#linkReferenceModal" title="Reference this headline"></a></h1>
76+
77+
<p>Lorem Ipsum Dolor. See <a href="sub/index.singlepage#sub-index">Sub index</a>.</p>
78+
<div class="toctree-wrapper compound">
79+
<ul class="menu-level">
80+
<li class="toc-item"><a href="sub/index.singlepage#sub-index">Sub index</a></li>
81+
82+
</ul>
83+
</div>
84+
85+
</section>
86+
87+
88+
</article>
89+
<article>
90+
<section class="section" id="sub-index">
91+
<h1>Sub index<a class="headerlink" href="#sub-index" data-bs-toggle="modal" data-bs-target="#linkReferenceModal" title="Reference this headline"></a></h1>
92+
93+
<p>Lorem Ipsum Dolor. See <a href="../index.singlepage#root-index">Root index</a>.</p>
94+
</section>
95+
96+
97+
</article>
98+
<!-- content end -->
99+
</div>
100+
</div>
101+
</div>
102+
</main>
103+
104+
<div class="modal fade" id="linkReferenceModal" tabindex="-1" aria-labelledby="linkReferenceModalLabel"
105+
aria-hidden="true" data-current-filename="">
106+
<div class="modal-dialog">
107+
<div class="modal-content">
108+
<div class="modal-header">
109+
<h5 class="modal-title" id="linkReferenceModalLabel">Reference to the headline</h5>
110+
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
111+
</div>
112+
<div class="modal-body">
113+
<div class="alert alert-success d-none" id="permalink-alert-success" role="alert"></div>
114+
<div class="mb-3">
115+
<label for="permalink-uri" class="col-form-label">Permalink</label>
116+
<div class="input-group">
117+
<input class="form-control code" id="permalink-uri" readonly>
118+
<button type="button" class="btn btn-outline-secondary copy-button" data-target="permalink-uri"><i class="far fa-clone"></i></button>
119+
</div>
120+
<p>Copy and freely share the link</p>
121+
</div>
122+
<div class="mb-3">
123+
<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.
124+
</div>
125+
<label for="permalink-rst" class="col-form-label">reStructuredText (reST):</label>
126+
<div class="input-group">
127+
<textarea class="form-control code" id="permalink-rst" readonly></textarea>
128+
<button type="button" class="btn btn-outline-secondary copy-button" data-target="permalink-rst"><i class="far fa-clone"></i></button>
129+
</div>
130+
<p>Copy this link into your TYPO3 manual. </p>
131+
</div>
132+
<div class="mb-3">
133+
<label for="permalink-html" class="col-form-label">HTML:</label>
134+
<div class="input-group">
135+
<textarea class="form-control code" id="permalink-html" readonly></textarea>
136+
<button type="button" class="btn btn-outline-secondary copy-button" data-target="permalink-html"><i class="far fa-clone"></i></button>
137+
</div>
138+
</div>
139+
</div>
140+
<div class="modal-footer">
141+
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
142+
</div>
143+
</div>
144+
</div>
145+
</div>
146+
<!-- Google Tag Manager -->
147+
<script type="text/plain" data-usercentrics="Google Tag Manager">(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
148+
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
149+
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
150+
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
151+
})(window,document,'script','dataLayer','GTM-MKNXD8Q');</script>
152+
<!-- End Google Tag Manager -->
153+
154+
<footer class="page-footer">
155+
<!-- footer.html -->
156+
<div class="frame frame-ruler-before frame-background-dark">
157+
<div class="frame-container">
158+
<div class="frame-inner">
159+
<ul class="footer-simplemenu"><li><a href="https://typo3.org/community/teams/documentation/#c9886" title="Contact"><span>Contact</span></a></li>
160+
<li><a href="https://github.com/TYPO3-Documentation/DocsTypo3Org-Homepage/issues" rel="nofollow noopener" title="Issues"><span>Issues</span></a></li>
161+
<li><a href="https://github.com/TYPO3-Documentation/DocsTypo3Org-Homepage" rel="nofollow noopener" title="Repository"><span>Repository</span></a></li>
162+
</ul>
163+
<div class="footer-additional">
164+
<p class="text-center">Last rendered: Jan 01, 2023 12:00</p>
165+
</div>
166+
<div class="footer-meta">
167+
<div class="footer-meta-copyright">
168+
</div>
169+
<ul class="footer-meta-navigation">
170+
<li><a href="https://typo3.org/legal-notice" rel="nofollow" target="_blank" title="Legal Notice">Legal Notice</a></li>
171+
<li><a href="https://typo3.org/privacy-policy" rel="nofollow" target="_blank" title="Privacy Policy">Privacy Policy</a></li>
172+
</ul>
173+
</div>
174+
</div>
175+
</div>
176+
</div>
177+
<!-- /footer.html -->
178+
</footer>
179+
</div>
180+
181+
<script>
182+
var DOCUMENTATION_OPTIONS = {
183+
URL_ROOT: './',
184+
VERSION: '',
185+
COLLAPSE_INDEX: false,
186+
FILE_SUFFIX: '.html',
187+
HAS_SOURCE: true
188+
};
189+
</script>
190+
<script src="../_resources/js/jquery.min.js"></script>
191+
<script src="../_resources/js/popper.min.js"></script>
192+
<script src="../_resources/js/bootstrap.min.js"></script>
193+
<script src="../_resources/js/theme.min.js"></script>
194+
195+
<script id="R9wBKTwzv" src="https://app.usercentrics.eu/latest/main.js"></script>
196+
<script data-usercentrics="Matomo" src="/js/piwik.js" type="text/plain"></script>
197+
</body>
198+
</html>

tests/Integration/tests-full/page-with-subpages/input/guides.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,7 @@
66
theme="typo3docs"
77
links-are-relative="true"
88
>
9+
<output-format>html</output-format>
10+
<output-format>singlepage</output-format>
11+
<output-format>interlink</output-format>
912
</guides>

tests/Integration/tests/singlepage-by-toctree/expected/singlehtml/Index.html

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<!-- content start -->
2-
<section class="section" id="root-index">
2+
<article>
3+
<section class="section" id="root-index">
34
<h1>Root index<a class="headerlink" href="#root-index" data-bs-toggle="modal" data-bs-target="#linkReferenceModal" title="Reference this headline"></a></h1>
45

56
<p>Lorem Ipsum Dolor.</p>
@@ -24,21 +25,27 @@ <h1>Root index<a class="headerlink" href="#root-index" data-bs-toggle="modal" da
2425
</section>
2526

2627

27-
<section class="section" id="one">
28+
</article>
29+
<article>
30+
<section class="section" id="one">
2831
<h1>One<a class="headerlink" href="#one" data-bs-toggle="modal" data-bs-target="#linkReferenceModal" title="Reference this headline"></a></h1>
2932

3033
<p>Lorem Ipsum Dolor 1</p>
3134
</section>
3235

3336

34-
<section class="section" id="two">
37+
</article>
38+
<article>
39+
<section class="section" id="two">
3540
<h1>Two<a class="headerlink" href="#two" data-bs-toggle="modal" data-bs-target="#linkReferenceModal" title="Reference this headline"></a></h1>
3641

3742
<p>Lorem Ipsum Dolor. 2</p>
3843
</section>
3944

4045

41-
<section class="section" id="three-point-something">
46+
</article>
47+
<article>
48+
<section class="section" id="three-point-something">
4249
<h1>Three point something<a class="headerlink" href="#three-point-something" data-bs-toggle="modal" data-bs-target="#linkReferenceModal" title="Reference this headline"></a></h1>
4350

4451
<p>Lorem Ipsum Dolor.</p>
@@ -54,39 +61,50 @@ <h1>Three point something<a class="headerlink" href="#three-point-something" dat
5461
</section>
5562

5663

57-
<section class="section" id="three">
64+
</article>
65+
<article>
66+
<section class="section" id="three">
5867
<h1>Three<a class="headerlink" href="#three" data-bs-toggle="modal" data-bs-target="#linkReferenceModal" title="Reference this headline"></a></h1>
5968

6069
<p>Lorem Ipsum Dolor. 3.</p>
6170
</section>
6271

6372

64-
<section class="section" id="3-5">
73+
</article>
74+
<article>
75+
<section class="section" id="3-5">
6576
<h1>3.5<a class="headerlink" href="#3-5" data-bs-toggle="modal" data-bs-target="#linkReferenceModal" title="Reference this headline"></a></h1>
6677

6778
<p>Lorem Ipsum Dolor.</p>
6879
</section>
6980

7081

71-
<section class="section" id="four">
82+
</article>
83+
<article>
84+
<section class="section" id="four">
7285
<h1>Four<a class="headerlink" href="#four" data-bs-toggle="modal" data-bs-target="#linkReferenceModal" title="Reference this headline"></a></h1>
7386

7487
<p>Lorem Ipsum Dolor. <a href="https://typ03.org">index</a></p>
7588
</section>
7689

7790

78-
<section class="section" id="i-sqrt-1">
91+
</article>
92+
<article>
93+
<section class="section" id="i-sqrt-1">
7994
<h1>i (sqrt(-1))<a class="headerlink" href="#i-sqrt-1" data-bs-toggle="modal" data-bs-target="#linkReferenceModal" title="Reference this headline"></a></h1>
8095

8196
<p>Irreal: orphan</p>
8297
</section>
8398

8499

85-
<section class="section" id="pi">
100+
</article>
101+
<article>
102+
<section class="section" id="pi">
86103
<h1>Pi<a class="headerlink" href="#pi" data-bs-toggle="modal" data-bs-target="#linkReferenceModal" title="Reference this headline"></a></h1>
87104

88105
<p>Irrational: Orphan</p>
89106
</section>
90107

91108

109+
</article>
92110
<!-- content end -->
Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,20 @@
11
<!-- content start -->
2-
<section class="section" id="root-index">
2+
<article>
3+
<section class="section" id="root-index">
34
<h1>Root index<a class="headerlink" href="#root-index" data-bs-toggle="modal" data-bs-target="#linkReferenceModal" title="Reference this headline"></a></h1>
45

56
<p>Lorem Ipsum Dolor. <a href="https://typ03.org">index</a></p>
67
</section>
78

89

9-
<section class="section" id="sub-index">
10+
</article>
11+
<article>
12+
<section class="section" id="sub-index">
1013
<h1>Sub index<a class="headerlink" href="#sub-index" data-bs-toggle="modal" data-bs-target="#linkReferenceModal" title="Reference this headline"></a></h1>
1114

1215
<p>Lorem Ipsum Dolor. <a href="https://typ03.org">index</a></p>
1316
</section>
1417

1518

19+
</article>
1620
<!-- content end -->

0 commit comments

Comments
 (0)