Tobias Gritschacher has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/313212

Change subject: Use Electron service for printable version
......................................................................

Use Electron service for printable version

This is replacing the link behind "printable version" with a link
to the PDF renedered by Electron service.
This is not yet working together with Collection extension since
this extension has another special handling for the
"printable version" link.

Bug: T146894
Change-Id: Ifbf9bc5af1cc95789fe545f473b8a71d8d5cca32
---
M ElectronPdfService.hooks.php
M extension.json
M i18n/en.json
M specials/SpecialElectronPdf.php
4 files changed, 29 insertions(+), 14 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ElectronPdfService 
refs/changes/12/313212/1

diff --git a/ElectronPdfService.hooks.php b/ElectronPdfService.hooks.php
index bd45f34..e5ab240 100644
--- a/ElectronPdfService.hooks.php
+++ b/ElectronPdfService.hooks.php
@@ -25,18 +25,26 @@
                                        [ 'articletitle' => 
$title->getPrefixedText() ]
                                )
                        ];
-               } else {
-                       $bar[ 'electronPdfService-sidebar-portlet-heading' ] = [
-                               [
-                                       'text' => $skin->msg( 
'electronPdfService-sidebar-portlet-print-text' )->escaped(),
-                                       'id' => 'electron-print_pdf',
-                                       'href' => 
$specialPageTitle->getLocalURL(
-                                               [ 'articletitle' => 
$title->getPrefixedText() ]
-                                       )
-                               ]
-                       ];
                }
 
                return true;
        }
+
+       public static function onBuildNavUrls( Skin $skin, &$navUrls ) {
+               $title = $skin->getTitle();
+               if ( is_null( $title ) || !$title->exists() ) {
+                       return false;
+               }
+
+               $specialPageTitle = SpecialPage::getTitleFor( 'ElectronPdf' );
+
+               $navUrls['print'] = [
+                       'text' => $skin->msg( 'printableversion' )->text(),
+                       'href' => $specialPageTitle->getLocalURL(
+                               [ 'articletitle' => $title->getPrefixedText() ]
+                       )
+               ];
+
+               return true;
+       }
 }
diff --git a/extension.json b/extension.json
index 458bbcd..74a83b9 100644
--- a/extension.json
+++ b/extension.json
@@ -27,6 +27,9 @@
        "Hooks": {
          "SidebarBeforeOutput": [
                "ElectronPdfServiceHooks::onSidebarBeforeOutput"
+         ],
+         "SkinTemplateBuildNavUrlsNav_urlsAfterPermalink": [
+               "ElectronPdfServiceHooks::onBuildNavUrls"
          ]
        },
        "MessagesDirs": {
diff --git a/i18n/en.json b/i18n/en.json
index 932866e..3b6e556 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -5,11 +5,11 @@
                ]
        },
        "electronPdfService": "ElectronPdfService",
-       "electronPdfService-desc": "This is an extension for adding browser 
based PDF rendering support through Electron PDF service",
+       "electronPdfService-desc": "Adds browser based PDF rendering support 
through Electron PDF service",
        "electronPdfService-sidebar-portlet-heading": "Print",
        "electronPdfService-sidebar-portlet-print-text": "Print PDF",
-       "electronPdfService-invalid-article-title": "Invalid article",
-       "electronPdfService-invalid-article-text": "The specified page is not a 
valid article.",
-       "electronPdfService-article-notfound-title": "Article not found by 
service",
+       "electronPdfService-invalid-article-title": "Invalid page",
+       "electronPdfService-invalid-article-text": "The specified page is not 
valid.",
+       "electronPdfService-article-notfound-title": "Page not found by 
service",
        "electronPdfService-article-notfound-text": "The service was not able 
to resolve the specified link."
 }
\ No newline at end of file
diff --git a/specials/SpecialElectronPdf.php b/specials/SpecialElectronPdf.php
index ae0cd95..187d976 100644
--- a/specials/SpecialElectronPdf.php
+++ b/specials/SpecialElectronPdf.php
@@ -90,4 +90,8 @@
                fpassthru( $this->tempFile );
                $this->getOutput()->disable();
        }
+
+       protected function getGroupName() {
+               return 'pagetools';
+       }
 }

-- 
To view, visit https://gerrit.wikimedia.org/r/313212
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ifbf9bc5af1cc95789fe545f473b8a71d8d5cca32
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/ElectronPdfService
Gerrit-Branch: master
Gerrit-Owner: Tobias Gritschacher <tobias.gritschac...@wikimedia.de>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to