Giter VIP home page Giter VIP logo

pdfembed's Introduction

PDFEmbed

This is a "fork" of https://gitlab.com/hydrawiki/extensions/PDFEmbed. It tries to fix https://gitlab.com/hydrawiki/extensions/PDFEmbed/-/issues/19

PDFEmbed allows Adobe Acrobat PDF files to be embedded into a wiki article using tags. The PDF file extension is automatically added and necessarily default permissions are configured. Future functionality will allow this extension to act as a media handler for PDF files.

Installation

To install this extension, add the following to the end of the LocalSettings.php file:

//PDFEmbed
wfLoadExtension('PDFEmbed');

Composer installation: composer.local.json:

{
  "repositories": [
    {
      "type": "vcs",
      "url": "https://github.com/WolfgangFahl/PDFEmbed"
    }
  ],
  "require": {
    "WolfgangFahl/PDFembed": "*"
  },
  "extra": {
    "merge-plugin": {
      "include": [
        "extensions/*/composer.json",
        "skins/*/composer.json"
      ]
    }
  }
}

Configuration

If the default configuration needs to be altered add these settings to the LocalSettings.php file below the require:

//Default width for the PDF object container.
$wgPdfEmbed['width'] = 800;

//Default height for the PDF object container.
$wgPdfEmbed['height'] = 1090;

pdfembed's People

Contributors

bertrandgorge avatar cfoellmann avatar hexmode avatar pa4080 avatar tholzheim avatar wolfgangfahl avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

pdfembed's Issues

Add composer.json

Hi,

I am helping myself with manually defining composer data but adding a composer.json would make it easier to define how to fetch your extension

[c0313584c707ac05b0f0d8ab] 2020-12-16 13:42:10: Exceção fatal do tipo “Error”

I tried

<pdf>File:Cadastrodeprodutos.pdf</pdf>

and

<pdf width="500" height="300">File:Cadastrodeprodutos.pdf</pdf>

my configuration is the same of the example

// Default width for the PDF object container.
$wgPdfEmbed['width'] = 800;

// Default height for the PDF object container.
$wgPdfEmbed['height'] = 1090;

//Allow user the usage of the pdf tag
$wgGroupPermissions['*']['embed_pdf'] = true;

I looked on the wiki version and the extension is loaded

Support width as percentage of parent

Currently the extension only supports fixed width for the object/iframe. This makes the rendering of the embedded pdf very problematic on responsive layouts and mobile devices.

If I try <pdf width="100%">File:test.pdf</pdf>, this gets converted to a fixed width of 100 due to the intval() cast on line 144 of PDFEmbed.hooks.php (and the regex on line 139 would need updated). If this support is added, I'd also suggest that a width of 100% should be the default value of the $wgPdfEmbed['width'] config variable.

undefined variable $user in PDFEmbed.hooks.php on line 125

Hello again :-)
same setup as in issue "embed_pdf_no_permission #23"

If we use the visual editor and try to save our changes, we get (at least on an articles with two embedded PDFs) an error: Something went wrong, Invalid reply from Server.
This error is forced by a warning i could find in the Serverresponse using the developer tools:
Warning: Undefined variable $user in /var/www/html/extensions/PDFEmbed/PDFEmbed.hooks.php on line 125

Under some circumstances, the $user seems to be null.
Again. I don't understand the need of additional rights check in PDFEmbed. Is there a possibility to disable those checks completly?

Best regards

Incompatible with MW 1.39.4, 1.40

It can be installed but instead of the file, only the black borders are shown, no file is displayed. iframe with https link is generated so it is some conflict with mediawiki core. During opening the page the file is embedded (iframed) on, it asks for saving the file which is highly undesirable behaviour.

Call To Undefined Method getUserFactory()

Hi there,

I have installed this fork on my MW server and got the following error:

[ZR2GJ1vfaLpntRMuxbsNNAAAAA4] /index.php?title=My_Page Error from line 120 of /var/www/XXX/XXX/XXX/web/extensions/PDFEmbed/PDFEmbed.hooks.php: Call to undefined method MediaWiki\MediaWikiServices::getUserFactory()

If I link a PDF and click show preview, I can see the PDF shown fine. If I click the submit button I get this error.

MediaWiki 1.34.0
PHP 7.2.34 (cgi-fcgi)
PDFEmbed | 3.0.1 (27cd011)

Is this a known issue or have I setup the extension incorrectly?

Thankyou,
Will.

Fatal error in PDFEmbed, using userHasRight in PDFEmbed.hooks.php

Hello, I get this fatal error when rebuilding data on SMW, with MW 1.35:

