diff --git a/CHANGELOG.md b/CHANGELOG.md index 6e6c3ad02..33aef6aa3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -35,6 +35,8 @@ [#402](https://github.com/nextcloud/cookbook/pull/402/) @seyfeb - Allow checking of ingredients in web UI [#393](https://github.com/nextcloud/cookbook/pull/393) @christianlupus +- Support for dateCreated and dateModified field of schema.org Recipe + [#377](https://github.com/nextcloud/cookbook/pull/366/) @seyfeb ### Changed - Switch of project ownership to neextcloud organization in GitHub diff --git a/l10n/de.js b/l10n/de.js index 119926245..8b389068e 100644 --- a/l10n/de.js +++ b/l10n/de.js @@ -64,6 +64,8 @@ OC.L10N.register( "Loading recipe failed" : "Laden des Rezepts fehlgeschlagen", "Recipe could not be saved" : "Rezept konnte nicht gespeichert werden", "Cooking time is up!" : "Die Kochzeit ist vorbei!", - "Source" : "Quelle" + "Source" : "Quelle", + "Date created" : "Erzeugt am", + "Last modified" : "Zuletzt geändert" }, "nplurals=2; plural=(n != 1);"); diff --git a/l10n/de.json b/l10n/de.json index dc81ed17c..f7b52e8a9 100644 --- a/l10n/de.json +++ b/l10n/de.json @@ -62,6 +62,8 @@ "Loading recipe failed" : "Laden des Rezepts fehlgeschlagen", "Recipe could not be saved" : "Rezept konnte nicht gespeichert werden", "Cooking time is up!" : "Die Kochzeit ist vorbei!", - "Source" : "Quelle" + "Source" : "Quelle", + "Date created" : "Erzeugt am", + "Last modified" : "Zuletzt geändert" },"pluralForm" :"nplurals=2; plural=(n != 1);" } \ No newline at end of file diff --git a/l10n/de_DE.js b/l10n/de_DE.js index dbc07faf7..e7ef968f2 100644 --- a/l10n/de_DE.js +++ b/l10n/de_DE.js @@ -64,6 +64,8 @@ OC.L10N.register( "Loading recipe failed" : "Laden des Rezepts fehlgeschlagen", "Recipe could not be saved" : "Rezept konnte nicht gespeichert werden", "Cooking time is up!" : "Die Kochzeit ist vorbei!", - "Source" : "Quelle" + "Source" : "Quelle", + "Date created" : "Erzeugt am", + "Last modified" : "Zuletzt geändert" }, "nplurals=2; plural=(n != 1);"); diff --git a/l10n/de_DE.json b/l10n/de_DE.json index 6fdbcd44e..d961698d5 100644 --- a/l10n/de_DE.json +++ b/l10n/de_DE.json @@ -62,6 +62,8 @@ "Loading recipe failed" : "Laden des Rezepts fehlgeschlagen", "Recipe could not be saved" : "Rezept konnte nicht gespeichert werden", "Cooking time is up!" : "Die Kochzeit ist vorbei!", - "Source" : "Quelle" -},"pluralForm" :"nplurals=2; plural=(n != 1);" + "Source" : "Quelle", + "Date created" : "Erzeugt am", + "Last modified" : "Zuletzt geändert" + },"pluralForm" :"nplurals=2; plural=(n != 1);" } \ No newline at end of file diff --git a/l10n/en_GB.js b/l10n/en_GB.js index 4bc0e4a6d..94c96ba98 100644 --- a/l10n/en_GB.js +++ b/l10n/en_GB.js @@ -64,6 +64,8 @@ OC.L10N.register( "Loading recipe failed" : "Loading recipe failed", "Recipe could not be saved" : "Recipe could not be saved", "Cooking time is up!" : "Cooking time is up!", - "Source" : "Source" + "Source" : "Source", + "Date created" : "Date created", + "Last modified" : "Last modified" }, "nplurals=2; plural=(n != 1);"); diff --git a/l10n/en_GB.json b/l10n/en_GB.json index deb11608a..debd72fe0 100644 --- a/l10n/en_GB.json +++ b/l10n/en_GB.json @@ -62,6 +62,8 @@ "Loading recipe failed" : "Loading recipe failed", "Recipe could not be saved" : "Recipe could not be saved", "Cooking time is up!" : "Cooking time is up!", - "Source" : "Source" -},"pluralForm" :"nplurals=2; plural=(n != 1);" + "Source" : "Source", + "Date created" : "Date created", + "Last modified" : "Last modified" + },"pluralForm" :"nplurals=2; plural=(n != 1);" } \ No newline at end of file diff --git a/lib/Service/RecipeService.php b/lib/Service/RecipeService.php index a1ce33b94..44d32f43d 100755 --- a/lib/Service/RecipeService.php +++ b/lib/Service/RecipeService.php @@ -657,9 +657,14 @@ public function addRecipe($json) { throw new Exception('Recipe name not found'); } + $now = date(DATE_ISO8601); + // Sanity check $json = $this->checkRecipe($json); + // Update modification date + $json['dateModified'] = $now; + // Create/move recipe folder $user_folder = $this->getFolderForUser(); $recipe_folder = null; @@ -682,6 +687,8 @@ public function addRecipe($json) { // This is a new recipe, create it } else { + $json['dateCreated'] = $now; + if ($user_folder->nodeExists($json['name'])) { throw new Exception('Another recipe with that name already exists'); } @@ -1041,11 +1048,13 @@ public function parseRecipeFile($file) { $json['id'] = $file->getParent()->getId(); - if (method_exists($file, 'getCreationTime')) { + + if (!array_key_exists('dateCreated', $json) && method_exists($file, 'getCreationTime')) { $json['dateCreated'] = $file->getCreationTime(); } - - $json['dateModified'] = $file->getMTime(); + if (!array_key_exists('dateModified', $json)) { + $json['dateModified'] = $file->getMTime(); + } return $this->checkRecipe($json); } diff --git a/package.json b/package.json index 1bdcf26a5..5d320feaa 100644 --- a/package.json +++ b/package.json @@ -20,6 +20,7 @@ "homepage": "https://github.com/mrzapp/nextcloud-cookbook#readme", "dependencies": { "@nextcloud/event-bus": "^1.1.4", + "@nextcloud/moment": "^1.1.1", "@nextcloud/vue": "^1.5.0", "lozad": "^1.16.0", "vue": "^2.6.11", diff --git a/src/components/RecipeView.vue b/src/components/RecipeView.vue index 8c71222ac..9a49c8eca 100644 --- a/src/components/RecipeView.vue +++ b/src/components/RecipeView.vue @@ -1,6 +1,5 @@