Skip to content

Commit

Permalink
Merge pull request #264 from Liturgical-Calendar:refactor-for-localho…
Browse files Browse the repository at this point in the history
…st-development

refactor for localhost development
  • Loading branch information
JohnRDOrazio authored Nov 18, 2024
2 parents 5ee55f0 + 9a5cb0a commit ef27dd3
Show file tree
Hide file tree
Showing 179 changed files with 116 additions and 114 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<td><a href="https://translate.johnromanodorazio.com/engage/liturgical-calendar/">
<img src="https://translate.johnromanodorazio.com/widgets/liturgical-calendar/-/287x66-white.png" alt="Translation status" />
</a></td>
<td> <a href="https://validator.swagger.io/validator?url=https://raw.githubusercontent.com/Liturgical-Calendar/LiturgicalCalendarAPI/master/schemas/openapi.json"><img src="https://validator.swagger.io/validator?url=https://raw.githubusercontent.com/Liturgical-Calendar/LiturgicalCalendarAPI/master/schemas/openapi.json" alt="OpenAPI validation result" /></a></td>
<td> <a href="https://validator.swagger.io/validator?url=https://raw.githubusercontent.com/Liturgical-Calendar/LiturgicalCalendarAPI/master/jsondata/schemas/openapi.json"><img src="https://validator.swagger.io/validator?url=https://raw.githubusercontent.com/Liturgical-Calendar/LiturgicalCalendarAPI/master/jsondata/schemas/openapi.json" alt="OpenAPI validation result" /></a></td>
</tr>
</tbody>
</table>
Expand Down
2 changes: 2 additions & 0 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@
* Perhaps we could find a better way to set this in a class such as Core ...
*/
define('API_BASE_PATH', "{$server_request_scheme}://{$server_name}");
define('SCHEMAS_FOLDER', 'jsondata/schemas');
define('TESTS_FOLDER', 'jsondata/tests');

