Skip to content

Commit

Permalink
Merge pull request #221 from Liturgical-Calendar/v8
Browse files Browse the repository at this point in the history
create composer package
  • Loading branch information
JohnRDOrazio authored Jun 9, 2024
2 parents 4ef110d + ae758a5 commit 566d847
Show file tree
Hide file tree
Showing 39 changed files with 242 additions and 273 deletions.
6 changes: 1 addition & 5 deletions LitCalTestServer.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,11 @@
// error_reporting(E_ALL);

require_once 'vendor/autoload.php';
require_once 'includes/enums/LitSchema.php';
require_once 'includes/enums/ICSErrorLevel.php';
require_once 'includes/LitTest.php';
require_once 'includes/Health.php';

use Ratchet\Server\IoServer;
use Ratchet\Http\HttpServer;
use Ratchet\WebSocket\WsServer;
use LitCal\Health;
use Johnrdorazio\LitCal\Health;

$server = IoServer::factory(
new HttpServer(
Expand Down
29 changes: 28 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,38 @@
{
"name": "johnrdorazio/litcal",
"description": "an API for a perpetual Catholic Liturgical Calendar",
"type": "library",
"keywords": ["api","rest","restful","liturgy","calendar","liturgical","universal","roman","catholic"],
"homepage": "https://litcal.johnromanodorazio.com",
"require": {
"php": ">=7.4",
"swaggest/json-schema": "^0.12",
"phpunit/phpunit": "^10",
"cboden/ratchet": "^0.4.4",
"sabre/vobject": "~4.1"
},
"require-dev": {
"squizlabs/php_codesniffer": "*"
},
"license": "MIT",
"autoload": {
"psr-4": {
"Johnrdorazio\\LitCal\\": "src/"
},
"files": ["src/pgettext.php"]
},
"authors": [
{
"name": "John R. D'Orazio",
"email": "priest@johnromanodorazio.com"
}
],
"minimum-stability": "stable",
"scripts": {
"post-install-cmd": [
"Johnrdorazio\\LitCal\\LitMessages::postInstall"
],
"post-update-cmd": [
"Johnrdorazio\\LitCal\\LitMessages::postInstall"
]
}
}
162 changes: 4 additions & 158 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,168 +10,14 @@
* Date Created: 27 December 2017
*/

/**********************************************************************************
* ABBREVIATIONS *
* CB Cerimonial of Bishops *
* CCL Code of Canon Law *
* IM General Instruction of the Roman Missal *
* IH General Instruction of the Liturgy of the Hours *
* LH Liturgy of the Hours *
* LY Universal Norms for the Liturgical Year and the Calendar ( Roman Missal ) *
* OM Order of Matrimony *
* PC Instruction regarding Proper Calendars *
* RM Roman Missal *
* SC Sacrosanctum Concilium, Conciliar Constitution on the Sacred Liturgy *
* *
*********************************************************************************/


/**********************************************************************************
* EDITIONS OF THE ROMAN MISSAL AND OF THE GENERAL ROMAN CALENDAR *
* *
* Editio typica, 1970 *
* Reimpressio emendata, 1971 *
* Editio typica secunda, 1975 *
* Editio typica tertia, 2002 *
* Editio typica tertia emendata, 2008 *
* ----------------------------------- *
* Roman Missal [ USA ], 2011 *
* ----------------------------------- *
* Messale Romano [ ITALIA ], 1983 *
* Messale Romano [ ITALIA ], 2020 *
* ----------------------------------- *
* Romeins Missaal [ NETHERLANDS ], 1978
*********************************************************************************/

// error_reporting(E_ALL);
// ini_set('display_errors', 1);
ini_set('date.timezone', 'Europe/Vatican');
require_once 'vendor/autoload.php';

include_once('includes/enums/AcceptHeader.php');
include_once('includes/enums/CacheDuration.php');
include_once('includes/enums/RequestMethod.php');
include_once('includes/enums/RequestContentType.php');
include_once('includes/enums/ReturnType.php');


use LitCal\API;
use LitCal\Metadata;
use LitCal\TestsIndex;
use LitCal\AllEvents;
use LitCal\RegionalData;
use LitCal\Easter;
use LitCal\enum\RequestMethod;
use LitCal\enum\RequestContentType;
use LitCal\enum\AcceptHeader;
use LitCal\enum\ReturnType;
use LitCal\enum\CacheDuration;

if (file_exists("allowedOrigins.php")) {
include_once('allowedOrigins.php');
}

$allowedOrigins = [
"https://johnromanodorazio.com",
"https://www.johnromanodorazio.com",
"https://litcal.johnromanodorazio.com",
"https://litcal-staging.johnromanodorazio.com"
];

if (defined('ALLOWED_ORIGINS') && is_array(ALLOWED_ORIGINS)) {
$allowedOrigins = array_merge($allowedOrigins, ALLOWED_ORIGINS);
}

$requestPath = explode('?', $_SERVER['REQUEST_URI'])[0];
$requestPath = preg_replace('/^\/api\/(?:dev|v[4-9])/', '', $requestPath);
use Johnrdorazio\LitCal\Router;

switch ($requestPath) {
case '/':
include_once('includes/enums/RomanMissal.php');
include_once('includes/DateTime.php');
include_once("includes/Festivity.php");
include_once("includes/FestivityCollection.php");
include_once('includes/enums/LitColor.php');
include_once('includes/enums/LitCommon.php');
include_once('includes/enums/LitFeastType.php');
include_once('includes/enums/LitGrade.php');
include_once('includes/enums/LitLocale.php');
include_once('includes/enums/LitSeason.php');
include_once('includes/enums/Ascension.php');
include_once('includes/enums/Epiphany.php');
include_once('includes/enums/CorpusChristi.php');
include_once('includes/enums/CalendarType.php');
include_once("includes/LitSettings.php");
include_once("includes/LitFunc.php");
include_once("includes/LitMessages.php");
include_once("includes/pgettext.php");
include_once('includes/APICore.php');
include_once("includes/API.php");
$LitCalEngine = new API();
$LitCalEngine->APICore->setAllowedOrigins($allowedOrigins);
$LitCalEngine->APICore->setAllowedRequestMethods([ RequestMethod::GET, RequestMethod::POST, RequestMethod::OPTIONS ]);
$LitCalEngine->APICore->setAllowedRequestContentTypes([ RequestContentType::JSON, RequestContentType::FORMDATA ]);
$LitCalEngine->APICore->setAllowedAcceptHeaders([ AcceptHeader::JSON, AcceptHeader::XML, AcceptHeader::ICS, AcceptHeader::YML ]);
$LitCalEngine->setAllowedReturnTypes([ ReturnType::JSON, ReturnType::XML, ReturnType::ICS, ReturnType::YML ]);
$LitCalEngine->setCacheDuration(CacheDuration::MONTH);
$LitCalEngine->init();
break;
case '/metadata':
case '/metadata/':
include_once('includes/enums/RomanMissal.php');
include_once('includes/Metadata.php');
Metadata::init();
break;
case '/testsindex':
case '/testsindex/':
include_once('vendor/autoload.php');
include_once('includes/enums/StatusCode.php');
include_once('includes/TestsIndex.php');
echo TestsIndex::handleRequest();
break;
case '/allevents':
case '/allevents/':
include_once('includes/enums/LitLocale.php');
include_once('includes/enums/RomanMissal.php');
include_once('includes/enums/LitGrade.php');
include_once('includes/enums/StatusCode.php');
include_once('includes/AllEvents.php');
AllEvents::init();
break;
case '/regionaldata':
case '/regionaldata/':
include_once('vendor/autoload.php');
include_once('includes/enums/AcceptHeader.php');
include_once('includes/enums/LitSchema.php');
include_once('includes/enums/RequestMethod.php');
include_once('includes/enums/RequestContentType.php');
include_once('includes/enums/ReturnType.php');
include_once('includes/APICore.php');
include_once('includes/RegionalData.php');
$LitCalRegionalData = new RegionalData();
$LitCalRegionalData->APICore->setAllowedOrigins($allowedOrigins);
$LitCalRegionalData->APICore->setAllowedReferers(
array_map(
function ($el) {
return $el . "/";
},
$allowedOrigins
)
);
$LitCalRegionalData->APICore->setAllowedAcceptHeaders([AcceptHeader::JSON]);
$LitCalRegionalData->APICore->setAllowedRequestContentTypes([RequestContentType::JSON, RequestContentType::FORMDATA]);
$LitCalRegionalData->init();
break;
case '/easter':
case '/easter/':
include_once('includes/enums/LitLocale.php');
include_once('includes/DateTime.php');
include_once('includes/LitFunc.php');
include_once('includes/LitMessages.php');
include_once('includes/Easter.php');
Easter::init();
break;
default:
http_response_code(404);
}
Router::setAllowedOrigins('allowedOrigins.php');
Router::route();

die();
46 changes: 23 additions & 23 deletions includes/API.php → src/API.php
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
<?php

namespace LitCal;

use LitCal\APICore;
use LitCal\DateTime;
use LitCal\FestivityCollection;
use LitCal\LitFunc;
use LitCal\LitSettings;
use LitCal\LitMessages;
use LitCal\enum\Ascension;
use LitCal\enum\CorpusChristi;
use Litcal\enum\Epiphany;
use LitCal\enum\AcceptHeader;
use LitCal\enum\CacheDuration;
use LitCal\enum\CalendarType;
use LitCal\enum\LitColor;
use LitCal\enum\LitCommon;
use LitCal\enum\LitFeastType;
use LitCal\enum\LitGrade;
use LitCal\enum\LitLocale;
use LitCal\enum\RequestContentType;
use Litcal\enum\RequestMethod;
use LitCal\enum\ReturnType;
use LitCal\enum\RomanMissal;
namespace Johnrdorazio\LitCal;

use Johnrdorazio\LitCal\APICore;
use Johnrdorazio\LitCal\DateTime;
use Johnrdorazio\LitCal\FestivityCollection;
use Johnrdorazio\LitCal\LitFunc;
use Johnrdorazio\LitCal\LitSettings;
use Johnrdorazio\LitCal\LitMessages;
use Johnrdorazio\LitCal\Enum\Ascension;
use Johnrdorazio\LitCal\Enum\CorpusChristi;
use Johnrdorazio\LitCal\Enum\Epiphany;
use Johnrdorazio\LitCal\Enum\AcceptHeader;
use Johnrdorazio\LitCal\Enum\CacheDuration;
use Johnrdorazio\LitCal\Enum\CalendarType;
use Johnrdorazio\LitCal\Enum\LitColor;
use Johnrdorazio\LitCal\Enum\LitCommon;
use Johnrdorazio\LitCal\Enum\LitFeastType;
use Johnrdorazio\LitCal\Enum\LitGrade;
use Johnrdorazio\LitCal\Enum\LitLocale;
use Johnrdorazio\LitCal\Enum\RequestContentType;
use Johnrdorazio\LitCal\Enum\RequestMethod;
use Johnrdorazio\LitCal\Enum\ReturnType;
use Johnrdorazio\LitCal\Enum\RomanMissal;

class API
{
Expand Down
8 changes: 4 additions & 4 deletions includes/APICore.php → src/APICore.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?php

namespace LitCal;
namespace Johnrdorazio\LitCal;

use LitCal\enum\AcceptHeader;
use LitCal\enum\RequestMethod;
use LitCal\enum\RequestContentType;
use Johnrdorazio\LitCal\Enum\AcceptHeader;
use Johnrdorazio\LitCal\Enum\RequestMethod;
use Johnrdorazio\LitCal\Enum\RequestContentType;

class APICore
{
Expand Down
10 changes: 5 additions & 5 deletions includes/AllEvents.php → src/AllEvents.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?php

namespace LitCal;
namespace Johnrdorazio\LitCal;

use LitCal\enum\RomanMissal;
use LitCal\enum\LitLocale;
use LitCal\enum\LitGrade;
use LitCal\enum\StatusCode;
use Johnrdorazio\LitCal\Enum\RomanMissal;
use Johnrdorazio\LitCal\Enum\LitLocale;
use Johnrdorazio\LitCal\Enum\LitGrade;
use Johnrdorazio\LitCal\Enum\StatusCode;

class AllEvents
{
Expand Down
2 changes: 1 addition & 1 deletion includes/DateTime.php → src/DateTime.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace LitCal;
namespace Johnrdorazio\LitCal;

class DateTime extends \DateTime implements \JsonSerializable
{
Expand Down
8 changes: 4 additions & 4 deletions includes/Easter.php → src/Easter.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?php

namespace LitCal;
namespace Johnrdorazio\LitCal;

use LitCal\enum\LitLocale;
use LitCal\LitFunc;
use LitCal\LitMessages;
use Johnrdorazio\LitCal\Enum\LitLocale;
use Johnrdorazio\LitCal\LitFunc;
use Johnrdorazio\LitCal\LitMessages;

class Easter
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace LitCal\enum;
namespace Johnrdorazio\LitCal\Enum;

class AcceptHeader
{
Expand Down
2 changes: 1 addition & 1 deletion includes/enums/Ascension.php → src/Enum/Ascension.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace LitCal\enum;
namespace Johnrdorazio\LitCal\Enum;

class Ascension
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace LitCal\enum;
namespace Johnrdorazio\LitCal\Enum;

class CacheDuration
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace LitCal\enum;
namespace Johnrdorazio\LitCal\Enum;

class CalendarType
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace LitCal\enum;
namespace Johnrdorazio\LitCal\Enum;

class CorpusChristi
{
Expand Down
2 changes: 1 addition & 1 deletion includes/enums/Epiphany.php → src/Enum/Epiphany.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace LitCal\enum;
namespace Johnrdorazio\LitCal\Enum;

class Epiphany
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace LitCal\enum;
namespace Johnrdorazio\LitCal\Enum;

class ICSErrorLevel
{
Expand Down
Loading

0 comments on commit 566d847

Please sign in to comment.