diff --git a/README.md b/README.md index 38a5635..c5c884e 100644 --- a/README.md +++ b/README.md @@ -1,31 +1,30 @@ Checksum ======== -**Plugin for [Nextcloud](https://nextcloud.com) and [ownCloud](https://owncloud.org) to create hashes of files.** +**App for [Nextcloud](https://nextcloud.com) to print files using the CUPS/LPR printing ecosystem.** -![animation](screenshots/checksum.gif) +![animation](screenshots/printer.gif) Installation ------------ **Nextcloud** -In your Instance, simply navigate to »Apps«, choose the category »Files«, find the Checksum app and enable it. +You need a working CUPS setup with a compatible printer set up as the default printer and the LPR daemon installed on your server. -**ownCloud** -- Copy the checksum folder in the app directory of owncloud. -- If not already done, rename the app-folder to "checksum" - causes overwise an sql error. -- Enable this app in the admin interface. +In your Instance, simply navigate to »Apps«, choose the category »Tools«, find the Printer app and enable it. Usage ----- -Just open the details view of the file (Sidebar). There should be a new tab called "Checksum". Select a algorithm and it will try to generate a hash. If you want an other algorithm, just click on the reload button. +Just open the details view of the file (Sidebar). There should be a new tab called "Printer". Select a Orientation of your print and it will try to ececute the LPR (Line Printing Daemon) on the CLI to send the job to a printer configured in CUPS. Currently, only the printer set as default can be used for printing. -Possible algorithms are md5, sha1, sha256, sha384, sha512 and crc32. +Possible orientations are "Landscape" and "Portrait". Further options will be added in the future. Compatibility ------------- -- I only tested the app for the current version of owncloud (9.x) and Nextcloud 10 and 11. +- I only tested the app for the current versions of Nextcloud (14 and up). - I tried to use the current api as much as possible. It should be safe for future versions. +- Currently only files supported by CUPS natively are supported for printing. This includes Images, PDFs, text files and probably others. Not all filetypes are supported by CUPS. +- The app currently misses a lot of features that will be added in future versions of the app. If you want to help out with development, a PR is highly welcome. diff --git a/js/printer.tabview.js b/js/printer.tabview.js index 0a40f66..dffdd40 100644 --- a/js/printer.tabview.js +++ b/js/printer.tabview.js @@ -62,7 +62,7 @@ }, /** - * ajax callback for generating md5 hash + * ajax callback for printing file */ check: function(fileInfo, orientation) { // skip call if fileInfo is null @@ -139,7 +139,7 @@ }); - OCA.Printer = OCA.Primter || {}; + OCA.Printer = OCA.Printer || {}; OCA.Printer.PrinterTabView = PrinterTabView; diff --git a/lib/Controller/PrinterController.php b/lib/Controller/PrinterController.php index 7326583..956144d 100644 --- a/lib/Controller/PrinterController.php +++ b/lib/Controller/PrinterController.php @@ -23,12 +23,13 @@ class PrinterController extends Controller { /** * callback function to get md5 hash of a file * @NoAdminRequired - * @param (string) $source - filename + * @param (string) $sourcefile - filename * @param (string) $orientation - Orientation of printed file */ - public function printfile($source, $orientation) { - if($orientation == "landscape") { - shell_exec('lpr ' . $source); + public function printfile($sourcefile, $orientation) { + if($orientation === "landscape") { + $filefullpath = \OC\Files\Filesystem::getLocalFile($sourcefile); + exec('lpr ' . $filefullpath); return new JSONResponse( array( 'response' => 'success', @@ -37,8 +38,9 @@ class PrinterController extends Controller { ); } - if($orientation == "portrait"){ - shell_exec('lpr -o orientation-requested=4 ' . $source); + if($orientation === "portrait"){ + $filefullpath = \OC\Files\Filesystem::getLocalFile($sourcefile); + exec('lpr -o orientation-requested=4 ' . $filefullpath); return new JSONResponse( array( 'response' => 'success', diff --git a/screenshots/printer.gif b/screenshots/printer.gif new file mode 100644 index 0000000..b3d9a3d Binary files /dev/null and b/screenshots/printer.gif differ