From 46e428b4846ce0e93879bc291976eb7751fd4609 Mon Sep 17 00:00:00 2001 From: Victor IT Date: Fri, 5 Oct 2018 02:10:14 +0300 Subject: [PATCH 1/2] Updated Russian translation (#17) --- Locale/ru_RU/translations.php | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/Locale/ru_RU/translations.php b/Locale/ru_RU/translations.php index 599eec2..451a4d9 100755 --- a/Locale/ru_RU/translations.php +++ b/Locale/ru_RU/translations.php @@ -17,14 +17,14 @@ 'Wiki lines' => 'Wiki строки', 'Cost' => 'Стоимость', 'Cost breakdown' => 'Детализация затрат', - 'Do you really want to remove this wiki page?' => 'Вы действительно хотите удалить эту строку wiki?', + 'Do you really want to remove this wiki page?' => 'Вы действительно хотите удалить эту страницу wiki?', 'Expenses' => 'Расходы', - 'New Wiki page' => 'Новая wiki строка', + 'New Wiki page' => 'Новая wiki страница', 'Remove a wiki line' => 'Удалить строку в wiki', 'Remove wiki line' => 'Удалить wiki строку', 'The wiki line have been created successfully.' => 'Wiki строка успешно создана.', 'Unable to create the wiki line.' => 'Не удается создать эту wiki строку.', - 'Unable to remove this wiki page.' => 'Не удается удалить эту wiki строку.', + 'Unable to remove this wiki page.' => 'Не удается удалить эту wiki страницу.', 'Remaining' => 'Прочее', 'Currency rates are used to calculate project wiki.' => 'Курсы валют используются для расчета wiki проекта.', 'Burndown chart for "%s"' => 'Диаграмма сгорания для "%s"', @@ -43,12 +43,12 @@ 'Date Creation' => 'Дата создания', 'Date Modification' => 'Дата модификации', 'Content' => 'Контент', - // 'Date Created' => 'Fecha de creacion', - // 'Date Modified' => 'Fecha modificada', - // '%d Wiki pages' => '%d Páginas Wiki', - // 'Search by content' => 'Buscar por contenido', - // 'Wiki page Title' => 'Título de la página Wiki', - // 'There are no editions for this Wiki page saved to restore.' => '', - // 'There are no Wiki pages that you have access to.' => '', - // 'There are no Wiki pages for this project.' => '' + 'Date Created' => 'Дата создания', + 'Date Modified' => 'Дата модификации', + '%d Wiki pages' => '%d Wiki страниц', + 'Search by content' => 'Поиск по содержимому', + 'Wiki page Title' => 'Заголовок Wiki страницы', + 'There are no editions for this Wiki page saved to restore.' => 'Нет сохраненных редакций этой Wiki страницы для восстановления.', + 'There are no Wiki pages that you have access to.' => 'Нет Wiki страниц, к которым у вас есть доступ.', + 'There are no Wiki pages for this project.' => 'Для этого проекта нет Wiki страниц.' ); From 071854897c1334425b002c1b51241beb86eeefe0 Mon Sep 17 00:00:00 2001 From: Craig Crosby Date: Thu, 4 Oct 2018 19:12:05 -0400 Subject: [PATCH 2/2] File Attachments (#19) * Update WikiFile.php * Update WikiFile.php * Update Sqlite.php * Update Sqlite.php * Update Mysql.php * Update Postgres.php * Create WikiFileEventJob.php * Delete WikiFileEventJob.php * Update WikiFile.php * Update WikiFile.php * Update WikiController.php * Update WikiController.php * Update detail.php * Update detail.php * Update detail.php * Update WikiController.php * Update images.php * Update files.php * Update images.php * Update WikiFileController.php * Update WikiFile.php * Update WikiFileController.php * Update WikiFileController.php * Update images.php * Update images.php * Update images.php * Update images.php * Create WikiFileViewController.php * Update images.php * Update WikiFileViewController.php * Update WikiFile.php * Update WikiFileViewController.php * Update WikiFileViewController.php * Update WikiFileViewController.php * Update WikiFileViewController.php * Update Plugin.php * Update images.php * Update images.php * Update WikiFileViewController.php * Update WikiFileViewController.php * Update images.php * Update images.php * Update WikiFileViewController.php * Update WikiFileViewController.php * Update WikiFileViewController.php * Update images.php * Update files.php * Update ChangeLog * Update Plugin.php * Update Makefile * Update ChangeLog * Update README.md --- ChangeLog | 13 ++- Controller/WikiController.php | 3 + Controller/WikiFileController.php | 4 +- Controller/WikiFileViewController.php | 159 ++++++++++++++++++++++++++ Makefile | 2 +- Model/WikiFile.php | 10 +- Plugin.php | 3 +- README.md | 4 +- Schema/Mysql.php | 9 +- Schema/Postgres.php | 9 +- Schema/Sqlite.php | 9 +- Template/wiki_file/files.php | 6 +- Template/wiki_file/images.php | 8 +- 13 files changed, 220 insertions(+), 19 deletions(-) create mode 100644 Controller/WikiFileViewController.php diff --git a/ChangeLog b/ChangeLog index 1cdd539..ba70368 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +Version 0.2.9-alpha + +Improvements: + +* File and Image Attachments Feature + * Added Upload Support + * Added Thumbnail Support + * Added Download Support + * Added Removal Support + * Added Slideshow Support for images + Version 0.2.8-alpha Improvements: @@ -124,4 +135,4 @@ Improvements: Bug fixes: -* \ No newline at end of file +* diff --git a/Controller/WikiController.php b/Controller/WikiController.php index eefeebb..3532d0f 100755 --- a/Controller/WikiController.php +++ b/Controller/WikiController.php @@ -139,6 +139,9 @@ public function detail() 'project' => $project, 'title' => t('Wikipage'), 'wiki_id' => $wiki_id, + 'wiki' => $wikipage, + 'files' => $this->wikiFile->getAllDocuments($wiki_id), + 'images' => $this->wikiFile->getAllImages($wiki_id), // 'wikipage' => $this->wiki->getWikipage($wiki_id), 'wikipage' => $wikipage, 'wikipages' => $wikipages, diff --git a/Controller/WikiFileController.php b/Controller/WikiFileController.php index f9c0ba7..1c9b10f 100644 --- a/Controller/WikiFileController.php +++ b/Controller/WikiFileController.php @@ -97,13 +97,13 @@ public function remove() $wiki = $this->wiki->getWiki(); $file = $this->wikiFile->getById($this->request->getIntegerParam('file_id')); - if ($file['wiki_id'] == $wiki['id'] && $this->wikiFile->remove($file['id'])) { + if ($file['wikipage_id'] == $wiki['id'] && $this->wikiFile->remove($file['id'])) { $this->flash->success(t('File removed successfully.')); } else { $this->flash->failure(t('Unable to remove this file.')); } + $this->response->redirect($this->helper->url->to('WikiController', 'detail', array('plugin' => 'wiki', 'project_id' => $wiki['project_id'], 'wiki_id' => $wiki['id'])), true); - $this->response->redirect($this->helper->url->to('WikiViewController', 'show', array('wiki_id' => $wiki['id'], 'project_id' => $wiki['project_id']))); } /** diff --git a/Controller/WikiFileViewController.php b/Controller/WikiFileViewController.php new file mode 100644 index 0000000..5776b1c --- /dev/null +++ b/Controller/WikiFileViewController.php @@ -0,0 +1,159 @@ +objectStorage->get($file['path']); + } + } catch (ObjectStorageException $e) { + $this->logger->error($e->getMessage()); + } + + return $content; + } + + /** + * Output file with cache + * + * @param array $file + * @param $mimetype + */ + protected function renderFileWithCache(array $file, $mimetype) + { + $etag = md5($file['path']); + + if ($this->request->getHeader('If-None-Match') === '"'.$etag.'"') { + $this->response->status(304); + } else { + try { + $this->response->withContentType($mimetype); + $this->response->withCache(5 * 86400, $etag); + $this->response->send(); + $this->objectStorage->output($file['path']); + } catch (ObjectStorageException $e) { + $this->logger->error($e->getMessage()); + } + } + } + + /** + * Show file content in a popover + * + * @access public + */ + public function show() + { + $file = $file = $this->wikiFile->getById($this->request->getIntegerParam('fid')); + $type = $this->helper->file->getPreviewType($file['name']); + $params = array('file_id' => $file['id'], 'project_id' => $this->request->getIntegerParam('project_id')); + + + $params['wikipage_id'] = $file['wikipage_id']; + + + $this->response->html($this->template->render('file_viewer/show', array( + 'file' => $file, + 'params' => $params, + 'type' => $type, + 'content' => $this->getFileContent($file), + ))); + } + + /** + * Display image + * + * @access public + */ + public function image() + { + $file = $this->wikiFile->getById($this->request->getIntegerParam('fid')); + $this->renderFileWithCache($file, $this->helper->file->getImageMimeType($file['name'])); + } + + /** + * Display file in browser + * + * @access public + */ + public function browser() + { + $file = $this->wikiFile->getById($this->request->getIntegerParam('fid')); + $this->renderFileWithCache($file, $this->helper->file->getBrowserViewType($file['name'])); + } + + /** + * Display image thumbnail + * + * @access public + */ + public function thumbnail() + { + $file = $this->wikiFile->getById($this->request->getIntegerParam('fid')); + $model = 'wikiFile'; + $filename = $this->$model->getThumbnailPath($file['path']); + $etag = md5($filename); + + $this->response->withCache(5 * 86400, $etag); + $this->response->withContentType('image/jpeg'); + + if ($this->request->getHeader('If-None-Match') === '"'.$etag.'"') { + $this->response->status(304); + } else { + + $this->response->send(); + + try { + + $this->objectStorage->output($filename); + } catch (ObjectStorageException $e) { + $this->logger->error($e->getMessage()); + + // Try to generate thumbnail on the fly for images uploaded before Kanboard < 1.0.19 + $data = $this->objectStorage->get($file['path']); + $this->$model->generateThumbnailFromData($file['path'], $data); + $this->objectStorage->output($this->$model->getThumbnailPath($file['path'])); + } + } + } + + /** + * File download + * + * @access public + */ + public function download() + { + try { + $file = $this->wikiFile->getById($this->request->getIntegerParam('fid')); + $file['model'] = 'wikiFile'; + $this->response->withFileDownload($file['name']); + $this->response->send(); + $this->objectStorage->output($file['path']); + } catch (ObjectStorageException $e) { + $this->logger->error($e->getMessage()); + } + } +} diff --git a/Makefile b/Makefile index a46a52d..449f2b8 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ plugin=Wiki -version=0.2.8 +version=0.2.9 all: @ echo "Build archive for plugin ${plugin} version=${version}" @ git archive HEAD --prefix=${plugin}/ --format=zip -o ${plugin}-${version}.zip diff --git a/Model/WikiFile.php b/Model/WikiFile.php index d5e68e6..79f5012 100644 --- a/Model/WikiFile.php +++ b/Model/WikiFile.php @@ -2,13 +2,16 @@ namespace Kanboard\Plugin\Wiki\Model; +use Kanboard\Model\FileModel; +use Kanboard\Plugin\Wiki\Model\Wiki; + /** * Wiki File Model * * @package Kanboard\Model * @author Frederic Guillot */ -class WikiFileModel extends FileModel +class WikiFile extends FileModel { /** * Table name @@ -23,6 +26,7 @@ class WikiFileModel extends FileModel * @var string */ const EVENT_CREATE = 'wiki.file.create'; + /** * Get the table @@ -35,6 +39,7 @@ protected function getTable() { return self::TABLE; } + /** * Define the foreign key @@ -98,6 +103,7 @@ public function uploadScreenshot($wiki_id, $blob) */ protected function fireCreationEvent($file_id) { - $this->queueManager->push($this->wikiFileEventJob->withParams($file_id, self::EVENT_CREATE)); + return null; } + } diff --git a/Plugin.php b/Plugin.php index 23051ec..df0a189 100755 --- a/Plugin.php +++ b/Plugin.php @@ -12,6 +12,7 @@ public function initialize() { $this->projectAccessMap->add('WikiController', '*', Role::PROJECT_MEMBER); $this->projectAccessMap->add('WikiFileController', '*', Role::PROJECT_MEMBER); + $this->projectAccessMap->add('WikiFileViewController', '*', Role::PROJECT_MEMBER); $this->route->addRoute('/wiki/project/:project_id', 'WikiController', 'show', 'wiki'); $this->route->addRoute('/wiki/project/:project_id', 'WikiController', 'detail', 'wiki'); @@ -84,7 +85,7 @@ public function getPluginAuthor() public function getPluginVersion() { - return '0.2.8'; + return '0.2.9'; } public function getPluginHomepage() diff --git a/README.md b/README.md index 7ebc770..f708f26 100644 --- a/README.md +++ b/README.md @@ -85,7 +85,7 @@ Note that you can only restore **saved** editions. So you if you have the global - style updates - ordering -- [file attachment support](https://github.com/funktechno/kanboard-plugin-wiki/issues/3) +- [x] [file attachment support](https://github.com/funktechno/kanboard-plugin-wiki/issues/3) - [x] global wiki page search [issue 5](https://github.com/funktechno/kanboard-plugin-wiki/issues/5) prob next year - rest support - LOW PRIORITY - [issues/bugs](https://github.com/funktechno/kanboard-plugin-wiki/issues) @@ -128,4 +128,4 @@ After testing create a new tag in github or via cli. `git tag -a 0.2.6 -m "Trans "compatible_version": ">=1.0.37" } } -``` \ No newline at end of file +``` diff --git a/Schema/Mysql.php b/Schema/Mysql.php index 28bd983..b61bbbb 100644 --- a/Schema/Mysql.php +++ b/Schema/Mysql.php @@ -4,7 +4,14 @@ use PDO; -const VERSION = 7; +const VERSION = 8; + +function version_8(PDO $pdo) +{ + $pdo->exec('ALTER TABLE wikipage_has_files ADD COLUMN `date` INT NOT NULL DEFAULT 0'); + $pdo->exec('ALTER TABLE wikipage_has_files ADD COLUMN `user_id` INT NOT NULL DEFAULT 0'); + $pdo->exec('ALTER TABLE wikipage_has_files ADD COLUMN `size` INT NOT NULL DEFAULT 0'); +} function version_7(PDO $pdo){ $pdo->exec("ALTER TABLE wikipage CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;"); diff --git a/Schema/Postgres.php b/Schema/Postgres.php index 8704a09..82ed3f4 100644 --- a/Schema/Postgres.php +++ b/Schema/Postgres.php @@ -4,7 +4,14 @@ use PDO; -const VERSION = 2; +const VERSION = 3; + +function version_3(PDO $pdo) +{ + $pdo->exec('ALTER TABLE files ADD COLUMN "date" INTEGER NOT NULL DEFAULT 0'); + $pdo->exec('ALTER TABLE files ADD COLUMN "user_id" INTEGER NOT NULL DEFAULT 0'); + $pdo->exec('ALTER TABLE files ADD COLUMN "size" INTEGER NOT NULL DEFAULT 0'); +} function version_2(PDO $pdo) { diff --git a/Schema/Sqlite.php b/Schema/Sqlite.php index 534b18e..c292915 100644 --- a/Schema/Sqlite.php +++ b/Schema/Sqlite.php @@ -4,7 +4,14 @@ use PDO; -const VERSION = 2; +const VERSION = 3; + +function version_3(PDO $pdo) +{ + $pdo->exec('ALTER TABLE wikipage_has_files ADD COLUMN "date" INTEGER NOT NULL DEFAULT 0'); + $pdo->exec('ALTER TABLE wikipage_has_files ADD COLUMN "user_id" INTEGER NOT NULL DEFAULT 0'); + $pdo->exec('ALTER TABLE wikipage_has_files ADD COLUMN "size" INTEGER NOT NULL DEFAULT 0'); +} function version_2(PDO $pdo) { diff --git a/Template/wiki_file/files.php b/Template/wiki_file/files.php index e62ebe2..85b604a 100644 --- a/Template/wiki_file/files.php +++ b/Template/wiki_file/files.php @@ -15,16 +15,16 @@