Skip to content

Commit

Permalink
Merge branch 'changePluginName' into 'main'
Browse files Browse the repository at this point in the history
Rename plugin to "OA Switchboard"

See merge request softwares-pkp/plugins_ojs/OASwitchboardForOJS!15
  • Loading branch information
iudizm committed Mar 11, 2024
2 parents f47271c + 80d241e commit 1c29149
Show file tree
Hide file tree
Showing 20 changed files with 151 additions and 154 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/generate-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
create-release:
name: Create release and package
env:
PLUGIN_NAME: OASwitchboardForOJS
PLUGIN_NAME: OASwitchboard
runs-on: ubuntu-latest
steps:
- name: Checkout code
Expand Down
2 changes: 1 addition & 1 deletion .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
variables:
PLUGIN_NAME: 'OASwitchboardForOJS'
PLUGIN_NAME: 'OASwitchboard'

include:
- project: 'documentacao-e-tarefas/modelosparaintegracaocontinua'
Expand Down
22 changes: 11 additions & 11 deletions OASwitchboardForOJSPlugin.inc.php → OASwitchboardPlugin.inc.php
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
<?php
/**
* @file plugins/generic/OASwitchboardForOJS/OASwitchboardForOJSPlugin.inc.php
* @file plugins/generic/OASwitchboard/OASwitchboardPlugin.inc.php
*
* Copyright (c) 2024 Lepidus Tecnologia
* Distributed under the GNU GPL v3. For full terms see the file LICENSE.
*
* @class OASwitchboardForOJSPlugin
* @ingroup plugins_generic_OASwitchboardForOJS
* @class OASwitchboardPlugin
* @ingroup plugins_generic_OASwitchboard
*
* @brief OASwitchboardForOJS plugin class
* @brief OASwitchboard plugin class
*/

import('lib.pkp.classes.plugins.GenericPlugin');
import('plugins.generic.OASwitchboardForOJS.classes.OASwitchboardService');
import('plugins.generic.OASwitchboard.classes.OASwitchboardService');

