🖼 Simple file viewer with slideshow for media
Перейти к файлу
John Molakvoæ 489ec1284b
Merge pull request #1336 from nextcloud/fix/hover-editor-vars
2022-08-17 22:35:16 +02:00
.github Update dependabot-approve-merge.yml 2022-08-03 14:27:12 +02:00
.tx Add transifex config 2019-03-06 23:58:22 +01:00
appinfo Update version on master 2022-04-15 06:23:09 +00:00
cypress Editor design fixes 2022-08-17 10:57:58 +02:00
img Fix player controls on Firefox 2020-10-03 12:16:42 -04:00
js Fix hover variables 2022-08-17 19:48:42 +00:00
l10n [tx-robot] updated from transifex 2022-08-09 03:31:26 +00:00
lib Update php styling for 7.4 2022-04-09 17:17:38 +02:00
src Fix hover variables 2022-08-17 19:48:42 +00:00
.editorconfig Viewer first commit 2019-02-21 21:45:35 +01:00
.eslintrc.js Comply to new addScript API 2021-12-01 17:47:11 +00:00
.gitattributes Remove ie and last 2 versions 2021-02-22 10:09:11 +01:00
.gitignore Add visual regression testing 2022-05-03 08:34:53 +02:00
.l10nignore Update .l10nignore to exclude bundled JS files 2020-09-15 12:34:31 +02:00
.npmignore Viewer first commit 2019-02-21 21:45:35 +01:00
.php-cs-fixer.dist.php Rename .php_cs.dist to .php-cs-fixer.dist.php 2022-02-28 09:23:02 +01:00
.stylelintignore Bump deps and audit fix 2022-01-04 07:26:06 +01:00
COPYING Viewer first commit 2019-02-21 21:45:35 +01:00
Makefile Remove test 2022-03-10 10:55:12 +01:00
README.md doc: open function with a destructuring object 2020-07-08 17:43:09 +02:00
babel.config.js Fix bundles 2021-07-26 21:56:17 +02:00
composer.json Merge branch 'master' into dependabot/composer/nextcloud/coding-standard-1.0.0 2022-02-28 10:17:28 +01:00
composer.lock build(deps-dev): bump phpunit/phpunit from 9.5.20 to 9.5.21 2022-06-21 16:17:51 +00:00
cypress.config.js Move to cypress 10 2022-07-01 17:45:53 +02:00
package-lock.json Merge pull request #1320 from nextcloud/dependabot/npm_and_yarn/nextcloud/webpack-vue-config-5.3.0 2022-08-17 13:21:53 +02:00
package.json Merge pull request #1320 from nextcloud/dependabot/npm_and_yarn/nextcloud/webpack-vue-config-5.3.0 2022-08-17 13:21:53 +02:00
stylelint.config.js Bump deps and use npm7 2021-06-16 08:54:20 +02:00
webpack.js Migrate to webpack5 and use our own vue-plyr fork 2021-03-29 13:11:25 +02:00

README.md

Files viewer for nextcloud

Show your latest holiday photos and videos like in the movies. Show a glimpse of your latest novel directly from your nextcloud. Choose the best GIF of your collection thanks to the direct view of your favorites files!

viewer

📋 Current support

  • Images
  • Videos

🏗 Development setup

  1. ☁ Clone this app into the apps folder of your Nextcloud: git clone https://github.com/nextcloud/viewer.git
  2. 👩‍💻 In the folder of the app, run the command make to install dependencies and build the Javascript.
  3. Enable the app through the app management of your Nextcloud
  4. 🎉 Partytime!

🧙 Advanced development stuff

To build the Javascript whenever you make changes, instead of the full make you can also run make build-js.

API

Add the viewer to your app

In php, on your page, emit the LoadViewer event. Check the documentation/tutorial for more info on this type of page controller sample.

use OCA\Viewer\Event\LoadViewer;
use OCP\AppFramework\Controller;
use OCP\AppFramework\Http\TemplateResponse;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\IRequest;

class PageController extends Controller {
	protected $appName;
	
	/** @var IEventDispatcher */
	private $eventDispatcher;
	
	public function __construct($appName,
								IRequest $request,
								IEventDispatcher $eventDispatcher) {
		parent::__construct($appName, $request);
	
		$this->appName = $appName;
		$this->eventDispatcher = $eventDispatcher;
	}

	/**
	 * @NoAdminRequired
	 * @NoCSRFRequired
	 * Render default index template
	 *
	 * @return TemplateResponse
	 */
	public function index(): TemplateResponse {
		$this->eventDispatcher->dispatch(LoadViewer::class, new LoadViewer());
		$response = new TemplateResponse($this->appName, 'main');
		return $response;
	}
}

This will load all the necessary scripts and make the Viewer accessible trough javascript at OCA.Viewer

Open a file

  1. Open a file and let the viewer fetch the folder data
OCA.Viewer.open({path: '/path/to/file.jpg'})
  1. Open a file and profide a list of files
OCA.Viewer.open({
  	path: '/path/to/file.jpg',
  	list: [
  		{
  			basename: 'file.jpg',
  			filename: '/path/to/file.jpg',
  			...
  		},
  		...
  	],
})

The list parameter requires an array of fileinfo. You can check how we generate a fileinfo object here from a dav PROPFIND request data. There is currently no dedicated package for it, but this is coming. You can check the photos repository where we also uses it.

Close the viewer

OCA.Viewer.close()

🔍 Add you own file view

If you want to make your app compatible with this app, you can use the OCA.Viewer methods

  1. Create a vue component which use the path and mime props (they will be automatically passed by the viewer)
  2. Register your mime viewer with the following:
     import VideoView from 'VideoView.vue'
    
     OCA.Viewer.registerHandler({
         // unique id
         id: 'video',
    
        // optional, it will group every view of this group and
        // use the proper view when building the file list
        // of the slideshow.
        // e.g. you open an image/jpeg that have the `media` group
        // you will be able to see the video/mpeg from the `video` handler
        // files that also have the `media` group set.
        group: 'media',
    
        // the list of mimes your component is able to display
        mimes: [
             'video/mpeg',
             'video/ogg',
             'video/webm',
             'video/mp4'
         ],
    
         // your vue component view
         component: VideoView
     })
    
  3. if you feel like your mime should be integrated on this repo, you can also create a pull request with your object on the models directory and the view on the components directory. Please have a look at what's already here and take example of it. 🙇‍♀️