Skip to content
This repository was archived by the owner on May 28, 2026. It is now read-only.
Merged
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
4 changes: 1 addition & 3 deletions config/packages/nelmio_api_doc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,4 @@ nelmio_api_doc:
areas:
path_patterns:
- ^/api$
- ^/api/available_langs$
- ^/api/tesseract/available_psms$
- ^/api/transkribus/available_line_ids$
- ^/api/
22 changes: 22 additions & 0 deletions src/Controller/OcrController.php
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,28 @@ public function apiAction(): JsonResponse {
return $this->getApiResponse( $responseParams );
}

/**
* Serve the models config with CORS headers so it can be fetched directly
* from the Wikisource frontend without requiring a MediaWiki proxy.
* Returns a simplified map of engine->{code: title} matching the shape
* previously provided by the available_langs API.
*
* @Route("/api/models", name="apiModels", methods={"GET"})
* @return JsonResponse
*/
public function apiModelsAction(): JsonResponse {
$path = $this->getParameter( 'kernel.project_dir' ) . '/public/models.json';
$raw = json_decode( file_get_contents( $path ), true );
$out = [];
foreach ( $raw as $engine => $models ) {
$out[ $engine ] = [];
foreach ( $models as $code => $info ) {
$out[ $engine ][ $code ] = $info[ 'title' ];
}
}
return $this->getApiResponse( $out );
}

/**
* Get a list of models available for use with a specific OCR engine.
*
Expand Down
Loading