class OASwitchboardForOJSPlugin extends GenericPlugin
class OASwitchboardPlugin extends GenericPlugin
{
public function register($category, $path, $mainContextId = null)
{
Expand All @@ -25,12 +25,12 @@ public function register($category, $path, $mainContextId = null)

public function getDisplayName()
{
return __('plugins.generic.OASwitchboardForOJS.displayName');
return __('plugins.generic.OASwitchboard.displayName');
}

public function getDescription()
{
return __('plugins.generic.OASwitchboardForOJS.description');
return __('plugins.generic.OASwitchboard.description');
}

public function getActions($request, $actionArgs)
Expand Down Expand Up @@ -69,8 +69,8 @@ public function manage($args, $request)
switch ($request->getUserVar('verb')) {
case 'settings':
$context = $request->getContext();
$this->import('classes.settings.OASwitchboardForOJSSettingsForm');
$form = new OASwitchboardForOJSSettingsForm($this, $context->getId());
$this->import('classes.settings.OASwitchboardSettingsForm');
$form = new OASwitchboardSettingsForm($this, $context->getId());
$form->initData();
if ($request->getUserVar('save')) {
$form->readInputData();
Expand Down Expand Up @@ -119,7 +119,7 @@ public function sendOASwitchboardMessage($hookName, $args)
try {
if ($publication->getData('status') === STATUS_PUBLISHED) {
$OASwitchboard->sendP1PioMessage();
$this->sendNotification($userId, __('plugins.generic.OASwitchboardForOJS.sendMessageWithSuccess'), NOTIFICATION_TYPE_SUCCESS);
$this->sendNotification($userId, __('plugins.generic.OASwitchboard.sendMessageWithSuccess'), NOTIFICATION_TYPE_SUCCESS);
}
} catch (Exception $e) {
$this->sendNotification($userId, $e->getMessage(), NOTIFICATION_TYPE_WARNING);
Expand Down
15 changes: 6 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
# Open Access Switchboard For OJS
# Open Access Switchboard Plugin

This plugin integrates OJS to the [Open Access Switchboard](https://www.oaswitchboard.org/) API.
This plugin enables **[OJS](https://pkp.sfu.ca/software/ojs/)** journals to automatically send **P1-PIO** type messages to the **[Open Access Switchboard](https://www.oaswitchboard.org/)** API at the moment of article publication.

It enables journals to automatically send **P1-PIO** type messages to OASwitchboard, in the moment of the publication of articles, containing public information.

The current version sends P1-PIO messages with only the mandatory data about the article.

> Notice: This plugin is not yet ready for general use.
> The current version of this plugin sends P1-PIO messages with only the mandatory data about the article.
For that reason, it may not be ready for a comprehensive general use.

## Compatibility

Expand Down Expand Up @@ -45,11 +42,11 @@ The DOI Plugin must be active and properly configured in the journal.

## Plugin Installation

1. To download the plugin, go to the [Releases page](https://github.com/lepidus/OASwitchboardForOJS/releases) and download the tar.gz package of the latest release compatible with your website.
1. To download the plugin, go to the [Releases page](https://github.com/lepidus/OASwitchboard/releases) and download the tar.gz package of the latest release compatible with your website.

2. Enter the administration area of ​​your OJS website through the *Dashboard*.

Navigate to `Settings` > `Website` > `Plugins` > `Upload a new plugin` and select the file **`OASwitchboardForOJS.tar.gz`**.
Navigate to `Settings` > `Website` > `Plugins` > `Upload a new plugin` and select the file **`OASwitchboard.tar.gz`**.

Click Save and the plugin will be installed on your website.

Expand Down
12 changes: 6 additions & 6 deletions classes/OASwitchboardService.inc.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

/**
* @file plugins/generic/OASwitchboardForOJS/classes/OASwitchboard.inc.php
* @file plugins/generic/OASwitchboard/classes/OASwitchboard.inc.php
*
* Copyright (c) 2024 Lepidus Tecnologia
* Distributed under the GNU GPL v3. For full terms see the file LICENSE.
Expand All @@ -11,14 +11,14 @@
* @brief OASwitchboard plugin class
*/

import('plugins.generic.OASwitchboardForOJS.classes.messages.P1Pio');
import('plugins.generic.OASwitchboardForOJS.lib.APIKeyEncryption.APIKeyEncryption');
import('plugins.generic.OASwitchboardForOJS.OASwitchboardForOJSPlugin');
import('plugins.generic.OASwitchboardForOJS.classes.api.OASwitchboardAPIClient');
import('plugins.generic.OASwitchboard.classes.messages.P1Pio');
import('plugins.generic.OASwitchboard.lib.APIKeyEncryption.APIKeyEncryption');
import('plugins.generic.OASwitchboard.OASwitchboardPlugin');
import('plugins.generic.OASwitchboard.classes.api.OASwitchboardAPIClient');

class OASwitchboardService
{
private OASwitchboardForOJSPlugin $plugin;
private OASwitchboardPlugin $plugin;
private OASwitchboardAPIClient $apiClient;
private $contextId;
private $submission;
Expand Down
4 changes: 2 additions & 2 deletions classes/api/OASwitchboardAPIClient.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,12 @@ private function makeRequest(string $method, string $endpoint, array $options)
} catch (ServerException $e) {
error_log($e);
throw new Exception(
__('plugins.generic.OASwitchboardForOJS.serverError')
__('plugins.generic.OASwitchboard.serverError')
);
} catch (ClientException $e) {
error_log($e);
throw new Exception(
__('plugins.generic.OASwitchboardForOJS.postRequirements')
__('plugins.generic.OASwitchboard.postRequirements')
);
}
}
Expand Down
18 changes: 9 additions & 9 deletions classes/messages/P1Pio.inc.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php

import('plugins.generic.OASwitchboardForOJS.classes.messages.P1PioDataFormat');
import('plugins.generic.OASwitchboardForOJS.classes.messages.LicenseAcronym');
import('plugins.generic.OASwitchboardForOJS.classes.exceptions.P1PioException');
import('plugins.generic.OASwitchboard.classes.messages.P1PioDataFormat');
import('plugins.generic.OASwitchboard.classes.messages.LicenseAcronym');
import('plugins.generic.OASwitchboard.classes.exceptions.P1PioException');
import('classes.submission.Submission');
import('lib.pkp.classes.log.SubmissionLog');

Expand All @@ -20,7 +20,7 @@ public function __construct(Submission $submission)
$this->submission = $submission;
$minimumData = $this->validateHasMinimumSubmissionData();
if (!empty($minimumData)) {
throw new P1PioException(__('plugins.generic.OASwitchboardForOJS.postRequirementsError'), 0, $minimumData);
throw new P1PioException(__('plugins.generic.OASwitchboard.postRequirementsError'), 0, $minimumData);
}
}

Expand Down Expand Up @@ -117,22 +117,22 @@ public function validateHasMinimumSubmissionData(): array
$data = $message['data'];

if (empty($header['to']['address'])) {
$missingDataMessages[] = 'plugins.generic.OASwitchboardForOJS.postRequirementsError.recipient';
$missingDataMessages[] = 'plugins.generic.OASwitchboard.postRequirementsError.recipient';
}

foreach ($data['authors'] as $key => $author) {
if (empty($author['lastName'])) {
$missingDataMessages[] = 'plugins.generic.OASwitchboardForOJS.postRequirementsError.familyName';
$missingDataMessages[] = 'plugins.generic.OASwitchboard.postRequirementsError.familyName';
}
if (empty($author['affiliation'])) {
$missingDataMessages[] = 'plugins.generic.OASwitchboardForOJS.postRequirementsError.affiliation';
$missingDataMessages[] = 'plugins.generic.OASwitchboard.postRequirementsError.affiliation';
}
}
if (empty($data['article']['doi'])) {
$missingDataMessages[] = 'plugins.generic.OASwitchboardForOJS.postRequirementsError.doi';
$missingDataMessages[] = 'plugins.generic.OASwitchboard.postRequirementsError.doi';
}
if (empty($data['journal']['id'])) {
$missingDataMessages[] = 'plugins.generic.OASwitchboardForOJS.postRequirementsError.issn';
$missingDataMessages[] = 'plugins.generic.OASwitchboard.postRequirementsError.issn';
}

return $missingDataMessages;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?php

import('lib.pkp.classes.form.Form');
import('plugins.generic.OASwitchboardForOJS.lib.APIKeyEncryption.APIKeyEncryption');
import('plugins.generic.OASwitchboardForOJS.classes.api.OASwitchboardAPIClient');
import('plugins.generic.OASwitchboard.lib.APIKeyEncryption.APIKeyEncryption');
import('plugins.generic.OASwitchboard.classes.api.OASwitchboardAPIClient');

class OASwitchboardForOJSSettingsForm extends Form
class OASwitchboardSettingsForm extends Form
{
private $plugin;
private $contextId;
Expand Down Expand Up @@ -38,7 +38,7 @@ private function authenticationFailNotification(): void
$notificationManager->createTrivialNotification(
$user->getId(),
NOTIFICATION_TYPE_ERROR,
array('contents' => __('plugins.generic.OASwitchboardForOJS.settings.apiAuthenticatorFailed'))
array('contents' => __('plugins.generic.OASwitchboard.settings.apiAuthenticatorFailed'))
);
}

Expand Down
10 changes: 5 additions & 5 deletions cypress/tests/Test0_pluginSetup.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,23 @@ describe('Setup OASwitchboard plugin', function () {
cy.contains('a', 'Website').click();
cy.waitJQuery();
cy.get('#plugins-button').click();
cy.get('input[id^=select-cell-oaswitchboardforojsplugin]').check();
cy.get('input[id^=select-cell-oaswitchboardforojsplugin]').should('be.checked');
cy.get('input[id^=select-cell-oaswitchboardplugin]').check();
cy.get('input[id^=select-cell-oaswitchboardplugin]').should('be.checked');
})
it('Access the plugin configuration form', function () {
cy.login('dbarnes', null, 'publicknowledge');
cy.contains('a', 'Website').click();
cy.waitJQuery();
cy.get('#plugins-button').click();

const pluginRowId = 'component-grid-settings-plugins-settingsplugingrid-category-generic-row-oaswitchboardforojsplugin';
const pluginRowId = 'component-grid-settings-plugins-settingsplugingrid-category-generic-row-oaswitchboardplugin';

cy.get('tr#' + pluginRowId + ' a.show_extras').click();
cy.get('a[id^=' + pluginRowId + '-settings-button]').click();

cy.get('form#OASwitchboardForOJSSettingsForm').should('be.visible')
cy.get('form#OASwitchboardSettingsForm').should('be.visible')

cy.contains('OA Switchboard Integration Plugin for OJS');
cy.contains('OA Switchboard Plugin');
cy.contains('Please, enter your Open Access Switchboard credentials below, to allow the plugin to access the API.')

cy.get('input[name=OASUsername]').should('be.visible');
Expand Down
10 changes: 5 additions & 5 deletions cypress/tests/Test1_settingsFormInvalidAuth.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,26 @@ describe('Setup OASwitchboard invalid credentials', function () {
cy.waitJQuery();
cy.get('#plugins-button').click();

const pluginRowId = 'component-grid-settings-plugins-settingsplugingrid-category-generic-row-oaswitchboardforojsplugin';
const pluginRowId = 'component-grid-settings-plugins-settingsplugingrid-category-generic-row-oaswitchboardplugin';

cy.get('tr#' + pluginRowId + ' a.show_extras').click();
cy.get('a[id^=' + pluginRowId + '-settings-button]').click();

cy.contains('OA Switchboard Integration Plugin for OJS');
cy.contains('OA Switchboard Plugin');

cy.contains('Please, enter your Open Access Switchboard credentials below, to allow the plugin to access the API.');
cy.get('input[name=OASUsername]').should('be.visible');
cy.get('input[name=OASPassword]').should('be.visible');

cy.get('input[name=OASUsername]').focus().clear();
cy.get('input[name=OASPassword]').focus().clear();
cy.get('form#OASwitchboardForOJSSettingsForm button:contains("Save")').click();
cy.get('form#OASwitchboardSettingsForm button:contains("Save")').click();
cy.get('label[for^=OASUsername].error').should('contain', 'This field is required.');
cy.get('label[for^=OASPassword].error').should('contain', 'This field is required.');

cy.get('input[name=OASUsername]').type('username');
cy.get('input[name=OASPassword]').type('password');
cy.get('form#OASwitchboardForOJSSettingsForm button:contains("Save")').click();
cy.get('form#OASwitchboardForOJSSettingsForm').should('contain', 'Failed to authenticate, please check the OA Switchboard API credentials again');
cy.get('form#OASwitchboardSettingsForm button:contains("Save")').click();
cy.get('form#OASwitchboardSettingsForm').should('contain', 'Failed to authenticate, please check the OA Switchboard API credentials again');
})
})
14 changes: 7 additions & 7 deletions cypress/tests/Test2_settingsFormAuthentication.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ describe('Setup OASwitchboard credentials', function () {
cy.waitJQuery();
cy.get('#plugins-button').click();

const pluginRowId = 'component-grid-settings-plugins-settingsplugingrid-category-generic-row-oaswitchboardforojsplugin';
const pluginRowId = 'component-grid-settings-plugins-settingsplugingrid-category-generic-row-oaswitchboardplugin';

cy.get('tr#' + pluginRowId + ' a.show_extras').click();
cy.get('a[id^=' + pluginRowId + '-settings-button]').click();

cy.contains('OA Switchboard Integration Plugin for OJS');
cy.contains('OA Switchboard Plugin');

cy.contains('Please, enter your Open Access Switchboard credentials below, to allow the plugin to access the API.');
cy.get('input[name=OASUsername]').should('be.visible');
Expand All @@ -22,14 +22,14 @@ describe('Setup OASwitchboard credentials', function () {

cy.get('input[name=OASUsername]').type(Cypress.env('OASUsername'), {force: true});
cy.get('input[name=OASPassword]').type(Cypress.env('OASPassword'));
cy.get('form#OASwitchboardForOJSSettingsForm button:contains("Save")').click();
cy.get('form#OASwitchboardForOJSSettingsForm').should('not.be.visible');
cy.get('form#OASwitchboardSettingsForm button:contains("Save")').click();
cy.get('form#OASwitchboardSettingsForm').should('not.be.visible');
cy.contains('Your changes have been saved.');

cy.get('a[id^=' + pluginRowId + '-settings-button]').click();

cy.contains('OA Switchboard Integration Plugin for OJS');
cy.get('form#OASwitchboardForOJSSettingsForm').contains('The API credentials are ready to use! Currently using credentials for: ' + Cypress.env('OASUsername') + '.');
cy.get('form#OASwitchboardForOJSSettingsForm').contains('You can edit the credentials below, or click the Cancel button.');
cy.contains('OA Switchboard Plugin');
cy.get('form#OASwitchboardSettingsForm').contains('The API credentials are ready to use! Currently using credentials for: ' + Cypress.env('OASUsername') + '.');
cy.get('form#OASwitchboardSettingsForm').contains('You can edit the credentials below, or click the Cancel button.');
})
})
4 changes: 2 additions & 2 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
*
*/

require_once('OASwitchboardForOJSPlugin.inc.php');
require_once('OASwitchboardPlugin.inc.php');

return new OASwitchboardForOJSPlugin();
return new OASwitchboardPlugin();
Loading

0 comments on commit 1c29149

Please sign in to comment.