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/**
## Building the app

View File

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

View File

@ -1,5 +1,5 @@
{
"name": "Better Photos",
"name": "Polaroid",
"description": "p",
"type": "project",
"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\BetterPhotos\Listeners\PostDeleteListener;
use OCA\Polaroid\Listeners\PostWriteListener;
use OCA\Polaroid\Listeners\PostDeleteListener;
use OCP\AppFramework\App;
use OCP\AppFramework\Bootstrap\IBootContext;
use OCP\AppFramework\Bootstrap\IBootstrap;
@ -37,7 +37,7 @@ use OCP\Files\Events\Node\NodeDeletedEvent;
use OCP\Files\Events\Node\NodeTouchedEvent;
class Application extends App implements IBootstrap {
public const APPNAME = 'betterphotos';
public const APPNAME = 'polaroid';
public const IMAGE_MIMES = [
'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\Files\File;
@ -58,7 +58,7 @@ class Index extends Command {
protected OutputInterface $output;
protected IManager $encryptionManager;
protected IDBConnection $connection;
protected \OCA\BetterPhotos\Db\Util $util;
protected \OCA\Polaroid\Db\Util $util;
public function __construct(IRootFolder $rootFolder,
IUserManager $userManager,
@ -75,7 +75,7 @@ class Index extends Command {
$this->config = $config;
$this->encryptionManager = $encryptionManager;
$this->connection = $connection;
$this->util = new \OCA\BetterPhotos\Db\Util($connection);
$this->util = new \OCA\Polaroid\Db\Util($connection);
try {
$this->globalService = $container->get(GlobalStoragesService::class);
@ -86,7 +86,7 @@ class Index extends Command {
protected function configure(): void {
$this
->setName('betterphotos:index')
->setName('polaroid:index')
->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\Http;
use OCP\AppFramework\Http\JSONResponse;
@ -40,7 +40,7 @@ class ApiController extends Controller {
private IConfig $config;
private IUserSession $userSession;
private IDBConnection $connection;
private \OCA\BetterPhotos\Db\Util $util;
private \OCA\Polaroid\Db\Util $util;
public function __construct(
IRequest $request,
@ -53,7 +53,7 @@ class ApiController extends Controller {
$this->config = $config;
$this->userSession = $userSession;
$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
namespace OCA\BetterPhotos\Controller;
namespace OCA\Polaroid\Controller;
use OCP\IRequest;
use OCP\AppFramework\Http\TemplateResponse;
@ -30,7 +30,7 @@ class PageController extends Controller {
* @NoCSRFRequired
*/
public function index() {
Util::addScript($this->appName, 'betterphotos-main');
Util::addScript($this->appName, 'polaroid-main');
Util::addStyle($this->appName, 'icons');
$this->eventDispatcher->dispatchTyped(new LoadViewer());

View File

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

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\IEventListener;
@ -33,12 +33,12 @@ use OCP\IUserManager;
class PostWriteListener implements IEventListener {
private IUserManager $userManager;
private \OCA\BetterPhotos\Db\Util $util;
private \OCA\Polaroid\Db\Util $util;
public function __construct(IDBConnection $connection,
IUserManager $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 {

View File

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

4
package-lock.json generated
View File

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

View File

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

View File

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

View File

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

View File

@ -43,7 +43,7 @@
mode: 'history',
// 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
base: generateUrl('/apps/betterphotos', ''),
base: generateUrl('/apps/polaroid', ''),
linkActiveClass: 'active',
routes: [
{

View File

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

View File

@ -1,12 +1,12 @@
<?php
namespace OCA\BetterPhotos\Tests\Unit\Controller;
namespace OCA\Polaroid\Tests\Unit\Controller;
use PHPUnit_Framework_TestCase;
use OCP\AppFramework\Http\TemplateResponse;
use OCA\BetterPhotos\Controller\PageController;
use OCA\Polaroid\Controller\PageController;
class PageControllerTest extends PHPUnit_Framework_TestCase {
@ -17,7 +17,7 @@ class PageControllerTest extends PHPUnit_Framework_TestCase {
$request = $this->getMockBuilder('OCP\IRequest')->getMock();
$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"
\OC::$loader->addValidRoot(OC::$SERVERROOT . '/tests');
// Fix for "Autoload path not allowed: .../betterphotos/tests/testcase.php"
\OC_App::loadApp('betterphotos');
// Fix for "Autoload path not allowed: .../polaroid/tests/testcase.php"
\OC_App::loadApp('polaroid');
if(!class_exists('PHPUnit_Framework_TestCase')) {
require_once('PHPUnit/Autoload.php');