if (false === Router::isLocalhost()) {
Router::setAllowedOrigins('allowedOrigins.php');
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
20 changes: 10 additions & 10 deletions data/nations/index.json → jsondata/sourcedata/nations/index.json
Original file line number Diff line number Diff line change
@@ -1,63 +1,63 @@
[
{
"calendar_id": "romamo_it",
"path": "data\/nations\/IT\/Diocesi di Roma.json",
"path": "jsondata\/sourcedata\/nations\/IT\/Diocesi di Roma.json",
"nation": "IT",
"diocese": "Diocesi di Roma",
"group": "Diocesi del Lazio"
},
{
"calendar_id": "boston_us",
"path": "data\/nations\/US\/Archdiocese of Boston (Massachusetts).json",
"path": "jsondata\/sourcedata\/nations\/US\/Archdiocese of Boston (Massachusetts).json",
"nation": "US",
"diocese": "Archdiocese of Boston (Massachusetts)"
},
{
"calendar_id": "socaap_it",
"path": "data\/nations\/IT\/Diocesi di Sora - Cassino - Aquino - Pontecorvo.json",
"path": "jsondata\/sourcedata\/nations\/IT\/Diocesi di Sora - Cassino - Aquino - Pontecorvo.json",
"nation": "IT",
"diocese": "Diocesi di Sora - Cassino - Aquino - Pontecorvo",
"group": "Diocesi del Lazio"
},
{
"calendar_id": "roermo_nl",
"path": "data\/nations\/NL\/Roermond.json",
"path": "jsondata\/sourcedata\/nations\/NL\/Roermond.json",
"nation": "NL",
"diocese": "Roermond"
},
{
"calendar_id": "sherto_nl",
"path": "data\/nations\/NL\/'s-Hertogenbosch.json",
"path": "jsondata\/sourcedata\/nations\/NL\/'s-Hertogenbosch.json",
"nation": "NL",
"diocese": "'s-Hertogenbosch"
},
{
"calendar_id": "utrech_nl",
"path": "data\/nations\/NL\/Utrecht.json",
"path": "jsondata\/sourcedata\/nations\/NL\/Utrecht.json",
"nation": "NL",
"diocese": "Utrecht"
},
{
"calendar_id": "rotter_nl",
"path": "data\/nations\/NL\/Rotterdam.json",
"path": "jsondata\/sourcedata\/nations\/NL\/Rotterdam.json",
"nation": "NL",
"diocese": "Rotterdam"
},
{
"calendar_id": "grolee_nl",
"path": "data\/nations\/NL\/Groningen-Leeuwarden.json",
"path": "jsondata\/sourcedata\/nations\/NL\/Groningen-Leeuwarden.json",
"nation": "NL",
"diocese": "Groningen-Leeuwarden"
},
{
"calendar_id": "bredad_nl",
"path": "data\/nations\/NL\/Breda.json",
"path": "jsondata\/sourcedata\/nations\/NL\/Breda.json",
"nation": "NL",
"diocese": "Breda"
},
{
"calendar_id": "haaams_nl",
"path": "data\/nations\/NL\/Haarlem-Amsterdam.json",
"path": "jsondata\/sourcedata\/nations\/NL\/Haarlem-Amsterdam.json",
"nation": "NL",
"diocese": "Haarlem-Amsterdam"
}
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion parseOpenAPI.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/

var fs = require('fs');
var openAPI = fs.readFileSync('schemas/openapi.json', 'utf8');
var openAPI = fs.readFileSync('jsondata/schemas/openapi.json', 'utf8');

var obj = JSON.parse(openAPI);

Expand Down
4 changes: 2 additions & 2 deletions redocly.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ extends:

apis:
main:
root: ./schemas/openapi.json
root: ./jsondata/schemas/openapi.json
#rules:
# # A sample custom rule. Read more about rules: https://redocly.com/docs/cli/rules/
# rule/operation-description:
# subject:
# subject:
# type: Operation
# property: description
# assertions:
Expand Down
16 changes: 8 additions & 8 deletions src/Enum/RomanMissal.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,23 +65,23 @@ class RomanMissal
];

public static array $jsonFiles = [
self::EDITIO_TYPICA_1970 => "data/missals/propriumdesanctis_1970/propriumdesanctis_1970.json",
self::EDITIO_TYPICA_1970 => "jsondata/sourcedata/missals/propriumdesanctis_1970/propriumdesanctis_1970.json",
self::REIMPRESSIO_EMENDATA_1971 => false,
self::EDITIO_TYPICA_SECUNDA_1975 => false,
self::EDITIO_TYPICA_TERTIA_2002 => "data/missals/propriumdesanctis_2002/propriumdesanctis_2002.json",
self::EDITIO_TYPICA_TERTIA_EMENDATA_2008 => "data/missals/propriumdesanctis_2008/propriumdesanctis_2008.json",
self::USA_EDITION_2011 => "data/missals/propriumdesanctis_US_2011/propriumdesanctis_US_2011.json",
self::ITALY_EDITION_1983 => "data/missals/propriumdesanctis_IT_1983/propriumdesanctis_IT_1983.json",
self::EDITIO_TYPICA_TERTIA_2002 => "jsondata/sourcedata/missals/propriumdesanctis_2002/propriumdesanctis_2002.json",
self::EDITIO_TYPICA_TERTIA_EMENDATA_2008 => "jsondata/sourcedata/missals/propriumdesanctis_2008/propriumdesanctis_2008.json",
self::USA_EDITION_2011 => "jsondata/sourcedata/missals/propriumdesanctis_US_2011/propriumdesanctis_US_2011.json",
self::ITALY_EDITION_1983 => "jsondata/sourcedata/missals/propriumdesanctis_IT_1983/propriumdesanctis_IT_1983.json",
self::ITALY_EDITION_2020 => false,
self::NETHERLANDS_EDITION_1978 => false
];

public static array $i18nPath = [
self::EDITIO_TYPICA_1970 => "data/missals/propriumdesanctis_1970/i18n/",
self::EDITIO_TYPICA_1970 => "jsondata/sourcedata/missals/propriumdesanctis_1970/i18n/",
self::REIMPRESSIO_EMENDATA_1971 => false,
self::EDITIO_TYPICA_SECUNDA_1975 => false,
self::EDITIO_TYPICA_TERTIA_2002 => "data/missals/propriumdesanctis_2002/i18n/",
self::EDITIO_TYPICA_TERTIA_EMENDATA_2008 => "data/missals/propriumdesanctis_2008/i18n/",
self::EDITIO_TYPICA_TERTIA_2002 => "jsondata/sourcedata/missals/propriumdesanctis_2002/i18n/",
self::EDITIO_TYPICA_TERTIA_EMENDATA_2008 => "jsondata/sourcedata/missals/propriumdesanctis_2008/i18n/",
self::USA_EDITION_2011 => false,
self::ITALY_EDITION_1983 => false,
self::ITALY_EDITION_2020 => false,
Expand Down
14 changes: 7 additions & 7 deletions src/Health.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,14 @@ class Health implements MessageComponentInterface
* @var string[] $DATA_PATH_TO_SCHEMA
*/
public const DATA_PATH_TO_SCHEMA = [
"data/missals/propriumdetempore/propriumdetempore.json" => LitSchema::PROPRIUMDETEMPORE,
"data/missals/propriumdesanctis_1970/propriumdesanctis_1970.json" => LitSchema::PROPRIUMDESANCTIS,
"data/missals/propriumdesanctis_2002/propriumdesanctis_2002.json" => LitSchema::PROPRIUMDESANCTIS,
"data/missals/propriumdesanctis_2008/propriumdesanctis_2008.json" => LitSchema::PROPRIUMDESANCTIS,
"data/missals/propriumdesanctis_IT_1983/propriumdesanctis_IT_1983.json"
"jsondata/sourcedata/missals/propriumdetempore/propriumdetempore.json" => LitSchema::PROPRIUMDETEMPORE,
"jsondata/sourcedata/missals/propriumdesanctis_1970/propriumdesanctis_1970.json" => LitSchema::PROPRIUMDESANCTIS,
"jsondata/sourcedata/missals/propriumdesanctis_2002/propriumdesanctis_2002.json" => LitSchema::PROPRIUMDESANCTIS,
"jsondata/sourcedata/missals/propriumdesanctis_2008/propriumdesanctis_2008.json" => LitSchema::PROPRIUMDESANCTIS,
"jsondata/sourcedata/missals/propriumdesanctis_IT_1983/propriumdesanctis_IT_1983.json"
=> LitSchema::PROPRIUMDESANCTIS,
"data/missals/propriumdesanctis_US_2011/propriumdesanctis_US_2011" => LitSchema::PROPRIUMDESANCTIS,
"data/nations/index.json" => LitSchema::INDEX,
"jsondata/sourcedata/missals/propriumdesanctis_US_2011/propriumdesanctis_US_2011" => LitSchema::PROPRIUMDESANCTIS,
"jsondata/sourcedata/nations/index.json" => LitSchema::INDEX,
API_BASE_PATH . '/calendars' => LitSchema::METADATA,
API_BASE_PATH . '/decrees' => LitSchema::DECREES,
API_BASE_PATH . '/events' => LitSchema::EVENTS,
Expand Down
4 changes: 2 additions & 2 deletions src/LitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,13 @@ public function __construct(string $Test, object $testData)
self::$testCache = new \stdClass();
}
if (false === property_exists(self::$testCache, $Test)) {
$testPath = "tests/{$Test}.json";
$testPath = "jsondata/tests/{$Test}.json";
if (file_exists($testPath)) {
$testInstructions = file_get_contents($testPath);
if ($testInstructions) {
$this->testInstructions = json_decode($testInstructions);
if (JSON_ERROR_NONE === json_last_error()) {
$schemaFile = 'schemas/LitCalTest.json';
$schemaFile = 'jsondata/schemas/LitCalTest.json';
$schemaContents = file_get_contents($schemaFile);
$jsonSchema = json_decode($schemaContents);
try {
Expand Down
8 changes: 4 additions & 4 deletions src/Params/EventsParams.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,17 @@ public function __construct(array $DATA = [])
$this->Locale = LitLocale::LATIN;
}

$directories = array_map('basename', glob('data/nations/*', GLOB_ONLYDIR));
$directories = array_map('basename', glob('jsondata/sourcedata/nations/*', GLOB_ONLYDIR));
//self::debugWrite(json_encode($directories));
foreach ($directories as $directory) {
//self::debugWrite($directory);
if (file_exists("data/nations/$directory/$directory.json")) {
if (file_exists("jsondata/sourcedata/nations/$directory/$directory.json")) {
$this->SupportedNationalCalendars[] = $directory;
}
}

if (file_exists("data/nations/index.json")) {
$DiocesesIndex = json_decode(file_get_contents("data/nations/index.json"), true);
if (file_exists("jsondata/sourcedata/nations/index.json")) {
$DiocesesIndex = json_decode(file_get_contents("jsondata/sourcedata/nations/index.json"), true);
if (JSON_ERROR_NONE === json_last_error()) {
$this->SupportedDiocesanCalendars = array_column($DiocesesIndex, 'calendar_id');
}
Expand Down
14 changes: 7 additions & 7 deletions src/Paths/Calendar.php
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,7 @@ private function loadDiocesanCalendarData(): void
if ($this->CalendarParams->DiocesanCalendar !== null) {
//since a Diocesan calendar is being requested, we need to retrieve the JSON data
//first we need to discover the path, so let's retrieve our index file
$dioceseIndexPath = "data/nations/index.json";
$dioceseIndexPath = "jsondata/sourcedata/nations/index.json";
if (file_exists($dioceseIndexPath)) {
$this->DioceseIndex = json_decode(file_get_contents($dioceseIndexPath));
$dioceseData = array_values(array_filter($this->DioceseIndex, function ($el) {
Expand Down Expand Up @@ -686,7 +686,7 @@ private function dieIfBeforeMinYear(): void

/**
* Loads localization data stored in JSON format from a file in the
* data/missals/propriumdetempore/i18n directory, named according to the locale
* jsondata/sourcedata/missals/propriumdetempore/i18n directory, named according to the locale
* specified in LitLocale::$PRIMARY_LANGUAGE.
*
* If the file does not exist, or if there is an error decoding the
Expand All @@ -697,7 +697,7 @@ private function dieIfBeforeMinYear(): void
private function loadPropriumDeTemporeI18nData(): ?array
{
$locale = LitLocale::$PRIMARY_LANGUAGE;
$propriumDeTemporeI18nFile = "data/missals/propriumdetempore/i18n/{$locale}.json";
$propriumDeTemporeI18nFile = "jsondata/sourcedata/missals/propriumdetempore/i18n/{$locale}.json";
if (file_exists($propriumDeTemporeI18nFile)) {
$rawData = file_get_contents($propriumDeTemporeI18nFile);
$PropriumDeTemporeI18n = json_decode($rawData, true);
Expand All @@ -724,7 +724,7 @@ private function loadPropriumDeTemporeI18nData(): ?array
*/
private function loadPropriumDeTemporeData(): void
{
$propriumDeTemporeFile = "data/missals/propriumdetempore/propriumdetempore.json";
$propriumDeTemporeFile = "jsondata/sourcedata/missals/propriumdetempore/propriumdetempore.json";
if (file_exists($propriumDeTemporeFile)) {
$rawData = file_get_contents($propriumDeTemporeFile);
$PropriumDeTempore = json_decode($rawData, true);
Expand Down Expand Up @@ -852,8 +852,8 @@ private function loadPropriumDeSanctisData(string $missal): void
*/
private function loadMemorialsFromDecreesData(): void
{
$decreesFile = "data/decrees/decrees.json";
$decreesI18nPath = "data/decrees/i18n/";
$decreesFile = "jsondata/sourcedata/decrees/decrees.json";
$decreesI18nPath = "jsondata/sourcedata/decrees/i18n/";
$locale = LitLocale::$PRIMARY_LANGUAGE;
$decreesI18nFile = $decreesI18nPath . $locale . ".json";
$NAME = null;
Expand Down Expand Up @@ -3177,7 +3177,7 @@ private function calculateSaturdayMemorialBVM(): void
*/
private function loadNationalCalendarData(): void
{
$nationalDataFile = "data/nations/{$this->CalendarParams->NationalCalendar}/{$this->CalendarParams->NationalCalendar}.json";
$nationalDataFile = "jsondata/sourcedata/nations/{$this->CalendarParams->NationalCalendar}/{$this->CalendarParams->NationalCalendar}.json";
if (file_exists($nationalDataFile)) {
$this->NationalData = json_decode(file_get_contents($nationalDataFile));
if (json_last_error() === JSON_ERROR_NONE) {
Expand Down
2 changes: 1 addition & 1 deletion src/Paths/Decrees.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ public static function init(array $requestPathParts = [])
if (count($requestPathParts)) {
self::$requestPathParts = $requestPathParts;
}
$decreesFile = 'data/decrees/decrees.json';
$decreesFile = 'jsondata/sourcedata/decrees/decrees.json';
if (file_exists($decreesFile)) {
$rawData = file_get_contents($decreesFile);
self::$decreesIndex = new \stdClass();
Expand Down
18 changes: 9 additions & 9 deletions src/Paths/Events.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ private static function retrieveLatinMissals(): void
*/
private static function retrieveDioceseIndex(): void
{
$DioceseIndexContents = file_exists("data/nations/index.json") ? file_get_contents("data/nations/index.json") : null;
$DioceseIndexContents = file_exists("jsondata/sourcedata/nations/index.json") ? file_get_contents("jsondata/sourcedata/nations/index.json") : null;
if (null === $DioceseIndexContents || false === $DioceseIndexContents) {
echo self::produceErrorResponse(StatusCode::NOT_FOUND, "path data/nations/index.json not found");
echo self::produceErrorResponse(StatusCode::NOT_FOUND, "path jsondata/sourcedata/nations/index.json not found");
die();
}
self::$DioceseIndex = json_decode($DioceseIndexContents);
Expand Down Expand Up @@ -219,9 +219,9 @@ private function handleRequestParams(): void
/**
* Loads the JSON data for the specified diocesan calendar.
*
* If the diocese is not found in the diocesan calendars index or in the `data/nations/{nation}/` directory, the response will be a JSON error response with a status code of 404 Not Found.
* If the diocese is not found in the diocesan calendars index or in the `jsondata/sourcedata/nations/{nation}/` directory, the response will be a JSON error response with a status code of 404 Not Found.
* If the diocese is not found in the diocesan calendars index, the response will be a JSON error response with a status code of 400 Bad Request.
* If the diocese is found in the diocesan calendars index but not in the `data/nations/{nation}/` directory, the response will be a JSON error response with a status code of 503 Service Unavailable.
* If the diocese is found in the diocesan calendars index but not in the `jsondata/sourcedata/nations/{nation}/` directory, the response will be a JSON error response with a status code of 503 Service Unavailable.
* If the payload is not valid according to {@see LitSchema::DIOCESAN}, the response will be a JSON error response with a status code of 422 Unprocessable Content.
*
* @return void
Expand Down Expand Up @@ -263,7 +263,7 @@ private function loadDiocesanData(): void
private function loadNationalAndWiderRegionData(): void
{
if ($this->EventsParams->NationalCalendar !== null) {
$nationalDataFile = "data/nations/" . $this->EventsParams->NationalCalendar . "/" . $this->EventsParams->NationalCalendar . ".json";
$nationalDataFile = "jsondata/sourcedata/nations/" . $this->EventsParams->NationalCalendar . "/" . $this->EventsParams->NationalCalendar . ".json";
if (file_exists($nationalDataFile)) {
self::$NationalData = json_decode(file_get_contents($nationalDataFile));
if (json_last_error() === JSON_ERROR_NONE) {
Expand Down Expand Up @@ -416,8 +416,8 @@ private function processMissalData(): void
*/
private function processPropriumDeTemporeData(): void
{
$DataFile = 'data/missals/propriumdetempore/propriumdetempore.json';
$I18nFile = 'data/missals/propriumdetempore/i18n/' . $this->EventsParams->Locale . ".json";
$DataFile = 'jsondata/sourcedata/missals/propriumdetempore/propriumdetempore.json';
$I18nFile = 'jsondata/sourcedata/missals/propriumdetempore/i18n/' . $this->EventsParams->Locale . ".json";
if (!file_exists($DataFile) || !file_exists($I18nFile)) {
echo self::produceErrorResponse(
StatusCode::NOT_FOUND,
Expand Down Expand Up @@ -472,8 +472,8 @@ private function processPropriumDeTemporeData(): void
*/
private function processMemorialsFromDecreesData(): void
{
$DataFile = 'data/decrees/decrees.json';
$I18nFile = 'data/decrees/i18n/' . $this->EventsParams->Locale . ".json";
$DataFile = 'jsondata/sourcedata/decrees/decrees.json';
$I18nFile = 'jsondata/sourcedata/decrees/i18n/' . $this->EventsParams->Locale . ".json";
if (!file_exists($DataFile) || !file_exists($I18nFile)) {
echo self::produceErrorResponse(StatusCode::NOT_FOUND, "Could not find resource file $DataFile or resource file $I18nFile");
die();
Expand Down
Loading

0 comments on commit ef27dd3

Please sign in to comment.