Skip to content

Commit

Permalink
[BUGFIX] Edit on GitHub Button with adjusted path
Browse files Browse the repository at this point in the history
resovles #390
  • Loading branch information
linawolf committed Mar 7, 2024
1 parent 5490bca commit 1126d52
Show file tree
Hide file tree
Showing 8 changed files with 231 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public function load(array $configs, ContainerBuilder $container): void
'typo3_version' => $this->getConfigValue($configs, 'typo3_version', 'main'),
'edit_on_github' => $this->getConfigValue($configs, 'edit_on_github', ''),
'edit_on_github_branch' => $this->getConfigValue($configs, 'edit_on_github_branch', 'main'),
'edit_on_github_directory' => $this->getConfigValue($configs, 'edit_on_github_directory', 'Documentation'),
'how_to_edit' => $this->getConfigValue($configs, 'how_to_edit', 'https://docs.typo3.org/m/typo3/docs-how-to-document/main/en-us/WritingDocsOfficial/GithubMethod.html'),
'interlink_shortcode' => $this->getConfigValue($configs, 'interlink_shortcode', ''),
'copy_sources' => $this->getConfigValue($configs, 'copy_sources', 'true'),
Expand Down
3 changes: 2 additions & 1 deletion packages/typo3-docs-theme/src/Twig/TwigExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ public function getEditOnGitHubLink(array $context): string
if ($currentFileName === '') {
return '';
}
return sprintf("https://github.com/%s/edit/%s/Documentation/%s.rst", $githubButton, $githubBranch, $currentFileName);
$githubDirectory = trim($this->themeSettings->getSettings('edit_on_github_directory', 'Documentation'), '/');
return sprintf("https://github.com/%s/edit/%s/%s/%s.rst", $githubButton, $githubBranch, $githubDirectory, $currentFileName);
}
/**
* @param array{env: RenderContext} $context
Expand Down
4 changes: 4 additions & 0 deletions packages/typo3-guides-cli/src/Command/ConfigureCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ protected function configure(): void
--extension-value="https://github.com/vendor/extension" \
\
--extension-class="\T3Docs\Typo3DocsTheme\DependencyInjection\Typo3DocsThemeExtension" \
--extension-attribute="edit-on-github-directory" \
--extension-value="path/to/Documentation" \
\
--extension-class="\T3Docs\Typo3DocsTheme\DependencyInjection\Typo3DocsThemeExtension" \
--extension-attribute="project-contact" \
--extension-value="mailto:mail@example.com" \
\
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ enum HtmlThemeOptions: string
case github_revision_msg = 'github-revision-msg';
case github_branch = 'edit-on-github-branch';
case github_repository = 'edit-on-github';
case path_to_documentation_dir = 'edit-on-github-directory';
case github_sphinx_locale = 'github-sphinx-locale';
case github_commit_hash = 'github-commit-hash';
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public static function providerForMigrateReturnsXmlDocumentCorrectly(): \Generat
'github_revision_msg' => 'some github message',
'github_branch' => 'main',
'github_repository' => 'my-example-repository',
'path_to_documentation_dir' => 'typo3/sysext/redirects/Documentation/',
'github_sphinx_locale' => 'de',
'github_commit_hash' => 'abcdef',
],
Expand All @@ -64,6 +65,7 @@ public static function providerForMigrateReturnsXmlDocumentCorrectly(): \Generat
class="\T3Docs\Typo3DocsTheme\DependencyInjection\Typo3DocsThemeExtension"
edit-on-github="my-example-repository"
edit-on-github-branch="main"
edit-on-github-directory="typo3/sysext/redirects/Documentation/"
github-commit-hash="abcdef"
github-revision-msg="some github message"
github-sphinx-locale="de"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,203 @@
<!DOCTYPE html>
<html class="no-js" lang="en">
<head>
<title>Document Title documentation</title>


<meta charset="utf-8">
<meta content="width=device-width, initial-scale=1.0" name="viewport">
<meta content="phpdocumentor/guides" name="generator">
<meta content="" name="docsearch:name">
<meta content="" name="docsearch:package_type">
<meta content="" name="docsearch:release">
<meta content="" name="docsearch:version">
<meta content="2023-01-01T12:00:00+00:00" name="docsearch:modified">
<meta content="2023-01-01T12:00:00+00:00" name="dc.modified">
<meta content="2023-01-01T12:00:00+00:00" property="article:modified_time">
<link href="http://purl.org/dc/elements/1.1/" rel="schema.dc">
<link href="_resources/css/theme.css" rel="stylesheet">
<link href="https://docs.typo3.org/search/" rel="search" title="Search">
<script src="https://typo3.azureedge.net/typo3infrastructure/universe/dist/webcomponents-loader.js"></script>
<script src="https://typo3.azureedge.net/typo3infrastructure/universe/dist/typo3-universe.js" type="module"></script>

<link href="#" rel="top" title="Document Title"/>
</head>
<body>
<div class="page">

<header>
<div class="page-topbar">
<div class="page-topbar-inner">
<typo3-universe active="documentation">
<div style="display: block; height: 44px; background-color: #313131;"></div>
</typo3-universe>
</div>
</div>
<div class="page-header">
<div class="page-header-inner">
<div class="row">
<div class="col-sm-6 col-lg-7">
<a class="logo" href="https://docs.typo3.org/" title="TYPO3 Documentation">
<img alt="TYPO3 Logo" class="logo-image" src="_resources/img/typo3-logo.svg" width="484" height="130">
</a>
</div>
<div class="col-sm-6 col-lg-5">
<search role="search">
<form action="https://docs.typo3.org/search/search" id="global-search-form" method="get">
<div class="sr-only"><label for="globalsearchinput">Search all TYPO3 Documentation</label></div>
<div class="input-group mb-3 mt-sm-3">
<input autocomplete="off" class="form-control shadow-none" id="globalsearchinput" name="q" placeholder="Search all TYPO3 documentation" type="text" value="">
<button class="btn btn-primary" type="submit"><i class="fa fa-search"></i>&nbsp;Search</button>
</div>
</form>
</search>
</div>
</div>
</div>
</div>
</header>
<main class="page-main">
<div class="page-main-inner">
<div class="page-main-navigation">
<nav>
<input class="toc-checkbox" id="toggleToc" type="checkbox">


<div class="toc-header">
<div class="toc-title">
<a class="toc-title-project" href="#"></a>
</div>
<div class="toc-actions">
<label class="toc-toggle" for="toggleToc">
Menu
</label>
</div>
</div>
<div class="toc-collapse">
<div aria-label="main navigation" class="toc" role="navigation">
<div aria-label="Main navigation" class="main_menu" role="navigation">


</div>
</div>
</div>
</nav>
</div>
<div class="page-main-content">
<div class="rst-content"> <nav aria-label="breadcrumbs navigation" class="breadcrumb-bar" role="navigation">

<ol class="breadcrumb">
<li aria-current="page" class="breadcrumb-item active">Document Title</li>
</ol>

<div class="breadcrumb-additions"> <a class="btn btn-sm btn-light" href="_sources/Index.rst.txt" rel="nofollow noopener" target="_blank">
<span class="btn-icon"><span class="fas fa-code"></span></span>
<span class="btn-text">View source</span>
</a>
<a class="btn btn-sm btn-light" href="https://docs.typo3.org/m/typo3/docs-how-to-document/main/en-us/WritingDocsOfficial/GithubMethod.html" id="btnHowToEdit" rel="nofollow noopener" target="_blank">
<span class="btn-icon"><span class="fas fa-info-circle"></span></span>
<span class="btn-text">How to edit</span>
</a>
<a class="btn btn-sm btn-primary" href="https://github.com/typo3/typo3/edit/main/typo3/sysext/adminpanel/Documentation/Index.rst" id="btnEditOnGitHub" rel="nofollow noopener" target="_blank">
<span class="btn-icon"><span class="fab fa-github"></span></span>
<span class="btn-text">Edit on GitHub</span>
</a>
</div>
</nav>

<article class="document" itemscope="itemscope" itemtype="http://schema.org/Article" role="main">
<div itemprop="articleBody">
<!-- content start -->
<section class="section" id="document-title">
<h1>Document Title<a class="headerlink" href="#document-title" data-bs-toggle="modal" data-bs-target="#linkReferenceModal" title="Reference this headline"></a></h1>

<p>Lorem Ipsum Dolor.</p>
</section>

<!-- content end -->
</div>
</article>

</div>
</div>
</div>
</main>

<div class="modal fade" id="linkReferenceModal" tabindex="-1" aria-labelledby="linkReferenceModalLabel"
aria-hidden="true" data-current-filename="Index">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="linkReferenceModalLabel">Reference to the headline</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<div class="alert alert-success d-none" id="permalink-alert-success" role="alert"></div>
<div class="mb-3">
<label for="permalink-uri" class="col-form-label">Permalink</label>
<div class="input-group">
<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>
</div>
<div class="mb-3">
<div class="alert alert-warning alert-permalink-rst" role="alert">This link target has no permanent anchor assigned. You can make a <a href="https://github.com/typo3/typo3/edit/main/typo3/sysext/adminpanel/Documentation/Index.rst">pull request on GitHub</a> to suggest an anchor.
The link below can be used, but is prone to change if the page gets moved.
</div>
<label for="permalink-rst" class="col-form-label">reStructuredText (reST):</label>
<div class="input-group">
<textarea class="form-control code" id="permalink-rst" readonly></textarea>
<button type="button" class="btn btn-outline-secondary copy-button" data-target="permalink-rst"><i class="far fa-clone"></i></button>
</div>
<p>Copy this link into your TYPO3 manual. </p>
</div>
<div class="mb-3">
<label for="permalink-html" class="col-form-label">HTML:</label>
<div class="input-group">
<textarea class="form-control code" id="permalink-html" readonly></textarea>
<button type="button" class="btn btn-outline-secondary copy-button" data-target="permalink-html"><i class="far fa-clone"></i></button>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
</div>


<footer class="page-footer">
<div class="frame frame-ruler-before frame-background-dark">
<div class="frame-container">
<div class="frame-inner">
<div class="footer-additional">
<p class="text-center">Last rendered: Jan 01, 2023 12:00</p>
</div>
<div class="footer-meta">
<ul class="footer-meta-navigation">
<li><a href="https://typo3.org/legal-notice" rel="nofollow" target="_blank" title="Legal Notice">Legal Notice</a></li>
<li><a href="https://typo3.org/privacy-policy" rel="nofollow" target="_blank" title="Privacy Policy">Privacy Policy</a></li>
</ul>
</div>
</div>
</div>
</div>
</footer>

<script src="_resources/js/popper.min.js"></script>
<script src="_resources/js/bootstrap.min.js"></script>
<script src="_resources/js/theme.min.js"></script>

<script id="R9wBKTwzv" src="https://app.usercentrics.eu/latest/main.js"></script>
<script data-usercentrics="Matomo" src="/js/piwik.js" type="text/plain"></script>

<script type="text/plain" data-usercentrics="Google Tag Manager">(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','GTM-MKNXD8Q');</script>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
==============
Document Title
==============

Lorem Ipsum Dolor.
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8" ?>
<guides xmlns="https://www.phpdoc.org/guides"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://www.phpdoc.org/guides vendor/phpdocumentor/guides-cli/resources/schema/guides.xsd"
links-are-relative="true"
>

<extension class="\T3Docs\Typo3DocsTheme\DependencyInjection\Typo3DocsThemeExtension"
edit-on-github="typo3/typo3"
edit-on-github-branch="main"
edit-on-github-directory="typo3/sysext/adminpanel/Documentation/"
/>
</guides>

0 comments on commit 1126d52

Please sign in to comment.