TypeError: Argument 1 passed to MediaWiki\Permissions\PermissionManager::userHasRight() must implement interface MediaWiki\User\UserIdentity, null given, called in /var/www/html/extensions/PDFEmbed/PDFEmbed.hooks.php on line 123
Backtrace:
from /var/www/html/includes/Permissions/PermissionManager.php(1366)
#0 /var/www/html/extensions/PDFEmbed/PDFEmbed.hooks.php(123): MediaWiki\Permissions\PermissionManager->userHasRight(NULL, string)
#1 /var/www/html/includes/parser/Parser.php(3973): PDFEmbed::generateTag(string, array, Parser, PPFrame_Hash)
#2 /var/www/html/includes/parser/PPFrame_Hash.php(350): Parser->extensionSubstitution(array, PPFrame_Hash)
#3 /var/www/html/includes/parser/Parser.php(2930): PPFrame_Hash->expand(PPNode_Hash_Tree, integer)
#4 /var/www/html/includes/parser/Parser.php(1598): Parser->replaceVariables(string)
#5 /var/www/html/includes/parser/Parser.php(656): Parser->internalParse(string)
#6 /var/www/html/includes/content/WikitextContent.php(327): Parser->parse(string, Title, ParserOptions, boolean, boolean, integer)
#7 /var/www/html/includes/content/AbstractContent.php(548): WikitextContent->fillParserOutput(Title, integer, ParserOptions, boolean, ParserOutput)
#8 /var/www/html/extensions/SemanticMediaWiki/includes/ContentParser.php(173): AbstractContent->getParserOutput(Title, integer)
#9 /var/www/html/extensions/SemanticMediaWiki/includes/ContentParser.php(130): SMW\ContentParser->fetchFromContent()
#10 /var/www/html/extensions/SemanticMediaWiki/src/MediaWiki/Jobs/UpdateJob.php(197): SMW\ContentParser->parse()
#11 /var/www/html/extensions/SemanticMediaWiki/src/MediaWiki/Jobs/UpdateJob.php(137): SMW\MediaWiki\Jobs\UpdateJob->parse_content()
#12 /var/www/html/extensions/SemanticMediaWiki/src/MediaWiki/Jobs/UpdateJob.php(94): SMW\MediaWiki\Jobs\UpdateJob->doUpdate()
#13 /var/www/html/extensions/SemanticMediaWiki/src/SQLStore/Rebuilder/Rebuilder.php(239): SMW\MediaWiki\Jobs\UpdateJob->run()
#14 /var/www/html/extensions/SemanticMediaWiki/src/Maintenance/DataRebuilder.php(466): SMW\SQLStore\Rebuilder\Rebuilder->rebuild(integer)
#15 /var/www/html/extensions/SemanticMediaWiki/src/Maintenance/DataRebuilder.php(383): SMW\Maintenance\DataRebuilder->doUpdateById(integer)
#16 /var/www/html/extensions/SemanticMediaWiki/src/Maintenance/DataRebuilder.php(222): SMW\Maintenance\DataRebuilder->rebuildAll()
#17 /var/www/html/extensions/SemanticMediaWiki/maintenance/rebuildData.php(198): SMW\Maintenance\DataRebuilder->rebuild()
#18 /var/www/html/maintenance/doMaintenance.php(108): SMW\Maintenance\rebuildData->execute()
#19 /var/www/html/extensions/SemanticMediaWiki/maintenance/rebuildData.php(294): require_once(string)
#20 {main}

Error after mediawiki update to 1.37.1

Hi,

i love the PDFEmbed extension, but after i updated mediawiki to 1.37.1, there is the folowing error on the sites who use the extension:

"Use of wfFindFile was deprecated in MediaWiki 1.34. [Called from PDFEmbed::generateTag in /var/www/html/extensions/PDFEmbed/PDFEmbed.hooks.php at line 160] in /var/www/html/includes/debug/MWDebug.php 375"

What can I do?

Thanks a lot

greeting
Eugene

embed_pdf_no_permission

Hello,
we have a docker instance of mediawiki 1.39.4 and try to use PDFEmbed (we clone https://github.com/WolfgangFahl/PDFEmbed.git and mount it to the extensions folder).

We want everybody (in our intranet) to be able to read all wiki pages. Login is necessary for editing.

We include PDFEmbed in our localSettings.php:

wfLoadExtension( 'PDFEmbed' );
//Allow all users the usage of the pdf tag
$wgGroupPermissions['*']['embed_pdf'] = true;

In "User group rights" we see "Embed PDFs into pages (embed_pdf)" for the groups "all", "Administrators" and "Users".

Currently we only have a test environment set up and only one Admin user (administrator). Neither the logged in Admin user nor a simple "guest" (group "*") is allowed to see PDFs: "The last editor of this page did not have the right to Embed PDFs into pages." (the german message is different: "Du bist nicht berechtigt PDF-Dateien einzubetten."). The last editor was "Admin", german "Du" is either the logged in Admin or a guest...

While I don't understand the need to consider the requestAction or the page's editor, ultimately there seems to be a problem with $user instanceof UserIdentity in PDFEmbed.hooks.php Line 125.

if (!( // $user instanceof UserIdentity &&
      MediaWikiServices::getInstance()->getPermissionManager()->userHasRight($user, 'embed_pdf')

Omitting this check (see above), pdf_embed works as expected. Any ideas?

Best regards
matthias-oe

PS: In which scenario are the additional rights checks required?

English version of `embed_pdf_invalid_user` message sounds like nonsense

Google translate tells me the German language version is “An invalid user was specified” but that, too, seems wrong. A better message would probably, like other MW permission messages, tell the user what permission they are missing.

In fact, the embed_pdf_invalid_user message appears when an anonymous user successfully edits the page because the anonymous user does not result in a valid user when

$revUserName = $parser->getRevisionUser();
// $revUserName is "10.5.5.1" for an anonymous user here
// [...]
$user = $userFactory->newFromName($revUserName);

So, the error doesn't keep the edit from being saved, but it does stop the version of the page created by an un-permission-ed user from being displayed.

If a user with the correct permissions later comes and edits the page and leave the tag intact, it will display properly.

Can't display PDF

Hi Wolfgang,
great to see there's a simple PDF Tool to display PDFs. I choosed your tool because i'm hosting my mediawiki. After activating the plugin i'm not able to display a pdf file. My syntax is: "File:abcd.pdf" but after saving it doesn't show the pdf, it shows my main mediawiki screen :-) (looks like printscreen)

Would be great if you or any other have a hint/tipp for me.

BR Mark

mediawiki-pdf

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.