Skip to content

Main #7

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
19 changes: 19 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/* eslint-env node */
require("@rushstack/eslint-patch/modern-module-resolution");

module.exports = {
root: true,
extends: [
"plugin:vue/vue3-essential",
"eslint:recommended",
"@vue/eslint-config-prettier",
],
parserOptions: {
ecmaVersion: "latest",
},
globals: {
pkp: true,
__dirname: true,
},
ignorePatterns: ["dist/"],
};
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node_modules
public
registry
package-lock.json
41 changes: 28 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,32 +1,47 @@
# Introduction
## Introduction

This plug-in is a general conversion plugin for various XML formats in Open Journal Systems (OJS).
This plugin converts various XML formats in Open Journal Systems (OJS) and supports interoperability between publication systems that have different XML export and import requirements.

xmlConveter plugin supports inter-oprobability between publication systems that have different export and import XML requirements.
Currently, JATS-XML and TEI-XML are supported, which are used by OJS, Lodel, and Janeway. However, the plugin can easily be extended to support other XML formats.

Currently, JATS XML and TEI-XML , which is supported by OJS, Lodel and Janeway.But the plugin can be extenede to any other XML formats easily.
Both JATS-XML and TEI-XML formats are widely used in publication systems, indexing systems, long-term preservation systems, article production systems, and analysis systems in academia.

Both JATS and TEIl formats are widely used in the in publication systems, indexing systems, long-term preservation systems, article production systems and analysis systems in academia.
The plugin can also be used to plug into the OAI interface for extracting or converting XML.

The plugin can also used to plugging to extract or convert XML in the OAI-Interface
The original implementation was created by [TIB](https://www.tib.eu) and developed in collaboration with [OpenEdition](https://www.openedition.org/) as part of the EU-fundend [Craft-OA](https://www.craft-oa.eu/) project. [Métopes](https://www.metopes.fr/metopes.html) stylesheets were used to support the conversions.

The original implementation was carried out as part of the EU Croft OA project.
## Compatible OJS Versions

- [ ] 3.3.0
- [X] 3.4.0 (release: *stable-3_4_0*)
- [X] 3.5.0

## Installation

From the root directory of the OJS 3.5.0 release package:

# Installation
```bash
git clone https://github.com/withanage/xmlConverter
cd $OJS
php lib/pkp/tools/installPluginVersion.php plugins/generic/xmlConverter/version.xml
$ git clone -b stable-3_5_0 https://github.com/withanage/xmlConverter.git plugins/generic/xmlConverter
$ php lib/pkp/tools/installPluginVersion.php plugins/generic/xmlConverter/version.xml
$ npm install
$ npm run dev (developments)
$ npm run build (productions)
```

# Contributors
## Activation

The plugin named **XML Converter Plugin** should be enabled by default. However, if needed, you can activate it manually in your Dashboard:

*Settings > Website > Plugins*

## Contributors

- Jeanette Hatherill, Coalition Publica
- Edith Cannet, IR Métopes
- Marisa Tutt, PKP
- Martin Brändle, University of Zurich
- Dominique Roux, IR Métopes
- João Martins, OpenEdition
- Jean-Christophe Souplet, OpenEdition
- Ipula Ranasinghe, TIB
- Dulip Withanage, TIB

138 changes: 0 additions & 138 deletions XMLConverterPlugin.inc.php

This file was deleted.

123 changes: 123 additions & 0 deletions XmlConverterPlugin.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
<?php

namespace APP\plugins\generic\xmlConverter;

use APP\API\v1\submissions\SubmissionController;
use APP\core\Application;
use APP\plugins\generic\xmlConverter\api\v1\submissions\XmlConvertController;
use APP\plugins\generic\xmlConverter\handlers\XmlConverterHandler;
use APP\template\TemplateManager;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
use PKP\core\PKPBaseController;
use PKP\handler\APIHandler;
use PKP\plugins\GenericPlugin;
use PKP\plugins\Hook;
use PKP\security\Role;

/**
* Class XmlConverterPlugin
*
* This plugin provides XML conversion capabilities within the application.
* It supports specific file conversions (e.g., TEI to JATS and JATS to TEI)
* and integrates into the application's workflow through hooks and custom handlers.
*/
class XmlConverterPlugin extends GenericPlugin
{
/**
* Register the plugin and initialize its hooks and resources.
*
* @copydoc GenericPlugin::register()
*
* @param string $category The category to register the plugin in.
* @param string $path The path to the plugin.
* @param mixed $mainContextId The context ID, if applicable.
*
* @return bool
*/
public function register($category, $path, $mainContextId = null): bool
{
$success = parent::register($category, $path, $mainContextId);

if ($success && $this->getEnabled()) {
// Check if Java is available on the system
$javaChecker = exec('command java --version >/dev/null && echo "yes" || echo "no"');

if ('yes' == $javaChecker) {
$request = Application::get()->getRequest();
$templateMgr = TemplateManager::getManager($request);
$this->addJavaScript($request, $templateMgr);
$this->addRoute(); // add an API route to xmlConverter
}
}

return $success;
}

/**
* Get the display name of the plugin.
* The name will appear in the Plugin Gallery where editors can install, enable and disable plugins.
*
* @return string
*/
public function getDisplayName(): string
{
return __('plugins.generic.xmlConverter.displayName');
}

/**
* Get the description of the plugin.
* The name will appear in the Plugin Gallery where editors can install, enable and disable plugins.
*
* @return string
*/
public function getDescription(): string
{
return __('plugins.generic.xmlConverter.description');
}

/**
* Get the list of allowed workflow stage IDs.
*
* @return array
*/
public function getAllowedWorkflowStages(): array
{
return [
WORKFLOW_STAGE_ID_EDITING,
WORKFLOW_STAGE_ID_PRODUCTION,
];
}
public function addJavaScript($request, $templateMgr)
{
$templateMgr->addJavaScript(
'xmlConverter',
"{$request->getBaseUrl()}/{$this->getPluginPath()}/public/build/build.iife.js",
[
'inline' => false,
'contexts' => ['backend'],
'priority' => TemplateManager::STYLE_SEQUENCE_LAST
]
);
}

/**
* Add/override new api endpoints to existing list of api endpoints
*/
public function addRoute(): void
{
Hook::add('APIHandler::endpoints::submissions', function(string $hookName, PKPBaseController &$apiController, APIHandler $apiHandler): bool {
if ($apiController instanceof SubmissionController) {
$apiController = new XmlConvertController();
}

return false;
});
}

}

if (!PKP_STRICT_MODE) {
// Allow legacy aliasing for backward compatibility
class_alias('\APP\plugins\generic\xmlConverter\XmlConverterPlugin', '\XmlConverterPlugin');
}
Loading