Compare commits

..

4 Commits

6 changed files with 36 additions and 36 deletions

View File

@ -12,7 +12,7 @@ composer require aerex/baikal-storage-plugin
You can use the CLI to help you generate a config file or use the example configuration provided in the project. Make sure the file is *writable* by your webserver (e.g Apache, Nginx). You can use the CLI to help you generate a config file or use the example configuration provided in the project. Make sure the file is *writable* by your webserver (e.g Apache, Nginx).
### Use the CLI ### Use the CLI
Run the command `./vendor/bin/baikalstorage` and follow the instructions Run the command `./vendor/baikalstorage` and follow the instructions
### Manual ### Manual
Copy the `example-config.yaml` file and rename it to `config.yaml`. Copy the `example-config.yaml` file and rename it to `config.yaml`.

View File

@ -12,7 +12,7 @@
"repositories": [ "repositories": [
{ {
"type": "vcs", "type": "vcs",
"url": "https://github.com/Aerex/baikal-storage-plugin" "url": "https://git.aerex.me/Aerex/baikal-storage-plugin"
} }
], ],
"bin": [ "bin": [
@ -27,7 +27,7 @@
"laminas/laminas-stdlib": "^3.2", "laminas/laminas-stdlib": "^3.2",
"psr/container": "^1.0", "psr/container": "^1.0",
"symfony/config": "3.4", "symfony/config": "3.4",
"symfony/process": "^3.4|^4.0|^5.0", "symfony/process": "^3.4",
"monolog/monolog": "^2.0", "monolog/monolog": "^2.0",
"symfony/yaml": "~3.0|~4.0", "symfony/yaml": "~3.0|~4.0",
"symfony/console": "^3.4|^4.0|^5.0" "symfony/console": "^3.4|^4.0|^5.0"

View File

@ -47,12 +47,11 @@ class Plugin extends ServerPlugin {
function __construct($configFile){ function __construct($configFile){
$this->rawConfigs = $this->buildConfigurations($configFile); $this->rawConfigs = $this->buildConfigurations($configFile);
$this->storageManager = new StorageManager($this->rawConfigs); $this->storageManager = new StorageManager($this->rawConfigs);
$this->logger = new Logger($this->rawConfigs, 'BaikalStorage');
$this->initializeStorages($this->rawConfigs); $this->initializeStorages($this->rawConfigs);
} }
private function getDisplayName($path) { private function getDisplayName($path) {
// Remove filepath // Remove filepath (e.g Remove xxxx.ics from calendars/collection_name/xxxx.ics)
$urlParts = explode('/', $path); $urlParts = explode('/', $path);
$calendarUrl = implode('/', array_slice($urlParts, 0, sizeof($urlParts)-1)); $calendarUrl = implode('/', array_slice($urlParts, 0, sizeof($urlParts)-1));
@ -308,3 +307,4 @@ class Plugin extends ServerPlugin {
} }
} }

View File

@ -22,10 +22,6 @@ class StorageManager {
$this->configs = $configs; $this->configs = $configs;
} }
public function getStorages() {
return $this->storages;
}
public function fromStorageSource(Calendar $calendar) { public function fromStorageSource(Calendar $calendar) {
if (!isset($this->configs)) { if (!isset($this->configs)) {
throw new \Exception('StorageManager was not initialize or configs are not defined'); throw new \Exception('StorageManager was not initialize or configs are not defined');
@ -38,6 +34,9 @@ class StorageManager {
return false; return false;
} }
public function getStorages() {
return $this->storages;
}
public function getConfigs() { public function getConfigs() {
return $this->configs; return $this->configs;
@ -73,3 +72,4 @@ class StorageManager {
} }
} }
} }

View File

@ -11,3 +11,4 @@ interface IStorage {
public function getConfigBrowser(); public function getConfigBrowser();
public function updateConfigs($postData); public function updateConfigs($postData);
} }

View File

@ -179,7 +179,6 @@ class Taskwarrior implements IStorage {
if (!isset($c->VTODO)){ if (!isset($c->VTODO)){
throw new \Exception('Calendar event does not contain VTODO'); throw new \Exception('Calendar event does not contain VTODO');
} }
$this->logger->info(sprintf('Executing on calendar %s', $displayname));
$this->logger->info(json_encode($c->jsonSerialize())); $this->logger->info(json_encode($c->jsonSerialize()));
$this->refresh(); $this->refresh();
$task = $this->vObjectToTask($c->VTODO, $displayname); $task = $this->vObjectToTask($c->VTODO, $displayname);
@ -207,7 +206,6 @@ class Taskwarrior implements IStorage {
} }
$task = $this->tasks[(string)$uid]; $task = $this->tasks[(string)$uid];
if (isset($task) && $task['status'] !== 'deleted') { if (isset($task) && $task['status'] !== 'deleted') {
$this->logger->info(sprintf('Deleting iCal %s from taskwarrior', $uid));
$uuid = $task['uuid']; $uuid = $task['uuid'];
$this->logger->info( $this->logger->info(
sprintf('Executing TASKRC = %s TASKDATA = %s task delete %s', $this->configs['taskrc'], $this->configs['taskdata'], $uuid) sprintf('Executing TASKRC = %s TASKDATA = %s task delete %s', $this->configs['taskrc'], $this->configs['taskdata'], $uuid)
@ -227,5 +225,6 @@ class Taskwarrior implements IStorage {
$this->logger->error($e->getTraceAsString()); $this->logger->error($e->getTraceAsString());
throw $e; throw $e;
} }
} }
} }