Merge branch 'master' into stable24

old_stable24
Varun Patil 2022-10-31 21:07:03 -07:00
commit 7d21cd5053
9 changed files with 135 additions and 66 deletions

View File

@ -1,38 +1,39 @@
![Screenshot](appinfo/screenshot.jpg)
## Photo Viewer and Manager
# Memories: Photo Management for Nextcloud
![GitHub](https://img.shields.io/github/license/pulsejet/memories)
[![e2e](https://github.com/pulsejet/memories/actions/workflows/e2e.yaml/badge.svg)](https://github.com/pulsejet/memories/actions/workflows/e2e.yaml)
[![Demo](https://img.shields.io/badge/demo-online-blue)](https://memories-demo.radialapps.com/apps/memories/)
[![Gitter](https://img.shields.io/gitter/room/pulsejet/memories)](https://gitter.im/pulsejet/memories)
[![GitHub issues](https://img.shields.io/github/issues/pulsejet/memories)](https://github.com/pulsejet/memories/issues)
Memories is a photo management app for Nextcloud with advanced features including:
- **📸 Timeline**: Sort photos and videos by date taken, parsed from Exif data.
- **⏪ Rewind**: Jump to any time in the past instantly and relive your memories.
- **🤖 AI Tagging**: Group photos by people and objects using AI, powered by the [recognize](https://github.com/nextcloud/recognize) app.
- **🤖 AI Tagging**: Group photos by people and objects using AI, powered by [recognize](https://github.com/nextcloud/recognize).
- **🖼️ Albums**: Create albums to group photos and videos together. Then share these albums with others.
- **📁 Folders**: Browse your own and shared folders with a similar, efficient timeline.
- **🎦 Slideshow**: View photos from your timeline and folders easily.
- **📱 Mobile Support**: Works on devices of any shape and size through the web app.
- **✏️ Edit Metadata**: Edit Exif dates on photos quickly and easily.
- **📦 Archive**: Store photos you don't want to see in your timeline in a separate folder.
- **📷 RAW Support**: View RAW photos from your camera with the [Camera RAW Previews](https://apps.nextcloud.com/apps/camerarawpreviews) app.
- **🫱🏻‍🫲🏻 External Sharing**: Share photos and videos with people outside of your Nextcloud instance.
- **⚡️ Fast**: Memories is extremely fast. Period. More details below.
- **📱 Mobile Support**: Works on devices of any shape and size through the web app.
- **✏️ Edit Metadata**: Edit dates on photos quickly and easily.
- **📦 Archive**: Store photos you don't want to see in your timeline in a separate folder.
- **⚡️ Performance**: Memories is extremely fast.
To get an idea of what memories looks and feels like, check out the [public demo](https://memories-demo.radialapps.com/apps/memories/). Note that the demo is read-only and may be slow since it runs in a low-end free tier VM provided by [Oracle Cloud](https://www.oracle.com/cloud/free/). Photo credits go to [Unsplash](https://unsplash.com/) (for individual credits, refer to each folder).
## 🌐 Online Demo
## How to support development
- **🌟 Star this repository**: This is the easiest way to support the project and costs nothing.
- **🪲 Report bugs**: If you find a bug, please report it on the issue tracker.
- **📝 Contribute**: If you want to contribute, please read file / comment on an issue and ask for guidance.
- To get an idea of what memories looks and feels like, check out the [public demo](https://memories-demo.radialapps.com/apps/memories/).
- The demo is read-only and may be slow (free tier VM from [Oracle Cloud](https://www.oracle.com/cloud/free/)).
- Photo credits go to [Unsplash](https://unsplash.com/) (for individual credits, refer to each folder).
## 🚀 Installation
1. Install the app from the Nextcloud app store.
1. Perform the recommended [configuration steps](https://github.com/pulsejet/memories/wiki/Configuration).
1. Run `php ./occ memories:index` to generate metadata indices for existing photos.
1. Open the 📷 Memories app in Nextcloud and set the directory containing your photos. Photos from this directory will be displayed in the timeline, including any photos in nested subdirectories.
1. Installing the [preview generator](https://github.com/rullzer/previewgenerator) for pre-generating thumbnails is strongly recommended.
1. Open the 📷 Memories app in Nextcloud and set the directory containing your photos.
## 🏗 Development setup
## 🏗 Development Setup
1. ☁ Clone this into your `apps` folder of your Nextcloud.
1. 👩‍💻 In a terminal, run the command `make dev-setup` to install the dependencies.
@ -40,21 +41,11 @@ To get an idea of what memories looks and feels like, check out the [public demo
1. ✅ Enable the app through the app management of your Nextcloud.
1. ⚒️ (Strongly recommended) use VS Code and install Vetur and Prettier.
## ⚡ Performance
## How to support development
- Once properly configured, Memories is **extremely fast**, possibly one of the fastest web photo viewers.
- On a server with relatively cheap hardware (`Intel Pentium G6400 / 8GB RAM / SSD`), loading the timeline takes only `~400ms` without cache on a laptop (`Intel Core i5-1035G1 / Windows 11 / Chrome`) for a library of `~17000 photos` totaling `100GB`. The test was performed on Nextcloud 24 with `nginx`, `php-fpm` and `mariadb` running in Docker.
- For best performance, install the [preview generator](https://github.com/rullzer/previewgenerator) and make sure HTTP/2 is enabled for your Nextcloud instance.
## 📝 Notes
- You may need to configure the Nextcloud preview generator and Imagemagick / ffmpeg to support all types of images and videos (e.g. HEIC). If using the official docker image, add `OC\Preview\HEIC` to `enabledPreviewProviders` in your `config.php`.
- If local time is not found in the photo (especially for videos), the server timezone is used.
- All photos in the timeline _must_ be on a single storage. For example, you cannot have a mounted directory inside your photos directory.
- The app can work with external storage for photos. Just set the mountpoint as the timeline directory.
- If you add any photos from outside Nextcloud, you must run the scan and index commands.
- Indexing may be slow, since all files must be downloaded from the storage.
- The archive feature moves photos to a separate folder called `.archive` at the root of your timeline. You can use this, for example, to move these photos to a cold storage.
1. **🌟 Star this repository**: This is the easiest way to support the project and costs nothing.
1. **🪲 Report bugs**: If you find a bug, please report it on the issue tracker.
1. **📝 Contribute**: If you want to contribute, please read file / comment on an issue and ask for guidance.
## Special Thanks

View File

@ -11,25 +11,26 @@ Memories is a photo management app for Nextcloud with advanced features includin
- **📸 Timeline**: Sort photos and videos by date taken, parsed from Exif data.
- **⏪ Rewind**: Jump to any time in the past instantly and relive your memories.
- **🤖 AI Tagging**: Group photos by people and objects using AI, powered by the [recognize](https://github.com/nextcloud/recognize) app.
- **🤖 AI Tagging**: Group photos by people and objects using AI, powered by [recognize](https://github.com/nextcloud/recognize).
- **🖼️ Albums**: Create albums to group photos and videos together. Then share these albums with others.
- **📁 Folders**: Browse your own and shared folders with a similar, efficient timeline.
- **🎦 Slideshow**: View photos from your timeline and folders easily.
- **📱 Mobile Support**: Works on devices of any shape and size through the web app.
- **✏️ Edit Metadata**: Edit Exif dates on photos quickly and easily.
- **📦 Archive**: Store photos you don't want to see in your timeline in a separate folder.
- **📷 RAW Support**: View RAW photos from your camera with the [Camera RAW Previews](https://apps.nextcloud.com/apps/camerarawpreviews) app.
- **🫱🏻‍🫲🏻 External Sharing**: Share photos and videos with people outside of your Nextcloud instance.
- **⚡️ Fast**: Memories is extremely fast. Period.
- **📱 Mobile Support**: Works on devices of any shape and size through the web app.
- **✏️ Edit Metadata**: Edit dates on photos quickly and easily.
- **📦 Archive**: Store photos you don't want to see in your timeline in a separate folder.
- **⚡️ Performance**: Memories is extremely fast.
To get an idea of what memories looks and feels like, check out the [public demo](https://memories-demo.radialapps.com/apps/memories/). Note that the demo is read-only and may be slow since it runs in a low-end free tier VM provided by [Oracle Cloud](https://www.oracle.com/cloud/free/). Photo credits go to [Unsplash](https://unsplash.com/) (for individual credits, refer to each folder).
## 🌐 Online Demo
- To get an idea of what memories looks and feels like, check out the [public demo](https://memories-demo.radialapps.com/apps/memories/).
- The demo is read-only and may be slow (free tier VM from [Oracle Cloud](https://www.oracle.com/cloud/free/)).
- Photo credits go to [Unsplash](https://unsplash.com/) (for individual credits, refer to each folder).
## 🚀 Installation
1. Install the app from the Nextcloud app store
1. Install the app from the Nextcloud app store.
1. Perform the recommended [configuration steps](https://github.com/pulsejet/memories/wiki/Extra-Configuration).
1. Run `php ./occ memories:index` to generate metadata indices for existing photos.
1. Open the 📷 Memories app in Nextcloud and set the directory containing your photos. Photos from this directory will be displayed in the timeline, including any photos in nested subdirectories.
1. Installing the [preview generator](https://github.com/rullzer/previewgenerator) for pre-generating thumbnails is strongly recommended.
1. Open the 📷 Memories app in Nextcloud and set the directory containing your photos.
]]></description>
<version>3.5.2</version>
<licence>agpl</licence>

View File

@ -23,7 +23,7 @@ const CTE_FOLDERS = // CTE to get all folders recursively in the given top folde
*PREFIX*filecache f
INNER JOIN *PREFIX*cte_folders c
ON (f.parent = c.fileid
AND f.mimetype = 2
AND f.mimetype = (SELECT `id` FROM `*PREFIX*mimetypes` WHERE `mimetype` = "httpd/unix-directory")
AND f.fileid <> :excludedFolderId
)
)';

View File

@ -33,7 +33,7 @@ trait TimelineQueryTags
$query->innerJoin('m', 'systemtag_object_mapping', 'stom', $query->expr()->andX(
$query->expr()->eq('stom.objecttype', $query->createNamedParameter('files')),
$query->expr()->eq('stom.objectid', 'm.fileid'),
$query->expr()->eq('stom.objectid', 'm.objectid'),
$query->expr()->eq('stom.systemtagid', $query->createNamedParameter($tagId)),
));
}
@ -55,20 +55,10 @@ trait TimelineQueryTags
));
// WHERE these items are memories indexed photos
$query->innerJoin('stom', 'memories', 'm', $query->expr()->eq('m.fileid', 'stom.objectid'));
$query->innerJoin('stom', 'memories', 'm', $query->expr()->eq('m.objectid', 'stom.objectid'));
// WHERE these photos are in the user's requested folder recursively
// This is a hack to speed up the query instead of using joinFilecache
// The problem is objectid is VARCHAR(64) and fileid is BIGINT(20), so a
// join is extremely slow. Instead, we use a subquery to check existence.
//
// https://blog.sqlauthority.com/2010/06/05/sql-server-convert-in-to-exists-performance-talk/
$this->addSubfolderJoinParams($query, $folder, false);
$query->innerJoin('m', 'filecache', 'f', $query->expr()->andX(
$query->expr()->eq('f.fileid', 'm.fileid'),
$query->createFunction('EXISTS (SELECT 1 from *PREFIX*cte_folders WHERE *PREFIX*cte_folders.fileid = `f`.parent)')
));
$query = $this->joinFilecache($query, $folder, true, false);
// GROUP and ORDER by tag name
$query->groupBy('st.name');
@ -106,15 +96,10 @@ trait TimelineQueryTags
);
// WHERE these items are memories indexed photos
$query->innerJoin('stom', 'memories', 'm', $query->expr()->eq('m.fileid', 'stom.objectid'));
$query->innerJoin('stom', 'memories', 'm', $query->expr()->eq('m.objectid', 'stom.objectid'));
// WHERE these photos are in the user's requested folder recursively
// See the function above for an explanation of this hack
$this->addSubfolderJoinParams($query, $folder, false);
$query->innerJoin('m', 'filecache', 'f', $query->expr()->andX(
$query->expr()->eq('f.fileid', 'm.fileid'),
$query->createFunction('EXISTS (SELECT 1 from *PREFIX*cte_folders WHERE *PREFIX*cte_folders.fileid = `f`.parent)')
));
$query = $this->joinFilecache($query, $folder, true, false);
// MAX 4
$query->setMaxResults(4);

View File

@ -99,6 +99,7 @@ class TimelineWrite
if ($prevRow) {
// Update existing row
// No need to set objectid again
$query->update('memories')
->set('dayid', $query->createNamedParameter($dayId, IQueryBuilder::PARAM_INT))
->set('datetaken', $query->createNamedParameter($dateTaken, IQueryBuilder::PARAM_STR))
@ -115,6 +116,7 @@ class TimelineWrite
$query->insert('memories')
->values([
'fileid' => $query->createNamedParameter($fileId, IQueryBuilder::PARAM_INT),
'objectid' => $query->createNamedParameter((string) $fileId, IQueryBuilder::PARAM_STR),
'dayid' => $query->createNamedParameter($dayId, IQueryBuilder::PARAM_INT),
'datetaken' => $query->createNamedParameter($dateTaken, IQueryBuilder::PARAM_STR),
'mtime' => $query->createNamedParameter($mtime, IQueryBuilder::PARAM_INT),

View File

@ -0,0 +1,86 @@
<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2022 Your name <your@email.com>
* @author Your name <your@email.com>
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
namespace OCA\Memories\Migration;
use Closure;
use OCP\DB\ISchemaWrapper;
use OCP\IDBConnection;
use OCP\Migration\IOutput;
use OCP\Migration\SimpleMigrationStep;
/**
* Auto-generated migration step: Please modify to your needs!
*/
class Version400503Date20221101033144 extends SimpleMigrationStep
{
/** @var IDBConnection */
private $dbc;
public function __construct(IDBConnection $dbc)
{
$this->dbc = $dbc;
}
/**
* @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
*/
public function preSchemaChange(IOutput $output, Closure $schemaClosure, array $options): void
{
}
/**
* @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
*/
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper
{
/** @var ISchemaWrapper $schema */
$schema = $schemaClosure();
$table = $schema->getTable('memories');
// This is a hack to speed up the tags queries.
// The problem is objectid in systemtags is VARCHAR(64) while fileid in
// filecache and memories is BIGINT(20), so a join is extremely slow,
// because the entire tags table must be scanned for the conversion.
$table->addColumn('objectid', 'string', [
'notnull' => true,
'length' => 64,
'default' => '0', // set to real value in postSchemaChange
]);
$table->addIndex(['objectid'], 'memories_objectid_index');
return $schema;
}
/**
* @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
*/
public function postSchemaChange(IOutput $output, Closure $schemaClosure, array $options): void
{
// Update oc_memories to set objectid equal to fileid for all rows
$this->dbc->executeQuery('UPDATE *PREFIX*memories SET objectid = CAST(fileid AS CHAR)');
}
}

View File

@ -1,5 +1,6 @@
<template>
<router-link
draggable="false"
class="folder fill-block"
:class="{
hasPreview: previewFileInfos.length > 0,

View File

@ -20,8 +20,8 @@
<div
class="img-outer fill-block"
@click="emitClick"
@contextmenu="contextmenu"
@mousedown.passive="emitClick"
@touchstart.passive="touchstart"
@touchmove.passive="touchend"
@touchend.passive="touchend"
@ -30,6 +30,7 @@
<img
ref="img"
class="fill-block"
draggable="false"
:src="src"
:key="data.fileid"
@load="load"

View File

@ -1,5 +1,6 @@
<template>
<router-link
draggable="false"
class="tag fill-block"
:class="{
hasPreview: previews.length > 0,
@ -21,6 +22,7 @@
<div class="previews fill-block" ref="previews">
<div class="img-outer" v-for="info of previews" :key="info.fileid">
<img
draggable="false"
class="fill-block"
:class="{ error: info.flag & c.FLAG_LOAD_FAIL }"
:key="'fpreview-' + info.fileid"