Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
103 commits
Select commit Hold shift + click to select a range
e899d10
Added first Certificate Identifier Field to submission form
dxL1nus Oct 8, 2025
19a91f5
Updated Certificate ID Fields to now include Reserve and Remove Butto…
dxL1nus Oct 9, 2025
8b0dee2
Small comments on what to do next github.com/codecheckers/ojs-codeche…
dxL1nus Oct 9, 2025
2788bb7
Remove Identifier button now removes ID from Input correctly (https:/…
dxL1nus Oct 9, 2025
45c90d5
Added initial Selects for Venue Type and Name (https://github.com/cod…
dxL1nus Oct 9, 2025
1c85bed
New labels for Venue Name and Venue Type (https://github.com/codechec…
dxL1nus Oct 9, 2025
4ed37f3
Intitial Structure for AJAX Call, but fails at the moment (https://gi…
dxL1nus Oct 9, 2025
315d9d6
Changed Ajax Path to now use API Hook provided to me by @subhanaliweb…
dxL1nus Oct 13, 2025
96718f6
Minor changes to API, but still not working yet (https://github.com/c…
dxL1nus Oct 14, 2025
fc633ee
Trying to fix the API not found bug (but not successful so far) https…
dxL1nus Oct 16, 2025
4d028af
Small updates, but still API 404 Error (https://github.com/codechecke…
dxL1nus Oct 16, 2025
4fa5d51
LoadHandler Hook now calls my APIHandler, but it seems, that APIHandl…
dxL1nus Oct 18, 2025
203a04e
Refactored RetrieveReserveIdentifiers to have separate files for each…
dxL1nus Oct 18, 2025
6c76726
Refactored Set to now use custom UniqueArray, for better support (htt…
dxL1nus Oct 20, 2025
50e6181
added require statement for own composer autoloader file (https://git…
dxL1nus Oct 22, 2025
d72ad4b
Fixed API bug by implemented our very own journal/codecheck_api/{ourA…
dxL1nus Oct 22, 2025
6c48b63
Finally VenueTypes and VenueNames is shown in the Selects after API w…
dxL1nus Oct 22, 2025
51bc3a3
Reserving of Identifier now works with Button through UI (https://git…
dxL1nus Oct 23, 2025
649e5aa
Now returns link to the newly created GitHub issue (https://github.co…
dxL1nus Oct 23, 2025
c1c3693
Link to newly created Github Issue is now displayed below Certificate…
dxL1nus Oct 23, 2025
fefecd9
Used refactor by subhan to refactor my fields to use Vue.js (https://…
dxL1nus Oct 23, 2025
26c9f40
Changed small css (https://github.com/codecheckers/ojs-codecheck/issu…
dxL1nus Oct 23, 2025
6ddb28f
Deleted old CertificateRetrievingAndCreation.php file (https://github…
dxL1nus Oct 23, 2025
91681bd
Added support for own codecheck Route in OJS API through existing rou…
dxL1nus Oct 28, 2025
ddb0378
Selects and Reserve Button are now disabled once the new Identifier i…
dxL1nus Oct 29, 2025
8076deb
Initial commit for this branch so the UI branch can be merged into it
dxL1nus Oct 30, 2025
f9d36e4
Merged UI branch into this branch #64
dxL1nus Oct 30, 2025
2985718
Certificate Identifier Fields now in Metadata Form #64
dxL1nus Oct 30, 2025
38b9afd
Began to reimplement Certificate Identifier Fields without extra Comp…
dxL1nus Oct 31, 2025
94432d1
Doesn't quite work yet #64
dxL1nus Oct 31, 2025
298c276
small changes #64
dxL1nus Nov 3, 2025
a1236f4
ran npm run build once
dxL1nus Nov 3, 2025
2886b6f
Added custom PKP modal for Remove Identifier #64
dxL1nus Nov 4, 2025
a0c8675
Now works and saves Certificate Identifier correctly to YAML file #64
dxL1nus Nov 4, 2025
613e38b
Made Author Name in Issue work initially #64 #47
dxL1nus Nov 4, 2025
10f283c
Removed print divs from submission form #64
dxL1nus Nov 5, 2025
c0b1f9b
Merged upstream metadata form into this forks metadata form branch
dxL1nus Nov 5, 2025
1d7a792
Changed URL of API to be relative
dxL1nus Nov 5, 2025
f41da54
Merged updates from metadata form branch into this one #64 #47
dxL1nus Nov 5, 2025
26c4024
Merged upstream codecheck-metadata-form branch
dxL1nus Nov 6, 2025
cd9a56b
Updated apiURL to be relative
dxL1nus Nov 6, 2025
d03c16a
Merged current state of metadata form into this one #64
dxL1nus Nov 6, 2025
1b338dc
Changed Title to be WORKFLOW: CODECHECK #64
dxL1nus Nov 7, 2025
e8575c2
Deleted method that binds Certificate Identifier Vue fields to Submis…
dxL1nus Nov 7, 2025
c1f24a3
Now initializes with null #64
dxL1nus Nov 11, 2025
06eb9a7
Added Exception Handling (API will now send success false with Except…
dxL1nus Nov 11, 2025
ff6daa2
First attempts at Dispatcher::dispatch for the API #64
dxL1nus Nov 12, 2025
7b57cf9
The new API Controller now works and it utilizes api/v1/codecheck/our…
dxL1nus Nov 12, 2025
db508e8
Merge CodecheckMetadataHandler and CodecheckApiHandler #54
dxL1nus Nov 13, 2025
329a14f
Added Authorization API check for correct CSRF Token #64
dxL1nus Nov 13, 2025
3177082
No authorize checks for correct role assignments #64
dxL1nus Nov 13, 2025
a6aa31b
Initial structure for unittests plus first tests for getRawIdentifier…
dxL1nus Nov 14, 2025
332fb6d
Found command to run unittests #70
dxL1nus Nov 26, 2025
16bccc1
Added Comments and PHPDoc for all functions I wrote #69
dxL1nus Nov 26, 2025
d58b905
Changed behavior of getRawIdentifier based on unittests #70
dxL1nus Nov 26, 2025
7ea28bd
New behavior for getRawIdentifier
dxL1nus Nov 26, 2025
457d032
Added new unit-test for getRawIdentifier() #70
dxL1nus Nov 26, 2025
d95b477
Update README.md to include Guide on how to run Unit Tests #70
dxL1nus Nov 26, 2025
e07650d
Update README.md to include guide for registering new Api Endpoints #…
dxL1nus Nov 26, 2025
4c227c9
Updated Venue Names to now fetch from Codecheck Rest Api #48, #64
dxL1nus Nov 27, 2025
4760d88
CertificateIdentifierList is now fully covered #70
dxL1nus Nov 27, 2025
15fe422
Simplified setup of CertificateIdentifierList tests #70
dxL1nus Nov 27, 2025
aa09da4
Added Unit Tests for CertificateIdentifier #70
dxL1nus Nov 27, 2025
4c10b7d
Added further Unit tests for Codecheck Venues #70
dxL1nus Nov 27, 2025
88322fc
Added some more UnitTests for the GitHub Api Parser #70
dxL1nus Nov 28, 2025
eec777e
Correct Api path
dxL1nus Nov 28, 2025
6bc61f4
New version of subhan now works
dxL1nus Dec 1, 2025
3bebfae
Merged newest commits from upstream
dxL1nus Dec 1, 2025
f4a98cb
Updated the UI to be up to date with the newest version of codecheck …
dxL1nus Dec 1, 2025
5e568d1
#36, #74: Added initial Button to Load Metadata and Linked it to API …
dxL1nus Dec 2, 2025
71351e2
Script now looks for codecheck.yml and returns the file contents if f…
dxL1nus Dec 3, 2025
33d3749
The codecheck.yml content is now parsed and returned as a metadata ar…
dxL1nus Dec 3, 2025
cb67b99
Metadata can now be loaded from file into metadata form #74
dxL1nus Dec 3, 2025
d86b328
Load Metadata now works for Zenodo Repositories as well #75
dxL1nus Dec 3, 2025
0ac7a9a
The support for OSF repositories now works with the OSF API #76
dxL1nus Dec 4, 2025
5f2f2ec
Now the loading of existing metadata also works for GitLab repositori…
dxL1nus Dec 4, 2025
840e345
Merged Unit Tests to this branch so I can begin to write tests for th…
dxL1nus Dec 4, 2025
42ee394
Made existing tests work with this branch #36
dxL1nus Dec 4, 2025
336eb5d
Added UnitTest for Import Metadata from Github #74
dxL1nus Dec 4, 2025
4459f02
Added Unit Test for Zenodo, though this is still accessing the real u…
dxL1nus Dec 4, 2025
5c25ae4
Added Repository Info Button #36
dxL1nus Dec 4, 2025
7dddf28
Made the link to the documentation of the different repo types work #36
dxL1nus Dec 4, 2025
c6a384e
Forgot npm run build, now it should work #36
dxL1nus Dec 4, 2025
ed35c9c
Added last UnitTests to reach 100% coverage #70
dxL1nus Dec 4, 2025
571313e
Added warning to Repositories Info #36
dxL1nus Dec 10, 2025
eeb927f
Corrected a spelling mistake #36
dxL1nus Dec 10, 2025
ae18d6b
Fixed bug on main #59
dxL1nus Dec 12, 2025
2bc7131
Merged main into my branch #48 #64
dxL1nus Dec 12, 2025
2895b1d
Merged main and adapted to latest version of RetrieveReserveIdentifie…
dxL1nus Dec 18, 2025
86b8ea9
Added unit test for Unique Array from factory method #70
dxL1nus Dec 18, 2025
5661235
Fixed Merge conflict in Readme Test Documentation #70
dxL1nus Dec 18, 2025
d4fd9a1
Added test coverage file path to README #70
dxL1nus Dec 18, 2025
e2fd739
Merged main into this branch #36, #74, #75, #76, #77
dxL1nus Dec 18, 2025
b77b6dd
Merge upstream main into my forks main
dxL1nus Dec 20, 2025
b2f1c80
Merged new commits to Unit Tests #70
dxL1nus Dec 20, 2025
a127801
Merged new commits to this branch #36, #74, #75, #76, #77
dxL1nus Dec 20, 2025
76a28eb
Reworked the JSON Response Object to be better usable #36
dxL1nus Jan 3, 2026
610dcf2
Added Wrapper for Curl functions #36
dxL1nus Jan 3, 2026
3b70be7
Finished reworking curl calls, now possible to mock them #36, #75
dxL1nus Jan 4, 2026
8dac8df
Added first unit test for OSF #36, #76
dxL1nus Jan 4, 2026
70e54c2
Added full test coverage for imports from github and OSF #36, 74, #76
dxL1nus Jan 7, 2026
be9fbc0
finished unit tests for gitlab and read yaml contents #36, #77, #70
dxL1nus Jan 8, 2026
3c6b7be
Merged current state of feature/unit-tests to this branch #36
dxL1nus Jan 9, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 41 additions & 45 deletions CodecheckPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,20 @@
use APP\plugins\generic\codecheck\classes\FrontEnd\ArticleDetails;
use APP\plugins\generic\codecheck\classes\Settings\Actions;
use APP\plugins\generic\codecheck\classes\migration\CodecheckSchemaMigration;
use APP\plugins\generic\codecheck\classes\Workflow\CodecheckMetadataHandler;
use APP\plugins\generic\codecheck\classes\Submission\Schema;
use APP\plugins\generic\codecheck\classes\Submission\SubmissionWizardHandler;
use PKP\plugins\GenericPlugin;
use PKP\plugins\Hook;
use PKP\components\forms\FieldOptions;
use APP\facades\Repo;
use APP\plugins\generic\codecheck\api\v1\CodecheckApiHandler;

class CodecheckPlugin extends GenericPlugin
{
public function register($category, $path, $mainContextId = null): bool
{
error_log('[CodecheckPlugin] register() called, path=' . $path);

$success = parent::register($category, $path);

if ($success && $this->getEnabled()) {
Expand All @@ -26,53 +28,17 @@ public function register($category, $path, $mainContextId = null): bool
$articleDetails = new ArticleDetails($this);
Hook::add('Templates::Article::Details', $articleDetails->addCodecheckInfo(...));

// Opt-in checkbox on submission start
Hook::add('Schema::get::submission', $this->addOptInToSchema(...));
Hook::add('Form::config::before', $this->addOptInCheckbox(...));
Hook::add('Submission::edit', $this->saveOptIn(...));

Hook::add('Submission::validate', $this->saveWizardFieldsFromRequest(...));

// Add hook for Ajax API calls
Hook::add('Dispatcher::dispatch', [$this, 'setupAPIHandler']);
// Add hook for the Template Manager
Hook::add('TemplateManager::display', $this->callbackTemplateManagerDisplay(...));

$metadataHandler = new CodecheckMetadataHandler($this);
Hook::add('LoadHandler', function($hookName, $args) use ($metadataHandler) {
$page = $args[0];
$op = $args[1];

error_log("[CODECHECK Plugin] LoadHandler: page=$page, op=$op");

if ($page === 'codecheck') {
$request = Application::get()->getRequest();
$submissionId = $request->getUserVar('submissionId');

error_log("[CODECHECK Plugin] Matched codecheck page, submissionId=$submissionId");

if ($op === 'metadata' && $request->isGet()) {
error_log("[CODECHECK Plugin] Handling GET metadata");
$result = $metadataHandler->getMetadata($request, $submissionId);
header('Content-Type: application/json');
echo json_encode($result);
exit;
} elseif ($op === 'metadata' && $request->isPost()) {
error_log("[CODECHECK Plugin] Handling POST metadata");
$result = $metadataHandler->saveMetadata($request, $submissionId);
header('Content-Type: application/json');
echo json_encode($result);
exit;
} elseif ($op === 'yaml') {
error_log("[CODECHECK Plugin] Handling YAML generation");
$result = $metadataHandler->generateYaml($request, $submissionId);
header('Content-Type: application/json');
echo json_encode($result);
exit;
}

error_log("[CODECHECK Plugin] No matching operation for: $op");
}

return false;
});

// Wizard fields schema
$codecheckSchema = new Schema();
Hook::add('Schema::get::publication', function($hookName, $args) use ($codecheckSchema) {
Expand All @@ -95,6 +61,29 @@ public function register($category, $path, $mainContextId = null): bool

return $success;
}

public function setupAPIHandler(string $hookName, array $args): void
{
$request = $args[0];
$router = $request->getRouter();

if (!($router instanceof \PKP\core\APIRouter)) {
return;
}

if (str_contains($request->getRequestPath(), 'api/v1/codecheck')) {
error_log("[CODECHECK Plugin] Instanciating the CODECHECK APIHandler");
$apiHandler = new CodecheckApiHandler($request);
error_log("[CODECHECK Plugin] API request: " . $request->getRequestPath() . "\n");
}

if (!isset($apiHandler)) {
return;
}

$router->setHandler($apiHandler);
exit;
}

private function addAssets(): void
{
Expand Down Expand Up @@ -139,10 +128,11 @@ public function callbackTemplateManagerDisplay($hookName, $args): bool
'codecheckSubmission' => [
'id' => $submission->getId(),
'codecheckOptIn' => $submission->getData('codecheckOptIn'),
'codeRepository' => $publication?->getData('codeRepository'),
'dataRepository' => $publication?->getData('dataRepository'),
'manifestFiles' => $publication?->getData('manifestFiles'),
'dataAvailabilityStatement' => $publication?->getData('dataAvailabilityStatement'),
'retrieveReserveCertificateIdentifier' => $submission->getData('retrieveReserveCertificateIdentifier'),
'codeRepository' => $submission->getData('codeRepository'),
'dataRepository' => $submission->getData('dataRepository'),
'manifestFiles' => $submission->getData('manifestFiles'),
'dataAvailabilityStatement' => $submission->getData('dataAvailabilityStatement'),
]
]);
}
Expand All @@ -160,6 +150,12 @@ public function addOptInToSchema(string $hookName, array $args): bool
'apiSummary' => true,
'validation' => ['nullable']
];

$schema->properties->retrieveReserveCertificateIdentifier = (object) [
'type' => 'string',
'apiSummary' => true,
'validation' => ['nullable']
];

return false;
}
Expand Down
46 changes: 46 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,52 @@ codecheck/

If you want to contribute to this project, we kindly ask you to follow our [contribution guidelines](CONTRIBUTING.md).

### Api

If you want to add a new Api Endpoint, please first register it inside the constructor of the CODECHECK Api Handler like this:

```php
$this->endpoints = [
'Your method (e.g. GET, POST, ...)' => [
[
'route' => 'your endpoint route',
'handler' => [$this, 'yourFunction'],
'roles' => $this->roles,
],
],
];
```

Then define what `yourFunction()` should do when your Endpoint is called. It is important, that the function creates a JSON response.

```php
private function yourFunction(): void
{
/* Do some calculations */

// Serve your Api endpoint route
// success should be true or false along with a matching HTML response code like 200 or 404
$this->response->response([
'success' => true,
'payload' => $test,
], 200);
}
```

## Running Tests

### Unit Tests

To execute the unit tests, run the following command from root of the PKP Application directory:
```bash
lib/pkp/lib/vendor/phpunit/phpunit/phpunit -c lib/pkp/tests/phpunit.xml plugins/generic/codecheck/tests/
```

If you want to visualize the test coverage, open the following file which is created during each test run.
```bash
/var/www/html/ojs-tests/lib/pkp/tests/results/index.html
```

## License

Copyright (c) 2025 CODECHECK Initiative
Expand Down
8 changes: 8 additions & 0 deletions api/v1/ApiClientInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php

namespace APP\plugins\generic\codecheck\api\v1;

interface ApiClientInterface
{
public function get(string $url): string|bool;
}
Loading