From 12262157a52189d9fb56279fe2aadbf232562952 Mon Sep 17 00:00:00 2001 From: Jhon Date: Wed, 20 Jul 2022 16:38:39 -0400 Subject: [PATCH 01/55] WIP: Get galley annotation number through Hypothesis API Signed-off-by: Jhon Signed-off-by: Vitoria --- HypothesisPlugin.inc.php | 31 +++++++++++++++++++++++++++---- classes/HypothesisClient.inc.php | 19 +++++++++++++++++++ 2 files changed, 46 insertions(+), 4 deletions(-) create mode 100644 classes/HypothesisClient.inc.php diff --git a/HypothesisPlugin.inc.php b/HypothesisPlugin.inc.php index 007180c..d1f0dea 100644 --- a/HypothesisPlugin.inc.php +++ b/HypothesisPlugin.inc.php @@ -13,6 +13,7 @@ import('lib.pkp.classes.plugins.GenericPlugin'); +import('plugins.generic.hypothesis.classes.HypothesisClient'); class HypothesisPlugin extends GenericPlugin { /** @@ -55,13 +56,17 @@ function callbackTemplateDisplay($hookName, $args) { $templateMgr = $args[0]; $template = $args[1]; $plugin = 'plugins-generic-pdfJsViewer'; - $submissiontpl = 'submissionGalley.tpl'; - $issuetpl = 'issueGalley.tpl'; - + $submissionGalleyTpl = 'submissionGalley.tpl'; + $issueGalleyTpl = 'issueGalley.tpl'; + $preprintTpl = 'preprint.tpl'; + // template path contains the plugin path, and ends with the tpl file - if ( (strpos($template, $plugin) !== false) && ( (strpos($template, ':'.$submissiontpl, -1 - strlen($submissiontpl)) !== false) || (strpos($template, ':'.$issuetpl, -1 - strlen($issuetpl)) !== false))) { + if ( (strpos($template, $plugin) !== false) && ( (strpos($template, ':'.$submissionGalleyTpl, -1 - strlen($submissionGalleyTpl)) !== false) || (strpos($template, ':'.$issueGalleyTpl, -1 - strlen($issueGalleyTpl)) !== false))) { $templateMgr->registerFilter("output", array($this, 'changePdfjsPath')); } + else if (strpos($template, $preprintTpl, -1 - strlen($preprintTpl)) !== false) { + $templateMgr->registerFilter("output", array($this, 'addViewerNumberAnnotations')); + } return false; } @@ -76,6 +81,24 @@ function changePdfjsPath($output, $templateMgr) { return $newOutput; } + function addViewerNumberAnnotations($output, $templateMgr) { + $publication = $templateMgr->get_template_vars('publication'); + $galleys = $publication->getData('galleys'); + $annotationNumbers = []; + + $hypothesisClient = new HypothesisClient(); + + foreach($galleys as $galley) { + $annotationNumbers[] = $hypothesisClient->getGalleyAnnotationsNumber($galley); + } + + // assign annotationNumbers no templateMgr + // adiciona nosos template ao output (provavelmente um script js) + + $templateMgr->unregisterFilter('output', array($this, 'addViewerNumberAnnotations')); + return $output; + } + /** * Get the display name of this plugin * @return string diff --git a/classes/HypothesisClient.inc.php b/classes/HypothesisClient.inc.php new file mode 100644 index 0000000..d661d62 --- /dev/null +++ b/classes/HypothesisClient.inc.php @@ -0,0 +1,19 @@ +getRequest(); + $indexUrl = $request->getIndexUrl(); + $contextPath = $request->getContext()->getPath(); + + $submissionFile = $galley->getFile(); + $submissionId = $submissionFile->getData('submissionId'); + $assocId = $submissionFile->getData('assocId'); + $submissionFileId = $submissionFile->getId(); + + $galleyLinkUrl = $indexUrl . "/$contextPath/preprint/download/$submissionId/$assocId/$submissionFileId"; + return 10; + } + +} \ No newline at end of file From 4270fcac96f3d49f7dce7b34c28f4d85ab08b841 Mon Sep 17 00:00:00 2001 From: Jhon Date: Thu, 21 Jul 2022 14:59:27 -0400 Subject: [PATCH 02/55] Finishes HypothesisClient class It can now request the number of annotations of a galley to the Hypothesis API Signed-off-by: Jhon Signed-off-by: Vitoria --- classes/HypothesisClient.inc.php | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/classes/HypothesisClient.inc.php b/classes/HypothesisClient.inc.php index d661d62..ef4d34c 100644 --- a/classes/HypothesisClient.inc.php +++ b/classes/HypothesisClient.inc.php @@ -2,7 +2,7 @@ class HypothesisClient { - public function getGalleyAnnotationsNumber($galley) { + private function getGalleyDownloadURL($galley) { $request = Application::get()->getRequest(); $indexUrl = $request->getIndexUrl(); $contextPath = $request->getContext()->getPath(); @@ -12,8 +12,30 @@ public function getGalleyAnnotationsNumber($galley) { $assocId = $submissionFile->getData('assocId'); $submissionFileId = $submissionFile->getId(); - $galleyLinkUrl = $indexUrl . "/$contextPath/preprint/download/$submissionId/$assocId/$submissionFileId"; - return 10; + return $indexUrl . "/$contextPath/preprint/download/$submissionId/$assocId/$submissionFileId"; + } + + private function checkRequestStatus($responseHeaders) { + $partitionedStatus = explode(" ", $responseHeaders[0]); + + $responseStatusCode = $partitionedStatus[1]; + $httpOKCode = "200"; + + return $responseStatusCode == $httpOKCode; + } + + public function getGalleyAnnotationsNumber($galley) { + $galleyFileDownloadURL = $this->getGalleyDownloadURL($galley); + $requestURL = "https://hypothes.is/api/search?limit=0&group=__world__&uri={$galleyFileDownloadURL}"; + + $requestSuccedeed = $this->checkRequestStatus(get_headers($requestURL)); + if(!$requestSuccedeed) + return null; + + $response = json_decode(file_get_contents($requestURL), true); + $annotationsNumber = $response['total']; + + return $annotationsNumber; } } \ No newline at end of file From f91a402cdf1aa88ed2a6e10d384465212827933c Mon Sep 17 00:00:00 2001 From: Jhon Date: Fri, 22 Jul 2022 14:05:50 -0400 Subject: [PATCH 03/55] Prepares the including of custom template in preprint landing page Signed-off-by: Jhon Signed-off-by: Vitoria --- HypothesisPlugin.inc.php | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/HypothesisPlugin.inc.php b/HypothesisPlugin.inc.php index d1f0dea..1cfcb61 100644 --- a/HypothesisPlugin.inc.php +++ b/HypothesisPlugin.inc.php @@ -82,21 +82,31 @@ function changePdfjsPath($output, $templateMgr) { } function addViewerNumberAnnotations($output, $templateMgr) { - $publication = $templateMgr->get_template_vars('publication'); + if (preg_match('/]+class="item galleys/', $output, $matches, PREG_OFFSET_CAPTURE)) { + $posMatch = $matches[0][1]; + $publication = $templateMgr->get_template_vars('publication'); + $templateMgr->assign('annotationNumbers', $this->getPublicationAnnotationNumbers($publication)); + $annotationViewerTpl = $templateMgr->fetch($this->getTemplateResource('annotationViewer.tpl')); + + $ulEndTag = ""; + $posToInsert = strpos($output, $ulEndTag, $posMatch); + $output = substr_replace($output, $annotationViewerTpl, $posToInsert + strlen($ulEndTag), 0); + + $templateMgr->unregisterFilter('output', array($this, 'addViewerNumberAnnotations')); + } + return $output; + } + + private function getPublicationAnnotationNumbers($publication) { $galleys = $publication->getData('galleys'); $annotationNumbers = []; $hypothesisClient = new HypothesisClient(); - foreach($galleys as $galley) { $annotationNumbers[] = $hypothesisClient->getGalleyAnnotationsNumber($galley); } - // assign annotationNumbers no templateMgr - // adiciona nosos template ao output (provavelmente um script js) - - $templateMgr->unregisterFilter('output', array($this, 'addViewerNumberAnnotations')); - return $output; + return $annotationNumbers; } /** From 62a38d862b57d213a8ec6f7bd3d89451d31df03f Mon Sep 17 00:00:00 2001 From: Jhon Date: Fri, 22 Jul 2022 15:18:35 -0400 Subject: [PATCH 04/55] Creates the template to add the annotation viewer to landing page Signed-off-by: Jhon Signed-off-by: Vitoria --- HypothesisPlugin.inc.php | 4 ++++ locale/en_US/locale.po | 6 ++++++ locale/es_ES/locale.po | 6 ++++++ locale/pt_BR/locale.po | 6 ++++++ locale/pt_PT/locale.po | 6 ++++++ styles/annotationViewer.css | 14 ++++++++++++++ templates/annotationViewer.tpl | 35 ++++++++++++++++++++++++++++++++++ 7 files changed, 77 insertions(+) create mode 100644 styles/annotationViewer.css create mode 100644 templates/annotationViewer.tpl diff --git a/HypothesisPlugin.inc.php b/HypothesisPlugin.inc.php index 1cfcb61..f39ce40 100644 --- a/HypothesisPlugin.inc.php +++ b/HypothesisPlugin.inc.php @@ -124,5 +124,9 @@ function getDisplayName() { function getDescription() { return __('plugins.generic.hypothesis.description'); } + + function getStyleSheet() { + return $this->getPluginPath() . '/styles/annotationViewer.css'; + } } diff --git a/locale/en_US/locale.po b/locale/en_US/locale.po index 1d54807..cb70c87 100644 --- a/locale/en_US/locale.po +++ b/locale/en_US/locale.po @@ -16,3 +16,9 @@ msgstr "Hypothes.is Plugin" msgid "plugins.generic.hypothesis.description" msgstr "This plugin enables Hypothes.is integration into OJS article views for reader annotation and commenting." + +msgid "plugins.generic.hypothesis.annotation" +msgstr "annotation" + +msgid "plugins.generic.hypothesis.annotations" +msgstr "annotations" \ No newline at end of file diff --git a/locale/es_ES/locale.po b/locale/es_ES/locale.po index 7ffe464..a218a71 100644 --- a/locale/es_ES/locale.po +++ b/locale/es_ES/locale.po @@ -18,3 +18,9 @@ msgstr "" msgid "plugins.generic.hypothesis.name" msgstr "Módulo Hypothes.is" + +msgid "plugins.generic.hypothesis.annotation" +msgstr "annotación" + +msgid "plugins.generic.hypothesis.annotations" +msgstr "anotaciones" \ No newline at end of file diff --git a/locale/pt_BR/locale.po b/locale/pt_BR/locale.po index 7339509..e53a4be 100644 --- a/locale/pt_BR/locale.po +++ b/locale/pt_BR/locale.po @@ -18,3 +18,9 @@ msgstr "" msgid "plugins.generic.hypothesis.name" msgstr "Plugin Hypothes.is" + +msgid "plugins.generic.hypothesis.annotation" +msgstr "anotação" + +msgid "plugins.generic.hypothesis.annotations" +msgstr "anotações" \ No newline at end of file diff --git a/locale/pt_PT/locale.po b/locale/pt_PT/locale.po index df28e3b..c270d1e 100644 --- a/locale/pt_PT/locale.po +++ b/locale/pt_PT/locale.po @@ -16,3 +16,9 @@ msgstr "Plugin Hypothes.is" msgid "plugins.generic.hypothesis.description" msgstr "Este plugin permite a integração do Hypothes.is nas visualizações de artigo do OJS permitindo anotações e comentários dos leitores." + +msgid "plugins.generic.hypothesis.annotation" +msgstr "anotação" + +msgid "plugins.generic.hypothesis.annotations" +msgstr "anotações" \ No newline at end of file diff --git a/styles/annotationViewer.css b/styles/annotationViewer.css new file mode 100644 index 0000000..d78e41a --- /dev/null +++ b/styles/annotationViewer.css @@ -0,0 +1,14 @@ +.annotation_viewer_li { + display: block !important; + margin-top: 8px; +} + +.annotation_viewer_span { + padding: 4px 8px; + border: 1px solid rgba(0,0,0,0.54); + border-radius: 15px; + line-height: 20px; + font-size: 14px; + margin-top: 1em; + margin-left: 0.25em; +} diff --git a/templates/annotationViewer.tpl b/templates/annotationViewer.tpl new file mode 100644 index 0000000..a8162bd --- /dev/null +++ b/templates/annotationViewer.tpl @@ -0,0 +1,35 @@ + + + \ No newline at end of file From ea10bc6d33962ba05395a7580be7879d72d7b95d Mon Sep 17 00:00:00 2001 From: Jhon Date: Tue, 26 Jul 2022 14:25:24 -0400 Subject: [PATCH 05/55] Removes left margin of annotation viewer Signed-off-by: Jhon --- styles/annotationViewer.css | 1 - 1 file changed, 1 deletion(-) diff --git a/styles/annotationViewer.css b/styles/annotationViewer.css index d78e41a..d667ceb 100644 --- a/styles/annotationViewer.css +++ b/styles/annotationViewer.css @@ -10,5 +10,4 @@ line-height: 20px; font-size: 14px; margin-top: 1em; - margin-left: 0.25em; } From c755f8fe394c548f97f202599ed1e91d7f49fca0 Mon Sep 17 00:00:00 2001 From: Jhon Date: Tue, 26 Jul 2022 17:12:15 -0400 Subject: [PATCH 06/55] Switch annotation viewer addin strategy Signed-off-by: Jhon --- HypothesisPlugin.inc.php | 48 +++++++++++++++------------------- templates/annotationViewer.tpl | 44 +++++++------------------------ 2 files changed, 30 insertions(+), 62 deletions(-) diff --git a/HypothesisPlugin.inc.php b/HypothesisPlugin.inc.php index f39ce40..c07c3ac 100644 --- a/HypothesisPlugin.inc.php +++ b/HypothesisPlugin.inc.php @@ -23,6 +23,16 @@ function register($category, $path, $mainContextId = null) { if (parent::register($category, $path, $mainContextId)) { HookRegistry::register('ArticleHandler::download',array(&$this, 'callback')); HookRegistry::register('TemplateManager::display', array(&$this, 'callbackTemplateDisplay')); + HookRegistry::register('Hypothesis::annotationNumber', array(&$this, 'addAnnotationNumberViewer')); + + $request = PKPApplication::get()->getRequest(); + $templateMgr = TemplateManager::getManager($request); + $templateMgr->addStyleSheet( + 'Hypothesis', + $request->getBaseUrl() . '/' . $this->getPluginPath() . '/styles/annotationViewer.css', + ['contexts' => ['frontend']] + ); + return true; } return false; @@ -58,15 +68,11 @@ function callbackTemplateDisplay($hookName, $args) { $plugin = 'plugins-generic-pdfJsViewer'; $submissionGalleyTpl = 'submissionGalley.tpl'; $issueGalleyTpl = 'issueGalley.tpl'; - $preprintTpl = 'preprint.tpl'; // template path contains the plugin path, and ends with the tpl file if ( (strpos($template, $plugin) !== false) && ( (strpos($template, ':'.$submissionGalleyTpl, -1 - strlen($submissionGalleyTpl)) !== false) || (strpos($template, ':'.$issueGalleyTpl, -1 - strlen($issueGalleyTpl)) !== false))) { $templateMgr->registerFilter("output", array($this, 'changePdfjsPath')); } - else if (strpos($template, $preprintTpl, -1 - strlen($preprintTpl)) !== false) { - $templateMgr->registerFilter("output", array($this, 'addViewerNumberAnnotations')); - } return false; } @@ -81,32 +87,20 @@ function changePdfjsPath($output, $templateMgr) { return $newOutput; } - function addViewerNumberAnnotations($output, $templateMgr) { - if (preg_match('/]+class="item galleys/', $output, $matches, PREG_OFFSET_CAPTURE)) { - $posMatch = $matches[0][1]; - $publication = $templateMgr->get_template_vars('publication'); - $templateMgr->assign('annotationNumbers', $this->getPublicationAnnotationNumbers($publication)); - $annotationViewerTpl = $templateMgr->fetch($this->getTemplateResource('annotationViewer.tpl')); - - $ulEndTag = ""; - $posToInsert = strpos($output, $ulEndTag, $posMatch); - $output = substr_replace($output, $annotationViewerTpl, $posToInsert + strlen($ulEndTag), 0); - - $templateMgr->unregisterFilter('output', array($this, 'addViewerNumberAnnotations')); - } - return $output; - } - - private function getPublicationAnnotationNumbers($publication) { - $galleys = $publication->getData('galleys'); - $annotationNumbers = []; - + public function addAnnotationNumberViewer($hookName, $args) { + $templateMgr = $args[1]; + $output =& $args[2]; + $galley = $args[0]['galley']; + $hypothesisClient = new HypothesisClient(); - foreach($galleys as $galley) { - $annotationNumbers[] = $hypothesisClient->getGalleyAnnotationsNumber($galley); + $annotationsNumber = 2;//$hypothesisClient->getGalleyAnnotationsNumber($galley); + + if($annotationsNumber > 0) { + $templateMgr->assign('annotationsNumber', $annotationsNumber); + $output .= $templateMgr->fetch($this->getTemplateResource('annotationViewer.tpl')); } - return $annotationNumbers; + return false; } /** diff --git a/templates/annotationViewer.tpl b/templates/annotationViewer.tpl index a8162bd..db0b87a 100644 --- a/templates/annotationViewer.tpl +++ b/templates/annotationViewer.tpl @@ -1,35 +1,9 @@ - - - \ No newline at end of file +
  • + + {if $annotationsNumber eq 1} + {$annotationsNumber} {translate key="plugins.generic.hypothesis.annotation"} + {else} + {$annotationsNumber} {translate key="plugins.generic.hypothesis.annotations"} + {/if} + +
  • \ No newline at end of file From 9912be6096c5b779bc7360a9cd4e8d9581e2e047 Mon Sep 17 00:00:00 2001 From: Jhon Date: Tue, 26 Jul 2022 17:13:20 -0400 Subject: [PATCH 07/55] Removes commented code Signed-off-by: Jhon --- HypothesisPlugin.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/HypothesisPlugin.inc.php b/HypothesisPlugin.inc.php index c07c3ac..6f62e04 100644 --- a/HypothesisPlugin.inc.php +++ b/HypothesisPlugin.inc.php @@ -93,7 +93,7 @@ public function addAnnotationNumberViewer($hookName, $args) { $galley = $args[0]['galley']; $hypothesisClient = new HypothesisClient(); - $annotationsNumber = 2;//$hypothesisClient->getGalleyAnnotationsNumber($galley); + $annotationsNumber = $hypothesisClient->getGalleyAnnotationsNumber($galley); if($annotationsNumber > 0) { $templateMgr->assign('annotationsNumber', $annotationsNumber); From 80d50b41652cf4ff8aaca6a1386b5d25c490a2c2 Mon Sep 17 00:00:00 2001 From: Jhon Date: Wed, 27 Jul 2022 15:14:59 -0400 Subject: [PATCH 08/55] Brings Hypothesis API call to the template Also changes some visual styling Signed-off-by: Jhon --- HypothesisPlugin.inc.php | 23 +++++++++++------- classes/HypothesisClient.inc.php | 41 -------------------------------- styles/annotationViewer.css | 10 +++++--- templates/annotationViewer.tpl | 30 ++++++++++++++++------- 4 files changed, 43 insertions(+), 61 deletions(-) delete mode 100644 classes/HypothesisClient.inc.php diff --git a/HypothesisPlugin.inc.php b/HypothesisPlugin.inc.php index 6f62e04..570ecda 100644 --- a/HypothesisPlugin.inc.php +++ b/HypothesisPlugin.inc.php @@ -13,7 +13,6 @@ import('lib.pkp.classes.plugins.GenericPlugin'); -import('plugins.generic.hypothesis.classes.HypothesisClient'); class HypothesisPlugin extends GenericPlugin { /** @@ -92,17 +91,25 @@ public function addAnnotationNumberViewer($hookName, $args) { $output =& $args[2]; $galley = $args[0]['galley']; - $hypothesisClient = new HypothesisClient(); - $annotationsNumber = $hypothesisClient->getGalleyAnnotationsNumber($galley); - - if($annotationsNumber > 0) { - $templateMgr->assign('annotationsNumber', $annotationsNumber); - $output .= $templateMgr->fetch($this->getTemplateResource('annotationViewer.tpl')); - } + $templateMgr->assign('galleyDownloadURL', $this->getGalleyDownloadURL($galley)); + $output .= $templateMgr->fetch($this->getTemplateResource('annotationViewer.tpl')); return false; } + private function getGalleyDownloadURL($galley) { + $request = Application::get()->getRequest(); + $indexUrl = $request->getIndexUrl(); + $contextPath = $request->getContext()->getPath(); + + $submissionFile = $galley->getFile(); + $submissionId = $submissionFile->getData('submissionId'); + $assocId = $submissionFile->getData('assocId'); + $submissionFileId = $submissionFile->getId(); + + return $indexUrl . "/$contextPath/preprint/download/$submissionId/$assocId/$submissionFileId"; + } + /** * Get the display name of this plugin * @return string diff --git a/classes/HypothesisClient.inc.php b/classes/HypothesisClient.inc.php deleted file mode 100644 index ef4d34c..0000000 --- a/classes/HypothesisClient.inc.php +++ /dev/null @@ -1,41 +0,0 @@ -getRequest(); - $indexUrl = $request->getIndexUrl(); - $contextPath = $request->getContext()->getPath(); - - $submissionFile = $galley->getFile(); - $submissionId = $submissionFile->getData('submissionId'); - $assocId = $submissionFile->getData('assocId'); - $submissionFileId = $submissionFile->getId(); - - return $indexUrl . "/$contextPath/preprint/download/$submissionId/$assocId/$submissionFileId"; - } - - private function checkRequestStatus($responseHeaders) { - $partitionedStatus = explode(" ", $responseHeaders[0]); - - $responseStatusCode = $partitionedStatus[1]; - $httpOKCode = "200"; - - return $responseStatusCode == $httpOKCode; - } - - public function getGalleyAnnotationsNumber($galley) { - $galleyFileDownloadURL = $this->getGalleyDownloadURL($galley); - $requestURL = "https://hypothes.is/api/search?limit=0&group=__world__&uri={$galleyFileDownloadURL}"; - - $requestSuccedeed = $this->checkRequestStatus(get_headers($requestURL)); - if(!$requestSuccedeed) - return null; - - $response = json_decode(file_get_contents($requestURL), true); - $annotationsNumber = $response['total']; - - return $annotationsNumber; - } - -} \ No newline at end of file diff --git a/styles/annotationViewer.css b/styles/annotationViewer.css index d667ceb..e488c05 100644 --- a/styles/annotationViewer.css +++ b/styles/annotationViewer.css @@ -1,9 +1,13 @@ -.annotation_viewer_li { - display: block !important; +.obj_article_details .galleys_links li { + margin-right: 0.25em; +} + +.annotation_viewer { margin-top: 8px; + visibility: hidden; } -.annotation_viewer_span { +.annotation_viewer > span { padding: 4px 8px; border: 1px solid rgba(0,0,0,0.54); border-radius: 15px; diff --git a/templates/annotationViewer.tpl b/templates/annotationViewer.tpl index db0b87a..31f75a8 100644 --- a/templates/annotationViewer.tpl +++ b/templates/annotationViewer.tpl @@ -1,9 +1,21 @@ -
  • - - {if $annotationsNumber eq 1} - {$annotationsNumber} {translate key="plugins.generic.hypothesis.annotation"} - {else} - {$annotationsNumber} {translate key="plugins.generic.hypothesis.annotations"} - {/if} - -
  • \ No newline at end of file +
  • + +
  • + + \ No newline at end of file From f6e5fbd29fa0f01e691dd7587efea162e66a2b3b Mon Sep 17 00:00:00 2001 From: Jhon Date: Tue, 2 Aug 2022 17:01:58 -0400 Subject: [PATCH 09/55] Adds Hypothesis config template Signed-off-by: Jhon --- HypothesisPlugin.inc.php | 12 ++++++++++++ templates/hypothesisConfig.tpl | 12 ++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 templates/hypothesisConfig.tpl diff --git a/HypothesisPlugin.inc.php b/HypothesisPlugin.inc.php index 570ecda..630c58e 100644 --- a/HypothesisPlugin.inc.php +++ b/HypothesisPlugin.inc.php @@ -71,6 +71,7 @@ function callbackTemplateDisplay($hookName, $args) { // template path contains the plugin path, and ends with the tpl file if ( (strpos($template, $plugin) !== false) && ( (strpos($template, ':'.$submissionGalleyTpl, -1 - strlen($submissionGalleyTpl)) !== false) || (strpos($template, ':'.$issueGalleyTpl, -1 - strlen($issueGalleyTpl)) !== false))) { $templateMgr->registerFilter("output", array($this, 'changePdfjsPath')); + $templateMgr->registerFilter("output", array($this, 'addHypothesisConfig')); } return false; } @@ -86,6 +87,17 @@ function changePdfjsPath($output, $templateMgr) { return $newOutput; } + function addHypothesisConfig($output, $templateMgr) { + if (preg_match('/]+id="pdfCanvasContainer/', $output, $matches, PREG_OFFSET_CAPTURE)) { + $posMatch = $matches[0][1]; + $config = $templateMgr->fetch($this->getTemplateResource('hypothesisConfig.tpl')); + + $output = substr_replace($output, $config, $posMatch, 0); + $templateMgr->unregisterFilter('output', array($this, 'addHypothesisConfig')); + } + return $output; + } + public function addAnnotationNumberViewer($hookName, $args) { $templateMgr = $args[1]; $output =& $args[2]; diff --git a/templates/hypothesisConfig.tpl b/templates/hypothesisConfig.tpl new file mode 100644 index 0000000..9faf6e0 --- /dev/null +++ b/templates/hypothesisConfig.tpl @@ -0,0 +1,12 @@ + \ No newline at end of file From 9a1eab7e77501207a2909c14d4f6fad6c0922f8d Mon Sep 17 00:00:00 2001 From: Jhon Date: Wed, 3 Aug 2022 14:25:28 -0400 Subject: [PATCH 10/55] Uses load event for configuring Hypothesis client Signed-off-by: Jhon --- templates/hypothesisConfig.tpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/hypothesisConfig.tpl b/templates/hypothesisConfig.tpl index 9faf6e0..4c2b9f7 100644 --- a/templates/hypothesisConfig.tpl +++ b/templates/hypothesisConfig.tpl @@ -1,6 +1,6 @@ \ No newline at end of file From a502236c06c76424bc752956de3a15833688d39d Mon Sep 17 00:00:00 2001 From: Jhon Date: Fri, 5 Aug 2022 14:45:34 -0400 Subject: [PATCH 12/55] Redesigns annotation viewer to use the same link of the galley Signed-off-by: Jhon --- styles/annotationViewer.css | 12 ++++++++---- templates/annotationViewer.tpl | 25 ++++++++++++++++--------- 2 files changed, 24 insertions(+), 13 deletions(-) diff --git a/styles/annotationViewer.css b/styles/annotationViewer.css index 1fa8181..9c91c06 100644 --- a/styles/annotationViewer.css +++ b/styles/annotationViewer.css @@ -2,16 +2,20 @@ margin-right: 0.25em; } -li[class^="annotation_viewer-"] { - margin-top: 8px; +.annotation_viewer { + margin: 0.5em 0 1em; visibility: hidden; } -li[id^="annotation_viewer-"] > a[class^="obj_galley_link"] { +.annotation_viewer > a { padding: 4px 8px; border: 1px solid rgba(0,0,0,0.54); border-radius: 15px; + color: rgba(0,0,0,0.54); line-height: 20px; font-size: 14px; - margin-top: 1em; } + +.annotation_viewer > a:hover { + color: rgba(0,0,0,0.54); +} \ No newline at end of file diff --git a/templates/annotationViewer.tpl b/templates/annotationViewer.tpl index 520fcf4..295bec8 100644 --- a/templates/annotationViewer.tpl +++ b/templates/annotationViewer.tpl @@ -1,21 +1,28 @@ -
  • - {include file="frontend/objects/galley_link.tpl" parent=$preprint publication=$publication galley=$galley} +
  • +
  • \ No newline at end of file From 521a4883d747f4eea49e01114f5e70c585552ee3 Mon Sep 17 00:00:00 2001 From: Jhon Date: Mon, 26 Sep 2022 15:30:37 -0400 Subject: [PATCH 33/55] Adds read more button for annotation targets Signed-off-by: Jhon Signed-off-by: Richard --- classes/AnnotationsPageHandler.inc.php | 5 +++- js/load.js | 26 ++++++++++++++++++++ styles/annotationsPage.css | 17 +++++++++++-- templates/submissionAnnotations.tpl | 33 +++----------------------- 4 files changed, 48 insertions(+), 33 deletions(-) create mode 100644 js/load.js diff --git a/classes/AnnotationsPageHandler.inc.php b/classes/AnnotationsPageHandler.inc.php index 160f9c3..772625f 100644 --- a/classes/AnnotationsPageHandler.inc.php +++ b/classes/AnnotationsPageHandler.inc.php @@ -10,9 +10,12 @@ function index($args, $request) { $context = $request->getContext(); $paginationParams = $this->getPaginationParams($args, $context); - $templateMgr = TemplateManager::getManager($request); $templateMgr->assign($paginationParams); + + $jsUrl = $request->getBaseUrl() . '/' . $plugin->getPluginPath() . '/js/load.js'; + $templateMgr->addJavascript('AnnotationsPage', $jsUrl, ['contexts' => 'frontend']); + return $templateMgr->display($plugin->getTemplateResource('annotationsPage.tpl')); } diff --git a/js/load.js b/js/load.js new file mode 100644 index 0000000..e1252b0 --- /dev/null +++ b/js/load.js @@ -0,0 +1,26 @@ +let maxCharNumber = 300; +let annotationTargets = document.querySelectorAll('.annotation_target > blockquote'); + +annotationTargets.forEach(target => { + if(target.textContent.length <= maxCharNumber) { + let readMoreBtn = target.nextElementSibling; + readMoreBtn.style.display = "none"; + } + else { + let trimmedText = target.textContent.trim(); + let textToDisplay = trimmedText.slice(0, maxCharNumber); + let textMore = trimmedText.slice(maxCharNumber); + target.innerHTML = `${textToDisplay}...${textMore}`; + } +}); + +function toggleReadMore(btn){ + let annotation = btn.parentElement; + annotation.querySelector('.dots').classList.toggle('hide'); + annotation.querySelector('.more').classList.toggle('hide'); + if(btn.classList.contains('read_more')) + btn.nextElementSibling.classList.remove('hide'); + else + btn.previousElementSibling.classList.remove('hide'); + btn.classList.add('hide'); +} \ No newline at end of file diff --git a/styles/annotationsPage.css b/styles/annotationsPage.css index 3b6842a..4dd4e5a 100644 --- a/styles/annotationsPage.css +++ b/styles/annotationsPage.css @@ -20,7 +20,6 @@ } .annotation_header span { - font-size: 13px; color: rgba(0,0,0,0.54); margin-left: 8px; float: right; @@ -28,11 +27,25 @@ .annotation_target { font-style: italic; - margin-top: 1em; + margin: 1em 0; padding: 0 1em; color: rgba(0,0,0,0.54); } +.annotation_target blockquote { + margin-bottom: 4px; +} + +.read_more, .read_less { + padding: 3px 6px; + border: 1px solid #007bff; + border-radius: 14px; + color: #007bff; + background-color: #FFF; + line-height: 20px; + font-weight: 700; +} + .hide { display: none; } \ No newline at end of file diff --git a/templates/submissionAnnotations.tpl b/templates/submissionAnnotations.tpl index 9f2e366..d79c339 100644 --- a/templates/submissionAnnotations.tpl +++ b/templates/submissionAnnotations.tpl @@ -24,7 +24,8 @@
    {$annotation->target}
    - + + {/if} @@ -32,32 +33,4 @@ {/foreach} - - \ No newline at end of file + \ No newline at end of file From 84fc02e8d60c13e76f15bcad8186077fa2e6c985 Mon Sep 17 00:00:00 2001 From: Jhon Date: Mon, 26 Sep 2022 15:43:27 -0400 Subject: [PATCH 34/55] Adds read more button for annotation content Signed-off-by: Jhon Signed-off-by: Richard --- js/load.js | 25 +++++++++++++++++-------- styles/annotationsPage.css | 2 +- templates/submissionAnnotations.tpl | 8 ++++---- 3 files changed, 22 insertions(+), 13 deletions(-) diff --git a/js/load.js b/js/load.js index e1252b0..299015d 100644 --- a/js/load.js +++ b/js/load.js @@ -1,23 +1,32 @@ let maxCharNumber = 300; let annotationTargets = document.querySelectorAll('.annotation_target > blockquote'); +let annotationContents = document.querySelectorAll('.annotation_content > blockquote'); annotationTargets.forEach(target => { - if(target.textContent.length <= maxCharNumber) { - let readMoreBtn = target.nextElementSibling; + addReadMoreLogic(target); +}); + +annotationContents.forEach(content => { + addReadMoreLogic(content); +}); + +function addReadMoreLogic(element) { + if(element.textContent.length <= maxCharNumber) { + let readMoreBtn = element.nextElementSibling; readMoreBtn.style.display = "none"; } else { - let trimmedText = target.textContent.trim(); + let trimmedText = element.textContent.trim(); let textToDisplay = trimmedText.slice(0, maxCharNumber); let textMore = trimmedText.slice(maxCharNumber); - target.innerHTML = `${textToDisplay}...${textMore}`; + element.innerHTML = `${textToDisplay}...${textMore}`; } -}); +} function toggleReadMore(btn){ - let annotation = btn.parentElement; - annotation.querySelector('.dots').classList.toggle('hide'); - annotation.querySelector('.more').classList.toggle('hide'); + let parent = btn.parentElement; + parent.querySelector('.dots').classList.toggle('hide'); + parent.querySelector('.more').classList.toggle('hide'); if(btn.classList.contains('read_more')) btn.nextElementSibling.classList.remove('hide'); else diff --git a/styles/annotationsPage.css b/styles/annotationsPage.css index 4dd4e5a..1433f51 100644 --- a/styles/annotationsPage.css +++ b/styles/annotationsPage.css @@ -32,7 +32,7 @@ color: rgba(0,0,0,0.54); } -.annotation_target blockquote { +.annotation_target blockquote, .annotation_content blockquote { margin-bottom: 4px; } diff --git a/templates/submissionAnnotations.tpl b/templates/submissionAnnotations.tpl index d79c339..b812d2a 100644 --- a/templates/submissionAnnotations.tpl +++ b/templates/submissionAnnotations.tpl @@ -21,15 +21,15 @@ {if not empty($annotation->target)}
    -
    - {$annotation->target} -
    +
    {$annotation->target}
    {/if} - {$annotation->content} +
    {$annotation->content}
    + +
    {/foreach} From 95c22478d6c9837275280068bcf2a1dae43c1088 Mon Sep 17 00:00:00 2001 From: Jhon Date: Mon, 26 Sep 2022 16:06:27 -0400 Subject: [PATCH 35/55] Adds submission metadata to annotations page Signed-off-by: Jhon Signed-off-by> Richard --- classes/AnnotationsPageHandler.inc.php | 4 ++++ styles/annotationsPage.css | 14 ++++++++++++ templates/submissionAnnotations.tpl | 30 ++++++++++++++++++++++++++ 3 files changed, 48 insertions(+) diff --git a/classes/AnnotationsPageHandler.inc.php b/classes/AnnotationsPageHandler.inc.php index 772625f..511cde2 100644 --- a/classes/AnnotationsPageHandler.inc.php +++ b/classes/AnnotationsPageHandler.inc.php @@ -10,8 +10,12 @@ function index($args, $request) { $context = $request->getContext(); $paginationParams = $this->getPaginationParams($args, $context); + $pubIdPlugins = PluginRegistry::loadCategory('pubIds', true, $context->getId()); + $templateMgr = TemplateManager::getManager($request); $templateMgr->assign($paginationParams); + $templateMgr->assign('pubIdPlugins', $pubIdPlugins); + $templateMgr->assign('journal', $context); $jsUrl = $request->getBaseUrl() . '/' . $plugin->getPluginPath() . '/js/load.js'; $templateMgr->addJavascript('AnnotationsPage', $jsUrl, ['contexts' => 'frontend']); diff --git a/styles/annotationsPage.css b/styles/annotationsPage.css index 1433f51..c02584b 100644 --- a/styles/annotationsPage.css +++ b/styles/annotationsPage.css @@ -10,6 +10,20 @@ font-weight: 700; } +.meta { + padding-top: 5px; + font-size: 14px; + line-height: 20px; +} + +.meta > .authors { + padding-right: 5em; +} + +.meta > .published, .meta > .doi { + color: rgba(0,0,0,0.54); +} + .annotation { background-color: #FFF; font-size: 14px; diff --git a/templates/submissionAnnotations.tpl b/templates/submissionAnnotations.tpl index b812d2a..81aa7c8 100644 --- a/templates/submissionAnnotations.tpl +++ b/templates/submissionAnnotations.tpl @@ -13,6 +13,36 @@ {/if} +
    +
    + {$preprint->getAuthorString()|escape} +
    + + {* DOI *} + {foreach from=$pubIdPlugins item=pubIdPlugin} + {if $pubIdPlugin->getPubIdType() != 'doi'} + {continue} + {/if} + {assign var=pubId value=$preprint->getCurrentPublication()->getStoredPubId($pubIdPlugin->getPubIdType())} + {if $pubId} + {assign var="doiUrl" value=$pubIdPlugin->getResolvingURL($journal->getId(), $pubId)|escape} +
    + {capture assign=translatedDOI}{translate key="plugins.pubIds.doi.readerDisplayName"}{/capture} + {translate key="semicolon" label=$translatedDOI} + + + {$doiUrl} + + +
    + {/if} + {/foreach} + +
    + {translate key="submission.dates" submitted=$preprint->getDateSubmitted()|date_format:$dateFormatShort published=$preprint->getDatePublished()|date_format:$dateFormatShort} +
    +
    + {foreach from=$annotations item="annotation"}
    From 348665615f49eafd95904353d46181ccf103bd91 Mon Sep 17 00:00:00 2001 From: lucasDevLepidus Date: Tue, 4 Oct 2022 16:02:21 -0300 Subject: [PATCH 36/55] Remove search box MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Issue: documentacao-e-tarefas/scielo#396 Signed-off-by: Lucas Anselmo Signed-off-by: Laís Reis --- templates/annotationsPage.tpl | 1 - 1 file changed, 1 deletion(-) diff --git a/templates/annotationsPage.tpl b/templates/annotationsPage.tpl index e0d0dcf..04dd25a 100644 --- a/templates/annotationsPage.tpl +++ b/templates/annotationsPage.tpl @@ -9,7 +9,6 @@ {include file="frontend/components/header.tpl" pageTitleTranslated=$pageTitle}
    - {include file="frontend/components/archiveHeader.tpl"}

    {$pageTitle|escape}

    From 8e32bfa345dcee7b8cab87d5082805a70f7a028e Mon Sep 17 00:00:00 2001 From: Jhon Date: Fri, 3 Feb 2023 16:55:34 -0400 Subject: [PATCH 37/55] Adds order by date of last annotation Signed-off-by: Jhon --- classes/AnnotationsPageHandler.inc.php | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/classes/AnnotationsPageHandler.inc.php b/classes/AnnotationsPageHandler.inc.php index 511cde2..c5c1f46 100644 --- a/classes/AnnotationsPageHandler.inc.php +++ b/classes/AnnotationsPageHandler.inc.php @@ -1,5 +1,8 @@ getContext(); - $paginationParams = $this->getPaginationParams($args, $context); + $paginationParams = $this->getPaginationParams($args, $request, $context); $pubIdPlugins = PluginRegistry::loadCategory('pubIds', true, $context->getId()); $templateMgr = TemplateManager::getManager($request); @@ -23,12 +26,13 @@ function index($args, $request) { return $templateMgr->display($plugin->getTemplateResource('annotationsPage.tpl')); } - private function getPaginationParams($args, $context): array { + private function getPaginationParams($args, $request, $context): array { $page = isset($args[0]) ? (int) $args[0] : 1; $itemsPerPage = $context->getData('itemsPerPage') ? $context->getData('itemsPerPage') : Config::getVar('interface', 'items_per_page'); $offset = $page > 1 ? ($page - 1) * $itemsPerPage : 0; - $submissionsAnnotations = $this->getSubmissionsAnnotations($context->getId()); + $orderBy = ($request->getUserVar('orderBy') ?? ORDER_BY_DATE_PUBLISHED); + $submissionsAnnotations = $this->getSubmissionsAnnotations($context->getId(), $orderBy); $pageAnnotations = array_slice($submissionsAnnotations, $offset, $itemsPerPage); $total = count($submissionsAnnotations); @@ -52,7 +56,7 @@ private function getPaginationParams($args, $context): array { ]; } - private function getSubmissionsAnnotations($contextId) { + private function getSubmissionsAnnotations($contextId, $orderBy) { $cacheManager = CacheManager::getManager(); $cache = $cacheManager->getFileCache( $contextId, @@ -69,6 +73,17 @@ private function getSubmissionsAnnotations($contextId) { $submissionsAnnotations = $cache->getContents(); } + if($orderBy == ORDER_BY_LAST_ANNOTATION) { + usort($submissionsAnnotations, function($a, $b){ + $lastAnnotationA = $a->annotations[0]; + $lastAnnotationB = $b->annotations[0]; + + if($lastAnnotationA->dateCreated == $lastAnnotationB->dateCreated) return 0; + + return ($lastAnnotationA->dateCreated < $lastAnnotationB->dateCreated) ? 1 : -1; + }); + } + return $submissionsAnnotations; } From a0a8554c980ab986858f799d726f07430e60f4da Mon Sep 17 00:00:00 2001 From: Jhon Date: Fri, 3 Feb 2023 18:22:03 -0400 Subject: [PATCH 38/55] Adds ordering by date published Signed-off-by: Jhon --- classes/AnnotationsPageHandler.inc.php | 29 ++++++++++++++++++-------- classes/HypothesisDAO.inc.php | 23 ++++++++++++++++++++ 2 files changed, 43 insertions(+), 9 deletions(-) create mode 100644 classes/HypothesisDAO.inc.php diff --git a/classes/AnnotationsPageHandler.inc.php b/classes/AnnotationsPageHandler.inc.php index c5c1f46..2ded6d9 100644 --- a/classes/AnnotationsPageHandler.inc.php +++ b/classes/AnnotationsPageHandler.inc.php @@ -5,6 +5,7 @@ import('classes.handler.Handler'); import('plugins.generic.hypothesis.classes.HypothesisHandler'); +import('plugins.generic.hypothesis.classes.HypothesisDAO'); class AnnotationsPageHandler extends Handler { @@ -73,18 +74,28 @@ private function getSubmissionsAnnotations($contextId, $orderBy) { $submissionsAnnotations = $cache->getContents(); } - if($orderBy == ORDER_BY_LAST_ANNOTATION) { - usort($submissionsAnnotations, function($a, $b){ - $lastAnnotationA = $a->annotations[0]; - $lastAnnotationB = $b->annotations[0]; + usort($submissionsAnnotations, [$this, $orderBy.'Ordering']); - if($lastAnnotationA->dateCreated == $lastAnnotationB->dateCreated) return 0; + return $submissionsAnnotations; + } - return ($lastAnnotationA->dateCreated < $lastAnnotationB->dateCreated) ? 1 : -1; - }); - } + public function lastAnnotationOrdering($a, $b) { + $lastAnnotationA = $a->annotations[0]; + $lastAnnotationB = $b->annotations[0]; - return $submissionsAnnotations; + if($lastAnnotationA->dateCreated == $lastAnnotationB->dateCreated) return 0; + + return ($lastAnnotationA->dateCreated < $lastAnnotationB->dateCreated) ? 1 : -1; + } + + public function datePublishedOrdering($a, $b) { + $hypothesisDao = new HypothesisDAO(); + $datePublishedA = $hypothesisDao->getDatePublished($a->submissionId); + $datePublishedB = $hypothesisDao->getDatePublished($b->submissionId); + + if($datePublishedA == $datePublishedB) return 0; + + return ($datePublishedA < $datePublishedB) ? 1 : -1; } function cacheDismiss() { diff --git a/classes/HypothesisDAO.inc.php b/classes/HypothesisDAO.inc.php new file mode 100644 index 0000000..1d76241 --- /dev/null +++ b/classes/HypothesisDAO.inc.php @@ -0,0 +1,23 @@ +where('submission_id', $submissionId) + ->select('current_publication_id') + ->first(); + $currentPublicationId = get_object_vars($result)['current_publication_id']; + + $result = Capsule::table('publications') + ->where('publication_id', $currentPublicationId) + ->select('date_published') + ->first(); + + return get_object_vars($result)['date_published']; + } +} \ No newline at end of file From bd4a8659a31d55e090190e883e351361985082f2 Mon Sep 17 00:00:00 2001 From: Jhon Date: Mon, 6 Feb 2023 15:10:14 -0400 Subject: [PATCH 39/55] Adds select to order of submissions in annotations page Signed-off-by: Jhon --- locale/en_US/locale.po | 11 ++++++++++- locale/es_ES/locale.po | 11 ++++++++++- locale/pt_BR/locale.po | 11 ++++++++++- styles/annotationsPage.css | 12 ++++++++++++ templates/annotationsPage.tpl | 9 +++++++++ 5 files changed, 51 insertions(+), 3 deletions(-) diff --git a/locale/en_US/locale.po b/locale/en_US/locale.po index 95c78d9..8465ac0 100644 --- a/locale/en_US/locale.po +++ b/locale/en_US/locale.po @@ -30,4 +30,13 @@ msgid "plugins.generic.hypothesis.annotationsPageNumber" msgstr "Annotations - Page {$pageNumber}" msgid "plugins.generic.hypothesis.noSubmissionsWithAnnotations" -msgstr "There are no annotated submissions" \ No newline at end of file +msgstr "There are no annotated submissions" + +msgid "plugins.generic.hypothesis.orderBy" +msgstr "Order by:" + +msgid "plugins.generic.hypothesis.orderBy.datePublished" +msgstr "Date published" + +msgid "plugins.generic.hypothesis.orderBy.lastAnnotation" +msgstr "Date of last annotation" \ No newline at end of file diff --git a/locale/es_ES/locale.po b/locale/es_ES/locale.po index 598c461..951f79a 100644 --- a/locale/es_ES/locale.po +++ b/locale/es_ES/locale.po @@ -32,4 +32,13 @@ msgid "plugins.generic.hypothesis.annotationsPageNumber" msgstr "Anotaciones - Página {$pageNumber}" msgid "plugins.generic.hypothesis.noSubmissionsWithAnnotations" -msgstr "No hay envíos anotados" \ No newline at end of file +msgstr "No hay envíos anotados" + +msgid "plugins.generic.hypothesis.orderBy" +msgstr "Ordenar por:" + +msgid "plugins.generic.hypothesis.orderBy.datePublished" +msgstr "Fecha de publicación" + +msgid "plugins.generic.hypothesis.orderBy.lastAnnotation" +msgstr "Fecha de la última annotación" \ No newline at end of file diff --git a/locale/pt_BR/locale.po b/locale/pt_BR/locale.po index a273d83..ccec324 100644 --- a/locale/pt_BR/locale.po +++ b/locale/pt_BR/locale.po @@ -32,4 +32,13 @@ msgid "plugins.generic.hypothesis.annotationsPageNumber" msgstr "Anotações - Página {$pageNumber}" msgid "plugins.generic.hypothesis.noSubmissionsWithAnnotations" -msgstr "Não há submissões com anotações" \ No newline at end of file +msgstr "Não há submissões com anotações" + +msgid "plugins.generic.hypothesis.orderBy" +msgstr "Ordenar por:" + +msgid "plugins.generic.hypothesis.orderBy.datePublished" +msgstr "Data de postagem" + +msgid "plugins.generic.hypothesis.orderBy.lastAnnotation" +msgstr "Data da última anotação" \ No newline at end of file diff --git a/styles/annotationsPage.css b/styles/annotationsPage.css index c02584b..a799c8e 100644 --- a/styles/annotationsPage.css +++ b/styles/annotationsPage.css @@ -1,3 +1,15 @@ +#orderSubmissions { + margin-bottom: 1rem; +} + +#selectOrderSubmissions { + background: #FFF; + border: 1px solid rgba(0,0,0,0.4); + border-radius: 3px; + font-size: 0.93rem; + height: calc(2.143rem - 2px); +} + .submission_annotations { background-color: #fafaf8; padding: 10px 15px; diff --git a/templates/annotationsPage.tpl b/templates/annotationsPage.tpl index 04dd25a..c358704 100644 --- a/templates/annotationsPage.tpl +++ b/templates/annotationsPage.tpl @@ -15,6 +15,15 @@ {if empty($submissionsAnnotations)}

    {translate key="plugins.generic.hypothesis.noSubmissionsWithAnnotations"}

    {else} + +
    + + +
    +
      {foreach from=$submissionsAnnotations item="submissionAnnotations"}
    • From f1f146afff18ba0316ede24ef5a548b2402367d0 Mon Sep 17 00:00:00 2001 From: Jhon Date: Mon, 6 Feb 2023 15:44:48 -0400 Subject: [PATCH 40/55] OrderBy is selected according to page's URL Signed-off-by: Jhon --- classes/AnnotationsPageHandler.inc.php | 1 + templates/annotationsPage.tpl | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/classes/AnnotationsPageHandler.inc.php b/classes/AnnotationsPageHandler.inc.php index 2ded6d9..deda3a6 100644 --- a/classes/AnnotationsPageHandler.inc.php +++ b/classes/AnnotationsPageHandler.inc.php @@ -49,6 +49,7 @@ private function getPaginationParams($args, $request, $context): array { return [ 'submissionsAnnotations' => $pageAnnotations, + 'orderBy' => $orderBy, 'showingStart' => $showingStart, 'showingEnd' => $showingEnd, 'total' => $total, diff --git a/templates/annotationsPage.tpl b/templates/annotationsPage.tpl index c358704..3e29238 100644 --- a/templates/annotationsPage.tpl +++ b/templates/annotationsPage.tpl @@ -19,8 +19,12 @@
      From 7e7a1a3b6532a504743df84b099745a6dd747fc3 Mon Sep 17 00:00:00 2001 From: Jhon Date: Tue, 7 Feb 2023 13:24:59 -0400 Subject: [PATCH 41/55] Changes annotations page ordering when one is selected Signed-off-by: Jhon --- templates/annotationsPage.tpl | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/templates/annotationsPage.tpl b/templates/annotationsPage.tpl index 3e29238..1210a9f 100644 --- a/templates/annotationsPage.tpl +++ b/templates/annotationsPage.tpl @@ -56,4 +56,13 @@ {/if}
    -{include file="frontend/components/footer.tpl"} \ No newline at end of file +{include file="frontend/components/footer.tpl"} + + \ No newline at end of file From 27783ebce03deea04c82c7bd94af346a454a1f60 Mon Sep 17 00:00:00 2001 From: Jhon Date: Tue, 7 Feb 2023 17:46:02 -0400 Subject: [PATCH 42/55] Keeps selected order through annotations pagination Signed-off-by: Jhon --- templates/annotationsPage.tpl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/templates/annotationsPage.tpl b/templates/annotationsPage.tpl index 1210a9f..16a3a00 100644 --- a/templates/annotationsPage.tpl +++ b/templates/annotationsPage.tpl @@ -38,12 +38,12 @@ {* Pagination *} {if $prevPage > 1} - {capture assign=prevUrl}{url router=$smarty.const.ROUTE_PAGE page="annotations" path=$prevPage}{/capture} + {capture assign=prevUrl}{url router=$smarty.const.ROUTE_PAGE page="annotations" path=$prevPage params=['orderBy' => $orderBy]}{/capture} {elseif $prevPage === 1} - {capture assign=prevUrl}{url router=$smarty.const.ROUTE_PAGE page="annotations"}{/capture} + {capture assign=prevUrl}{url router=$smarty.const.ROUTE_PAGE page="annotations" params=['orderBy' => $orderBy]}{/capture} {/if} {if $nextPage} - {capture assign=nextUrl}{url router=$smarty.const.ROUTE_PAGE page="annotations" path=$nextPage}{/capture} + {capture assign=nextUrl}{url router=$smarty.const.ROUTE_PAGE page="annotations" path=$nextPage params=['orderBy' => $orderBy]}{/capture} {/if} {include file="frontend/components/pagination.tpl" From 58431e3c9463a64964b35b8d62cdb6adfaaaf724 Mon Sep 17 00:00:00 2001 From: Jhon Date: Tue, 14 Feb 2023 11:43:34 -0400 Subject: [PATCH 43/55] Refactors code of annotations ordering functions Signed-off-by: Jhon --- classes/AnnotationsPageHandler.inc.php | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/classes/AnnotationsPageHandler.inc.php b/classes/AnnotationsPageHandler.inc.php index deda3a6..4a5ba25 100644 --- a/classes/AnnotationsPageHandler.inc.php +++ b/classes/AnnotationsPageHandler.inc.php @@ -75,24 +75,25 @@ private function getSubmissionsAnnotations($contextId, $orderBy) { $submissionsAnnotations = $cache->getContents(); } - usort($submissionsAnnotations, [$this, $orderBy.'Ordering']); + $orderingFunction = $orderBy.'Ordering'; + usort($submissionsAnnotations, [$this, $orderingFunction]); return $submissionsAnnotations; } - public function lastAnnotationOrdering($a, $b) { - $lastAnnotationA = $a->annotations[0]; - $lastAnnotationB = $b->annotations[0]; + public function lastAnnotationOrdering($submissionAnnotationsA, $submissionAnnotationsB) { + $lastAnnotationA = $submissionAnnotationsA->annotations[0]; + $lastAnnotationB = $submissionAnnotationsB->annotations[0]; if($lastAnnotationA->dateCreated == $lastAnnotationB->dateCreated) return 0; return ($lastAnnotationA->dateCreated < $lastAnnotationB->dateCreated) ? 1 : -1; } - public function datePublishedOrdering($a, $b) { + public function datePublishedOrdering($submissionAnnotationsA, $submissionAnnotationsB) { $hypothesisDao = new HypothesisDAO(); - $datePublishedA = $hypothesisDao->getDatePublished($a->submissionId); - $datePublishedB = $hypothesisDao->getDatePublished($b->submissionId); + $datePublishedA = $hypothesisDao->getDatePublished($submissionAnnotationsA->submissionId); + $datePublishedB = $hypothesisDao->getDatePublished($submissionAnnotationsB->submissionId); if($datePublishedA == $datePublishedB) return 0; From ba8d71ed742c31f1efd1540ce96fa249dff0e17b Mon Sep 17 00:00:00 2001 From: Jhon Date: Thu, 9 Mar 2023 13:58:29 -0400 Subject: [PATCH 44/55] Changes default ordering to order by last annotation Signed-off-by: Jhon --- classes/AnnotationsPageHandler.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/classes/AnnotationsPageHandler.inc.php b/classes/AnnotationsPageHandler.inc.php index 4a5ba25..bed4ca2 100644 --- a/classes/AnnotationsPageHandler.inc.php +++ b/classes/AnnotationsPageHandler.inc.php @@ -32,7 +32,7 @@ private function getPaginationParams($args, $request, $context): array { $itemsPerPage = $context->getData('itemsPerPage') ? $context->getData('itemsPerPage') : Config::getVar('interface', 'items_per_page'); $offset = $page > 1 ? ($page - 1) * $itemsPerPage : 0; - $orderBy = ($request->getUserVar('orderBy') ?? ORDER_BY_DATE_PUBLISHED); + $orderBy = ($request->getUserVar('orderBy') ?? ORDER_BY_LAST_ANNOTATION); $submissionsAnnotations = $this->getSubmissionsAnnotations($context->getId(), $orderBy); $pageAnnotations = array_slice($submissionsAnnotations, $offset, $itemsPerPage); From b7f93283bf7a22a7faa85a7fcf3b96b6668548d4 Mon Sep 17 00:00:00 2001 From: Jhon Date: Wed, 7 Feb 2024 10:36:59 -0400 Subject: [PATCH 45/55] Escapes annotations content in annotations page Signed-off-by: Jhon --- templates/annotationsPage.tpl | 1 - templates/submissionAnnotations.tpl | 6 +++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/templates/annotationsPage.tpl b/templates/annotationsPage.tpl index 16a3a00..027ce29 100644 --- a/templates/annotationsPage.tpl +++ b/templates/annotationsPage.tpl @@ -15,7 +15,6 @@ {if empty($submissionsAnnotations)}

    {translate key="plugins.generic.hypothesis.noSubmissionsWithAnnotations"}

    {else} -