Change project name

pull/37/head
Varun Patil 2022-08-16 01:19:43 +00:00
parent 6f029fd49a
commit 2de33bff69
21 changed files with 70 additions and 57370 deletions

View File

@ -1,4 +1,4 @@
# Better Photos # Polaroid
Place this app in **nextcloud/apps/** Place this app in **nextcloud/apps/**
## Building the app ## Building the app

View File

@ -1,26 +1,26 @@
<?xml version="1.0"?> <?xml version="1.0"?>
<info xmlns:xsi= "http://www.w3.org/2001/XMLSchema-instance" <info xmlns:xsi= "http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://apps.nextcloud.com/schema/apps/info.xsd"> xsi:noNamespaceSchemaLocation="https://apps.nextcloud.com/schema/apps/info.xsd">
<id>betterphotos</id> <id>polaroid</id>
<name>Better Photos</name> <name>Polaroid</name>
<summary>Better Photos App</summary> <summary>Polaroid App</summary>
<description><![CDATA[p]]></description> <description><![CDATA[p]]></description>
<version>0.0.1</version> <version>0.0.1</version>
<licence>agpl</licence> <licence>agpl</licence>
<author mail="radialapps@gmail.com" >Varun Patil</author> <author mail="radialapps@gmail.com" >Varun Patil</author>
<namespace>BetterPhotos</namespace> <namespace>Polaroid</namespace>
<category>organization</category> <category>organization</category>
<bugs>https://github.com</bugs> <bugs>https://github.com</bugs>
<dependencies> <dependencies>
<nextcloud min-version="22" max-version="24"/> <nextcloud min-version="22" max-version="24"/>
</dependencies> </dependencies>
<commands> <commands>
<command>OCA\BetterPhotos\Command\Index</command> <command>OCA\Polaroid\Command\Index</command>
</commands> </commands>
<navigations> <navigations>
<navigation> <navigation>
<name>Better Photos</name> <name>Polaroid</name>
<route>betterphotos.page.index</route> <route>polaroid.page.index</route>
</navigation> </navigation>
</navigations> </navigations>
</info> </info>

View File

@ -1,5 +1,5 @@
{ {
"name": "Better Photos", "name": "Polaroid",
"description": "p", "description": "p",
"type": "project", "type": "project",
"license": "AGPL", "license": "AGPL",

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -24,10 +24,10 @@ declare(strict_types=1);
* *
*/ */
namespace OCA\BetterPhotos\AppInfo; namespace OCA\Polaroid\AppInfo;
use OCA\BetterPhotos\Listeners\PostWriteListener; use OCA\Polaroid\Listeners\PostWriteListener;
use OCA\BetterPhotos\Listeners\PostDeleteListener; use OCA\Polaroid\Listeners\PostDeleteListener;
use OCP\AppFramework\App; use OCP\AppFramework\App;
use OCP\AppFramework\Bootstrap\IBootContext; use OCP\AppFramework\Bootstrap\IBootContext;
use OCP\AppFramework\Bootstrap\IBootstrap; use OCP\AppFramework\Bootstrap\IBootstrap;
@ -37,7 +37,7 @@ use OCP\Files\Events\Node\NodeDeletedEvent;
use OCP\Files\Events\Node\NodeTouchedEvent; use OCP\Files\Events\Node\NodeTouchedEvent;
class Application extends App implements IBootstrap { class Application extends App implements IBootstrap {
public const APPNAME = 'betterphotos'; public const APPNAME = 'polaroid';
public const IMAGE_MIMES = [ public const IMAGE_MIMES = [
'image/png', 'image/png',

View File

@ -24,7 +24,7 @@ declare(strict_types=1);
* *
*/ */
namespace OCA\BetterPhotos\Command; namespace OCA\Polaroid\Command;
use OCP\Encryption\IManager; use OCP\Encryption\IManager;
use OCP\Files\File; use OCP\Files\File;
@ -58,7 +58,7 @@ class Index extends Command {
protected OutputInterface $output; protected OutputInterface $output;
protected IManager $encryptionManager; protected IManager $encryptionManager;
protected IDBConnection $connection; protected IDBConnection $connection;
protected \OCA\BetterPhotos\Db\Util $util; protected \OCA\Polaroid\Db\Util $util;
public function __construct(IRootFolder $rootFolder, public function __construct(IRootFolder $rootFolder,
IUserManager $userManager, IUserManager $userManager,
@ -75,7 +75,7 @@ class Index extends Command {
$this->config = $config; $this->config = $config;
$this->encryptionManager = $encryptionManager; $this->encryptionManager = $encryptionManager;
$this->connection = $connection; $this->connection = $connection;
$this->util = new \OCA\BetterPhotos\Db\Util($connection); $this->util = new \OCA\Polaroid\Db\Util($connection);
try { try {
$this->globalService = $container->get(GlobalStoragesService::class); $this->globalService = $container->get(GlobalStoragesService::class);
@ -86,7 +86,7 @@ class Index extends Command {
protected function configure(): void { protected function configure(): void {
$this $this
->setName('betterphotos:index') ->setName('polaroid:index')
->setDescription('Generate entries'); ->setDescription('Generate entries');
} }

View File

@ -23,9 +23,9 @@ declare(strict_types=1);
* *
*/ */
namespace OCA\BetterPhotos\Controller; namespace OCA\Polaroid\Controller;
use OCA\BetterPhotos\AppInfo\Application; use OCA\Polaroid\AppInfo\Application;
use OCP\AppFramework\Controller; use OCP\AppFramework\Controller;
use OCP\AppFramework\Http; use OCP\AppFramework\Http;
use OCP\AppFramework\Http\JSONResponse; use OCP\AppFramework\Http\JSONResponse;
@ -40,7 +40,7 @@ class ApiController extends Controller {
private IConfig $config; private IConfig $config;
private IUserSession $userSession; private IUserSession $userSession;
private IDBConnection $connection; private IDBConnection $connection;
private \OCA\BetterPhotos\Db\Util $util; private \OCA\Polaroid\Db\Util $util;
public function __construct( public function __construct(
IRequest $request, IRequest $request,
@ -53,7 +53,7 @@ class ApiController extends Controller {
$this->config = $config; $this->config = $config;
$this->userSession = $userSession; $this->userSession = $userSession;
$this->connection = $connection; $this->connection = $connection;
$this->util = new \OCA\BetterPhotos\Db\Util($this->connection); $this->util = new \OCA\Polaroid\Db\Util($this->connection);
} }
/** /**

View File

@ -1,5 +1,5 @@
<?php <?php
namespace OCA\BetterPhotos\Controller; namespace OCA\Polaroid\Controller;
use OCP\IRequest; use OCP\IRequest;
use OCP\AppFramework\Http\TemplateResponse; use OCP\AppFramework\Http\TemplateResponse;
@ -30,7 +30,7 @@ class PageController extends Controller {
* @NoCSRFRequired * @NoCSRFRequired
*/ */
public function index() { public function index() {
Util::addScript($this->appName, 'betterphotos-main'); Util::addScript($this->appName, 'polaroid-main');
Util::addStyle($this->appName, 'icons'); Util::addStyle($this->appName, 'icons');
$this->eventDispatcher->dispatchTyped(new LoadViewer()); $this->eventDispatcher->dispatchTyped(new LoadViewer());

View File

@ -1,9 +1,9 @@
<?php <?php
declare(strict_types=1); declare(strict_types=1);
namespace OCA\BetterPhotos\Db; namespace OCA\Polaroid\Db;
use OCA\BetterPhotos\AppInfo\Application; use OCA\Polaroid\AppInfo\Application;
use OCP\Files\File; use OCP\Files\File;
use OCP\IDBConnection; use OCP\IDBConnection;
@ -56,7 +56,7 @@ class Util {
$dayId = floor($dateTaken / 86400); $dayId = floor($dateTaken / 86400);
// Get existing entry // Get existing entry
$sql = 'SELECT * FROM oc_betterphotos WHERE $sql = 'SELECT * FROM oc_polaroid WHERE
user_id = ? AND file_id = ?'; user_id = ? AND file_id = ?';
$res = $this->connection->executeQuery($sql, [ $res = $this->connection->executeQuery($sql, [
$user, $fileId, $user, $fileId,
@ -66,12 +66,12 @@ class Util {
// Insert or update file // Insert or update file
if ($exists) { if ($exists) {
$sql = 'UPDATE oc_betterphotos SET $sql = 'UPDATE oc_polaroid SET
day_id = ?, date_taken = ?, is_video = ? day_id = ?, date_taken = ?, is_video = ?
WHERE user_id = ? AND file_id = ?'; WHERE user_id = ? AND file_id = ?';
} else { } else {
$sql = 'INSERT $sql = 'INSERT
INTO oc_betterphotos (day_id, date_taken, is_video, user_id, file_id) INTO oc_polaroid (day_id, date_taken, is_video, user_id, file_id)
VALUES (?, ?, ?, ?, ?)'; VALUES (?, ?, ?, ?, ?)';
} }
$res = $this->connection->executeStatement($sql, [ $res = $this->connection->executeStatement($sql, [
@ -88,7 +88,7 @@ class Util {
// Update day table // Update day table
if (!$exists || $dayChange) { if (!$exists || $dayChange) {
$sql = 'INSERT $sql = 'INSERT
INTO oc_betterphotos_day (user_id, day_id, count) INTO oc_polaroid_day (user_id, day_id, count)
VALUES (?, ?, 1) VALUES (?, ?, 1)
ON DUPLICATE KEY ON DUPLICATE KEY
UPDATE count = count + 1'; UPDATE count = count + 1';
@ -97,7 +97,7 @@ class Util {
]); ]);
if ($dayChange) { if ($dayChange) {
$sql = 'UPDATE oc_betterphotos_day SET $sql = 'UPDATE oc_polaroid_day SET
count = count - 1 count = count - 1
WHERE user_id = ? AND day_id = ?'; WHERE user_id = ? AND day_id = ?';
$this->connection->executeStatement($sql, [ $this->connection->executeStatement($sql, [
@ -111,7 +111,7 @@ class Util {
public function deleteFile(File $file) { public function deleteFile(File $file) {
$sql = 'DELETE $sql = 'DELETE
FROM oc_betterphotos FROM oc_polaroid
WHERE file_id = ? WHERE file_id = ?
RETURNING *'; RETURNING *';
$res = $this->connection->executeQuery($sql, [$file->getId()], [\PDO::PARAM_INT]); $res = $this->connection->executeQuery($sql, [$file->getId()], [\PDO::PARAM_INT]);
@ -120,7 +120,7 @@ class Util {
foreach ($rows as $row) { foreach ($rows as $row) {
$dayId = $row['day_id']; $dayId = $row['day_id'];
$userId = $row['user_id']; $userId = $row['user_id'];
$sql = 'UPDATE oc_betterphotos_day $sql = 'UPDATE oc_polaroid_day
SET count = count - 1 SET count = count - 1
WHERE user_id = ? AND day_id = ?'; WHERE user_id = ? AND day_id = ?';
$this->connection->executeStatement($sql, [$userId, $dayId], [ $this->connection->executeStatement($sql, [$userId, $dayId], [
@ -134,7 +134,7 @@ class Util {
): array { ): array {
$qb = $this->connection->getQueryBuilder(); $qb = $this->connection->getQueryBuilder();
$qb->select('day_id', 'count') $qb->select('day_id', 'count')
->from('betterphotos_day') ->from('polaroid_day')
->where($qb->expr()->eq('user_id', $qb->createNamedParameter($user))) ->where($qb->expr()->eq('user_id', $qb->createNamedParameter($user)))
->orderBy('day_id', 'DESC'); ->orderBy('day_id', 'DESC');
$result = $qb->executeQuery(); $result = $qb->executeQuery();
@ -147,9 +147,9 @@ class Util {
int $dayId, int $dayId,
): array { ): array {
$sql = 'SELECT file_id, oc_filecache.etag, is_video $sql = 'SELECT file_id, oc_filecache.etag, is_video
FROM oc_betterphotos FROM oc_polaroid
LEFT JOIN oc_filecache LEFT JOIN oc_filecache
ON oc_filecache.fileid = oc_betterphotos.file_id ON oc_filecache.fileid = oc_polaroid.file_id
WHERE user_id = ? AND day_id = ? WHERE user_id = ? AND day_id = ?
ORDER BY date_taken DESC'; ORDER BY date_taken DESC';
$rows = $this->connection->executeQuery($sql, [$user, $dayId], [ $rows = $this->connection->executeQuery($sql, [$user, $dayId], [

View File

@ -21,7 +21,7 @@ declare(strict_types=1);
* *
*/ */
namespace OCA\BetterPhotos\Listeners; namespace OCA\Polaroid\Listeners;
use OCP\EventDispatcher\Event; use OCP\EventDispatcher\Event;
use OCP\EventDispatcher\IEventListener; use OCP\EventDispatcher\IEventListener;
@ -31,11 +31,11 @@ use OCP\IPreview;
use OCP\IDBConnection; use OCP\IDBConnection;
class PostDeleteListener implements IEventListener { class PostDeleteListener implements IEventListener {
private \OCA\BetterPhotos\Db\Util $util; private \OCA\Polaroid\Db\Util $util;
public function __construct(IDBConnection $connection, public function __construct(IDBConnection $connection,
IPreview $previewGenerator) { IPreview $previewGenerator) {
$this->util = new \OCA\BetterPhotos\Db\Util($previewGenerator, $connection); $this->util = new \OCA\Polaroid\Db\Util($previewGenerator, $connection);
} }
public function handle(Event $event): void { public function handle(Event $event): void {

View File

@ -21,7 +21,7 @@ declare(strict_types=1);
* *
*/ */
namespace OCA\BetterPhotos\Listeners; namespace OCA\Polaroid\Listeners;
use OCP\EventDispatcher\Event; use OCP\EventDispatcher\Event;
use OCP\EventDispatcher\IEventListener; use OCP\EventDispatcher\IEventListener;
@ -33,12 +33,12 @@ use OCP\IUserManager;
class PostWriteListener implements IEventListener { class PostWriteListener implements IEventListener {
private IUserManager $userManager; private IUserManager $userManager;
private \OCA\BetterPhotos\Db\Util $util; private \OCA\Polaroid\Db\Util $util;
public function __construct(IDBConnection $connection, public function __construct(IDBConnection $connection,
IUserManager $userManager) { IUserManager $userManager) {
$this->userManager = $userManager; $this->userManager = $userManager;
$this->util = new \OCA\BetterPhotos\Db\Util($connection); $this->util = new \OCA\Polaroid\Db\Util($connection);
} }
public function handle(Event $event): void { public function handle(Event $event): void {

View File

@ -1,6 +1,6 @@
<?php <?php
namespace OCA\BetterPhotos\Migration; namespace OCA\Polaroid\Migration;
use Closure; use Closure;
use OCP\DB\Types; use OCP\DB\Types;
@ -20,8 +20,8 @@
/** @var ISchemaWrapper $schema */ /** @var ISchemaWrapper $schema */
$schema = $schemaClosure(); $schema = $schemaClosure();
if (!$schema->hasTable('betterphotos')) { if (!$schema->hasTable('polaroid')) {
$table = $schema->createTable('betterphotos'); $table = $schema->createTable('polaroid');
$table->addColumn('id', 'integer', [ $table->addColumn('id', 'integer', [
'autoincrement' => true, 'autoincrement' => true,
'notnull' => true, 'notnull' => true,
@ -46,13 +46,13 @@
]); ]);
$table->setPrimaryKey(['id']); $table->setPrimaryKey(['id']);
$table->addIndex(['user_id'], 'betterphotos_user_id_index'); $table->addIndex(['user_id'], 'polaroid_user_id_index');
$table->addIndex(['day_id'], 'betterphotos_day_id_index'); $table->addIndex(['day_id'], 'polaroid_day_id_index');
$table->addUniqueIndex(['user_id', 'file_id'], 'betterphotos_day_uf_ui'); $table->addUniqueIndex(['user_id', 'file_id'], 'polaroid_day_uf_ui');
} }
if (!$schema->hasTable('betterphotos_day')) { if (!$schema->hasTable('polaroid_day')) {
$table = $schema->createTable('betterphotos_day'); $table = $schema->createTable('polaroid_day');
$table->addColumn('id', 'integer', [ $table->addColumn('id', 'integer', [
'autoincrement' => true, 'autoincrement' => true,
'notnull' => true, 'notnull' => true,
@ -70,8 +70,8 @@
]); ]);
$table->setPrimaryKey(['id']); $table->setPrimaryKey(['id']);
$table->addIndex(['user_id'], 'betterphotos_day_user_id_index'); $table->addIndex(['user_id'], 'polaroid_day_user_id_index');
$table->addUniqueIndex(['user_id', 'day_id'], 'betterphotos_day_ud_ui'); $table->addUniqueIndex(['user_id', 'day_id'], 'polaroid_day_ud_ui');
} }
return $schema; return $schema;

4
package-lock.json generated
View File

@ -1,11 +1,11 @@
{ {
"name": "betterphotos", "name": "polaroid",
"version": "0.0.0", "version": "0.0.0",
"lockfileVersion": 2, "lockfileVersion": 2,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "betterphotos", "name": "polaroid",
"version": "0.0.0", "version": "0.0.0",
"license": "agpl", "license": "agpl",
"dependencies": { "dependencies": {

View File

@ -1,5 +1,5 @@
{ {
"name": "betterphotos", "name": "polaroid",
"description": "A better photos app", "description": "A better photos app",
"version": "0.0.0", "version": "0.0.0",
"author": "Varun Patil <radialapps@gmail.com>", "author": "Varun Patil <radialapps@gmail.com>",
@ -13,13 +13,13 @@
"vuejs" "vuejs"
], ],
"bugs": { "bugs": {
"url": "https://github.com/pulsejet/betterphotos/issues" "url": "https://github.com/pulsejet/polaroid/issues"
}, },
"repository": { "repository": {
"url": "https://github.com/pulsejet/betterphotos.git", "url": "https://github.com/pulsejet/polaroid.git",
"type": "git" "type": "git"
}, },
"homepage": "https://github.com/pulsejet/betterphotos", "homepage": "https://github.com/pulsejet/polaroid",
"license": "agpl", "license": "agpl",
"private": true, "private": true,
"scripts": { "scripts": {

View File

@ -1,7 +1,7 @@
<template> <template>
<Content app-name="betterphotos"> <Content app-name="polaroid">
<AppNavigation> <AppNavigation>
<template id="app-betterphotos-navigation" #list> <template id="app-polaroid-navigation" #list>
<AppNavigationItem :to="{name: 'timeline'}" <AppNavigationItem :to="{name: 'timeline'}"
class="app-navigation__photos" class="app-navigation__photos"
:title="t('timeline', 'Timeline')" :title="t('timeline', 'Timeline')"

View File

@ -163,7 +163,7 @@ export default {
/** Fetch timeline main call */ /** Fetch timeline main call */
async fetchDays() { async fetchDays() {
const res = await fetch('/apps/betterphotos/api/days'); const res = await fetch('/apps/polaroid/api/days');
const data = await res.json(); const data = await res.json();
this.days = data; this.days = data;
@ -235,7 +235,7 @@ export default {
let data = []; let data = [];
try { try {
const res = await fetch(`/apps/betterphotos/api/days/${dayId}`); const res = await fetch(`/apps/polaroid/api/days/${dayId}`);
data = await res.json(); data = await res.json();
this.days.find(d => d.day_id === dayId).detail = data; this.days.find(d => d.day_id === dayId).detail = data;
} catch (e) { } catch (e) {

View File

@ -43,7 +43,7 @@
mode: 'history', mode: 'history',
// if index.php is in the url AND we got this far, then it's working: // if index.php is in the url AND we got this far, then it's working:
// let's keep using index.php in the url // let's keep using index.php in the url
base: generateUrl('/apps/betterphotos', ''), base: generateUrl('/apps/polaroid', ''),
linkActiveClass: 'active', linkActiveClass: 'active',
routes: [ routes: [
{ {

View File

@ -1,6 +1,6 @@
<?php <?php
namespace OCA\BetterPhotos\Tests\Integration\Controller; namespace OCA\Polaroid\Tests\Integration\Controller;
use OCP\AppFramework\App; use OCP\AppFramework\App;
use Test\TestCase; use Test\TestCase;
@ -17,13 +17,13 @@ class AppTest extends TestCase {
public function setUp() { public function setUp() {
parent::setUp(); parent::setUp();
$app = new App('betterphotos'); $app = new App('polaroid');
$this->container = $app->getContainer(); $this->container = $app->getContainer();
} }
public function testAppInstalled() { public function testAppInstalled() {
$appManager = $this->container->query('OCP\App\IAppManager'); $appManager = $this->container->query('OCP\App\IAppManager');
$this->assertTrue($appManager->isInstalled('betterphotos')); $this->assertTrue($appManager->isInstalled('polaroid'));
} }
} }

View File

@ -1,12 +1,12 @@
<?php <?php
namespace OCA\BetterPhotos\Tests\Unit\Controller; namespace OCA\Polaroid\Tests\Unit\Controller;
use PHPUnit_Framework_TestCase; use PHPUnit_Framework_TestCase;
use OCP\AppFramework\Http\TemplateResponse; use OCP\AppFramework\Http\TemplateResponse;
use OCA\BetterPhotos\Controller\PageController; use OCA\Polaroid\Controller\PageController;
class PageControllerTest extends PHPUnit_Framework_TestCase { class PageControllerTest extends PHPUnit_Framework_TestCase {
@ -17,7 +17,7 @@ class PageControllerTest extends PHPUnit_Framework_TestCase {
$request = $this->getMockBuilder('OCP\IRequest')->getMock(); $request = $this->getMockBuilder('OCP\IRequest')->getMock();
$this->controller = new PageController( $this->controller = new PageController(
'betterphotos', $request, $this->userId 'polaroid', $request, $this->userId
); );
} }

View File

@ -9,8 +9,8 @@ require_once __DIR__.'/../../../lib/base.php';
// Fix for "Autoload path not allowed: .../tests/lib/testcase.php" // Fix for "Autoload path not allowed: .../tests/lib/testcase.php"
\OC::$loader->addValidRoot(OC::$SERVERROOT . '/tests'); \OC::$loader->addValidRoot(OC::$SERVERROOT . '/tests');
// Fix for "Autoload path not allowed: .../betterphotos/tests/testcase.php" // Fix for "Autoload path not allowed: .../polaroid/tests/testcase.php"
\OC_App::loadApp('betterphotos'); \OC_App::loadApp('polaroid');
if(!class_exists('PHPUnit_Framework_TestCase')) { if(!class_exists('PHPUnit_Framework_TestCase')) {
require_once('PHPUnit/Autoload.php'); require_once('PHPUnit/Autoload.php');