Merge pull request 'feed-and-misc' (#50) from feed-and-misc into master
All checks were successful
🚀 Deploy website on push / 🎉 Deploy (push) Successful in 18s
All checks were successful
🚀 Deploy website on push / 🎉 Deploy (push) Successful in 18s
Reviewed-on: #50
This commit is contained in:
commit
e6522fb05e
@ -1,5 +1,5 @@
|
||||
{
|
||||
"require": {
|
||||
"require": {
|
||||
"slim/slim-skeleton": "^4.3",
|
||||
"ext-pdo": "*",
|
||||
"slim/psr7": "^1.4",
|
||||
@ -15,6 +15,13 @@
|
||||
"rbdwllr/psr-jwt": "^2.0",
|
||||
"tuupola/slim-jwt-auth": "^3.6",
|
||||
"ext-dom": "*",
|
||||
"ext-libxml": "*"
|
||||
"ext-libxml": "*",
|
||||
"donatello-za/rake-php-plus": "^1.0"
|
||||
},
|
||||
"repositories": [
|
||||
{
|
||||
"type": "composer",
|
||||
"url": "https:\/\/www.phpclasses.org\/"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
409
composer.lock
generated
409
composer.lock
generated
@ -4,9 +4,69 @@
|
||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "79f27ef0ad8fb8ffff7e6726df8c1f79",
|
||||
"content-hash": "f675ad7eec6390b82dca0b13dec49e5b",
|
||||
"packages": [
|
||||
{
|
||||
"name": "donatello-za/rake-php-plus",
|
||||
"version": "v1.0.18",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/Donatello-za/rake-php-plus.git",
|
||||
"reference": "e9e9c0862b3dc953d288e8f42c76e4ceaeca0619"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/Donatello-za/rake-php-plus/zipball/e9e9c0862b3dc953d288e8f42c76e4ceaeca0619",
|
||||
"reference": "e9e9c0862b3dc953d288e8f42c76e4ceaeca0619",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"ext-json": "*",
|
||||
"ext-mbstring": "*",
|
||||
"php": ">=5.4.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"php": ">=5.5.0",
|
||||
"phpunit/phpunit": "~4.0|~5.0"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.0.13-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"DonatelloZa\\RakePlus\\": "src/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Don Schoeman",
|
||||
"email": "ta.maximus@gmail.com"
|
||||
}
|
||||
],
|
||||
"description": "Yet another PHP implementation of the Rapid Automatic Keyword Extraction algorithm (RAKE).",
|
||||
"homepage": "https://github.com/Donatello-za/rake-php-plus",
|
||||
"keywords": [
|
||||
"Algorithm",
|
||||
"automatic",
|
||||
"extraction",
|
||||
"keyword",
|
||||
"rake",
|
||||
"rapid"
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/Donatello-za/rake-php-plus/issues",
|
||||
"source": "https://github.com/Donatello-za/rake-php-plus"
|
||||
},
|
||||
"time": "2022-02-23T18:42:03+00:00"
|
||||
},
|
||||
{
|
||||
"name": "fig/http-message-util",
|
||||
"version": "1.1.5",
|
||||
"source": {
|
||||
@ -121,22 +181,22 @@
|
||||
},
|
||||
{
|
||||
"name": "guzzlehttp/psr7",
|
||||
"version": "2.4.3",
|
||||
"version": "2.6.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/guzzle/psr7.git",
|
||||
"reference": "67c26b443f348a51926030c83481b85718457d3d"
|
||||
"reference": "be45764272e8873c72dbe3d2edcfdfcc3bc9f727"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/guzzle/psr7/zipball/67c26b443f348a51926030c83481b85718457d3d",
|
||||
"reference": "67c26b443f348a51926030c83481b85718457d3d",
|
||||
"url": "https://api.github.com/repos/guzzle/psr7/zipball/be45764272e8873c72dbe3d2edcfdfcc3bc9f727",
|
||||
"reference": "be45764272e8873c72dbe3d2edcfdfcc3bc9f727",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": "^7.2.5 || ^8.0",
|
||||
"psr/http-factory": "^1.0",
|
||||
"psr/http-message": "^1.0",
|
||||
"psr/http-message": "^1.1 || ^2.0",
|
||||
"ralouphie/getallheaders": "^3.0"
|
||||
},
|
||||
"provide": {
|
||||
@ -156,9 +216,6 @@
|
||||
"bamarni-bin": {
|
||||
"bin-links": true,
|
||||
"forward-command": false
|
||||
},
|
||||
"branch-alias": {
|
||||
"dev-master": "2.4-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
@ -220,7 +277,7 @@
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/guzzle/psr7/issues",
|
||||
"source": "https://github.com/guzzle/psr7/tree/2.4.3"
|
||||
"source": "https://github.com/guzzle/psr7/tree/2.6.1"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
@ -236,7 +293,7 @@
|
||||
"type": "tidelift"
|
||||
}
|
||||
],
|
||||
"time": "2022-10-26T14:07:24+00:00"
|
||||
"time": "2023-08-27T10:13:57+00:00"
|
||||
},
|
||||
{
|
||||
"name": "http-interop/http-factory-guzzle",
|
||||
@ -298,22 +355,22 @@
|
||||
},
|
||||
{
|
||||
"name": "laminas/laminas-diactoros",
|
||||
"version": "2.24.0",
|
||||
"version": "2.26.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/laminas/laminas-diactoros.git",
|
||||
"reference": "6028af6c3b5ced4d063a680d2483cce67578b902"
|
||||
"reference": "6584d44eb8e477e89d453313b858daac6183cddc"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/laminas/laminas-diactoros/zipball/6028af6c3b5ced4d063a680d2483cce67578b902",
|
||||
"reference": "6028af6c3b5ced4d063a680d2483cce67578b902",
|
||||
"url": "https://api.github.com/repos/laminas/laminas-diactoros/zipball/6584d44eb8e477e89d453313b858daac6183cddc",
|
||||
"reference": "6584d44eb8e477e89d453313b858daac6183cddc",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": "~8.0.0 || ~8.1.0 || ~8.2.0",
|
||||
"php": "~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0",
|
||||
"psr/http-factory": "^1.0",
|
||||
"psr/http-message": "^1.0"
|
||||
"psr/http-message": "^1.1"
|
||||
},
|
||||
"conflict": {
|
||||
"zendframework/zend-diactoros": "*"
|
||||
@ -328,11 +385,11 @@
|
||||
"ext-gd": "*",
|
||||
"ext-libxml": "*",
|
||||
"http-interop/http-factory-tests": "^0.9.0",
|
||||
"laminas/laminas-coding-standard": "^2.4.0",
|
||||
"laminas/laminas-coding-standard": "^2.5",
|
||||
"php-http/psr7-integration-tests": "^1.2",
|
||||
"phpunit/phpunit": "^9.5.27",
|
||||
"phpunit/phpunit": "^9.5.28",
|
||||
"psalm/plugin-phpunit": "^0.18.4",
|
||||
"vimeo/psalm": "^5.4"
|
||||
"vimeo/psalm": "^5.6"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
@ -391,34 +448,34 @@
|
||||
"type": "community_bridge"
|
||||
}
|
||||
],
|
||||
"time": "2022-12-20T12:22:40+00:00"
|
||||
"time": "2023-10-29T16:17:44+00:00"
|
||||
},
|
||||
{
|
||||
"name": "laminas/laminas-httphandlerrunner",
|
||||
"version": "2.5.0",
|
||||
"version": "2.9.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/laminas/laminas-httphandlerrunner.git",
|
||||
"reference": "7a47834aaad7852816d2ec4fdbb0492163b039ae"
|
||||
"reference": "d3e84755a17e563b1c5f8290cbfb150210501a77"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/laminas/laminas-httphandlerrunner/zipball/7a47834aaad7852816d2ec4fdbb0492163b039ae",
|
||||
"reference": "7a47834aaad7852816d2ec4fdbb0492163b039ae",
|
||||
"url": "https://api.github.com/repos/laminas/laminas-httphandlerrunner/zipball/d3e84755a17e563b1c5f8290cbfb150210501a77",
|
||||
"reference": "d3e84755a17e563b1c5f8290cbfb150210501a77",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": "~8.0.0 || ~8.1.0 || ~8.2.0",
|
||||
"psr/http-message": "^1.0",
|
||||
"psr/http-message-implementation": "^1.0",
|
||||
"php": "~8.1.0 || ~8.2.0 || ~8.3.0",
|
||||
"psr/http-message": "^1.0 || ^2.0",
|
||||
"psr/http-message-implementation": "^1.0 || ^2.0",
|
||||
"psr/http-server-handler": "^1.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"laminas/laminas-coding-standard": "~2.4.0",
|
||||
"laminas/laminas-diactoros": "^2.18",
|
||||
"phpunit/phpunit": "^9.5.26",
|
||||
"psalm/plugin-phpunit": "^0.18.0",
|
||||
"vimeo/psalm": "^5.0.0"
|
||||
"laminas/laminas-coding-standard": "~2.5.0",
|
||||
"laminas/laminas-diactoros": "^3.0.0",
|
||||
"phpunit/phpunit": "^10.1.2",
|
||||
"psalm/plugin-phpunit": "^0.18.4",
|
||||
"vimeo/psalm": "^5.11"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
@ -458,20 +515,20 @@
|
||||
"type": "community_bridge"
|
||||
}
|
||||
],
|
||||
"time": "2023-01-05T21:54:03+00:00"
|
||||
"time": "2023-09-04T10:43:03+00:00"
|
||||
},
|
||||
{
|
||||
"name": "laravel/serializable-closure",
|
||||
"version": "v1.2.2",
|
||||
"version": "v1.3.2",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/laravel/serializable-closure.git",
|
||||
"reference": "47afb7fae28ed29057fdca37e16a84f90cc62fae"
|
||||
"reference": "076fe2cf128bd54b4341cdc6d49b95b34e101e4c"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/laravel/serializable-closure/zipball/47afb7fae28ed29057fdca37e16a84f90cc62fae",
|
||||
"reference": "47afb7fae28ed29057fdca37e16a84f90cc62fae",
|
||||
"url": "https://api.github.com/repos/laravel/serializable-closure/zipball/076fe2cf128bd54b4341cdc6d49b95b34e101e4c",
|
||||
"reference": "076fe2cf128bd54b4341cdc6d49b95b34e101e4c",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@ -518,20 +575,20 @@
|
||||
"issues": "https://github.com/laravel/serializable-closure/issues",
|
||||
"source": "https://github.com/laravel/serializable-closure"
|
||||
},
|
||||
"time": "2022-09-08T13:45:54+00:00"
|
||||
"time": "2023-10-17T13:38:16+00:00"
|
||||
},
|
||||
{
|
||||
"name": "monolog/monolog",
|
||||
"version": "2.8.0",
|
||||
"version": "2.9.2",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/Seldaek/monolog.git",
|
||||
"reference": "720488632c590286b88b80e62aa3d3d551ad4a50"
|
||||
"reference": "437cb3628f4cf6042cc10ae97fc2b8472e48ca1f"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/Seldaek/monolog/zipball/720488632c590286b88b80e62aa3d3d551ad4a50",
|
||||
"reference": "720488632c590286b88b80e62aa3d3d551ad4a50",
|
||||
"url": "https://api.github.com/repos/Seldaek/monolog/zipball/437cb3628f4cf6042cc10ae97fc2b8472e48ca1f",
|
||||
"reference": "437cb3628f4cf6042cc10ae97fc2b8472e48ca1f",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@ -546,7 +603,7 @@
|
||||
"doctrine/couchdb": "~1.0@dev",
|
||||
"elasticsearch/elasticsearch": "^7 || ^8",
|
||||
"ext-json": "*",
|
||||
"graylog2/gelf-php": "^1.4.2",
|
||||
"graylog2/gelf-php": "^1.4.2 || ^2@dev",
|
||||
"guzzlehttp/guzzle": "^7.4",
|
||||
"guzzlehttp/psr7": "^2.2",
|
||||
"mongodb/mongodb": "^1.8",
|
||||
@ -608,7 +665,7 @@
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/Seldaek/monolog/issues",
|
||||
"source": "https://github.com/Seldaek/monolog/tree/2.8.0"
|
||||
"source": "https://github.com/Seldaek/monolog/tree/2.9.2"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
@ -620,7 +677,7 @@
|
||||
"type": "tidelift"
|
||||
}
|
||||
],
|
||||
"time": "2022-07-24T11:55:47+00:00"
|
||||
"time": "2023-10-27T15:25:26+00:00"
|
||||
},
|
||||
{
|
||||
"name": "nikic/fast-route",
|
||||
@ -674,38 +731,39 @@
|
||||
},
|
||||
{
|
||||
"name": "nyholm/psr7",
|
||||
"version": "1.5.1",
|
||||
"version": "1.8.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/Nyholm/psr7.git",
|
||||
"reference": "f734364e38a876a23be4d906a2a089e1315be18a"
|
||||
"reference": "3cb4d163b58589e47b35103e8e5e6a6a475b47be"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/Nyholm/psr7/zipball/f734364e38a876a23be4d906a2a089e1315be18a",
|
||||
"reference": "f734364e38a876a23be4d906a2a089e1315be18a",
|
||||
"url": "https://api.github.com/repos/Nyholm/psr7/zipball/3cb4d163b58589e47b35103e8e5e6a6a475b47be",
|
||||
"reference": "3cb4d163b58589e47b35103e8e5e6a6a475b47be",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=7.1",
|
||||
"php-http/message-factory": "^1.0",
|
||||
"php": ">=7.2",
|
||||
"psr/http-factory": "^1.0",
|
||||
"psr/http-message": "^1.0"
|
||||
"psr/http-message": "^1.1 || ^2.0"
|
||||
},
|
||||
"provide": {
|
||||
"php-http/message-factory-implementation": "1.0",
|
||||
"psr/http-factory-implementation": "1.0",
|
||||
"psr/http-message-implementation": "1.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"http-interop/http-factory-tests": "^0.9",
|
||||
"php-http/message-factory": "^1.0",
|
||||
"php-http/psr7-integration-tests": "^1.0",
|
||||
"phpunit/phpunit": "^7.5 || 8.5 || 9.4",
|
||||
"phpunit/phpunit": "^7.5 || ^8.5 || ^9.4",
|
||||
"symfony/error-handler": "^4.4"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.4-dev"
|
||||
"dev-master": "1.8-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
@ -735,7 +793,7 @@
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/Nyholm/psr7/issues",
|
||||
"source": "https://github.com/Nyholm/psr7/tree/1.5.1"
|
||||
"source": "https://github.com/Nyholm/psr7/tree/1.8.0"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
@ -747,26 +805,26 @@
|
||||
"type": "github"
|
||||
}
|
||||
],
|
||||
"time": "2022-06-22T07:13:36+00:00"
|
||||
"time": "2023-05-02T11:26:24+00:00"
|
||||
},
|
||||
{
|
||||
"name": "nyholm/psr7-server",
|
||||
"version": "1.0.2",
|
||||
"version": "1.1.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/Nyholm/psr7-server.git",
|
||||
"reference": "b846a689844cef114e8079d8c80f0afd96745ae3"
|
||||
"reference": "4335801d851f554ca43fa6e7d2602141538854dc"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/Nyholm/psr7-server/zipball/b846a689844cef114e8079d8c80f0afd96745ae3",
|
||||
"reference": "b846a689844cef114e8079d8c80f0afd96745ae3",
|
||||
"url": "https://api.github.com/repos/Nyholm/psr7-server/zipball/4335801d851f554ca43fa6e7d2602141538854dc",
|
||||
"reference": "4335801d851f554ca43fa6e7d2602141538854dc",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": "^7.1 || ^8.0",
|
||||
"psr/http-factory": "^1.0",
|
||||
"psr/http-message": "^1.0"
|
||||
"psr/http-message": "^1.0 || ^2.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"nyholm/nsa": "^1.1",
|
||||
@ -801,7 +859,7 @@
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/Nyholm/psr7-server/issues",
|
||||
"source": "https://github.com/Nyholm/psr7-server/tree/1.0.2"
|
||||
"source": "https://github.com/Nyholm/psr7-server/tree/1.1.0"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
@ -813,20 +871,20 @@
|
||||
"type": "github"
|
||||
}
|
||||
],
|
||||
"time": "2021-05-12T11:11:27+00:00"
|
||||
"time": "2023-11-08T09:30:43+00:00"
|
||||
},
|
||||
{
|
||||
"name": "php-di/invoker",
|
||||
"version": "2.3.3",
|
||||
"version": "2.3.4",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/PHP-DI/Invoker.git",
|
||||
"reference": "cd6d9f267d1a3474bdddf1be1da079f01b942786"
|
||||
"reference": "33234b32dafa8eb69202f950a1fc92055ed76a86"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/PHP-DI/Invoker/zipball/cd6d9f267d1a3474bdddf1be1da079f01b942786",
|
||||
"reference": "cd6d9f267d1a3474bdddf1be1da079f01b942786",
|
||||
"url": "https://api.github.com/repos/PHP-DI/Invoker/zipball/33234b32dafa8eb69202f950a1fc92055ed76a86",
|
||||
"reference": "33234b32dafa8eb69202f950a1fc92055ed76a86",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@ -860,7 +918,7 @@
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/PHP-DI/Invoker/issues",
|
||||
"source": "https://github.com/PHP-DI/Invoker/tree/2.3.3"
|
||||
"source": "https://github.com/PHP-DI/Invoker/tree/2.3.4"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
@ -868,7 +926,7 @@
|
||||
"type": "github"
|
||||
}
|
||||
],
|
||||
"time": "2021-12-13T09:22:56+00:00"
|
||||
"time": "2023-09-08T09:24:21+00:00"
|
||||
},
|
||||
{
|
||||
"name": "php-di/php-di",
|
||||
@ -988,60 +1046,6 @@
|
||||
},
|
||||
"time": "2020-10-12T12:39:22+00:00"
|
||||
},
|
||||
{
|
||||
"name": "php-http/message-factory",
|
||||
"version": "v1.0.2",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/php-http/message-factory.git",
|
||||
"reference": "a478cb11f66a6ac48d8954216cfed9aa06a501a1"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/php-http/message-factory/zipball/a478cb11f66a6ac48d8954216cfed9aa06a501a1",
|
||||
"reference": "a478cb11f66a6ac48d8954216cfed9aa06a501a1",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.4",
|
||||
"psr/http-message": "^1.0"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.0-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Http\\Message\\": "src/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Márk Sági-Kazár",
|
||||
"email": "mark.sagikazar@gmail.com"
|
||||
}
|
||||
],
|
||||
"description": "Factory interfaces for PSR-7 HTTP Message",
|
||||
"homepage": "http://php-http.org",
|
||||
"keywords": [
|
||||
"factory",
|
||||
"http",
|
||||
"message",
|
||||
"stream",
|
||||
"uri"
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/php-http/message-factory/issues",
|
||||
"source": "https://github.com/php-http/message-factory/tree/master"
|
||||
},
|
||||
"time": "2015-12-19T14:08:53+00:00"
|
||||
},
|
||||
{
|
||||
"name": "psr/container",
|
||||
"version": "1.1.2",
|
||||
@ -1092,21 +1096,21 @@
|
||||
},
|
||||
{
|
||||
"name": "psr/http-factory",
|
||||
"version": "1.0.1",
|
||||
"version": "1.0.2",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/php-fig/http-factory.git",
|
||||
"reference": "12ac7fcd07e5b077433f5f2bee95b3a771bf61be"
|
||||
"reference": "e616d01114759c4c489f93b099585439f795fe35"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/php-fig/http-factory/zipball/12ac7fcd07e5b077433f5f2bee95b3a771bf61be",
|
||||
"reference": "12ac7fcd07e5b077433f5f2bee95b3a771bf61be",
|
||||
"url": "https://api.github.com/repos/php-fig/http-factory/zipball/e616d01114759c4c489f93b099585439f795fe35",
|
||||
"reference": "e616d01114759c4c489f93b099585439f795fe35",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=7.0.0",
|
||||
"psr/http-message": "^1.0"
|
||||
"psr/http-message": "^1.0 || ^2.0"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
@ -1126,7 +1130,7 @@
|
||||
"authors": [
|
||||
{
|
||||
"name": "PHP-FIG",
|
||||
"homepage": "http://www.php-fig.org/"
|
||||
"homepage": "https://www.php-fig.org/"
|
||||
}
|
||||
],
|
||||
"description": "Common interfaces for PSR-7 HTTP message factories",
|
||||
@ -1141,31 +1145,31 @@
|
||||
"response"
|
||||
],
|
||||
"support": {
|
||||
"source": "https://github.com/php-fig/http-factory/tree/master"
|
||||
"source": "https://github.com/php-fig/http-factory/tree/1.0.2"
|
||||
},
|
||||
"time": "2019-04-30T12:38:16+00:00"
|
||||
"time": "2023-04-10T20:10:41+00:00"
|
||||
},
|
||||
{
|
||||
"name": "psr/http-message",
|
||||
"version": "1.0.1",
|
||||
"version": "1.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/php-fig/http-message.git",
|
||||
"reference": "f6561bf28d520154e4b0ec72be95418abe6d9363"
|
||||
"reference": "cb6ce4845ce34a8ad9e68117c10ee90a29919eba"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/php-fig/http-message/zipball/f6561bf28d520154e4b0ec72be95418abe6d9363",
|
||||
"reference": "f6561bf28d520154e4b0ec72be95418abe6d9363",
|
||||
"url": "https://api.github.com/repos/php-fig/http-message/zipball/cb6ce4845ce34a8ad9e68117c10ee90a29919eba",
|
||||
"reference": "cb6ce4845ce34a8ad9e68117c10ee90a29919eba",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.0"
|
||||
"php": "^7.2 || ^8.0"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.0.x-dev"
|
||||
"dev-master": "1.1.x-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
@ -1194,27 +1198,27 @@
|
||||
"response"
|
||||
],
|
||||
"support": {
|
||||
"source": "https://github.com/php-fig/http-message/tree/master"
|
||||
"source": "https://github.com/php-fig/http-message/tree/1.1"
|
||||
},
|
||||
"time": "2016-08-06T14:39:51+00:00"
|
||||
"time": "2023-04-04T09:50:52+00:00"
|
||||
},
|
||||
{
|
||||
"name": "psr/http-server-handler",
|
||||
"version": "1.0.1",
|
||||
"version": "1.0.2",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/php-fig/http-server-handler.git",
|
||||
"reference": "aff2f80e33b7f026ec96bb42f63242dc50ffcae7"
|
||||
"reference": "84c4fb66179be4caaf8e97bd239203245302e7d4"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/php-fig/http-server-handler/zipball/aff2f80e33b7f026ec96bb42f63242dc50ffcae7",
|
||||
"reference": "aff2f80e33b7f026ec96bb42f63242dc50ffcae7",
|
||||
"url": "https://api.github.com/repos/php-fig/http-server-handler/zipball/84c4fb66179be4caaf8e97bd239203245302e7d4",
|
||||
"reference": "84c4fb66179be4caaf8e97bd239203245302e7d4",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=7.0",
|
||||
"psr/http-message": "^1.0"
|
||||
"psr/http-message": "^1.0 || ^2.0"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
@ -1234,7 +1238,7 @@
|
||||
"authors": [
|
||||
{
|
||||
"name": "PHP-FIG",
|
||||
"homepage": "http://www.php-fig.org/"
|
||||
"homepage": "https://www.php-fig.org/"
|
||||
}
|
||||
],
|
||||
"description": "Common interface for HTTP server-side request handler",
|
||||
@ -1250,28 +1254,27 @@
|
||||
"server"
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/php-fig/http-server-handler/issues",
|
||||
"source": "https://github.com/php-fig/http-server-handler/tree/master"
|
||||
"source": "https://github.com/php-fig/http-server-handler/tree/1.0.2"
|
||||
},
|
||||
"time": "2018-10-30T16:46:14+00:00"
|
||||
"time": "2023-04-10T20:06:20+00:00"
|
||||
},
|
||||
{
|
||||
"name": "psr/http-server-middleware",
|
||||
"version": "1.0.1",
|
||||
"version": "1.0.2",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/php-fig/http-server-middleware.git",
|
||||
"reference": "2296f45510945530b9dceb8bcedb5cb84d40c5f5"
|
||||
"reference": "c1481f747daaa6a0782775cd6a8c26a1bf4a3829"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/php-fig/http-server-middleware/zipball/2296f45510945530b9dceb8bcedb5cb84d40c5f5",
|
||||
"reference": "2296f45510945530b9dceb8bcedb5cb84d40c5f5",
|
||||
"url": "https://api.github.com/repos/php-fig/http-server-middleware/zipball/c1481f747daaa6a0782775cd6a8c26a1bf4a3829",
|
||||
"reference": "c1481f747daaa6a0782775cd6a8c26a1bf4a3829",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=7.0",
|
||||
"psr/http-message": "^1.0",
|
||||
"psr/http-message": "^1.0 || ^2.0",
|
||||
"psr/http-server-handler": "^1.0"
|
||||
},
|
||||
"type": "library",
|
||||
@ -1292,7 +1295,7 @@
|
||||
"authors": [
|
||||
{
|
||||
"name": "PHP-FIG",
|
||||
"homepage": "http://www.php-fig.org/"
|
||||
"homepage": "https://www.php-fig.org/"
|
||||
}
|
||||
],
|
||||
"description": "Common interface for HTTP server-side middleware",
|
||||
@ -1308,9 +1311,9 @@
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/php-fig/http-server-middleware/issues",
|
||||
"source": "https://github.com/php-fig/http-server-middleware/tree/master"
|
||||
"source": "https://github.com/php-fig/http-server-middleware/tree/1.0.2"
|
||||
},
|
||||
"time": "2018-10-30T17:12:04+00:00"
|
||||
"time": "2023-04-11T06:14:47+00:00"
|
||||
},
|
||||
{
|
||||
"name": "psr/log",
|
||||
@ -1585,16 +1588,16 @@
|
||||
},
|
||||
{
|
||||
"name": "slim/psr7",
|
||||
"version": "1.6",
|
||||
"version": "1.6.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/slimphp/Slim-Psr7.git",
|
||||
"reference": "3471c22c1a0d26c51c78f6aeb06489d38cf46a4d"
|
||||
"reference": "72d2b2bac94ab4575d369f605dbfafbe168d3163"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/slimphp/Slim-Psr7/zipball/3471c22c1a0d26c51c78f6aeb06489d38cf46a4d",
|
||||
"reference": "3471c22c1a0d26c51c78f6aeb06489d38cf46a4d",
|
||||
"url": "https://api.github.com/repos/slimphp/Slim-Psr7/zipball/72d2b2bac94ab4575d369f605dbfafbe168d3163",
|
||||
"reference": "72d2b2bac94ab4575d369f605dbfafbe168d3163",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@ -1613,7 +1616,7 @@
|
||||
"adriansuter/php-autoload-override": "^1.3",
|
||||
"ext-json": "*",
|
||||
"http-interop/http-factory-tests": "^0.9.0",
|
||||
"php-http/psr7-integration-tests": "dev-master",
|
||||
"php-http/psr7-integration-tests": "1.1",
|
||||
"phpspec/prophecy": "^1.15",
|
||||
"phpspec/prophecy-phpunit": "^2.0",
|
||||
"phpstan/phpstan": "^1.8",
|
||||
@ -1661,22 +1664,22 @@
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/slimphp/Slim-Psr7/issues",
|
||||
"source": "https://github.com/slimphp/Slim-Psr7/tree/1.6"
|
||||
"source": "https://github.com/slimphp/Slim-Psr7/tree/1.6.1"
|
||||
},
|
||||
"time": "2022-11-05T18:50:24+00:00"
|
||||
"time": "2023-04-17T16:02:20+00:00"
|
||||
},
|
||||
{
|
||||
"name": "slim/slim",
|
||||
"version": "4.11.0",
|
||||
"version": "4.12.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/slimphp/Slim.git",
|
||||
"reference": "b0f4ca393ea037be9ac7292ba7d0a34d18bac0c7"
|
||||
"reference": "e9e99c2b24398b967841c6c4c3048622cc7e2b18"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/slimphp/Slim/zipball/b0f4ca393ea037be9ac7292ba7d0a34d18bac0c7",
|
||||
"reference": "b0f4ca393ea037be9ac7292ba7d0a34d18bac0c7",
|
||||
"url": "https://api.github.com/repos/slimphp/Slim/zipball/e9e99c2b24398b967841c6c4c3048622cc7e2b18",
|
||||
"reference": "e9e99c2b24398b967841c6c4c3048622cc7e2b18",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@ -1685,26 +1688,26 @@
|
||||
"php": "^7.4 || ^8.0",
|
||||
"psr/container": "^1.0 || ^2.0",
|
||||
"psr/http-factory": "^1.0",
|
||||
"psr/http-message": "^1.0",
|
||||
"psr/http-message": "^1.1",
|
||||
"psr/http-server-handler": "^1.0",
|
||||
"psr/http-server-middleware": "^1.0",
|
||||
"psr/log": "^1.1 || ^2.0 || ^3.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"adriansuter/php-autoload-override": "^1.3",
|
||||
"adriansuter/php-autoload-override": "^1.4",
|
||||
"ext-simplexml": "*",
|
||||
"guzzlehttp/psr7": "^2.4",
|
||||
"httpsoft/http-message": "^1.0",
|
||||
"httpsoft/http-server-request": "^1.0",
|
||||
"guzzlehttp/psr7": "^2.5",
|
||||
"httpsoft/http-message": "^1.1",
|
||||
"httpsoft/http-server-request": "^1.1",
|
||||
"laminas/laminas-diactoros": "^2.17",
|
||||
"nyholm/psr7": "^1.5",
|
||||
"nyholm/psr7": "^1.8",
|
||||
"nyholm/psr7-server": "^1.0",
|
||||
"phpspec/prophecy": "^1.15",
|
||||
"phpspec/prophecy": "^1.17",
|
||||
"phpspec/prophecy-phpunit": "^2.0",
|
||||
"phpstan/phpstan": "^1.8",
|
||||
"phpunit/phpunit": "^9.5",
|
||||
"slim/http": "^1.2",
|
||||
"slim/psr7": "^1.5",
|
||||
"phpstan/phpstan": "^1.10",
|
||||
"phpunit/phpunit": "^9.6",
|
||||
"slim/http": "^1.3",
|
||||
"slim/psr7": "^1.6",
|
||||
"squizlabs/php_codesniffer": "^3.7"
|
||||
},
|
||||
"suggest": {
|
||||
@ -1778,7 +1781,7 @@
|
||||
"type": "tidelift"
|
||||
}
|
||||
],
|
||||
"time": "2022-11-06T16:33:39+00:00"
|
||||
"time": "2023-07-23T04:54:29+00:00"
|
||||
},
|
||||
{
|
||||
"name": "slim/slim-skeleton",
|
||||
@ -1848,16 +1851,16 @@
|
||||
},
|
||||
{
|
||||
"name": "symfony/polyfill-php80",
|
||||
"version": "v1.27.0",
|
||||
"version": "v1.28.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/polyfill-php80.git",
|
||||
"reference": "7a6ff3f1959bb01aefccb463a0f2cd3d3d2fd936"
|
||||
"reference": "6caa57379c4aec19c0a12a38b59b26487dcfe4b5"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/7a6ff3f1959bb01aefccb463a0f2cd3d3d2fd936",
|
||||
"reference": "7a6ff3f1959bb01aefccb463a0f2cd3d3d2fd936",
|
||||
"url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/6caa57379c4aec19c0a12a38b59b26487dcfe4b5",
|
||||
"reference": "6caa57379c4aec19c0a12a38b59b26487dcfe4b5",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@ -1866,7 +1869,7 @@
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-main": "1.27-dev"
|
||||
"dev-main": "1.28-dev"
|
||||
},
|
||||
"thanks": {
|
||||
"name": "symfony/polyfill",
|
||||
@ -1911,7 +1914,7 @@
|
||||
"shim"
|
||||
],
|
||||
"support": {
|
||||
"source": "https://github.com/symfony/polyfill-php80/tree/v1.27.0"
|
||||
"source": "https://github.com/symfony/polyfill-php80/tree/v1.28.0"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
@ -1927,7 +1930,7 @@
|
||||
"type": "tidelift"
|
||||
}
|
||||
],
|
||||
"time": "2022-11-03T14:55:06+00:00"
|
||||
"time": "2023-01-26T09:26:14+00:00"
|
||||
},
|
||||
{
|
||||
"name": "tuupola/callable-handler",
|
||||
@ -2060,22 +2063,22 @@
|
||||
},
|
||||
{
|
||||
"name": "tuupola/slim-jwt-auth",
|
||||
"version": "3.7.0",
|
||||
"version": "3.8.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/tuupola/slim-jwt-auth.git",
|
||||
"reference": "ef05b93d4dac7307ef6ef3b62feaff30c32e82c1"
|
||||
"reference": "7829d4482034e9eb5e051f3a1619db0c704ba7e7"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/tuupola/slim-jwt-auth/zipball/ef05b93d4dac7307ef6ef3b62feaff30c32e82c1",
|
||||
"reference": "ef05b93d4dac7307ef6ef3b62feaff30c32e82c1",
|
||||
"url": "https://api.github.com/repos/tuupola/slim-jwt-auth/zipball/7829d4482034e9eb5e051f3a1619db0c704ba7e7",
|
||||
"reference": "7829d4482034e9eb5e051f3a1619db0c704ba7e7",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"firebase/php-jwt": "^3.0|^4.0|^5.0",
|
||||
"php": "^7.2|^8.0",
|
||||
"psr/http-message": "^1.0",
|
||||
"php": "^7.4|^8.0",
|
||||
"psr/http-message": "^1.0|^2.0",
|
||||
"psr/http-server-middleware": "^1.0",
|
||||
"psr/log": "^1.0|^2.0|^3.0",
|
||||
"tuupola/callable-handler": "^1.0",
|
||||
@ -2083,9 +2086,9 @@
|
||||
},
|
||||
"require-dev": {
|
||||
"equip/dispatch": "^2.0",
|
||||
"laminas/laminas-diactoros": "^2.0",
|
||||
"laminas/laminas-diactoros": "^2.0|^3.0",
|
||||
"overtrue/phplint": "^1.0",
|
||||
"phpstan/phpstan": "^1.8",
|
||||
"phpstan/phpstan": "^1.10",
|
||||
"phpunit/phpunit": "^7.0|^8.5.30|^9.0",
|
||||
"squizlabs/php_codesniffer": "^3.7"
|
||||
},
|
||||
@ -2124,15 +2127,9 @@
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/tuupola/slim-jwt-auth/issues",
|
||||
"source": "https://github.com/tuupola/slim-jwt-auth/tree/3.7.0"
|
||||
"source": "https://github.com/tuupola/slim-jwt-auth/tree/3.8.0"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
"url": "https://github.com/tuupola",
|
||||
"type": "github"
|
||||
}
|
||||
],
|
||||
"time": "2022-12-23T11:23:05+00:00"
|
||||
"time": "2023-10-20T09:51:26+00:00"
|
||||
}
|
||||
],
|
||||
"packages-dev": [],
|
||||
@ -2143,8 +2140,10 @@
|
||||
"prefer-lowest": false,
|
||||
"platform": {
|
||||
"ext-pdo": "*",
|
||||
"ext-json": "*"
|
||||
"ext-json": "*",
|
||||
"ext-dom": "*",
|
||||
"ext-libxml": "*"
|
||||
},
|
||||
"platform-dev": [],
|
||||
"plugin-api-version": "2.3.0"
|
||||
"plugin-api-version": "2.6.0"
|
||||
}
|
||||
|
158
dist/api/blog/blogData.php
vendored
158
dist/api/blog/blogData.php
vendored
@ -2,13 +2,20 @@
|
||||
|
||||
namespace api\blog;
|
||||
|
||||
use api\utils\feedGenerator\FeedWriter;
|
||||
use api\utils\imgUtils;
|
||||
use DOMDocument;
|
||||
use PDO;
|
||||
use Psr\Http\Message\UploadedFileInterface;
|
||||
use DonatelloZa\RakePlus\RakePlus;
|
||||
use function DI\string;
|
||||
use const api\utils\feedGenerator\ATOM;
|
||||
use const api\utils\feedGenerator\RSS2;
|
||||
|
||||
|
||||
require_once __DIR__ . "/../utils/config.php";
|
||||
require_once __DIR__ . "/../utils/imgUtils.php";
|
||||
require_once __DIR__ . "/../utils/feedGenerator/FeedWriter.php";
|
||||
|
||||
/**
|
||||
* Blog Data Class
|
||||
@ -18,12 +25,15 @@ class blogData
|
||||
{
|
||||
/**
|
||||
* Get all blog posts
|
||||
* @return array - Array of all blog posts or error message
|
||||
* @return array<array> - Array of all blog posts or error message
|
||||
*/
|
||||
public function getBlogPosts(): array
|
||||
{
|
||||
$conn = dbConn();
|
||||
$stmt = $conn->prepare("SELECT * FROM blog ORDER BY featured DESC, dateCreated DESC;");
|
||||
$stmt = $conn->prepare("SELECT ID, title, DATE_FORMAT(dateCreated, '%Y-%m-%dT%TZ') AS dateCreated,
|
||||
DATE_FORMAT(dateModified, '%Y-%m-%dT%TZ') AS dateModified, featured, abstract,
|
||||
headerImg, body, bodyText, categories, keywords, folderID FROM blog ORDER BY featured DESC,
|
||||
dateCreated DESC;");
|
||||
$stmt->execute();
|
||||
|
||||
// set the resulting array to associative
|
||||
@ -40,12 +50,15 @@ class blogData
|
||||
/**
|
||||
* Get a blog post with the given ID
|
||||
* @param string $title - Title of the blog post
|
||||
* @return array - Array of all blog posts or error message
|
||||
* @return array - Array of blog post or error message
|
||||
*/
|
||||
public function getBlogPost(string $title): array
|
||||
{
|
||||
$conn = dbConn();
|
||||
$stmt = $conn->prepare("SELECT * FROM blog WHERE title = :title;");
|
||||
$stmt = $conn->prepare("SELECT ID, title, DATE_FORMAT(dateCreated, '%Y-%m-%dT%TZ') AS dateCreated,
|
||||
DATE_FORMAT(dateModified, '%Y-%m-%dT%TZ') AS dateModified, featured, abstract,
|
||||
headerImg, body, bodyText, categories, keywords, folderID FROM blog WHERE
|
||||
title = :title;");
|
||||
$stmt->bindParam(":title", $title);
|
||||
$stmt->execute();
|
||||
|
||||
@ -67,7 +80,10 @@ class blogData
|
||||
public function getLatestBlogPost(): array
|
||||
{
|
||||
$conn = dbConn();
|
||||
$stmt = $conn->prepare("SELECT * FROM blog ORDER BY dateCreated DESC LIMIT 1;");
|
||||
$stmt = $conn->prepare("SELECT ID, title, DATE_FORMAT(dateCreated, '%Y-%m-%dT%TZ') AS dateCreated,
|
||||
DATE_FORMAT(dateModified, '%Y-%m-%dT%TZ') AS dateModified, featured, abstract,
|
||||
headerImg, body, bodyText, categories, keywords, folderID FROM blog ORDER BY
|
||||
dateCreated DESC LIMIT 1;");
|
||||
$stmt->execute();
|
||||
|
||||
// set the resulting array to associative
|
||||
@ -88,7 +104,9 @@ class blogData
|
||||
public function getFeaturedBlogPost(): array
|
||||
{
|
||||
$conn = dbConn();
|
||||
$stmt = $conn->prepare("SELECT * FROM blog WHERE featured = 1;");
|
||||
$stmt = $conn->prepare("SELECT ID, title, DATE_FORMAT(dateCreated, '%Y-%m-%dT%TZ') AS dateCreated,
|
||||
DATE_FORMAT(dateModified, '%Y-%m-%dT%TZ') AS dateModified, featured, abstract,
|
||||
headerImg, body, bodyText, categories, keywords, folderID FROM blog WHERE featured = 1;");
|
||||
$stmt->execute();
|
||||
|
||||
$result = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
@ -209,7 +227,9 @@ class blogData
|
||||
$from = "../blog/imgs/tmp/";
|
||||
$newBody = $this->changeHTMLSrc($body, $to, $from);
|
||||
|
||||
$stmt = $conn->prepare("UPDATE blog SET title = :title, featured = :featured, abstract = :abstract, body = :body, bodyText = :bodyText, dateModified = :dateModified, categories = :categories WHERE ID = :ID;");
|
||||
$keywords = implode(", ", RakePlus::create($bodyText)->keywords());
|
||||
|
||||
$stmt = $conn->prepare("UPDATE blog SET title = :title, featured = :featured, abstract = :abstract, body = :body, bodyText = :bodyText, dateModified = :dateModified, categories = :categories, keywords = :keywords WHERE ID = :ID;");
|
||||
$stmt->bindParam(":ID", $ID);
|
||||
$stmt->bindParam(":title", $title);
|
||||
$stmt->bindParam(":featured", $featured);
|
||||
@ -218,6 +238,7 @@ class blogData
|
||||
$stmt->bindParam(":bodyText", $bodyText);
|
||||
$stmt->bindParam(":dateModified", $dateModified);
|
||||
$stmt->bindParam(":categories", $categories);
|
||||
$stmt->bindParam(":keywords", $keywords);
|
||||
|
||||
return $stmt->execute();
|
||||
}
|
||||
@ -266,8 +287,10 @@ class blogData
|
||||
$stmtMainProject->execute();
|
||||
}
|
||||
|
||||
$stmt = $conn->prepare("INSERT INTO blog (title, dateCreated, dateModified, featured, headerImg, abstract, body, bodyText, categories, folderID)
|
||||
VALUES (:title, :dateCreated, :dateModified, :featured, :headerImg, :abstract, :body, :bodyText, :categories, :folderID);");
|
||||
$keywords = implode(", ", RakePlus::create($bodyText)->keywords());
|
||||
|
||||
$stmt = $conn->prepare("INSERT INTO blog (title, dateCreated, dateModified, featured, headerImg, abstract, body, bodyText, categories, keywords, folderID)
|
||||
VALUES (:title, :dateCreated, :dateModified, :featured, :headerImg, :abstract, :body, :bodyText, :categories, :keywords, :folderID);");
|
||||
$stmt->bindParam(":title", $title);
|
||||
$stmt->bindParam(":dateCreated", $dateCreated);
|
||||
$stmt->bindParam(":dateModified", $dateCreated);
|
||||
@ -278,6 +301,7 @@ class blogData
|
||||
$stmt->bindParam(":body", $newBody);
|
||||
$stmt->bindParam(":bodyText", $bodyText);
|
||||
$stmt->bindParam(":categories", $categories);
|
||||
$stmt->bindParam(":keywords", $keywords);
|
||||
$stmt->bindParam(":folderID", $folderID);
|
||||
|
||||
if ($stmt->execute())
|
||||
@ -399,11 +423,10 @@ class blogData
|
||||
if (!in_array($from . $file, $srcList))
|
||||
{
|
||||
unlink($from . $file);
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
rename($from . $file, $to . $file);
|
||||
}
|
||||
|
||||
rename($from . $file, $to . $file);
|
||||
}
|
||||
}
|
||||
|
||||
@ -418,7 +441,7 @@ class blogData
|
||||
/**
|
||||
* Get all posts with the given category
|
||||
* @param string $category - Category of the post
|
||||
* @return array - Array of all posts with the given category or error message
|
||||
* @return array<array> - Array of all posts with the given category or error message
|
||||
*/
|
||||
public function getPostsByCategory(string $category): array
|
||||
{
|
||||
@ -432,7 +455,7 @@ class blogData
|
||||
/**
|
||||
* Search for a blog post with the given search term
|
||||
* @param string $searchTerm - Search term
|
||||
* @return array - Array of all posts with the given search term or error message
|
||||
* @return array<array> - Array of all posts with the given search term or error message
|
||||
*/
|
||||
public function searchBlog(string $searchTerm): array
|
||||
{
|
||||
@ -527,4 +550,109 @@ class blogData
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate the XML feed
|
||||
* @param mixed $type - Type of feed
|
||||
* @return array|string - Error message or the XML feed
|
||||
*/
|
||||
private function generateXMLFeed(mixed $type): array|string
|
||||
{
|
||||
ob_start();
|
||||
$feed = new FeedWriter($type);
|
||||
$feed->setTitle("Rohit Pai's Blog");
|
||||
$feed->setLink('https://rohitpai.co.uk/blog');
|
||||
$feed->setFeedURL('https://rohitpai.co.uk/api/blog/feed/atom');
|
||||
$feed->setChannelElement('updated', date(DATE_ATOM, time()));
|
||||
$feed->setChannelElement('author', ['name' => 'Rohit Pai']);
|
||||
$posts = $this->getBlogPosts();
|
||||
|
||||
if (isset($posts["errorMessage"]))
|
||||
{
|
||||
return $posts;
|
||||
}
|
||||
|
||||
foreach ($posts as $post)
|
||||
{
|
||||
$newItem = $feed->createNewItem();
|
||||
$newItem->setTitle($post["title"]);
|
||||
$newItem->setLink("https://rohitpai.co.uk/blog/post/" . rawurlencode($post["title"]) . "#disqus_thread");
|
||||
$newItem->setDate($post["dateModified"]);
|
||||
$newItem->setDescription($post["body"]);
|
||||
$feed->addItem($newItem);
|
||||
}
|
||||
|
||||
$feed->generateFeed();
|
||||
$atom = ob_get_contents();
|
||||
ob_end_clean();
|
||||
return $atom;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate the JSON feed
|
||||
* @return array|array[] - Error message or the JSON feed
|
||||
*/
|
||||
private function generateJSONFeed(): array
|
||||
{
|
||||
$posts = $this->getBlogPosts();
|
||||
|
||||
if (isset($posts["errorMessage"]))
|
||||
{
|
||||
return $posts;
|
||||
}
|
||||
|
||||
$json = array();
|
||||
$json["version"] = "https://jsonfeed.org/version/1.1";
|
||||
$json["title"] = "Rohit Pai's Blog";
|
||||
$json["home_page_url"] = "https://rohitpai.co.uk/blog";
|
||||
$json["feed_url"] = "https://rohitpai.co.uk/api/blog/feed/json";
|
||||
$json["description"] = "Rohit Pai's personal blog on all things self hosting and various other tech topics";
|
||||
$json["author"] = array(
|
||||
"name" => "Rohit Pai",
|
||||
"url" => "https://rohitpai.co.uk",
|
||||
"avatar" => "https://rohitpai.co.uk/imgs/profile.jpg"
|
||||
);
|
||||
$items = array();
|
||||
foreach ($posts as $post)
|
||||
{
|
||||
$items[] = array(
|
||||
"id" => string($post["ID"]),
|
||||
"url" => "https://rohitpai.co.uk/blog/post/" . rawurlencode($post["title"]) . "#disqus_thread",
|
||||
"title" => $post["title"],
|
||||
"date_published" => date($post["dateCreated"]),
|
||||
"date_modified" => date($post["dateModified"]),
|
||||
// "description" => $post["abstract"],
|
||||
"banner_image" => "https://rohitpai.co.uk/" . rawurlencode($post["headerImg"]),
|
||||
"content_html" => $post["body"]
|
||||
);
|
||||
}
|
||||
$json["items"] = $items;
|
||||
return $json;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate the RSS feed based on type
|
||||
* @param string $type - Type of feed
|
||||
* @return string|array - RSS feed or an error message
|
||||
*/
|
||||
public function getFeed(string $type): string|array
|
||||
{
|
||||
$feed = "";
|
||||
if ($type == "atom")
|
||||
{
|
||||
$feed = $this->generateXMLFeed(ATOM);
|
||||
}
|
||||
|
||||
if ($type == "rss")
|
||||
{
|
||||
$feed = $this->generateXMLFeed(RSS2);
|
||||
}
|
||||
|
||||
if ($type == "json")
|
||||
{
|
||||
$feed = $this->generateJSONFeed();
|
||||
}
|
||||
|
||||
return $feed;
|
||||
}
|
||||
}
|
302
dist/api/blog/blogRoutes.php
vendored
302
dist/api/blog/blogRoutes.php
vendored
@ -4,6 +4,7 @@ namespace api\blog;
|
||||
require_once __DIR__ . "/../utils/routesInterface.php";
|
||||
require_once "blogData.php";
|
||||
|
||||
|
||||
use api\utils\routesInterface;
|
||||
use Psr\Http\Message\ResponseInterface as Response;
|
||||
use Psr\Http\Message\ServerRequestInterface as Request;
|
||||
@ -80,35 +81,15 @@ class blogRoutes implements routesInterface
|
||||
|
||||
$app->get("/blog/post/{type}", function (Request $request, Response $response, $args)
|
||||
{
|
||||
if ($args["type"] != null)
|
||||
if ($args["type"] == null)
|
||||
{
|
||||
if ($args["type"] == "latest")
|
||||
{
|
||||
$post = $this->blogData->getLatestBlogPost();
|
||||
if (array_key_exists("errorMessage", $post))
|
||||
{
|
||||
$response->getBody()->write(json_encode($post));
|
||||
return $response->withStatus(404);
|
||||
}
|
||||
$response->getBody()->write(json_encode(array("error" => "Please provide a title")));
|
||||
return $response->withStatus(400);
|
||||
}
|
||||
|
||||
$response->getBody()->write(json_encode($post));
|
||||
return $response;
|
||||
}
|
||||
|
||||
if ($args["type"] == "featured")
|
||||
{
|
||||
$post = $this->blogData->getFeaturedBlogPost();
|
||||
if (array_key_exists("errorMessage", $post))
|
||||
{
|
||||
$response->getBody()->write(json_encode($post));
|
||||
return $response->withStatus(404);
|
||||
}
|
||||
|
||||
$response->getBody()->write(json_encode($post));
|
||||
return $response;
|
||||
}
|
||||
|
||||
$post = $this->blogData->getBlogPost($args["type"]);
|
||||
if ($args["type"] == "latest")
|
||||
{
|
||||
$post = $this->blogData->getLatestBlogPost();
|
||||
if (array_key_exists("errorMessage", $post))
|
||||
{
|
||||
$response->getBody()->write(json_encode($post));
|
||||
@ -119,114 +100,173 @@ class blogRoutes implements routesInterface
|
||||
return $response;
|
||||
}
|
||||
|
||||
$response->getBody()->write(json_encode(array("error" => "Please provide a title")));
|
||||
if ($args["type"] == "featured")
|
||||
{
|
||||
$post = $this->blogData->getFeaturedBlogPost();
|
||||
if (array_key_exists("errorMessage", $post))
|
||||
{
|
||||
$response->getBody()->write(json_encode($post));
|
||||
return $response->withStatus(404);
|
||||
}
|
||||
|
||||
$response->getBody()->write(json_encode($post));
|
||||
return $response;
|
||||
}
|
||||
|
||||
$post = $this->blogData->getBlogPost($args["type"]);
|
||||
if (array_key_exists("errorMessage", $post))
|
||||
{
|
||||
$response->getBody()->write(json_encode($post));
|
||||
return $response->withStatus(404);
|
||||
}
|
||||
|
||||
$response->getBody()->write(json_encode($post));
|
||||
return $response;
|
||||
|
||||
});
|
||||
|
||||
$app->get("/blog/feed/{type}", function (Request $request, Response $response, $args)
|
||||
{
|
||||
if ($args["type"] == null)
|
||||
{
|
||||
$response->getBody()->write(json_encode(array("error" => "Please provide a title")));
|
||||
return $response->withStatus(400);
|
||||
}
|
||||
|
||||
$feed = $this->blogData->getFeed($args["type"]);
|
||||
if (is_array($feed))
|
||||
{
|
||||
$response->getBody()->write(json_encode($feed));
|
||||
return $response->withStatus(404);
|
||||
}
|
||||
|
||||
if ($args["type"] == "atom")
|
||||
{
|
||||
$response->getBody()->write($feed);
|
||||
return $response->withHeader("Content-Type", "application/atom+xml");
|
||||
}
|
||||
|
||||
if ($args["type"] == "rss")
|
||||
{
|
||||
$response->getBody()->write($feed);
|
||||
return $response->withHeader("Content-Type", "application/rss+xml");
|
||||
}
|
||||
|
||||
if ($args["type"] == "json")
|
||||
{
|
||||
$response->getBody()->write(json_encode($feed));
|
||||
return $response->withHeader("Content-Type", "application/feed+json");
|
||||
}
|
||||
|
||||
$response->getBody()->write(json_encode(array("error" => "Invalid feed type")));
|
||||
return $response->withStatus(400);
|
||||
});
|
||||
|
||||
$app->get("/blog/search/{searchTerm}", function (Request $request, $response, $args)
|
||||
{
|
||||
if ($args["searchTerm"] != null)
|
||||
if ($args["searchTerm"] == null)
|
||||
{
|
||||
$posts = $this->blogData->searchBlog($args["searchTerm"]);
|
||||
|
||||
$json = json_encode($posts);
|
||||
|
||||
$response->getBody()->write($json);
|
||||
|
||||
if (array_key_exists("errorMessage", $posts))
|
||||
{
|
||||
$response->withStatus(404);
|
||||
}
|
||||
|
||||
return $response;
|
||||
$response->getBody()->write(json_encode(array("error" => "Please provide a search term")));
|
||||
return $response->withStatus(400);
|
||||
}
|
||||
|
||||
$response->getBody()->write(json_encode(array("error" => "Please provide a search term")));
|
||||
return $response->withStatus(400);
|
||||
$posts = $this->blogData->searchBlog($args["searchTerm"]);
|
||||
|
||||
$json = json_encode($posts);
|
||||
|
||||
$response->getBody()->write($json);
|
||||
|
||||
if (array_key_exists("errorMessage", $posts))
|
||||
{
|
||||
$response->withStatus(404);
|
||||
}
|
||||
|
||||
return $response;
|
||||
|
||||
});
|
||||
|
||||
$app->patch("/blog/post/{id}", function (Request $request, Response $response, $args)
|
||||
{
|
||||
$data = $request->getParsedBody();
|
||||
if ($args["id"] != null)
|
||||
if ($args["id"] == null)
|
||||
{
|
||||
if (empty($data["title"]) || strlen($data["featured"]) == 0 || empty($data["body"]) || empty($data["bodyText"]) || empty($data["dateModified"]) || empty($data["categories"]))
|
||||
{
|
||||
// uh oh sent some empty data
|
||||
$response->getBody()->write(json_encode(array("error" => "Only some of the data was sent")));
|
||||
return $response->withStatus(400);
|
||||
}
|
||||
|
||||
if (!preg_match('/[a-zA-Z0-9 ]+, |\w+/mx', $data["categories"]))
|
||||
{
|
||||
// uh oh sent some empty data
|
||||
$response->getBody()->write(json_encode(array("error" => "Categories must be in a CSV format")));
|
||||
return $response->withStatus(400);
|
||||
}
|
||||
|
||||
$message = $this->blogData->updatePost($args["id"], $data["title"], intval($data["featured"]), $data["abstract"], $data["body"], $data["bodyText"], $data["dateModified"], $data["categories"]);
|
||||
|
||||
if ($message === "post not found")
|
||||
{
|
||||
// uh oh something went wrong
|
||||
$response->getBody()->write(json_encode(array("error" => "Error, post not found")));
|
||||
return $response->withStatus(404);
|
||||
}
|
||||
|
||||
if ($message === "unset featured")
|
||||
{
|
||||
// uh oh something went wrong
|
||||
$response->getBody()->write(json_encode(array("error" => "Error, cannot unset featured post, try updating another post to be featured first")));
|
||||
return $response->withStatus(409);
|
||||
}
|
||||
|
||||
if (!is_bool($message) || $message === false)
|
||||
{
|
||||
// uh oh something went wrong
|
||||
$response->getBody()->write(json_encode(array("error" => $message)));
|
||||
return $response->withStatus(500);
|
||||
}
|
||||
|
||||
$response->withStatus(201);
|
||||
return $response;
|
||||
|
||||
$response->getBody()->write(json_encode(array("error" => "Please provide an ID")));
|
||||
return $response->withStatus(400);
|
||||
}
|
||||
|
||||
$response->getBody()->write(json_encode(array("error" => "Please provide an ID")));
|
||||
return $response->withStatus(400);
|
||||
if (empty($data["title"]) || strlen($data["featured"]) == 0 || empty($data["body"]) || empty($data["bodyText"]) || empty($data["dateModified"]) || empty($data["categories"]))
|
||||
{
|
||||
// uh oh sent some empty data
|
||||
$response->getBody()->write(json_encode(array("error" => "Only some of the data was sent")));
|
||||
return $response->withStatus(400);
|
||||
}
|
||||
|
||||
if (!preg_match('/[a-zA-Z0-9 ]+, |\w+/mx', $data["categories"]))
|
||||
{
|
||||
// uh oh sent some empty data
|
||||
$response->getBody()->write(json_encode(array("error" => "Categories must be in a CSV format")));
|
||||
return $response->withStatus(400);
|
||||
}
|
||||
|
||||
$message = $this->blogData->updatePost($args["id"], $data["title"], intval($data["featured"]), $data["abstract"], $data["body"], $data["bodyText"], $data["dateModified"], $data["categories"]);
|
||||
|
||||
if ($message === "post not found")
|
||||
{
|
||||
// uh oh something went wrong
|
||||
$response->getBody()->write(json_encode(array("error" => "Error, post not found")));
|
||||
return $response->withStatus(404);
|
||||
}
|
||||
|
||||
if ($message === "unset featured")
|
||||
{
|
||||
// uh oh something went wrong
|
||||
$response->getBody()->write(json_encode(array("error" => "Error, cannot unset featured post, try updating another post to be featured first")));
|
||||
return $response->withStatus(409);
|
||||
}
|
||||
|
||||
if (!is_bool($message) || $message === false)
|
||||
{
|
||||
// uh oh something went wrong
|
||||
$response->getBody()->write(json_encode(array("error" => $message)));
|
||||
return $response->withStatus(500);
|
||||
}
|
||||
|
||||
$response->withStatus(201);
|
||||
return $response;
|
||||
|
||||
});
|
||||
|
||||
$app->delete("/blog/post/{id}", function (Request $request, Response $response, $args)
|
||||
{
|
||||
if ($args["id"] != null)
|
||||
if ($args["id"] == null)
|
||||
{
|
||||
$message = $this->blogData->deletePost($args["id"]);
|
||||
|
||||
if ($message === "post not found")
|
||||
{
|
||||
// uh oh something went wrong
|
||||
$response->getBody()->write(json_encode(array("error" => "Error, post not found")));
|
||||
return $response->withStatus(404);
|
||||
}
|
||||
|
||||
if ($message === "error")
|
||||
{
|
||||
// uh oh something went wrong
|
||||
$response->getBody()->write(json_encode(array("error" => "Error, something went wrong")));
|
||||
return $response->withStatus(500);
|
||||
}
|
||||
|
||||
if ($message === "cannot delete")
|
||||
{
|
||||
// uh oh something went wrong
|
||||
$response->getBody()->write(json_encode(array("error" => "Error, cannot delete featured post")));
|
||||
return $response->withStatus(409);
|
||||
}
|
||||
return $response;
|
||||
$response->getBody()->write(json_encode(array("error" => "Please provide an ID")));
|
||||
return $response->withStatus(400);
|
||||
}
|
||||
|
||||
$response->getBody()->write(json_encode(array("error" => "Please provide an ID")));
|
||||
return $response->withStatus(400);
|
||||
$message = $this->blogData->deletePost($args["id"]);
|
||||
|
||||
if ($message === "post not found")
|
||||
{
|
||||
// uh oh something went wrong
|
||||
$response->getBody()->write(json_encode(array("error" => "Error, post not found")));
|
||||
return $response->withStatus(404);
|
||||
}
|
||||
|
||||
if ($message === "error")
|
||||
{
|
||||
// uh oh something went wrong
|
||||
$response->getBody()->write(json_encode(array("error" => "Error, something went wrong")));
|
||||
return $response->withStatus(500);
|
||||
}
|
||||
|
||||
if ($message === "cannot delete")
|
||||
{
|
||||
// uh oh something went wrong
|
||||
$response->getBody()->write(json_encode(array("error" => "Error, cannot delete featured post")));
|
||||
return $response->withStatus(409);
|
||||
}
|
||||
return $response;
|
||||
});
|
||||
|
||||
$app->post("/blog/post", function (Request $request, Response $response)
|
||||
@ -290,28 +330,28 @@ class blogRoutes implements routesInterface
|
||||
{
|
||||
$files = $request->getUploadedFiles();
|
||||
|
||||
if ($args["id"] != null)
|
||||
if ($args["id"] == null)
|
||||
{
|
||||
if (empty($files))
|
||||
{
|
||||
// uh oh sent some empty data
|
||||
$response->getBody()->write(json_encode(array("error" => array("message" => "Error, empty data sent"))));
|
||||
return $response->withStatus(400);
|
||||
}
|
||||
|
||||
$message = $this->blogData->uploadHeaderImage($args["id"], $files["headerImg"]);
|
||||
if (!is_array($message))
|
||||
{
|
||||
$response->getBody()->write(json_encode(array("error" => array("message" => $message))));
|
||||
return $response->withStatus(500);
|
||||
}
|
||||
|
||||
$response->getBody()->write(json_encode($message));
|
||||
return $response->withStatus(201);
|
||||
$response->getBody()->write(json_encode(array("error" => "Please provide an ID")));
|
||||
return $response->withStatus(400);
|
||||
}
|
||||
|
||||
$response->getBody()->write(json_encode(array("error" => "Please provide an ID")));
|
||||
return $response->withStatus(400);
|
||||
if (empty($files))
|
||||
{
|
||||
// uh oh sent some empty data
|
||||
$response->getBody()->write(json_encode(array("error" => array("message" => "Error, empty data sent"))));
|
||||
return $response->withStatus(400);
|
||||
}
|
||||
|
||||
$message = $this->blogData->uploadHeaderImage($args["id"], $files["headerImg"]);
|
||||
if (!is_array($message))
|
||||
{
|
||||
$response->getBody()->write(json_encode(array("error" => array("message" => $message))));
|
||||
return $response->withStatus(500);
|
||||
}
|
||||
|
||||
$response->getBody()->write(json_encode($message));
|
||||
return $response->withStatus(201);
|
||||
});
|
||||
}
|
||||
}
|
2
dist/api/project/projectData.php
vendored
2
dist/api/project/projectData.php
vendored
@ -17,7 +17,7 @@ class projectData
|
||||
{
|
||||
/**
|
||||
* Get all project data
|
||||
* @return array - Array of all project data or error message
|
||||
* @return array<array> - Array of all project data or error message
|
||||
*/
|
||||
public function getProjectData(): array
|
||||
{
|
||||
|
124
dist/api/project/projectRoutes.php
vendored
124
dist/api/project/projectRoutes.php
vendored
@ -50,78 +50,78 @@ class projectRoutes implements routesInterface
|
||||
$app->patch("/projectData/{id}", function (Request $request, Response $response, array $args)
|
||||
{
|
||||
$data = $request->getParsedBody();
|
||||
if ($args["id"] != null)
|
||||
if ($args["id"] == null)
|
||||
{
|
||||
if (empty($data["title"]) || empty($data["isMainProject"]) || empty($data["information"]) || empty($data["gitLink"]))
|
||||
{
|
||||
// uh oh sent some empty data
|
||||
$response->getBody()->write(json_encode(array("error" => "Only some of the data was sent")));
|
||||
return $response->withStatus(400);
|
||||
}
|
||||
|
||||
$isMainProject = $data["isMainProject"] === "true";
|
||||
$update = $this->projectData->updateProjectData($args["id"], $data["title"], $isMainProject, $data["information"], $data["projectLink"], $data["gitLink"]);
|
||||
|
||||
if ($update === "project not found")
|
||||
{
|
||||
// uh oh something went wrong
|
||||
$response->getBody()->write(json_encode(array("error" => "Project with ID " . $args["id"] . " not found")));
|
||||
return $response->withStatus(404);
|
||||
}
|
||||
|
||||
if ($update === "unset main project")
|
||||
{
|
||||
// uh oh something went wrong
|
||||
$response->getBody()->write(json_encode(array("error" => "Can't unset project as main project, try updating another project as the main project")));
|
||||
return $response->withStatus(400);
|
||||
}
|
||||
|
||||
if (!$update)
|
||||
{
|
||||
// uh oh something went wrong
|
||||
$response->getBody()->write(json_encode(array("error" => "Something went wrong")));
|
||||
return $response->withStatus(500);
|
||||
}
|
||||
|
||||
return $response;
|
||||
$response->getBody()->write(json_encode(array("error" => "Please provide an ID")));
|
||||
return $response->withStatus(400);
|
||||
}
|
||||
|
||||
$response->getBody()->write(json_encode(array("error" => "Please provide an ID")));
|
||||
return $response->withStatus(400);
|
||||
if (empty($data["title"]) || empty($data["isMainProject"]) || empty($data["information"]) || empty($data["gitLink"]))
|
||||
{
|
||||
// uh oh sent some empty data
|
||||
$response->getBody()->write(json_encode(array("error" => "Only some of the data was sent")));
|
||||
return $response->withStatus(400);
|
||||
}
|
||||
|
||||
$isMainProject = $data["isMainProject"] === "true";
|
||||
$update = $this->projectData->updateProjectData($args["id"], $data["title"], $isMainProject, $data["information"], $data["projectLink"], $data["gitLink"]);
|
||||
|
||||
if ($update === "project not found")
|
||||
{
|
||||
// uh oh something went wrong
|
||||
$response->getBody()->write(json_encode(array("error" => "Project with ID " . $args["id"] . " not found")));
|
||||
return $response->withStatus(404);
|
||||
}
|
||||
|
||||
if ($update === "unset main project")
|
||||
{
|
||||
// uh oh something went wrong
|
||||
$response->getBody()->write(json_encode(array("error" => "Can't unset project as main project, try updating another project as the main project")));
|
||||
return $response->withStatus(400);
|
||||
}
|
||||
|
||||
if (!$update)
|
||||
{
|
||||
// uh oh something went wrong
|
||||
$response->getBody()->write(json_encode(array("error" => "Something went wrong")));
|
||||
return $response->withStatus(500);
|
||||
}
|
||||
|
||||
return $response;
|
||||
});
|
||||
|
||||
$app->delete("/projectData/{id}", function (Request $request, Response $response, array $args)
|
||||
{
|
||||
if ($args["id"] != null)
|
||||
if ($args["id"] == null)
|
||||
{
|
||||
$message = $this->projectData->deleteProjectData($args["id"]);
|
||||
|
||||
if ($message === "project not found")
|
||||
{
|
||||
// uh oh something went wrong
|
||||
$response->getBody()->write(json_encode(array("error" => "Project with ID " . $args["id"] . " not found")));
|
||||
return $response->withStatus(404);
|
||||
}
|
||||
|
||||
if ($message === "cannot delete")
|
||||
{
|
||||
//uh oh cannot delete the main project
|
||||
$response->getBody()->write(json_encode(array("error" => "Cannot delete the main project")));
|
||||
return $response->withStatus(409);
|
||||
}
|
||||
|
||||
if ($message === "error")
|
||||
{
|
||||
// uh oh something went wrong
|
||||
$response->getBody()->write(json_encode(array("error" => "Something went wrong")));
|
||||
return $response->withStatus(500);
|
||||
}
|
||||
|
||||
return $response;
|
||||
$response->getBody()->write(json_encode(array("error" => "Please provide an ID")));
|
||||
return $response->withStatus(400);
|
||||
}
|
||||
|
||||
$response->getBody()->write(json_encode(array("error" => "Please provide an ID")));
|
||||
return $response->withStatus(400);
|
||||
$message = $this->projectData->deleteProjectData($args["id"]);
|
||||
|
||||
if ($message === "project not found")
|
||||
{
|
||||
// uh oh something went wrong
|
||||
$response->getBody()->write(json_encode(array("error" => "Project with ID " . $args["id"] . " not found")));
|
||||
return $response->withStatus(404);
|
||||
}
|
||||
|
||||
if ($message === "cannot delete")
|
||||
{
|
||||
//uh oh cannot delete the main project
|
||||
$response->getBody()->write(json_encode(array("error" => "Cannot delete the main project")));
|
||||
return $response->withStatus(409);
|
||||
}
|
||||
|
||||
if ($message === "error")
|
||||
{
|
||||
// uh oh something went wrong
|
||||
$response->getBody()->write(json_encode(array("error" => "Something went wrong")));
|
||||
return $response->withStatus(500);
|
||||
}
|
||||
|
||||
return $response;
|
||||
});
|
||||
|
||||
$app->post("/projectData", function (Request $request, Response $response)
|
||||
|
2
dist/api/timeline/timelineData.php
vendored
2
dist/api/timeline/timelineData.php
vendored
@ -14,7 +14,7 @@ class timelineData
|
||||
{
|
||||
/**
|
||||
* Get all education data
|
||||
* @return array - Array of all education data or error message
|
||||
* @return array<array> - Array of all education data or error message
|
||||
*/
|
||||
public function getEduData(): array
|
||||
{
|
||||
|
152
dist/api/utils/feedGenerator/FeedItem.php
vendored
Normal file
152
dist/api/utils/feedGenerator/FeedItem.php
vendored
Normal file
@ -0,0 +1,152 @@
|
||||
<?php
|
||||
|
||||
namespace api\utils\feedGenerator;
|
||||
|
||||
/**
|
||||
* Universal Feed Writer
|
||||
*
|
||||
* FeedItem class - Used as a feed element in FeedWriter class
|
||||
*
|
||||
* @package UniversalFeedWriter
|
||||
* @author Anis uddin Ahmad <anisniit@gmail.com>
|
||||
* @link http://www.ajaxray.com/projects/rss
|
||||
*/
|
||||
class FeedItem
|
||||
{
|
||||
private array $elements = []; // Collection of feed elements
|
||||
private string $version;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param string $version (RSS1/RSS2/ATOM) RSS2 is the default.
|
||||
*/
|
||||
public function __construct(string $version = RSS2)
|
||||
{
|
||||
$this->version = $version;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add an element to elements array
|
||||
*
|
||||
* @param string $elementName The tag name of an element
|
||||
* @param string $content The content of the tag
|
||||
* @param array|null $attributes Attributes (if any) in 'attrName' => 'attrValue' format
|
||||
*/
|
||||
public function addElement(string $elementName, string $content, ?array $attributes = null): void
|
||||
{
|
||||
$this->elements[$elementName]['name'] = $elementName;
|
||||
$this->elements[$elementName]['content'] = $content;
|
||||
$this->elements[$elementName]['attributes'] = $attributes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set multiple feed elements from an array.
|
||||
* Elements that have attributes cannot be added by this method
|
||||
*
|
||||
* @param array $elementArray Array of elements in 'tagName' => 'tagContent' format.
|
||||
*/
|
||||
public function addElementArray(array $elementArray): void
|
||||
{
|
||||
foreach ($elementArray as $elementName => $content)
|
||||
{
|
||||
$this->addElement($elementName, $content);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the collection of elements in this feed item
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getElements(): array
|
||||
{
|
||||
return $this->elements;
|
||||
}
|
||||
|
||||
// Wrapper functions ------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Set the 'description' element of the feed item
|
||||
*
|
||||
* @param string $description The content of the 'description' element
|
||||
*/
|
||||
public function setDescription(string $description): void
|
||||
{
|
||||
$tag = ($this->version === ATOM) ? 'summary' : 'description';
|
||||
$this->addElement($tag, $description);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the 'title' element of the feed item
|
||||
*
|
||||
* @param string $title The content of the 'title' element
|
||||
*/
|
||||
public function setTitle(string $title): void
|
||||
{
|
||||
$this->addElement('title', $title);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the 'date' element of the feed item
|
||||
*
|
||||
* @param string|int $date The content of the 'date' element
|
||||
*/
|
||||
public function setDate(string|int $date): void
|
||||
{
|
||||
if (!is_numeric($date))
|
||||
{
|
||||
$date = strtotime($date);
|
||||
}
|
||||
|
||||
if ($this->version === ATOM)
|
||||
{
|
||||
$tag = 'updated';
|
||||
$value = date(DATE_ATOM, $date);
|
||||
}
|
||||
elseif ($this->version === RSS2)
|
||||
{
|
||||
$tag = 'pubDate';
|
||||
$value = date(DATE_RSS, $date);
|
||||
}
|
||||
else
|
||||
{
|
||||
$tag = 'dc:date';
|
||||
$value = date("Y-m-d", $date);
|
||||
}
|
||||
|
||||
$this->addElement($tag, $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the 'link' element of the feed item
|
||||
*
|
||||
* @param string $link The content of the 'link' element
|
||||
*/
|
||||
public function setLink(string $link): void
|
||||
{
|
||||
if ($this->version === RSS2 || $this->version === RSS1)
|
||||
{
|
||||
$this->addElement('link', $link);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->addElement('link', '', ['href' => $link]);
|
||||
$this->addElement('id', FeedWriter::uuid($link, 'urn:uuid:'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the 'encloser' element of the feed item
|
||||
* For RSS 2.0 only
|
||||
*
|
||||
* @param string $url The url attribute of the encloser tag
|
||||
* @param string $length The length attribute of the encloser tag
|
||||
* @param string $type The type attribute of the encloser tag
|
||||
*/
|
||||
public function setEncloser(string $url, string $length, string $type): void
|
||||
{
|
||||
$attributes = ['url' => $url, 'length' => $length, 'type' => $type];
|
||||
$this->addElement('enclosure', '', $attributes);
|
||||
}
|
||||
}
|
386
dist/api/utils/feedGenerator/FeedWriter.php
vendored
Normal file
386
dist/api/utils/feedGenerator/FeedWriter.php
vendored
Normal file
@ -0,0 +1,386 @@
|
||||
<?php
|
||||
|
||||
namespace api\utils\feedGenerator;
|
||||
|
||||
require_once "FeedItem.php";
|
||||
|
||||
/**
|
||||
* Universal Feed Writer class
|
||||
*
|
||||
* Generate RSS 1.0, RSS 2.0, and Atom Feed
|
||||
*
|
||||
* @package UniversalFeedWriter
|
||||
* @link http://www.ajaxray.com/projects/rss
|
||||
*/
|
||||
class FeedWriter
|
||||
{
|
||||
private array $channels = []; // Collection of channel elements
|
||||
private array $items = []; // Collection of items as objects of FeedItem class
|
||||
private array $data = []; // Store some other version-wise data
|
||||
private array $CDATAEncoding = []; // The tag names that need to be encoded as CDATA
|
||||
|
||||
private string $version;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param string $version The version (RSS1, RSS2, ATOM).
|
||||
*/
|
||||
public function __construct(string $version = RSS2)
|
||||
{
|
||||
$this->version = $version;
|
||||
|
||||
// Setting default values for essential channel elements
|
||||
$this->channels['title'] = $version . ' Feed';
|
||||
$this->channels['link'] = 'http://www.ajaxray.com/blog';
|
||||
$this->channels["feedUrl"] = "http://example.com/feed";
|
||||
|
||||
// Tag names to encode in CDATA
|
||||
$this->CDATAEncoding = ['description', 'content:encoded', 'summary'];
|
||||
}
|
||||
|
||||
// Public functions
|
||||
|
||||
/**
|
||||
* Set a channel element
|
||||
*
|
||||
* @param string $elementName Name of the channel tag
|
||||
* @param string $content Content of the channel tag
|
||||
*/
|
||||
public function setChannelElement(string $elementName, string|array $content): void
|
||||
{
|
||||
$this->channels[$elementName] = $content;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate the actual RSS/Atom file
|
||||
*/
|
||||
public function generateFeed(): void
|
||||
{
|
||||
$this->printHead();
|
||||
$this->printChannels();
|
||||
$this->printItems();
|
||||
$this->printTail();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new FeedItem.
|
||||
*
|
||||
* @return FeedItem An instance of FeedItem class
|
||||
*/
|
||||
public function createNewItem(): FeedItem
|
||||
{
|
||||
$item = new FeedItem($this->version);
|
||||
return $item;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a FeedItem to the main class
|
||||
*
|
||||
* @param FeedItem $feedItem An instance of FeedItem class
|
||||
*/
|
||||
public function addItem(FeedItem $feedItem): void
|
||||
{
|
||||
$this->items[] = $feedItem;
|
||||
}
|
||||
|
||||
// Wrapper functions
|
||||
|
||||
/**
|
||||
* Set the 'title' channel element
|
||||
*
|
||||
* @param string $title Value of 'title' channel tag
|
||||
*/
|
||||
public function setTitle(string $title): void
|
||||
{
|
||||
$this->setChannelElement('title', $title);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the 'description' channel element
|
||||
*
|
||||
* @param string $description Value of 'description' channel tag
|
||||
*/
|
||||
public function setDescription(string $description): void
|
||||
{
|
||||
$this->setChannelElement('description', $description);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the 'link' channel element
|
||||
*
|
||||
* @param string $link Value of 'link' channel tag
|
||||
*/
|
||||
public function setLink(string $link): void
|
||||
{
|
||||
$this->setChannelElement('link', $link);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the 'image' channel element
|
||||
*
|
||||
* @param string $title Title of the image
|
||||
* @param string $link Link URL of the image
|
||||
* @param string $url Path URL of the image
|
||||
*/
|
||||
public function setImage(string $title, string $link, string $url): void
|
||||
{
|
||||
$this->setChannelElement('image', ['title' => $title, 'link' => $link, 'url' => $url]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the 'about' channel element. Only for RSS 1.0
|
||||
*
|
||||
* @param string $url Value of 'about' channel tag
|
||||
*/
|
||||
public function setChannelAbout(string $url): void
|
||||
{
|
||||
$this->data['ChannelAbout'] = $url;
|
||||
}
|
||||
|
||||
// Other functions
|
||||
|
||||
/**
|
||||
* Generates a UUID
|
||||
*
|
||||
* @param string $key An optional prefix
|
||||
* @param string $prefix A prefix
|
||||
* @return string The formatted UUID
|
||||
*/
|
||||
public static function uuid(?string $key = null, string $prefix = ''): string
|
||||
{
|
||||
$key = $key ?? uniqid((string)rand());
|
||||
$chars = md5($key);
|
||||
$uuid = substr($chars, 0, 8) . '-';
|
||||
$uuid .= substr($chars, 8, 4) . '-';
|
||||
$uuid .= substr($chars, 12, 4) . '-';
|
||||
$uuid .= substr($chars, 16, 4) . '-';
|
||||
$uuid .= substr($chars, 20, 12);
|
||||
|
||||
return $prefix . $uuid;
|
||||
}
|
||||
|
||||
// Private functions
|
||||
|
||||
/**
|
||||
* Prints the XML and RSS namespace
|
||||
*/
|
||||
private function printHead(): void
|
||||
{
|
||||
$out = '<?xml version="1.0" encoding="utf-8"?>' . "\n";
|
||||
|
||||
if ($this->version == RSS2)
|
||||
{
|
||||
$out .= '<rss version="2.0"
|
||||
xmlns:content="http://purl.org/rss/1.0/modules/content/"
|
||||
xmlns:wfw="http://wellformedweb.org/CommentAPI/"
|
||||
>' . PHP_EOL;
|
||||
}
|
||||
elseif ($this->version == RSS1)
|
||||
{
|
||||
$out .= '<rdf:RDF
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns="http://purl.org/rss/1.0/"
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
>' . PHP_EOL;
|
||||
}
|
||||
elseif ($this->version == ATOM)
|
||||
{
|
||||
$out .= '<feed xmlns="http://www.w3.org/2005/Atom">' . PHP_EOL;
|
||||
}
|
||||
echo $out;
|
||||
}
|
||||
|
||||
/**
|
||||
* Closes the open tags at the end of the file
|
||||
*/
|
||||
private function printTail(): void
|
||||
{
|
||||
if ($this->version == RSS2)
|
||||
{
|
||||
echo '</channel>' . PHP_EOL . '</rss>';
|
||||
}
|
||||
elseif ($this->version == RSS1)
|
||||
{
|
||||
echo '</rdf:RDF>';
|
||||
}
|
||||
elseif ($this->version == ATOM)
|
||||
{
|
||||
echo '</feed>';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a single node in XML format
|
||||
*
|
||||
* @param string $tagName Name of the tag
|
||||
* @param mixed $tagContent Tag value as a string or an array of nested tags in 'tagName' => 'tagValue' format
|
||||
* @param array|null $attributes Attributes (if any) in 'attrName' => 'attrValue' format
|
||||
* @return string Formatted XML tag
|
||||
*/
|
||||
private function makeNode(string $tagName, $tagContent, ?array $attributes = null): string
|
||||
{
|
||||
$nodeText = '';
|
||||
$attrText = '';
|
||||
|
||||
if (is_array($attributes))
|
||||
{
|
||||
foreach ($attributes as $key => $value)
|
||||
{
|
||||
$attrText .= " $key=\"$value\"";
|
||||
}
|
||||
}
|
||||
|
||||
if (is_array($tagContent) && $this->version == RSS1)
|
||||
{
|
||||
$attrText = ' rdf:parseType="Resource"';
|
||||
}
|
||||
|
||||
$attrText .= (in_array($tagName, $this->CDATAEncoding) && $this->version == ATOM) ? ' type="html" ' : '';
|
||||
$nodeText .= (in_array($tagName, $this->CDATAEncoding)) ? "<{$tagName}{$attrText}><![CDATA[" : "<{$tagName}{$attrText}>";
|
||||
|
||||
if (is_array($tagContent))
|
||||
{
|
||||
foreach ($tagContent as $key => $value)
|
||||
{
|
||||
$nodeText .= $this->makeNode($key, $value);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$nodeText .= (in_array($tagName, $this->CDATAEncoding)) ? $tagContent : htmlentities($tagContent);
|
||||
}
|
||||
|
||||
$nodeText .= (in_array($tagName, $this->CDATAEncoding)) ? "]]></$tagName>" : "</$tagName>";
|
||||
|
||||
return $nodeText . PHP_EOL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prints channel elements
|
||||
*/
|
||||
private function printChannels(): void
|
||||
{
|
||||
// Start channel tag
|
||||
switch ($this->version)
|
||||
{
|
||||
case RSS2:
|
||||
echo '<channel>' . PHP_EOL;
|
||||
break;
|
||||
case RSS1:
|
||||
echo (isset($this->data['ChannelAbout'])) ? "<channel rdf:about=\"{$this->data['ChannelAbout']}\">" : "<channel rdf:about=\"{$this->channels['link']}\">";
|
||||
break;
|
||||
}
|
||||
|
||||
// Print items of channel
|
||||
foreach ($this->channels as $key => $value)
|
||||
{
|
||||
if ($this->version == ATOM && $key == 'link')
|
||||
{
|
||||
// ATOM prints the link element as an href attribute
|
||||
echo $this->makeNode($key, '', ['href' => $value]);
|
||||
// Add the id for ATOM
|
||||
echo $this->makeNode('id', $this->uuid($value, 'urn:uuid:'));
|
||||
}
|
||||
else if ($this->version == ATOM && $key == 'feedUrl')
|
||||
{
|
||||
echo $this->makeNode('link', '', ['rel' => 'self', 'href' => $value]);
|
||||
}
|
||||
else
|
||||
{
|
||||
echo $this->makeNode($key, $value);
|
||||
}
|
||||
}
|
||||
|
||||
// RSS 1.0 has a special tag <rdf:Seq> with channel
|
||||
if ($this->version == RSS1)
|
||||
{
|
||||
echo "<items>" . PHP_EOL . "<rdf:Seq>" . PHP_EOL;
|
||||
foreach ($this->items as $item)
|
||||
{
|
||||
$thisItems = $item->getElements();
|
||||
echo "<rdf:li resource=\"{$thisItems['link']['content']}\"/>" . PHP_EOL;
|
||||
}
|
||||
echo "</rdf:Seq>" . PHP_EOL . "</items>" . PHP_EOL . "</channel>" . PHP_EOL;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Prints formatted feed items
|
||||
*/
|
||||
private function printItems(): void
|
||||
{
|
||||
foreach ($this->items as $item)
|
||||
{
|
||||
$thisItems = $item->getElements();
|
||||
|
||||
// The argument is printed as rdf:about attribute of item in RSS 1.0
|
||||
echo $this->startItem($thisItems['link']['content']);
|
||||
|
||||
foreach ($thisItems as $feedItem)
|
||||
{
|
||||
echo $this->makeNode($feedItem['name'], $feedItem['content'], $feedItem['attributes']);
|
||||
}
|
||||
echo $this->endItem();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes the starting tag of items
|
||||
*
|
||||
* @param string|false $about The value of about tag, which is used only for RSS 1.0
|
||||
*/
|
||||
private function startItem($about = false): void
|
||||
{
|
||||
if ($this->version == RSS2)
|
||||
{
|
||||
echo '<item>' . PHP_EOL;
|
||||
}
|
||||
elseif ($this->version == RSS1)
|
||||
{
|
||||
if ($about)
|
||||
{
|
||||
echo "<item rdf:about=\"$about\">" . PHP_EOL;
|
||||
}
|
||||
else
|
||||
{
|
||||
die("link element is not set.\n It's required for RSS 1.0 to be used as the about attribute of the item");
|
||||
}
|
||||
}
|
||||
elseif ($this->version == ATOM)
|
||||
{
|
||||
echo "<entry>" . PHP_EOL;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Closes the feed item tag
|
||||
*/
|
||||
private function endItem(): void
|
||||
{
|
||||
if ($this->version == RSS2 || $this->version == RSS1)
|
||||
{
|
||||
echo '</item>' . PHP_EOL;
|
||||
}
|
||||
elseif ($this->version == ATOM)
|
||||
{
|
||||
echo "</entry>" . PHP_EOL;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the Feed URL
|
||||
* @param string $string - The URL of the feed
|
||||
* @return void
|
||||
*/
|
||||
public function setFeedURL(string $string): void
|
||||
{
|
||||
$this->setChannelElement("feedUrl", $string);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Define constants for RSS 1.0, RSS 2.0, and Atom
|
||||
const RSS1 = 'RSS 1.0';
|
||||
const RSS2 = 'RSS 2.0';
|
||||
const ATOM = 'ATOM';
|
7
dist/api/utils/middleware.php
vendored
7
dist/api/utils/middleware.php
vendored
@ -65,7 +65,12 @@ class middleware
|
||||
$app->add(function ($request, $handler)
|
||||
{
|
||||
$response = $handler->handle($request);
|
||||
return $response->withHeader("Content-Type", "application/json");
|
||||
$contentType = $response->getHeaderLine("Content-Type");
|
||||
if (empty($contentType) || $contentType === "text/html")
|
||||
{
|
||||
return $response->withHeader("Content-Type", "application/json");
|
||||
}
|
||||
return $response;
|
||||
});
|
||||
}
|
||||
|
||||
|
2
dist/blog/css/main.css
vendored
2
dist/blog/css/main.css
vendored
File diff suppressed because one or more lines are too long
197
dist/blog/imgs/atomFeed.svg
vendored
Normal file
197
dist/blog/imgs/atomFeed.svg
vendored
Normal file
@ -0,0 +1,197 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||
<svg
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
id="svg2"
|
||||
inkscape:export-ydpi="90"
|
||||
inkscape:export-filename="C:\Users\Ilia\SVG\Atom_icon.png"
|
||||
viewBox="0 0 285.45 280.91"
|
||||
inkscape:export-xdpi="90"
|
||||
version="1.1"
|
||||
inkscape:version="0.91pre3 r13670"
|
||||
sodipodi:docname="_svgclean2.svg"
|
||||
>
|
||||
<sodipodi:namedview
|
||||
id="base"
|
||||
fit-margin-left="10"
|
||||
inkscape:zoom="1.979899"
|
||||
borderopacity="1.0"
|
||||
inkscape:current-layer="layer1"
|
||||
inkscape:cx="30.185218"
|
||||
inkscape:cy="330.70792"
|
||||
inkscape:snap-bbox-midpoints="true"
|
||||
inkscape:object-paths="true"
|
||||
inkscape:window-maximized="0"
|
||||
inkscape:snap-bbox="true"
|
||||
showgrid="false"
|
||||
fit-margin-right="10"
|
||||
inkscape:snap-nodes="false"
|
||||
units="mm"
|
||||
inkscape:document-units="px"
|
||||
inkscape:window-x="0"
|
||||
inkscape:window-y="0"
|
||||
inkscape:snap-smooth-nodes="true"
|
||||
inkscape:window-width="718"
|
||||
fit-margin-bottom="10"
|
||||
inkscape:snap-page="false"
|
||||
inkscape:pageopacity="0.0"
|
||||
inkscape:pageshadow="2"
|
||||
pagecolor="#ffffff"
|
||||
inkscape:window-height="645"
|
||||
fit-margin-top="10"
|
||||
/>
|
||||
<g
|
||||
id="layer1"
|
||||
inkscape:label="Layer 1"
|
||||
inkscape:groupmode="layer"
|
||||
transform="translate(-.31824 -771.33)"
|
||||
>
|
||||
<g
|
||||
id="g8434"
|
||||
transform="matrix(9.7655,0,0,9.7655,-2.8077,-9219.8)"
|
||||
>
|
||||
<ellipse
|
||||
id="path3089"
|
||||
style="fill:#FFFFFF"
|
||||
rx="2.0633"
|
||||
ry="2.0618"
|
||||
cy="1037.7"
|
||||
cx="14.936"
|
||||
/>
|
||||
<path
|
||||
id="circle3412"
|
||||
style="fill:#FFFFFF"
|
||||
inkscape:connector-curvature="0"
|
||||
transform="translate(0,1020.4)"
|
||||
d="m15.045 2.7051v3.3496a11.266 11.258 0 0 1 11.154 11.213h3.3516a14.617 14.606 0 0 0 -14.506 -14.563z"
|
||||
/>
|
||||
<path
|
||||
id="circle3428"
|
||||
style="fill:#FFFFFF"
|
||||
inkscape:connector-curvature="0"
|
||||
transform="translate(0,1020.4)"
|
||||
d="m15.045 9.4453v2.9492a4.9226 4.919 0 0 1 4.8105 4.873h2.9492a7.8711 7.8654 0 0 0 -7.76 -7.8217z"
|
||||
/>
|
||||
</g
|
||||
>
|
||||
<g
|
||||
id="g8430"
|
||||
transform="matrix(9.7655,0,0,9.7655,-2.8077,-9219.8)"
|
||||
>
|
||||
<path
|
||||
id="path3302"
|
||||
style="color:#000000;text-indent:0;block-progression:tb;text-decoration-line:none;text-transform:none;fill:#FFFFFF"
|
||||
inkscape:connector-curvature="0"
|
||||
transform="translate(0,1020.4)"
|
||||
d="m14.865 12.807c-3.944 0.0057-7.5137 0.47474-10.127 1.2383-1.3146 0.3841-2.3876 0.844-3.1562 1.375-0.76861 0.5309-1.2617 1.1648-1.2617 1.8906 0 0.7259 0.49311 1.3617 1.2617 1.8926 0.76861 0.5309 1.8417 0.97918 3.1562 1.3633 2.6292 0.7682 6.2246 1.2402 10.197 1.2402 3.9727 0 7.57-0.47204 10.199-1.2402 1.3146-0.3841 2.3857-0.83238 3.1543-1.3633 0.71878-0.49648 1.1813-1.0881 1.2402-1.7559h-0.64453c-0.05963 0.38822-0.35991 0.79958-0.9668 1.2188-0.67801 0.4684-1.6967 0.90955-2.9688 1.2812-2.5442 0.7433-6.0921 1.209-10.014 1.209-3.9216 0-7.4675-0.46568-10.012-1.209-1.2721-0.3717-2.3005-0.81285-2.9785-1.2812-0.67801-0.4683-0.98438-0.92797-0.98438-1.3555 0-0.4274 0.30637-0.89488 0.98438-1.3633 0.67801-0.4683 1.7064-0.90965 2.9785-1.2812 2.5286-0.73883 6.0485-1.2033 9.9414-1.209v-0.65039z"
|
||||
/>
|
||||
<circle
|
||||
id="path8416"
|
||||
cy="1034.4"
|
||||
cx="6.1108"
|
||||
r=".75893"
|
||||
style="fill:#FFFFFF"
|
||||
/>
|
||||
</g
|
||||
>
|
||||
<g
|
||||
id="g8439"
|
||||
transform="matrix(9.7655,0,0,9.7655,-2.8077,-9219.8)"
|
||||
>
|
||||
<g
|
||||
id="g8426"
|
||||
>
|
||||
<path
|
||||
id="path3304"
|
||||
d="m14.865 12.236c-0.72049 0.36795-1.4472 0.75012-2.1816 1.1738-3.4404 1.9848-6.3203 4.1911-8.2129 6.1699-0.94628 0.9894-1.6489 1.914-2.0488 2.7578-0.39997 0.8438-0.50968 1.639-0.14648 2.2676s1.1078 0.93201 2.0391 1.0078c0.93131 0.076 2.0893-0.06106 3.4199-0.38476 2.6613-0.6484 6.0127-2.0366 9.4531-4.0215 2.0899-1.2056 3.9354-2.4914 5.5156-3.7598h-1.0293c-1.411 1.0794-3.0286 2.1662-4.8125 3.1953-3.3962 1.9593-6.7001 3.3277-9.2754 3.9551-1.2876 0.3137-2.3914 0.43995-3.2129 0.37305-0.82153-0.067-1.3291-0.31535-1.543-0.68555-0.21387-0.3702-0.16922-0.92367 0.18359-1.668 0.35282-0.7444 1.014-1.6364 1.9297-2.5938 1.8314-1.9149 4.6702-4.0894 8.0664-6.0488 0.62532-0.36075 1.2403-0.68024 1.8555-1v-0.73828z"
|
||||
style="color:#000000;text-indent:0;block-progression:tb;text-decoration-line:none;text-transform:none;fill:#FFFFFF"
|
||||
transform="translate(0,1020.4)"
|
||||
inkscape:connector-curvature="0"
|
||||
/>
|
||||
<circle
|
||||
id="circle8418"
|
||||
cy="1045.1"
|
||||
cx="2.8068"
|
||||
r=".75893"
|
||||
style="fill:#FFFFFF"
|
||||
/>
|
||||
</g
|
||||
>
|
||||
<g
|
||||
id="g8422"
|
||||
>
|
||||
<path
|
||||
id="path3300"
|
||||
d="m11.682 3.1523c-0.17928-0.012267-0.35779 0.00188-0.5332 0.048828-0.70164 0.1879-1.1876 0.82968-1.502 1.709-0.31431 0.8792-0.47091 2.0283-0.50195 3.3965-0.062086 2.7365 0.4132 6.3316 1.4414 10.166s2.4148 7.1846 3.8379 9.5234c0.71153 1.1695 1.4246 2.087 2.1367 2.6914 0.71217 0.6045 1.4527 0.91642 2.1543 0.72852 0.70164-0.1879 1.1876-0.82783 1.502-1.707 0.31431-0.8793 0.48067-2.034 0.51172-3.4023 0.05491-2.42-0.33654-5.5249-1.1328-8.8594h-0.66797c0.81117 3.3483 1.2082 6.4642 1.1543 8.8418-0.03005 1.3241-0.19344 2.4196-0.4707 3.1953-0.27726 0.7756-0.64933 1.2019-1.0625 1.3125s-0.93818-0.07442-1.5664-0.60742c-0.62822-0.5332-1.3193-1.4036-2.0078-2.5352-1.377-2.2632-2.7448-5.5645-3.7598-9.3496-1.015-3.785-1.482-7.3305-1.4219-9.9785 0.030055-1.324 0.18954-2.4314 0.4668-3.207s0.64152-1.1882 1.0547-1.2988c0.41317-0.1106 0.946 0.062403 1.5742 0.5957 0.6182 0.52469 1.2989 1.3866 1.9766 2.4922v-1.1836c-0.521-0.7474-1.043-1.3562-1.561-1.7957-0.534-0.4534-1.086-0.7406-1.623-0.7774z"
|
||||
style="color:#000000;text-indent:0;block-progression:tb;text-decoration-line:none;text-transform:none;fill:#FFFFFF"
|
||||
transform="translate(0,1020.4)"
|
||||
inkscape:connector-curvature="0"
|
||||
/>
|
||||
<circle
|
||||
id="circle8420"
|
||||
cx="20.264"
|
||||
style="fill:#FFFFFF"
|
||||
r=".75893"
|
||||
cy="1043.4"
|
||||
/>
|
||||
</g
|
||||
>
|
||||
</g
|
||||
>
|
||||
</g
|
||||
>
|
||||
<metadata
|
||||
id="metadata19"
|
||||
>
|
||||
<rdf:RDF
|
||||
>
|
||||
<cc:Work
|
||||
>
|
||||
<dc:format
|
||||
>image/svg+xml</dc:format
|
||||
>
|
||||
<dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage"
|
||||
/>
|
||||
<cc:license
|
||||
rdf:resource="http://creativecommons.org/licenses/publicdomain/"
|
||||
/>
|
||||
<dc:publisher
|
||||
>
|
||||
<cc:Agent
|
||||
rdf:about="http://openclipart.org/"
|
||||
>
|
||||
<dc:title
|
||||
>Openclipart</dc:title
|
||||
>
|
||||
</cc:Agent
|
||||
>
|
||||
</dc:publisher
|
||||
>
|
||||
</cc:Work
|
||||
>
|
||||
<cc:License
|
||||
rdf:about="http://creativecommons.org/licenses/publicdomain/"
|
||||
>
|
||||
<cc:permits
|
||||
rdf:resource="http://creativecommons.org/ns#Reproduction"
|
||||
/>
|
||||
<cc:permits
|
||||
rdf:resource="http://creativecommons.org/ns#Distribution"
|
||||
/>
|
||||
<cc:permits
|
||||
rdf:resource="http://creativecommons.org/ns#DerivativeWorks"
|
||||
/>
|
||||
</cc:License
|
||||
>
|
||||
</rdf:RDF
|
||||
>
|
||||
</metadata
|
||||
>
|
||||
</svg
|
||||
>
|
After Width: | Height: | Size: 7.6 KiB |
9
dist/blog/imgs/jsonFeed.svg
vendored
Normal file
9
dist/blog/imgs/jsonFeed.svg
vendored
Normal file
@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" standalone="no"?>
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" >
|
||||
<!-- Uploaded to: SVG Repo, www.svgrepo.com, Generator: SVG Repo Mixer Tools -->
|
||||
<svg width="800px" height="800px" viewBox="-10 -5 1034 1034" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1">
|
||||
<path fill="#FFFFFF"
|
||||
d="M854 175q-27 0 -46 19t-19 45.5t18.5 45t45 18.5t45.5 -18.5t19 -45t-18.5 -45.5t-44.5 -19zM205 192l-34 34q-83 83 -88 154t68 144l82 82q45 46 48.5 78t-33.5 69v0q-16 19 -15.5 44.5t18.5 43.5t43.5 18.5t44.5 -15.5l1 1q25 -25 47 -32t45.5 4.5t53.5 41.5l95 96
|
||||
q75 74 147.5 70t155.5 -87l33 -34l-71 -72l-18 18q-47 47 -84 47.5t-82 -44.5l-112 -112q-86 -86 -169 -17l-11 -11q35 -42 31.5 -83t-45.5 -82l-100 -101q-31 -31 -40.5 -56.5t1 -51.5t42.5 -59l17 -17zM703 326q-28 0 -46.5 19t-18.5 45.5t18.5 45.5t45 19t45.5 -19
|
||||
t19 -45.5t-18.5 -45t-44.5 -19.5zM551 477q-27 0 -46 19t-19 45.5t19 45.5t45.5 19t45.5 -19t19 -45.5t-19 -45t-45 -19.5z" />
|
||||
</svg>
|
After Width: | Height: | Size: 1023 B |
2
dist/blog/index.html
vendored
2
dist/blog/index.html
vendored
@ -1 +1 @@
|
||||
<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width,user-scalable=no,initial-scale=1,maximum-scale=1,minimum-scale=1"><meta http-equiv="X-UA-Compatible" content="ie=edge"><title>Rohit Pai - Blog</title><meta name="title" content="Rohit Pai - Blog"><meta name="description" content="This is all the blog posts that Rohit Pai has posted. You'll find posts on various topics, mostly on tech but some on various other random topics."><meta name="keywords" content="Blog, all posts, rohit, pai, rohit pai, tech, web development, self-hosting, hosting"><meta name="robots" content="index, follow"><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><meta name="language" content="English"><meta name="author" content="Rohit Pai"><link rel="stylesheet" href="/blog/css/main.css"><script src="https://kit.fontawesome.com/ed3c25598e.js" crossorigin="anonymous"></script></head><body><nav><input type="checkbox" id="nav-check"><h1><a href="/" class="link">rohit pai</a></h1><div class="nav-btn"><label for="nav-check"><span></span> <span></span> <span></span></label></div><ul><li><a href="/#about" class="textShadow link">about</a></li><li><a href="/#curriculumVitae" class="textShadow link">cv</a></li><li><a href="/#projects" class="textShadow link">projects</a></li><li><a href="/#contact" class="textShadow link">contact</a></li><li><a href="/blog" class="textShadow link active">blog</a></li></ul></nav><header><div><h1>full stack developer</h1><a href="/#sayHello" class="btn btnPrimary boxShadowIn boxShadowOut">Contact Me</a> <a href="" id="arrow"><i class="fa-solid fa-chevron-down"></i></a></div></header><div class="menuBar"><div class="menu"><ul><li><a href="/blog" class="link active">All posts</a></li><li><a href="/blog/category" class="link">categories</a></li><li><label for="searchField" aria-hidden="true" hidden>search</label> <input type="search" name="search" id="searchField" placeholder="Search..."> <button type="submit" id="searchBtn" class="btn btnPrimary"><i class="fa fa-search"></i></button></li></ul></div></div><main id="main"></main><footer class="flexRow"><div class="spacer"></div><p>© <span id="year"></span> Rohit Pai all rights reserved</p><div class="button"><button id="goBackToTop"><i class="fa-solid fa-chevron-up"></i></button></div></footer><script src="/js/typewriter.js"></script><script src="/blog/js/index.js"></script><script id="dsq-count-scr" src="https://rohitpaiportfolio.disqus.com/count.js" async></script></body></html>
|
||||
<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width,user-scalable=no,initial-scale=1,maximum-scale=1,minimum-scale=1"><meta http-equiv="X-UA-Compatible" content="ie=edge"><title>Rohit Pai - Blog</title><meta name="title" content="Rohit Pai - Blog"><meta name="description" content="This is all the blog posts that Rohit Pai has posted. You'll find posts on various topics, mostly on tech but some on various other random topics."><meta name="keywords" content="Blog, all posts, rohit, pai, rohit pai, tech, web development, self-hosting, hosting"><meta name="robots" content="index, follow"><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><meta name="language" content="English"><meta name="author" content="Rohit Pai"><link rel="stylesheet" href="/blog/css/main.css"><script src="https://kit.fontawesome.com/ed3c25598e.js" crossorigin="anonymous"></script><script type="text/javascript" src="https://platform-api.sharethis.com/js/sharethis.js#property=6550cdc47a115e0012964576&product=sop" async="async"></script></head><body><nav><input type="checkbox" id="nav-check"><h1><a href="/" class="link">rohit pai</a></h1><div class="nav-btn"><label for="nav-check"><span></span> <span></span> <span></span></label></div><ul><li><a href="/#about" class="textShadow link">about</a></li><li><a href="/#curriculumVitae" class="textShadow link">cv</a></li><li><a href="/#projects" class="textShadow link">projects</a></li><li><a href="/#contact" class="textShadow link">contact</a></li><li><a href="/blog" class="textShadow link active">blog</a></li></ul></nav><header><div><h1>full stack developer</h1><a href="/#sayHello" class="btn btnPrimary boxShadowIn boxShadowOut">Contact Me</a> <a href="" id="arrow"><i class="fa-solid fa-chevron-down"></i></a></div></header><div class="menuBar"><div class="menu"><ul><li><a href="/blog" class="link active">All posts</a></li><li><a href="/blog/category" class="link">categories</a></li><li><label for="searchField" aria-hidden="true" hidden>search</label> <input type="search" name="search" id="searchField" placeholder="Search..."> <button type="submit" id="searchBtn" class="btn btnPrimary"><i class="fa fa-search"></i></button></li></ul></div></div><main id="main"></main><footer class="flexRow"><div class="nav"><ul><li><a href="/blog/policy/privacy" class="link">privacy policy</a></li><li><a href="/blog/policy/cookie" class="link">cookie policy</a></li></ul></div><p>© <span id="year"></span> Rohit Pai all rights reserved</p><div class="button"><button id="goBackToTop"><i class="fa-solid fa-chevron-up"></i></button></div></footer><script src="/js/typewriter.js"></script><script src="/blog/js/index.js"></script><script id="dsq-count-scr" src="https://rohitpaiportfolio.disqus.com/count.js" async></script></body></html>
|
2
dist/blog/js/index.js
vendored
2
dist/blog/js/index.js
vendored
File diff suppressed because one or more lines are too long
2
dist/css/main.css
vendored
2
dist/css/main.css
vendored
File diff suppressed because one or more lines are too long
@ -2,13 +2,20 @@
|
||||
|
||||
namespace api\blog;
|
||||
|
||||
use api\utils\feedGenerator\FeedWriter;
|
||||
use api\utils\imgUtils;
|
||||
use DOMDocument;
|
||||
use PDO;
|
||||
use Psr\Http\Message\UploadedFileInterface;
|
||||
use DonatelloZa\RakePlus\RakePlus;
|
||||
use function DI\string;
|
||||
use const api\utils\feedGenerator\ATOM;
|
||||
use const api\utils\feedGenerator\RSS2;
|
||||
|
||||
|
||||
require_once __DIR__ . "/../utils/config.php";
|
||||
require_once __DIR__ . "/../utils/imgUtils.php";
|
||||
require_once __DIR__ . "/../utils/feedGenerator/FeedWriter.php";
|
||||
|
||||
/**
|
||||
* Blog Data Class
|
||||
@ -18,12 +25,15 @@ class blogData
|
||||
{
|
||||
/**
|
||||
* Get all blog posts
|
||||
* @return array - Array of all blog posts or error message
|
||||
* @return array<array> - Array of all blog posts or error message
|
||||
*/
|
||||
public function getBlogPosts(): array
|
||||
{
|
||||
$conn = dbConn();
|
||||
$stmt = $conn->prepare("SELECT * FROM blog ORDER BY featured DESC, dateCreated DESC;");
|
||||
$stmt = $conn->prepare("SELECT ID, title, DATE_FORMAT(dateCreated, '%Y-%m-%dT%TZ') AS dateCreated,
|
||||
DATE_FORMAT(dateModified, '%Y-%m-%dT%TZ') AS dateModified, featured, abstract,
|
||||
headerImg, body, bodyText, categories, keywords, folderID FROM blog ORDER BY featured DESC,
|
||||
dateCreated DESC;");
|
||||
$stmt->execute();
|
||||
|
||||
// set the resulting array to associative
|
||||
@ -40,12 +50,15 @@ class blogData
|
||||
/**
|
||||
* Get a blog post with the given ID
|
||||
* @param string $title - Title of the blog post
|
||||
* @return array - Array of all blog posts or error message
|
||||
* @return array - Array of blog post or error message
|
||||
*/
|
||||
public function getBlogPost(string $title): array
|
||||
{
|
||||
$conn = dbConn();
|
||||
$stmt = $conn->prepare("SELECT * FROM blog WHERE title = :title;");
|
||||
$stmt = $conn->prepare("SELECT ID, title, DATE_FORMAT(dateCreated, '%Y-%m-%dT%TZ') AS dateCreated,
|
||||
DATE_FORMAT(dateModified, '%Y-%m-%dT%TZ') AS dateModified, featured, abstract,
|
||||
headerImg, body, bodyText, categories, keywords, folderID FROM blog WHERE
|
||||
title = :title;");
|
||||
$stmt->bindParam(":title", $title);
|
||||
$stmt->execute();
|
||||
|
||||
@ -67,7 +80,10 @@ class blogData
|
||||
public function getLatestBlogPost(): array
|
||||
{
|
||||
$conn = dbConn();
|
||||
$stmt = $conn->prepare("SELECT * FROM blog ORDER BY dateCreated DESC LIMIT 1;");
|
||||
$stmt = $conn->prepare("SELECT ID, title, DATE_FORMAT(dateCreated, '%Y-%m-%dT%TZ') AS dateCreated,
|
||||
DATE_FORMAT(dateModified, '%Y-%m-%dT%TZ') AS dateModified, featured, abstract,
|
||||
headerImg, body, bodyText, categories, keywords, folderID FROM blog ORDER BY
|
||||
dateCreated DESC LIMIT 1;");
|
||||
$stmt->execute();
|
||||
|
||||
// set the resulting array to associative
|
||||
@ -88,7 +104,9 @@ class blogData
|
||||
public function getFeaturedBlogPost(): array
|
||||
{
|
||||
$conn = dbConn();
|
||||
$stmt = $conn->prepare("SELECT * FROM blog WHERE featured = 1;");
|
||||
$stmt = $conn->prepare("SELECT ID, title, DATE_FORMAT(dateCreated, '%Y-%m-%dT%TZ') AS dateCreated,
|
||||
DATE_FORMAT(dateModified, '%Y-%m-%dT%TZ') AS dateModified, featured, abstract,
|
||||
headerImg, body, bodyText, categories, keywords, folderID FROM blog WHERE featured = 1;");
|
||||
$stmt->execute();
|
||||
|
||||
$result = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
@ -209,7 +227,9 @@ class blogData
|
||||
$from = "../blog/imgs/tmp/";
|
||||
$newBody = $this->changeHTMLSrc($body, $to, $from);
|
||||
|
||||
$stmt = $conn->prepare("UPDATE blog SET title = :title, featured = :featured, abstract = :abstract, body = :body, bodyText = :bodyText, dateModified = :dateModified, categories = :categories WHERE ID = :ID;");
|
||||
$keywords = implode(", ", RakePlus::create($bodyText)->keywords());
|
||||
|
||||
$stmt = $conn->prepare("UPDATE blog SET title = :title, featured = :featured, abstract = :abstract, body = :body, bodyText = :bodyText, dateModified = :dateModified, categories = :categories, keywords = :keywords WHERE ID = :ID;");
|
||||
$stmt->bindParam(":ID", $ID);
|
||||
$stmt->bindParam(":title", $title);
|
||||
$stmt->bindParam(":featured", $featured);
|
||||
@ -218,6 +238,7 @@ class blogData
|
||||
$stmt->bindParam(":bodyText", $bodyText);
|
||||
$stmt->bindParam(":dateModified", $dateModified);
|
||||
$stmt->bindParam(":categories", $categories);
|
||||
$stmt->bindParam(":keywords", $keywords);
|
||||
|
||||
return $stmt->execute();
|
||||
}
|
||||
@ -266,8 +287,10 @@ class blogData
|
||||
$stmtMainProject->execute();
|
||||
}
|
||||
|
||||
$stmt = $conn->prepare("INSERT INTO blog (title, dateCreated, dateModified, featured, headerImg, abstract, body, bodyText, categories, folderID)
|
||||
VALUES (:title, :dateCreated, :dateModified, :featured, :headerImg, :abstract, :body, :bodyText, :categories, :folderID);");
|
||||
$keywords = implode(", ", RakePlus::create($bodyText)->keywords());
|
||||
|
||||
$stmt = $conn->prepare("INSERT INTO blog (title, dateCreated, dateModified, featured, headerImg, abstract, body, bodyText, categories, keywords, folderID)
|
||||
VALUES (:title, :dateCreated, :dateModified, :featured, :headerImg, :abstract, :body, :bodyText, :categories, :keywords, :folderID);");
|
||||
$stmt->bindParam(":title", $title);
|
||||
$stmt->bindParam(":dateCreated", $dateCreated);
|
||||
$stmt->bindParam(":dateModified", $dateCreated);
|
||||
@ -278,6 +301,7 @@ class blogData
|
||||
$stmt->bindParam(":body", $newBody);
|
||||
$stmt->bindParam(":bodyText", $bodyText);
|
||||
$stmt->bindParam(":categories", $categories);
|
||||
$stmt->bindParam(":keywords", $keywords);
|
||||
$stmt->bindParam(":folderID", $folderID);
|
||||
|
||||
if ($stmt->execute())
|
||||
@ -399,11 +423,10 @@ class blogData
|
||||
if (!in_array($from . $file, $srcList))
|
||||
{
|
||||
unlink($from . $file);
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
rename($from . $file, $to . $file);
|
||||
}
|
||||
|
||||
rename($from . $file, $to . $file);
|
||||
}
|
||||
}
|
||||
|
||||
@ -418,7 +441,7 @@ class blogData
|
||||
/**
|
||||
* Get all posts with the given category
|
||||
* @param string $category - Category of the post
|
||||
* @return array - Array of all posts with the given category or error message
|
||||
* @return array<array> - Array of all posts with the given category or error message
|
||||
*/
|
||||
public function getPostsByCategory(string $category): array
|
||||
{
|
||||
@ -432,7 +455,7 @@ class blogData
|
||||
/**
|
||||
* Search for a blog post with the given search term
|
||||
* @param string $searchTerm - Search term
|
||||
* @return array - Array of all posts with the given search term or error message
|
||||
* @return array<array> - Array of all posts with the given search term or error message
|
||||
*/
|
||||
public function searchBlog(string $searchTerm): array
|
||||
{
|
||||
@ -527,4 +550,109 @@ class blogData
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate the XML feed
|
||||
* @param mixed $type - Type of feed
|
||||
* @return array|string - Error message or the XML feed
|
||||
*/
|
||||
private function generateXMLFeed(mixed $type): array|string
|
||||
{
|
||||
ob_start();
|
||||
$feed = new FeedWriter($type);
|
||||
$feed->setTitle("Rohit Pai's Blog");
|
||||
$feed->setLink('https://rohitpai.co.uk/blog');
|
||||
$feed->setFeedURL('https://rohitpai.co.uk/api/blog/feed/atom');
|
||||
$feed->setChannelElement('updated', date(DATE_ATOM, time()));
|
||||
$feed->setChannelElement('author', ['name' => 'Rohit Pai']);
|
||||
$posts = $this->getBlogPosts();
|
||||
|
||||
if (isset($posts["errorMessage"]))
|
||||
{
|
||||
return $posts;
|
||||
}
|
||||
|
||||
foreach ($posts as $post)
|
||||
{
|
||||
$newItem = $feed->createNewItem();
|
||||
$newItem->setTitle($post["title"]);
|
||||
$newItem->setLink("https://rohitpai.co.uk/blog/post/" . rawurlencode($post["title"]) . "#disqus_thread");
|
||||
$newItem->setDate($post["dateModified"]);
|
||||
$newItem->setDescription($post["body"]);
|
||||
$feed->addItem($newItem);
|
||||
}
|
||||
|
||||
$feed->generateFeed();
|
||||
$atom = ob_get_contents();
|
||||
ob_end_clean();
|
||||
return $atom;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate the JSON feed
|
||||
* @return array|array[] - Error message or the JSON feed
|
||||
*/
|
||||
private function generateJSONFeed(): array
|
||||
{
|
||||
$posts = $this->getBlogPosts();
|
||||
|
||||
if (isset($posts["errorMessage"]))
|
||||
{
|
||||
return $posts;
|
||||
}
|
||||
|
||||
$json = array();
|
||||
$json["version"] = "https://jsonfeed.org/version/1.1";
|
||||
$json["title"] = "Rohit Pai's Blog";
|
||||
$json["home_page_url"] = "https://rohitpai.co.uk/blog";
|
||||
$json["feed_url"] = "https://rohitpai.co.uk/api/blog/feed/json";
|
||||
$json["description"] = "Rohit Pai's personal blog on all things self hosting and various other tech topics";
|
||||
$json["author"] = array(
|
||||
"name" => "Rohit Pai",
|
||||
"url" => "https://rohitpai.co.uk",
|
||||
"avatar" => "https://rohitpai.co.uk/imgs/profile.jpg"
|
||||
);
|
||||
$items = array();
|
||||
foreach ($posts as $post)
|
||||
{
|
||||
$items[] = array(
|
||||
"id" => string($post["ID"]),
|
||||
"url" => "https://rohitpai.co.uk/blog/post/" . rawurlencode($post["title"]) . "#disqus_thread",
|
||||
"title" => $post["title"],
|
||||
"date_published" => date($post["dateCreated"]),
|
||||
"date_modified" => date($post["dateModified"]),
|
||||
// "description" => $post["abstract"],
|
||||
"banner_image" => "https://rohitpai.co.uk/" . rawurlencode($post["headerImg"]),
|
||||
"content_html" => $post["body"]
|
||||
);
|
||||
}
|
||||
$json["items"] = $items;
|
||||
return $json;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate the RSS feed based on type
|
||||
* @param string $type - Type of feed
|
||||
* @return string|array - RSS feed or an error message
|
||||
*/
|
||||
public function getFeed(string $type): string|array
|
||||
{
|
||||
$feed = "";
|
||||
if ($type == "atom")
|
||||
{
|
||||
$feed = $this->generateXMLFeed(ATOM);
|
||||
}
|
||||
|
||||
if ($type == "rss")
|
||||
{
|
||||
$feed = $this->generateXMLFeed(RSS2);
|
||||
}
|
||||
|
||||
if ($type == "json")
|
||||
{
|
||||
$feed = $this->generateJSONFeed();
|
||||
}
|
||||
|
||||
return $feed;
|
||||
}
|
||||
}
|
@ -4,6 +4,7 @@ namespace api\blog;
|
||||
require_once __DIR__ . "/../utils/routesInterface.php";
|
||||
require_once "blogData.php";
|
||||
|
||||
|
||||
use api\utils\routesInterface;
|
||||
use Psr\Http\Message\ResponseInterface as Response;
|
||||
use Psr\Http\Message\ServerRequestInterface as Request;
|
||||
@ -80,35 +81,15 @@ class blogRoutes implements routesInterface
|
||||
|
||||
$app->get("/blog/post/{type}", function (Request $request, Response $response, $args)
|
||||
{
|
||||
if ($args["type"] != null)
|
||||
if ($args["type"] == null)
|
||||
{
|
||||
if ($args["type"] == "latest")
|
||||
{
|
||||
$post = $this->blogData->getLatestBlogPost();
|
||||
if (array_key_exists("errorMessage", $post))
|
||||
{
|
||||
$response->getBody()->write(json_encode($post));
|
||||
return $response->withStatus(404);
|
||||
}
|
||||
$response->getBody()->write(json_encode(array("error" => "Please provide a title")));
|
||||
return $response->withStatus(400);
|
||||
}
|
||||
|
||||
$response->getBody()->write(json_encode($post));
|
||||
return $response;
|
||||
}
|
||||
|
||||
if ($args["type"] == "featured")
|
||||
{
|
||||
$post = $this->blogData->getFeaturedBlogPost();
|
||||
if (array_key_exists("errorMessage", $post))
|
||||
{
|
||||
$response->getBody()->write(json_encode($post));
|
||||
return $response->withStatus(404);
|
||||
}
|
||||
|
||||
$response->getBody()->write(json_encode($post));
|
||||
return $response;
|
||||
}
|
||||
|
||||
$post = $this->blogData->getBlogPost($args["type"]);
|
||||
if ($args["type"] == "latest")
|
||||
{
|
||||
$post = $this->blogData->getLatestBlogPost();
|
||||
if (array_key_exists("errorMessage", $post))
|
||||
{
|
||||
$response->getBody()->write(json_encode($post));
|
||||
@ -119,114 +100,173 @@ class blogRoutes implements routesInterface
|
||||
return $response;
|
||||
}
|
||||
|
||||
$response->getBody()->write(json_encode(array("error" => "Please provide a title")));
|
||||
if ($args["type"] == "featured")
|
||||
{
|
||||
$post = $this->blogData->getFeaturedBlogPost();
|
||||
if (array_key_exists("errorMessage", $post))
|
||||
{
|
||||
$response->getBody()->write(json_encode($post));
|
||||
return $response->withStatus(404);
|
||||
}
|
||||
|
||||
$response->getBody()->write(json_encode($post));
|
||||
return $response;
|
||||
}
|
||||
|
||||
$post = $this->blogData->getBlogPost($args["type"]);
|
||||
if (array_key_exists("errorMessage", $post))
|
||||
{
|
||||
$response->getBody()->write(json_encode($post));
|
||||
return $response->withStatus(404);
|
||||
}
|
||||
|
||||
$response->getBody()->write(json_encode($post));
|
||||
return $response;
|
||||
|
||||
});
|
||||
|
||||
$app->get("/blog/feed/{type}", function (Request $request, Response $response, $args)
|
||||
{
|
||||
if ($args["type"] == null)
|
||||
{
|
||||
$response->getBody()->write(json_encode(array("error" => "Please provide a title")));
|
||||
return $response->withStatus(400);
|
||||
}
|
||||
|
||||
$feed = $this->blogData->getFeed($args["type"]);
|
||||
if (is_array($feed))
|
||||
{
|
||||
$response->getBody()->write(json_encode($feed));
|
||||
return $response->withStatus(404);
|
||||
}
|
||||
|
||||
if ($args["type"] == "atom")
|
||||
{
|
||||
$response->getBody()->write($feed);
|
||||
return $response->withHeader("Content-Type", "application/atom+xml");
|
||||
}
|
||||
|
||||
if ($args["type"] == "rss")
|
||||
{
|
||||
$response->getBody()->write($feed);
|
||||
return $response->withHeader("Content-Type", "application/rss+xml");
|
||||
}
|
||||
|
||||
if ($args["type"] == "json")
|
||||
{
|
||||
$response->getBody()->write(json_encode($feed));
|
||||
return $response->withHeader("Content-Type", "application/feed+json");
|
||||
}
|
||||
|
||||
$response->getBody()->write(json_encode(array("error" => "Invalid feed type")));
|
||||
return $response->withStatus(400);
|
||||
});
|
||||
|
||||
$app->get("/blog/search/{searchTerm}", function (Request $request, $response, $args)
|
||||
{
|
||||
if ($args["searchTerm"] != null)
|
||||
if ($args["searchTerm"] == null)
|
||||
{
|
||||
$posts = $this->blogData->searchBlog($args["searchTerm"]);
|
||||
|
||||
$json = json_encode($posts);
|
||||
|
||||
$response->getBody()->write($json);
|
||||
|
||||
if (array_key_exists("errorMessage", $posts))
|
||||
{
|
||||
$response->withStatus(404);
|
||||
}
|
||||
|
||||
return $response;
|
||||
$response->getBody()->write(json_encode(array("error" => "Please provide a search term")));
|
||||
return $response->withStatus(400);
|
||||
}
|
||||
|
||||
$response->getBody()->write(json_encode(array("error" => "Please provide a search term")));
|
||||
return $response->withStatus(400);
|
||||
$posts = $this->blogData->searchBlog($args["searchTerm"]);
|
||||
|
||||
$json = json_encode($posts);
|
||||
|
||||
$response->getBody()->write($json);
|
||||
|
||||
if (array_key_exists("errorMessage", $posts))
|
||||
{
|
||||
$response->withStatus(404);
|
||||
}
|
||||
|
||||
return $response;
|
||||
|
||||
});
|
||||
|
||||
$app->patch("/blog/post/{id}", function (Request $request, Response $response, $args)
|
||||
{
|
||||
$data = $request->getParsedBody();
|
||||
if ($args["id"] != null)
|
||||
if ($args["id"] == null)
|
||||
{
|
||||
if (empty($data["title"]) || strlen($data["featured"]) == 0 || empty($data["body"]) || empty($data["bodyText"]) || empty($data["dateModified"]) || empty($data["categories"]))
|
||||
{
|
||||
// uh oh sent some empty data
|
||||
$response->getBody()->write(json_encode(array("error" => "Only some of the data was sent")));
|
||||
return $response->withStatus(400);
|
||||
}
|
||||
|
||||
if (!preg_match('/[a-zA-Z0-9 ]+, |\w+/mx', $data["categories"]))
|
||||
{
|
||||
// uh oh sent some empty data
|
||||
$response->getBody()->write(json_encode(array("error" => "Categories must be in a CSV format")));
|
||||
return $response->withStatus(400);
|
||||
}
|
||||
|
||||
$message = $this->blogData->updatePost($args["id"], $data["title"], intval($data["featured"]), $data["abstract"], $data["body"], $data["bodyText"], $data["dateModified"], $data["categories"]);
|
||||
|
||||
if ($message === "post not found")
|
||||
{
|
||||
// uh oh something went wrong
|
||||
$response->getBody()->write(json_encode(array("error" => "Error, post not found")));
|
||||
return $response->withStatus(404);
|
||||
}
|
||||
|
||||
if ($message === "unset featured")
|
||||
{
|
||||
// uh oh something went wrong
|
||||
$response->getBody()->write(json_encode(array("error" => "Error, cannot unset featured post, try updating another post to be featured first")));
|
||||
return $response->withStatus(409);
|
||||
}
|
||||
|
||||
if (!is_bool($message) || $message === false)
|
||||
{
|
||||
// uh oh something went wrong
|
||||
$response->getBody()->write(json_encode(array("error" => $message)));
|
||||
return $response->withStatus(500);
|
||||
}
|
||||
|
||||
$response->withStatus(201);
|
||||
return $response;
|
||||
|
||||
$response->getBody()->write(json_encode(array("error" => "Please provide an ID")));
|
||||
return $response->withStatus(400);
|
||||
}
|
||||
|
||||
$response->getBody()->write(json_encode(array("error" => "Please provide an ID")));
|
||||
return $response->withStatus(400);
|
||||
if (empty($data["title"]) || strlen($data["featured"]) == 0 || empty($data["body"]) || empty($data["bodyText"]) || empty($data["dateModified"]) || empty($data["categories"]))
|
||||
{
|
||||
// uh oh sent some empty data
|
||||
$response->getBody()->write(json_encode(array("error" => "Only some of the data was sent")));
|
||||
return $response->withStatus(400);
|
||||
}
|
||||
|
||||
if (!preg_match('/[a-zA-Z0-9 ]+, |\w+/mx', $data["categories"]))
|
||||
{
|
||||
// uh oh sent some empty data
|
||||
$response->getBody()->write(json_encode(array("error" => "Categories must be in a CSV format")));
|
||||
return $response->withStatus(400);
|
||||
}
|
||||
|
||||
$message = $this->blogData->updatePost($args["id"], $data["title"], intval($data["featured"]), $data["abstract"], $data["body"], $data["bodyText"], $data["dateModified"], $data["categories"]);
|
||||
|
||||
if ($message === "post not found")
|
||||
{
|
||||
// uh oh something went wrong
|
||||
$response->getBody()->write(json_encode(array("error" => "Error, post not found")));
|
||||
return $response->withStatus(404);
|
||||
}
|
||||
|
||||
if ($message === "unset featured")
|
||||
{
|
||||
// uh oh something went wrong
|
||||
$response->getBody()->write(json_encode(array("error" => "Error, cannot unset featured post, try updating another post to be featured first")));
|
||||
return $response->withStatus(409);
|
||||
}
|
||||
|
||||
if (!is_bool($message) || $message === false)
|
||||
{
|
||||
// uh oh something went wrong
|
||||
$response->getBody()->write(json_encode(array("error" => $message)));
|
||||
return $response->withStatus(500);
|
||||
}
|
||||
|
||||
$response->withStatus(201);
|
||||
return $response;
|
||||
|
||||
});
|
||||
|
||||
$app->delete("/blog/post/{id}", function (Request $request, Response $response, $args)
|
||||
{
|
||||
if ($args["id"] != null)
|
||||
if ($args["id"] == null)
|
||||
{
|
||||
$message = $this->blogData->deletePost($args["id"]);
|
||||
|
||||
if ($message === "post not found")
|
||||
{
|
||||
// uh oh something went wrong
|
||||
$response->getBody()->write(json_encode(array("error" => "Error, post not found")));
|
||||
return $response->withStatus(404);
|
||||
}
|
||||
|
||||
if ($message === "error")
|
||||
{
|
||||
// uh oh something went wrong
|
||||
$response->getBody()->write(json_encode(array("error" => "Error, something went wrong")));
|
||||
return $response->withStatus(500);
|
||||
}
|
||||
|
||||
if ($message === "cannot delete")
|
||||
{
|
||||
// uh oh something went wrong
|
||||
$response->getBody()->write(json_encode(array("error" => "Error, cannot delete featured post")));
|
||||
return $response->withStatus(409);
|
||||
}
|
||||
return $response;
|
||||
$response->getBody()->write(json_encode(array("error" => "Please provide an ID")));
|
||||
return $response->withStatus(400);
|
||||
}
|
||||
|
||||
$response->getBody()->write(json_encode(array("error" => "Please provide an ID")));
|
||||
return $response->withStatus(400);
|
||||
$message = $this->blogData->deletePost($args["id"]);
|
||||
|
||||
if ($message === "post not found")
|
||||
{
|
||||
// uh oh something went wrong
|
||||
$response->getBody()->write(json_encode(array("error" => "Error, post not found")));
|
||||
return $response->withStatus(404);
|
||||
}
|
||||
|
||||
if ($message === "error")
|
||||
{
|
||||
// uh oh something went wrong
|
||||
$response->getBody()->write(json_encode(array("error" => "Error, something went wrong")));
|
||||
return $response->withStatus(500);
|
||||
}
|
||||
|
||||
if ($message === "cannot delete")
|
||||
{
|
||||
// uh oh something went wrong
|
||||
$response->getBody()->write(json_encode(array("error" => "Error, cannot delete featured post")));
|
||||
return $response->withStatus(409);
|
||||
}
|
||||
return $response;
|
||||
});
|
||||
|
||||
$app->post("/blog/post", function (Request $request, Response $response)
|
||||
@ -290,28 +330,28 @@ class blogRoutes implements routesInterface
|
||||
{
|
||||
$files = $request->getUploadedFiles();
|
||||
|
||||
if ($args["id"] != null)
|
||||
if ($args["id"] == null)
|
||||
{
|
||||
if (empty($files))
|
||||
{
|
||||
// uh oh sent some empty data
|
||||
$response->getBody()->write(json_encode(array("error" => array("message" => "Error, empty data sent"))));
|
||||
return $response->withStatus(400);
|
||||
}
|
||||
|
||||
$message = $this->blogData->uploadHeaderImage($args["id"], $files["headerImg"]);
|
||||
if (!is_array($message))
|
||||
{
|
||||
$response->getBody()->write(json_encode(array("error" => array("message" => $message))));
|
||||
return $response->withStatus(500);
|
||||
}
|
||||
|
||||
$response->getBody()->write(json_encode($message));
|
||||
return $response->withStatus(201);
|
||||
$response->getBody()->write(json_encode(array("error" => "Please provide an ID")));
|
||||
return $response->withStatus(400);
|
||||
}
|
||||
|
||||
$response->getBody()->write(json_encode(array("error" => "Please provide an ID")));
|
||||
return $response->withStatus(400);
|
||||
if (empty($files))
|
||||
{
|
||||
// uh oh sent some empty data
|
||||
$response->getBody()->write(json_encode(array("error" => array("message" => "Error, empty data sent"))));
|
||||
return $response->withStatus(400);
|
||||
}
|
||||
|
||||
$message = $this->blogData->uploadHeaderImage($args["id"], $files["headerImg"]);
|
||||
if (!is_array($message))
|
||||
{
|
||||
$response->getBody()->write(json_encode(array("error" => array("message" => $message))));
|
||||
return $response->withStatus(500);
|
||||
}
|
||||
|
||||
$response->getBody()->write(json_encode($message));
|
||||
return $response->withStatus(201);
|
||||
});
|
||||
}
|
||||
}
|
@ -17,7 +17,7 @@ class projectData
|
||||
{
|
||||
/**
|
||||
* Get all project data
|
||||
* @return array - Array of all project data or error message
|
||||
* @return array<array> - Array of all project data or error message
|
||||
*/
|
||||
public function getProjectData(): array
|
||||
{
|
||||
|
@ -50,78 +50,78 @@ class projectRoutes implements routesInterface
|
||||
$app->patch("/projectData/{id}", function (Request $request, Response $response, array $args)
|
||||
{
|
||||
$data = $request->getParsedBody();
|
||||
if ($args["id"] != null)
|
||||
if ($args["id"] == null)
|
||||
{
|
||||
if (empty($data["title"]) || empty($data["isMainProject"]) || empty($data["information"]) || empty($data["gitLink"]))
|
||||
{
|
||||
// uh oh sent some empty data
|
||||
$response->getBody()->write(json_encode(array("error" => "Only some of the data was sent")));
|
||||
return $response->withStatus(400);
|
||||
}
|
||||
|
||||
$isMainProject = $data["isMainProject"] === "true";
|
||||
$update = $this->projectData->updateProjectData($args["id"], $data["title"], $isMainProject, $data["information"], $data["projectLink"], $data["gitLink"]);
|
||||
|
||||
if ($update === "project not found")
|
||||
{
|
||||
// uh oh something went wrong
|
||||
$response->getBody()->write(json_encode(array("error" => "Project with ID " . $args["id"] . " not found")));
|
||||
return $response->withStatus(404);
|
||||
}
|
||||
|
||||
if ($update === "unset main project")
|
||||
{
|
||||
// uh oh something went wrong
|
||||
$response->getBody()->write(json_encode(array("error" => "Can't unset project as main project, try updating another project as the main project")));
|
||||
return $response->withStatus(400);
|
||||
}
|
||||
|
||||
if (!$update)
|
||||
{
|
||||
// uh oh something went wrong
|
||||
$response->getBody()->write(json_encode(array("error" => "Something went wrong")));
|
||||
return $response->withStatus(500);
|
||||
}
|
||||
|
||||
return $response;
|
||||
$response->getBody()->write(json_encode(array("error" => "Please provide an ID")));
|
||||
return $response->withStatus(400);
|
||||
}
|
||||
|
||||
$response->getBody()->write(json_encode(array("error" => "Please provide an ID")));
|
||||
return $response->withStatus(400);
|
||||
if (empty($data["title"]) || empty($data["isMainProject"]) || empty($data["information"]) || empty($data["gitLink"]))
|
||||
{
|
||||
// uh oh sent some empty data
|
||||
$response->getBody()->write(json_encode(array("error" => "Only some of the data was sent")));
|
||||
return $response->withStatus(400);
|
||||
}
|
||||
|
||||
$isMainProject = $data["isMainProject"] === "true";
|
||||
$update = $this->projectData->updateProjectData($args["id"], $data["title"], $isMainProject, $data["information"], $data["projectLink"], $data["gitLink"]);
|
||||
|
||||
if ($update === "project not found")
|
||||
{
|
||||
// uh oh something went wrong
|
||||
$response->getBody()->write(json_encode(array("error" => "Project with ID " . $args["id"] . " not found")));
|
||||
return $response->withStatus(404);
|
||||
}
|
||||
|
||||
if ($update === "unset main project")
|
||||
{
|
||||
// uh oh something went wrong
|
||||
$response->getBody()->write(json_encode(array("error" => "Can't unset project as main project, try updating another project as the main project")));
|
||||
return $response->withStatus(400);
|
||||
}
|
||||
|
||||
if (!$update)
|
||||
{
|
||||
// uh oh something went wrong
|
||||
$response->getBody()->write(json_encode(array("error" => "Something went wrong")));
|
||||
return $response->withStatus(500);
|
||||
}
|
||||
|
||||
return $response;
|
||||
});
|
||||
|
||||
$app->delete("/projectData/{id}", function (Request $request, Response $response, array $args)
|
||||
{
|
||||
if ($args["id"] != null)
|
||||
if ($args["id"] == null)
|
||||
{
|
||||
$message = $this->projectData->deleteProjectData($args["id"]);
|
||||
|
||||
if ($message === "project not found")
|
||||
{
|
||||
// uh oh something went wrong
|
||||
$response->getBody()->write(json_encode(array("error" => "Project with ID " . $args["id"] . " not found")));
|
||||
return $response->withStatus(404);
|
||||
}
|
||||
|
||||
if ($message === "cannot delete")
|
||||
{
|
||||
//uh oh cannot delete the main project
|
||||
$response->getBody()->write(json_encode(array("error" => "Cannot delete the main project")));
|
||||
return $response->withStatus(409);
|
||||
}
|
||||
|
||||
if ($message === "error")
|
||||
{
|
||||
// uh oh something went wrong
|
||||
$response->getBody()->write(json_encode(array("error" => "Something went wrong")));
|
||||
return $response->withStatus(500);
|
||||
}
|
||||
|
||||
return $response;
|
||||
$response->getBody()->write(json_encode(array("error" => "Please provide an ID")));
|
||||
return $response->withStatus(400);
|
||||
}
|
||||
|
||||
$response->getBody()->write(json_encode(array("error" => "Please provide an ID")));
|
||||
return $response->withStatus(400);
|
||||
$message = $this->projectData->deleteProjectData($args["id"]);
|
||||
|
||||
if ($message === "project not found")
|
||||
{
|
||||
// uh oh something went wrong
|
||||
$response->getBody()->write(json_encode(array("error" => "Project with ID " . $args["id"] . " not found")));
|
||||
return $response->withStatus(404);
|
||||
}
|
||||
|
||||
if ($message === "cannot delete")
|
||||
{
|
||||
//uh oh cannot delete the main project
|
||||
$response->getBody()->write(json_encode(array("error" => "Cannot delete the main project")));
|
||||
return $response->withStatus(409);
|
||||
}
|
||||
|
||||
if ($message === "error")
|
||||
{
|
||||
// uh oh something went wrong
|
||||
$response->getBody()->write(json_encode(array("error" => "Something went wrong")));
|
||||
return $response->withStatus(500);
|
||||
}
|
||||
|
||||
return $response;
|
||||
});
|
||||
|
||||
$app->post("/projectData", function (Request $request, Response $response)
|
||||
|
@ -14,7 +14,7 @@ class timelineData
|
||||
{
|
||||
/**
|
||||
* Get all education data
|
||||
* @return array - Array of all education data or error message
|
||||
* @return array<array> - Array of all education data or error message
|
||||
*/
|
||||
public function getEduData(): array
|
||||
{
|
||||
|
152
src/api/utils/feedGenerator/FeedItem.php
Normal file
152
src/api/utils/feedGenerator/FeedItem.php
Normal file
@ -0,0 +1,152 @@
|
||||
<?php
|
||||
|
||||
namespace api\utils\feedGenerator;
|
||||
|
||||
/**
|
||||
* Universal Feed Writer
|
||||
*
|
||||
* FeedItem class - Used as a feed element in FeedWriter class
|
||||
*
|
||||
* @package UniversalFeedWriter
|
||||
* @author Anis uddin Ahmad <anisniit@gmail.com>
|
||||
* @link http://www.ajaxray.com/projects/rss
|
||||
*/
|
||||
class FeedItem
|
||||
{
|
||||
private array $elements = []; // Collection of feed elements
|
||||
private string $version;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param string $version (RSS1/RSS2/ATOM) RSS2 is the default.
|
||||
*/
|
||||
public function __construct(string $version = RSS2)
|
||||
{
|
||||
$this->version = $version;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add an element to elements array
|
||||
*
|
||||
* @param string $elementName The tag name of an element
|
||||
* @param string $content The content of the tag
|
||||
* @param array|null $attributes Attributes (if any) in 'attrName' => 'attrValue' format
|
||||
*/
|
||||
public function addElement(string $elementName, string $content, ?array $attributes = null): void
|
||||
{
|
||||
$this->elements[$elementName]['name'] = $elementName;
|
||||
$this->elements[$elementName]['content'] = $content;
|
||||
$this->elements[$elementName]['attributes'] = $attributes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set multiple feed elements from an array.
|
||||
* Elements that have attributes cannot be added by this method
|
||||
*
|
||||
* @param array $elementArray Array of elements in 'tagName' => 'tagContent' format.
|
||||
*/
|
||||
public function addElementArray(array $elementArray): void
|
||||
{
|
||||
foreach ($elementArray as $elementName => $content)
|
||||
{
|
||||
$this->addElement($elementName, $content);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the collection of elements in this feed item
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getElements(): array
|
||||
{
|
||||
return $this->elements;
|
||||
}
|
||||
|
||||
// Wrapper functions ------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Set the 'description' element of the feed item
|
||||
*
|
||||
* @param string $description The content of the 'description' element
|
||||
*/
|
||||
public function setDescription(string $description): void
|
||||
{
|
||||
$tag = ($this->version === ATOM) ? 'summary' : 'description';
|
||||
$this->addElement($tag, $description);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the 'title' element of the feed item
|
||||
*
|
||||
* @param string $title The content of the 'title' element
|
||||
*/
|
||||
public function setTitle(string $title): void
|
||||
{
|
||||
$this->addElement('title', $title);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the 'date' element of the feed item
|
||||
*
|
||||
* @param string|int $date The content of the 'date' element
|
||||
*/
|
||||
public function setDate(string|int $date): void
|
||||
{
|
||||
if (!is_numeric($date))
|
||||
{
|
||||
$date = strtotime($date);
|
||||
}
|
||||
|
||||
if ($this->version === ATOM)
|
||||
{
|
||||
$tag = 'updated';
|
||||
$value = date(DATE_ATOM, $date);
|
||||
}
|
||||
elseif ($this->version === RSS2)
|
||||
{
|
||||
$tag = 'pubDate';
|
||||
$value = date(DATE_RSS, $date);
|
||||
}
|
||||
else
|
||||
{
|
||||
$tag = 'dc:date';
|
||||
$value = date("Y-m-d", $date);
|
||||
}
|
||||
|
||||
$this->addElement($tag, $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the 'link' element of the feed item
|
||||
*
|
||||
* @param string $link The content of the 'link' element
|
||||
*/
|
||||
public function setLink(string $link): void
|
||||
{
|
||||
if ($this->version === RSS2 || $this->version === RSS1)
|
||||
{
|
||||
$this->addElement('link', $link);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->addElement('link', '', ['href' => $link]);
|
||||
$this->addElement('id', FeedWriter::uuid($link, 'urn:uuid:'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the 'encloser' element of the feed item
|
||||
* For RSS 2.0 only
|
||||
*
|
||||
* @param string $url The url attribute of the encloser tag
|
||||
* @param string $length The length attribute of the encloser tag
|
||||
* @param string $type The type attribute of the encloser tag
|
||||
*/
|
||||
public function setEncloser(string $url, string $length, string $type): void
|
||||
{
|
||||
$attributes = ['url' => $url, 'length' => $length, 'type' => $type];
|
||||
$this->addElement('enclosure', '', $attributes);
|
||||
}
|
||||
}
|
386
src/api/utils/feedGenerator/FeedWriter.php
Normal file
386
src/api/utils/feedGenerator/FeedWriter.php
Normal file
@ -0,0 +1,386 @@
|
||||
<?php
|
||||
|
||||
namespace api\utils\feedGenerator;
|
||||
|
||||
require_once "FeedItem.php";
|
||||
|
||||
/**
|
||||
* Universal Feed Writer class
|
||||
*
|
||||
* Generate RSS 1.0, RSS 2.0, and Atom Feed
|
||||
*
|
||||
* @package UniversalFeedWriter
|
||||
* @link http://www.ajaxray.com/projects/rss
|
||||
*/
|
||||
class FeedWriter
|
||||
{
|
||||
private array $channels = []; // Collection of channel elements
|
||||
private array $items = []; // Collection of items as objects of FeedItem class
|
||||
private array $data = []; // Store some other version-wise data
|
||||
private array $CDATAEncoding = []; // The tag names that need to be encoded as CDATA
|
||||
|
||||
private string $version;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param string $version The version (RSS1, RSS2, ATOM).
|
||||
*/
|
||||
public function __construct(string $version = RSS2)
|
||||
{
|
||||
$this->version = $version;
|
||||
|
||||
// Setting default values for essential channel elements
|
||||
$this->channels['title'] = $version . ' Feed';
|
||||
$this->channels['link'] = 'http://www.ajaxray.com/blog';
|
||||
$this->channels["feedUrl"] = "http://example.com/feed";
|
||||
|
||||
// Tag names to encode in CDATA
|
||||
$this->CDATAEncoding = ['description', 'content:encoded', 'summary'];
|
||||
}
|
||||
|
||||
// Public functions
|
||||
|
||||
/**
|
||||
* Set a channel element
|
||||
*
|
||||
* @param string $elementName Name of the channel tag
|
||||
* @param string $content Content of the channel tag
|
||||
*/
|
||||
public function setChannelElement(string $elementName, string|array $content): void
|
||||
{
|
||||
$this->channels[$elementName] = $content;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate the actual RSS/Atom file
|
||||
*/
|
||||
public function generateFeed(): void
|
||||
{
|
||||
$this->printHead();
|
||||
$this->printChannels();
|
||||
$this->printItems();
|
||||
$this->printTail();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new FeedItem.
|
||||
*
|
||||
* @return FeedItem An instance of FeedItem class
|
||||
*/
|
||||
public function createNewItem(): FeedItem
|
||||
{
|
||||
$item = new FeedItem($this->version);
|
||||
return $item;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a FeedItem to the main class
|
||||
*
|
||||
* @param FeedItem $feedItem An instance of FeedItem class
|
||||
*/
|
||||
public function addItem(FeedItem $feedItem): void
|
||||
{
|
||||
$this->items[] = $feedItem;
|
||||
}
|
||||
|
||||
// Wrapper functions
|
||||
|
||||
/**
|
||||
* Set the 'title' channel element
|
||||
*
|
||||
* @param string $title Value of 'title' channel tag
|
||||
*/
|
||||
public function setTitle(string $title): void
|
||||
{
|
||||
$this->setChannelElement('title', $title);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the 'description' channel element
|
||||
*
|
||||
* @param string $description Value of 'description' channel tag
|
||||
*/
|
||||
public function setDescription(string $description): void
|
||||
{
|
||||
$this->setChannelElement('description', $description);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the 'link' channel element
|
||||
*
|
||||
* @param string $link Value of 'link' channel tag
|
||||
*/
|
||||
public function setLink(string $link): void
|
||||
{
|
||||
$this->setChannelElement('link', $link);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the 'image' channel element
|
||||
*
|
||||
* @param string $title Title of the image
|
||||
* @param string $link Link URL of the image
|
||||
* @param string $url Path URL of the image
|
||||
*/
|
||||
public function setImage(string $title, string $link, string $url): void
|
||||
{
|
||||
$this->setChannelElement('image', ['title' => $title, 'link' => $link, 'url' => $url]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the 'about' channel element. Only for RSS 1.0
|
||||
*
|
||||
* @param string $url Value of 'about' channel tag
|
||||
*/
|
||||
public function setChannelAbout(string $url): void
|
||||
{
|
||||
$this->data['ChannelAbout'] = $url;
|
||||
}
|
||||
|
||||
// Other functions
|
||||
|
||||
/**
|
||||
* Generates a UUID
|
||||
*
|
||||
* @param string $key An optional prefix
|
||||
* @param string $prefix A prefix
|
||||
* @return string The formatted UUID
|
||||
*/
|
||||
public static function uuid(?string $key = null, string $prefix = ''): string
|
||||
{
|
||||
$key = $key ?? uniqid((string)rand());
|
||||
$chars = md5($key);
|
||||
$uuid = substr($chars, 0, 8) . '-';
|
||||
$uuid .= substr($chars, 8, 4) . '-';
|
||||
$uuid .= substr($chars, 12, 4) . '-';
|
||||
$uuid .= substr($chars, 16, 4) . '-';
|
||||
$uuid .= substr($chars, 20, 12);
|
||||
|
||||
return $prefix . $uuid;
|
||||
}
|
||||
|
||||
// Private functions
|
||||
|
||||
/**
|
||||
* Prints the XML and RSS namespace
|
||||
*/
|
||||
private function printHead(): void
|
||||
{
|
||||
$out = '<?xml version="1.0" encoding="utf-8"?>' . "\n";
|
||||
|
||||
if ($this->version == RSS2)
|
||||
{
|
||||
$out .= '<rss version="2.0"
|
||||
xmlns:content="http://purl.org/rss/1.0/modules/content/"
|
||||
xmlns:wfw="http://wellformedweb.org/CommentAPI/"
|
||||
>' . PHP_EOL;
|
||||
}
|
||||
elseif ($this->version == RSS1)
|
||||
{
|
||||
$out .= '<rdf:RDF
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns="http://purl.org/rss/1.0/"
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
>' . PHP_EOL;
|
||||
}
|
||||
elseif ($this->version == ATOM)
|
||||
{
|
||||
$out .= '<feed xmlns="http://www.w3.org/2005/Atom">' . PHP_EOL;
|
||||
}
|
||||
echo $out;
|
||||
}
|
||||
|
||||
/**
|
||||
* Closes the open tags at the end of the file
|
||||
*/
|
||||
private function printTail(): void
|
||||
{
|
||||
if ($this->version == RSS2)
|
||||
{
|
||||
echo '</channel>' . PHP_EOL . '</rss>';
|
||||
}
|
||||
elseif ($this->version == RSS1)
|
||||
{
|
||||
echo '</rdf:RDF>';
|
||||
}
|
||||
elseif ($this->version == ATOM)
|
||||
{
|
||||
echo '</feed>';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a single node in XML format
|
||||
*
|
||||
* @param string $tagName Name of the tag
|
||||
* @param mixed $tagContent Tag value as a string or an array of nested tags in 'tagName' => 'tagValue' format
|
||||
* @param array|null $attributes Attributes (if any) in 'attrName' => 'attrValue' format
|
||||
* @return string Formatted XML tag
|
||||
*/
|
||||
private function makeNode(string $tagName, $tagContent, ?array $attributes = null): string
|
||||
{
|
||||
$nodeText = '';
|
||||
$attrText = '';
|
||||
|
||||
if (is_array($attributes))
|
||||
{
|
||||
foreach ($attributes as $key => $value)
|
||||
{
|
||||
$attrText .= " $key=\"$value\"";
|
||||
}
|
||||
}
|
||||
|
||||
if (is_array($tagContent) && $this->version == RSS1)
|
||||
{
|
||||
$attrText = ' rdf:parseType="Resource"';
|
||||
}
|
||||
|
||||
$attrText .= (in_array($tagName, $this->CDATAEncoding) && $this->version == ATOM) ? ' type="html" ' : '';
|
||||
$nodeText .= (in_array($tagName, $this->CDATAEncoding)) ? "<{$tagName}{$attrText}><![CDATA[" : "<{$tagName}{$attrText}>";
|
||||
|
||||
if (is_array($tagContent))
|
||||
{
|
||||
foreach ($tagContent as $key => $value)
|
||||
{
|
||||
$nodeText .= $this->makeNode($key, $value);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$nodeText .= (in_array($tagName, $this->CDATAEncoding)) ? $tagContent : htmlentities($tagContent);
|
||||
}
|
||||
|
||||
$nodeText .= (in_array($tagName, $this->CDATAEncoding)) ? "]]></$tagName>" : "</$tagName>";
|
||||
|
||||
return $nodeText . PHP_EOL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prints channel elements
|
||||
*/
|
||||
private function printChannels(): void
|
||||
{
|
||||
// Start channel tag
|
||||
switch ($this->version)
|
||||
{
|
||||
case RSS2:
|
||||
echo '<channel>' . PHP_EOL;
|
||||
break;
|
||||
case RSS1:
|
||||
echo (isset($this->data['ChannelAbout'])) ? "<channel rdf:about=\"{$this->data['ChannelAbout']}\">" : "<channel rdf:about=\"{$this->channels['link']}\">";
|
||||
break;
|
||||
}
|
||||
|
||||
// Print items of channel
|
||||
foreach ($this->channels as $key => $value)
|
||||
{
|
||||
if ($this->version == ATOM && $key == 'link')
|
||||
{
|
||||
// ATOM prints the link element as an href attribute
|
||||
echo $this->makeNode($key, '', ['href' => $value]);
|
||||
// Add the id for ATOM
|
||||
echo $this->makeNode('id', $this->uuid($value, 'urn:uuid:'));
|
||||
}
|
||||
else if ($this->version == ATOM && $key == 'feedUrl')
|
||||
{
|
||||
echo $this->makeNode('link', '', ['rel' => 'self', 'href' => $value]);
|
||||
}
|
||||
else
|
||||
{
|
||||
echo $this->makeNode($key, $value);
|
||||
}
|
||||
}
|
||||
|
||||
// RSS 1.0 has a special tag <rdf:Seq> with channel
|
||||
if ($this->version == RSS1)
|
||||
{
|
||||
echo "<items>" . PHP_EOL . "<rdf:Seq>" . PHP_EOL;
|
||||
foreach ($this->items as $item)
|
||||
{
|
||||
$thisItems = $item->getElements();
|
||||
echo "<rdf:li resource=\"{$thisItems['link']['content']}\"/>" . PHP_EOL;
|
||||
}
|
||||
echo "</rdf:Seq>" . PHP_EOL . "</items>" . PHP_EOL . "</channel>" . PHP_EOL;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Prints formatted feed items
|
||||
*/
|
||||
private function printItems(): void
|
||||
{
|
||||
foreach ($this->items as $item)
|
||||
{
|
||||
$thisItems = $item->getElements();
|
||||
|
||||
// The argument is printed as rdf:about attribute of item in RSS 1.0
|
||||
echo $this->startItem($thisItems['link']['content']);
|
||||
|
||||
foreach ($thisItems as $feedItem)
|
||||
{
|
||||
echo $this->makeNode($feedItem['name'], $feedItem['content'], $feedItem['attributes']);
|
||||
}
|
||||
echo $this->endItem();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes the starting tag of items
|
||||
*
|
||||
* @param string|false $about The value of about tag, which is used only for RSS 1.0
|
||||
*/
|
||||
private function startItem($about = false): void
|
||||
{
|
||||
if ($this->version == RSS2)
|
||||
{
|
||||
echo '<item>' . PHP_EOL;
|
||||
}
|
||||
elseif ($this->version == RSS1)
|
||||
{
|
||||
if ($about)
|
||||
{
|
||||
echo "<item rdf:about=\"$about\">" . PHP_EOL;
|
||||
}
|
||||
else
|
||||
{
|
||||
die("link element is not set.\n It's required for RSS 1.0 to be used as the about attribute of the item");
|
||||
}
|
||||
}
|
||||
elseif ($this->version == ATOM)
|
||||
{
|
||||
echo "<entry>" . PHP_EOL;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Closes the feed item tag
|
||||
*/
|
||||
private function endItem(): void
|
||||
{
|
||||
if ($this->version == RSS2 || $this->version == RSS1)
|
||||
{
|
||||
echo '</item>' . PHP_EOL;
|
||||
}
|
||||
elseif ($this->version == ATOM)
|
||||
{
|
||||
echo "</entry>" . PHP_EOL;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the Feed URL
|
||||
* @param string $string - The URL of the feed
|
||||
* @return void
|
||||
*/
|
||||
public function setFeedURL(string $string): void
|
||||
{
|
||||
$this->setChannelElement("feedUrl", $string);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Define constants for RSS 1.0, RSS 2.0, and Atom
|
||||
const RSS1 = 'RSS 1.0';
|
||||
const RSS2 = 'RSS 2.0';
|
||||
const ATOM = 'ATOM';
|
@ -65,7 +65,12 @@ class middleware
|
||||
$app->add(function ($request, $handler)
|
||||
{
|
||||
$response = $handler->handle($request);
|
||||
return $response->withHeader("Content-Type", "application/json");
|
||||
$contentType = $response->getHeaderLine("Content-Type");
|
||||
if (empty($contentType) || $contentType === "text/html")
|
||||
{
|
||||
return $response->withHeader("Content-Type", "application/json");
|
||||
}
|
||||
return $response;
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -73,6 +73,10 @@ article {
|
||||
padding: 0 2em;
|
||||
}
|
||||
|
||||
article a {
|
||||
padding: 0 1em;
|
||||
}
|
||||
|
||||
article a::before,
|
||||
article a::after {
|
||||
visibility: hidden;
|
||||
@ -81,7 +85,7 @@ article a::after {
|
||||
}
|
||||
|
||||
article a::before {
|
||||
content: '<';
|
||||
content: ' <';
|
||||
margin-left: -0.5em;
|
||||
}
|
||||
|
||||
@ -133,7 +137,7 @@ div.authorInfo h3 {
|
||||
grid-column: span 2;
|
||||
}
|
||||
|
||||
div.otherPosts {
|
||||
div.otherPosts, div.newsletter, div.feeds {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: flex-start;
|
||||
@ -143,10 +147,36 @@ div.otherPosts {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
div.otherPosts a {
|
||||
div.otherPosts a, div.feeds a {
|
||||
padding: 0.5em 1em;
|
||||
}
|
||||
|
||||
div.newsletter form input[type="submit"] {
|
||||
margin-top: 1em;
|
||||
padding: 0.5em 1em;
|
||||
}
|
||||
|
||||
div.feeds .icons {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: space-around;
|
||||
align-items: flex-start;
|
||||
gap: 0.5em;
|
||||
flex-wrap: wrap-reverse;
|
||||
}
|
||||
|
||||
div.feeds h2 {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
div.feeds i.fa-solid.fa-rss {
|
||||
font-size: 2em;
|
||||
}
|
||||
|
||||
div.feeds img.atom, div.feeds img.json {
|
||||
width: 2em;
|
||||
}
|
||||
|
||||
div.categories {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
|
@ -10,6 +10,18 @@
|
||||
@import "category.css";
|
||||
@import "prism.css";
|
||||
|
||||
.policy {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
justify-content: center;
|
||||
padding-left: 5em;
|
||||
padding-bottom: 5em;
|
||||
}
|
||||
|
||||
.policy h3 {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
/**** Media Queries *****/
|
||||
|
||||
@ -78,27 +90,46 @@
|
||||
align-items: stretch;
|
||||
justify-content: space-around;
|
||||
border-bottom: 5px solid var(--mutedGrey);
|
||||
}
|
||||
|
||||
div.otherPosts, div.authorInfo {
|
||||
border-bottom: none;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
aside.sideContent > div.authorInfo {
|
||||
grid-template-columns: 1fr 1fr 1fr;
|
||||
grid-template-columns: 4fr 1fr 1fr 1fr;
|
||||
flex-basis: 100%;
|
||||
}
|
||||
|
||||
aside.sideContent > div.authorInfo .picture {
|
||||
grid-row: 1;
|
||||
grid-column: span 3;
|
||||
grid-row: span 3;
|
||||
}
|
||||
|
||||
div.byLine {
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
}
|
||||
|
||||
div.byLine h3:last-child {
|
||||
border-left: none;
|
||||
padding-left: 0;
|
||||
}
|
||||
|
||||
aside.sideContent > div.authorInfo h3 {
|
||||
grid-column: span 3;
|
||||
grid-column-start: 2;
|
||||
grid-column-end: end;
|
||||
grid-row: 3;
|
||||
}
|
||||
|
||||
div.otherPosts {
|
||||
aside.sideContent > div.categories {
|
||||
flex-basis: 100%;
|
||||
}
|
||||
|
||||
aside.sideContent > div.otherPosts {
|
||||
border-bottom: 5px solid var(--mutedGrey);
|
||||
}
|
||||
|
||||
|
||||
div.otherPosts, div.newsletter, div.feeds {
|
||||
justify-content: space-between;
|
||||
width: 50%;
|
||||
}
|
||||
|
||||
aside.sideContent > div {
|
||||
@ -125,41 +156,14 @@
|
||||
}
|
||||
|
||||
/***** Individual Blog Posts ***/
|
||||
aside.sideContent {
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
aside.sideContent > div.authorInfo {
|
||||
grid-template-columns: 2fr 1fr;
|
||||
border-bottom: 5px solid var(--mutedGrey);
|
||||
flex-basis: 100%;
|
||||
}
|
||||
|
||||
aside.sideContent > div.authorInfo .picture {
|
||||
grid-row: span 3;
|
||||
grid-column: initial;
|
||||
}
|
||||
|
||||
div.byLine {
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
}
|
||||
|
||||
div.byLine h3:last-child {
|
||||
border-left: none;
|
||||
padding-left: 0;
|
||||
grid-template-columns: 2fr 1fr 1fr;
|
||||
grid-template-rows: 1fr 1fr;
|
||||
}
|
||||
|
||||
aside.sideContent > div.authorInfo h3 {
|
||||
grid-column: span 2;
|
||||
}
|
||||
|
||||
aside.sideContent > div.categories {
|
||||
flex-basis: 100%;
|
||||
}
|
||||
|
||||
aside.sideContent > div.otherPosts {
|
||||
border-bottom: 5px solid var(--mutedGrey);
|
||||
grid-row: 2;
|
||||
}
|
||||
|
||||
}
|
||||
@ -183,6 +187,7 @@
|
||||
|
||||
aside.sideContent > div.authorInfo {
|
||||
grid-template-columns: 1fr 1fr 1fr;
|
||||
grid-template-rows: repeat(3, auto);
|
||||
border-top: 5px solid var(--mutedGrey);
|
||||
}
|
||||
|
||||
@ -194,4 +199,8 @@
|
||||
aside.sideContent > div.authorInfo h3 {
|
||||
grid-column: span 3;
|
||||
}
|
||||
|
||||
div.otherPosts, div.newsletter, div.feeds {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
199
src/blog/imgs/atomFeed.svg
Normal file
199
src/blog/imgs/atomFeed.svg
Normal file
@ -0,0 +1,199 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||
<svg
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
id="svg2"
|
||||
inkscape:export-ydpi="90"
|
||||
inkscape:export-filename="C:\Users\Ilia\SVG\Atom_icon.png"
|
||||
viewBox="0 0 285.45 280.91"
|
||||
inkscape:export-xdpi="90"
|
||||
version="1.1"
|
||||
inkscape:version="0.91pre3 r13670"
|
||||
sodipodi:docname="_svgclean2.svg"
|
||||
>
|
||||
<sodipodi:namedview
|
||||
id="base"
|
||||
fit-margin-left="10"
|
||||
inkscape:zoom="1.979899"
|
||||
borderopacity="1.0"
|
||||
inkscape:current-layer="layer1"
|
||||
inkscape:cx="30.185218"
|
||||
inkscape:cy="330.70792"
|
||||
inkscape:snap-bbox-midpoints="true"
|
||||
inkscape:object-paths="true"
|
||||
inkscape:window-maximized="0"
|
||||
inkscape:snap-bbox="true"
|
||||
showgrid="false"
|
||||
fit-margin-right="10"
|
||||
inkscape:snap-nodes="false"
|
||||
units="mm"
|
||||
inkscape:document-units="px"
|
||||
inkscape:window-x="0"
|
||||
inkscape:window-y="0"
|
||||
inkscape:snap-smooth-nodes="true"
|
||||
inkscape:window-width="718"
|
||||
fit-margin-bottom="10"
|
||||
inkscape:snap-page="false"
|
||||
inkscape:pageopacity="0.0"
|
||||
inkscape:pageshadow="2"
|
||||
pagecolor="#ffffff"
|
||||
inkscape:window-height="645"
|
||||
fit-margin-top="10"
|
||||
/>
|
||||
<g
|
||||
id="layer1"
|
||||
inkscape:label="Layer 1"
|
||||
inkscape:groupmode="layer"
|
||||
transform="translate(-.31824 -771.33)"
|
||||
>
|
||||
<g
|
||||
id="g8434"
|
||||
transform="matrix(9.7655,0,0,9.7655,-2.8077,-9219.8)"
|
||||
>
|
||||
<ellipse
|
||||
id="path3089"
|
||||
style="fill:#FFFFFF"
|
||||
rx="2.0633"
|
||||
ry="2.0618"
|
||||
cy="1037.7"
|
||||
cx="14.936"
|
||||
/>
|
||||
<path
|
||||
id="circle3412"
|
||||
style="fill:#FFFFFF"
|
||||
inkscape:connector-curvature="0"
|
||||
transform="translate(0,1020.4)"
|
||||
d="m15.045 2.7051v3.3496a11.266 11.258 0 0 1 11.154 11.213h3.3516a14.617 14.606 0 0 0 -14.506 -14.563z"
|
||||
/>
|
||||
<path
|
||||
id="circle3428"
|
||||
style="fill:#FFFFFF"
|
||||
inkscape:connector-curvature="0"
|
||||
transform="translate(0,1020.4)"
|
||||
d="m15.045 9.4453v2.9492a4.9226 4.919 0 0 1 4.8105 4.873h2.9492a7.8711 7.8654 0 0 0 -7.76 -7.8217z"
|
||||
/>
|
||||
</g
|
||||
>
|
||||
<g
|
||||
id="g8430"
|
||||
transform="matrix(9.7655,0,0,9.7655,-2.8077,-9219.8)"
|
||||
>
|
||||
<path
|
||||
id="path3302"
|
||||
style="color:#000000;text-indent:0;block-progression:tb;text-decoration-line:none;text-transform:none;fill:#FFFFFF"
|
||||
inkscape:connector-curvature="0"
|
||||
transform="translate(0,1020.4)"
|
||||
d="m14.865 12.807c-3.944 0.0057-7.5137 0.47474-10.127 1.2383-1.3146 0.3841-2.3876 0.844-3.1562 1.375-0.76861 0.5309-1.2617 1.1648-1.2617 1.8906 0 0.7259 0.49311 1.3617 1.2617 1.8926 0.76861 0.5309 1.8417 0.97918 3.1562 1.3633 2.6292 0.7682 6.2246 1.2402 10.197 1.2402 3.9727 0 7.57-0.47204 10.199-1.2402 1.3146-0.3841 2.3857-0.83238 3.1543-1.3633 0.71878-0.49648 1.1813-1.0881 1.2402-1.7559h-0.64453c-0.05963 0.38822-0.35991 0.79958-0.9668 1.2188-0.67801 0.4684-1.6967 0.90955-2.9688 1.2812-2.5442 0.7433-6.0921 1.209-10.014 1.209-3.9216 0-7.4675-0.46568-10.012-1.209-1.2721-0.3717-2.3005-0.81285-2.9785-1.2812-0.67801-0.4683-0.98438-0.92797-0.98438-1.3555 0-0.4274 0.30637-0.89488 0.98438-1.3633 0.67801-0.4683 1.7064-0.90965 2.9785-1.2812 2.5286-0.73883 6.0485-1.2033 9.9414-1.209v-0.65039z"
|
||||
/>
|
||||
<circle
|
||||
id="path8416"
|
||||
cy="1034.4"
|
||||
cx="6.1108"
|
||||
r=".75893"
|
||||
style="fill:#FFFFFF"
|
||||
/>
|
||||
</g
|
||||
>
|
||||
<g
|
||||
id="g8439"
|
||||
transform="matrix(9.7655,0,0,9.7655,-2.8077,-9219.8)"
|
||||
>
|
||||
<g
|
||||
id="g8426"
|
||||
>
|
||||
<path
|
||||
id="path3304"
|
||||
d="m14.865 12.236c-0.72049 0.36795-1.4472 0.75012-2.1816 1.1738-3.4404 1.9848-6.3203 4.1911-8.2129 6.1699-0.94628 0.9894-1.6489 1.914-2.0488 2.7578-0.39997 0.8438-0.50968 1.639-0.14648 2.2676s1.1078 0.93201 2.0391 1.0078c0.93131 0.076 2.0893-0.06106 3.4199-0.38476 2.6613-0.6484 6.0127-2.0366 9.4531-4.0215 2.0899-1.2056 3.9354-2.4914 5.5156-3.7598h-1.0293c-1.411 1.0794-3.0286 2.1662-4.8125 3.1953-3.3962 1.9593-6.7001 3.3277-9.2754 3.9551-1.2876 0.3137-2.3914 0.43995-3.2129 0.37305-0.82153-0.067-1.3291-0.31535-1.543-0.68555-0.21387-0.3702-0.16922-0.92367 0.18359-1.668 0.35282-0.7444 1.014-1.6364 1.9297-2.5938 1.8314-1.9149 4.6702-4.0894 8.0664-6.0488 0.62532-0.36075 1.2403-0.68024 1.8555-1v-0.73828z"
|
||||
style="color:#000000;text-indent:0;block-progression:tb;text-decoration-line:none;text-transform:none;fill:#FFFFFF"
|
||||
transform="translate(0,1020.4)"
|
||||
inkscape:connector-curvature="0"
|
||||
/>
|
||||
<circle
|
||||
id="circle8418"
|
||||
cy="1045.1"
|
||||
cx="2.8068"
|
||||
r=".75893"
|
||||
style="fill:#FFFFFF"
|
||||
/>
|
||||
</g
|
||||
>
|
||||
<g
|
||||
id="g8422"
|
||||
>
|
||||
<path
|
||||
id="path3300"
|
||||
d="m11.682 3.1523c-0.17928-0.012267-0.35779 0.00188-0.5332 0.048828-0.70164 0.1879-1.1876 0.82968-1.502 1.709-0.31431 0.8792-0.47091 2.0283-0.50195 3.3965-0.062086 2.7365 0.4132 6.3316 1.4414 10.166s2.4148 7.1846 3.8379 9.5234c0.71153 1.1695 1.4246 2.087 2.1367 2.6914 0.71217 0.6045 1.4527 0.91642 2.1543 0.72852 0.70164-0.1879 1.1876-0.82783 1.502-1.707 0.31431-0.8793 0.48067-2.034 0.51172-3.4023 0.05491-2.42-0.33654-5.5249-1.1328-8.8594h-0.66797c0.81117 3.3483 1.2082 6.4642 1.1543 8.8418-0.03005 1.3241-0.19344 2.4196-0.4707 3.1953-0.27726 0.7756-0.64933 1.2019-1.0625 1.3125s-0.93818-0.07442-1.5664-0.60742c-0.62822-0.5332-1.3193-1.4036-2.0078-2.5352-1.377-2.2632-2.7448-5.5645-3.7598-9.3496-1.015-3.785-1.482-7.3305-1.4219-9.9785 0.030055-1.324 0.18954-2.4314 0.4668-3.207s0.64152-1.1882 1.0547-1.2988c0.41317-0.1106 0.946 0.062403 1.5742 0.5957 0.6182 0.52469 1.2989 1.3866 1.9766 2.4922v-1.1836c-0.521-0.7474-1.043-1.3562-1.561-1.7957-0.534-0.4534-1.086-0.7406-1.623-0.7774z"
|
||||
style="color:#000000;text-indent:0;block-progression:tb;text-decoration-line:none;text-transform:none;fill:#FFFFFF"
|
||||
transform="translate(0,1020.4)"
|
||||
inkscape:connector-curvature="0"
|
||||
/>
|
||||
<circle
|
||||
id="circle8420"
|
||||
cx="20.264"
|
||||
style="fill:#FFFFFF"
|
||||
r=".75893"
|
||||
cy="1043.4"
|
||||
/>
|
||||
</g
|
||||
>
|
||||
</g
|
||||
>
|
||||
</g
|
||||
>
|
||||
<metadata
|
||||
id="metadata19"
|
||||
>
|
||||
<rdf:RDF
|
||||
>
|
||||
<cc:Work
|
||||
>
|
||||
<dc:format
|
||||
>image/svg+xml
|
||||
</dc:format
|
||||
>
|
||||
<dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage"
|
||||
/>
|
||||
<cc:license
|
||||
rdf:resource="http://creativecommons.org/licenses/publicdomain/"
|
||||
/>
|
||||
<dc:publisher
|
||||
>
|
||||
<cc:Agent
|
||||
rdf:about="http://openclipart.org/"
|
||||
>
|
||||
<dc:title
|
||||
>Openclipart
|
||||
</dc:title
|
||||
>
|
||||
</cc:Agent
|
||||
>
|
||||
</dc:publisher
|
||||
>
|
||||
</cc:Work
|
||||
>
|
||||
<cc:License
|
||||
rdf:about="http://creativecommons.org/licenses/publicdomain/"
|
||||
>
|
||||
<cc:permits
|
||||
rdf:resource="http://creativecommons.org/ns#Reproduction"
|
||||
/>
|
||||
<cc:permits
|
||||
rdf:resource="http://creativecommons.org/ns#Distribution"
|
||||
/>
|
||||
<cc:permits
|
||||
rdf:resource="http://creativecommons.org/ns#DerivativeWorks"
|
||||
/>
|
||||
</cc:License
|
||||
>
|
||||
</rdf:RDF
|
||||
>
|
||||
</metadata
|
||||
>
|
||||
</svg
|
||||
>
|
After Width: | Height: | Size: 8.0 KiB |
10
src/blog/imgs/jsonFeed.svg
Normal file
10
src/blog/imgs/jsonFeed.svg
Normal file
@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" standalone="no"?>
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" >
|
||||
<!-- Uploaded to: SVG Repo, www.svgrepo.com, Generator: SVG Repo Mixer Tools -->
|
||||
<svg width="800px" height="800px" viewBox="-10 -5 1034 1034" xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1">
|
||||
<path fill="#FFFFFF"
|
||||
d="M854 175q-27 0 -46 19t-19 45.5t18.5 45t45 18.5t45.5 -18.5t19 -45t-18.5 -45.5t-44.5 -19zM205 192l-34 34q-83 83 -88 154t68 144l82 82q45 46 48.5 78t-33.5 69v0q-16 19 -15.5 44.5t18.5 43.5t43.5 18.5t44.5 -15.5l1 1q25 -25 47 -32t45.5 4.5t53.5 41.5l95 96
|
||||
q75 74 147.5 70t155.5 -87l33 -34l-71 -72l-18 18q-47 47 -84 47.5t-82 -44.5l-112 -112q-86 -86 -169 -17l-11 -11q35 -42 31.5 -83t-45.5 -82l-100 -101q-31 -31 -40.5 -56.5t1 -51.5t42.5 -59l17 -17zM703 326q-28 0 -46.5 19t-18.5 45.5t18.5 45.5t45 19t45.5 -19
|
||||
t19 -45.5t-18.5 -45t-44.5 -19.5zM551 477q-27 0 -46 19t-19 45.5t19 45.5t45.5 19t45.5 -19t19 -45.5t-19 -45t-45 -19.5z"/>
|
||||
</svg>
|
After Width: | Height: | Size: 1.0 KiB |
@ -17,6 +17,9 @@
|
||||
<meta name="author" content="Rohit Pai">
|
||||
<link rel="stylesheet" href="/blog/css/main.css">
|
||||
<script src="https://kit.fontawesome.com/ed3c25598e.js" crossorigin="anonymous"></script>
|
||||
<script type='text/javascript'
|
||||
src='https://platform-api.sharethis.com/js/sharethis.js#property=6550cdc47a115e0012964576&product=sop'
|
||||
async='async'></script>
|
||||
</head>
|
||||
<body>
|
||||
<nav>
|
||||
@ -70,7 +73,12 @@
|
||||
</main>
|
||||
|
||||
<footer class="flexRow">
|
||||
<div class="spacer"></div>
|
||||
<div class="nav">
|
||||
<ul>
|
||||
<li><a href="/blog/policy/privacy" class="link">privacy policy</a></li>
|
||||
<li><a href="/blog/policy/cookie" class="link">cookie policy</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<p>© <span id="year"></span> Rohit Pai all rights reserved</p>
|
||||
<div class="button">
|
||||
<button id="goBackToTop"><i class="fa-solid fa-chevron-up"></i></button>
|
||||
|
@ -68,6 +68,21 @@ function goToURL(url)
|
||||
return;
|
||||
}
|
||||
|
||||
if (urlArray[2] === 'policy')
|
||||
{
|
||||
if (urlArray[3] === 'privacy')
|
||||
{
|
||||
loadPrivacyPolicy();
|
||||
return;
|
||||
}
|
||||
|
||||
if (urlArray[3] === 'cookie')
|
||||
{
|
||||
loadCookiePolicy();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
show404();
|
||||
|
||||
}
|
||||
@ -92,6 +107,17 @@ document.querySelector('#searchField').addEventListener('keyup', e =>
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Creates a formatted date
|
||||
* @param {string} dateString - the date string
|
||||
* @returns {string} the formatted date
|
||||
*/
|
||||
function createFormattedDate(dateString)
|
||||
{
|
||||
let formattedDate = new Date(dateString);
|
||||
return formattedDate.toLocaleDateString('en-GB', { day: '2-digit', month: 'short', year: 'numeric' });
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a large post element
|
||||
* @param post the post object
|
||||
@ -124,12 +150,13 @@ function createLargePost(post)
|
||||
{
|
||||
categories = categories.substring(0, categories.length - 2);
|
||||
}
|
||||
let dateModifiedString = createFormattedDate(post.dateModified);
|
||||
|
||||
postContent.innerHTML = `
|
||||
<h2>${post.title}</h2>
|
||||
<h3>Last updated: ${post.dateModified} | ${categories}</h3>
|
||||
<h3>Last updated: ${dateModifiedString} | ${categories}</h3>
|
||||
<p>${post.abstract}</p>
|
||||
<a href="/blog/post/${post.title}#disqus_thread" class="btn btnPrimary">See Post</a>
|
||||
<a href="/blog/post/${post.title}" class="btn btnPrimary">See Post</a>
|
||||
`;
|
||||
content.appendChild(postContent);
|
||||
outerContent.appendChild(content);
|
||||
@ -315,8 +342,8 @@ async function createSideContent()
|
||||
</g>
|
||||
</svg>
|
||||
</a>
|
||||
<h3>Avid Full Stack Dev | Uni of Notts Grad | Amateur Blogger</h3>
|
||||
|
||||
<h3>Avid Full Stack Dev | Uni of Notts Grad | Amateur Blogger</h3>
|
||||
</div>
|
||||
<div class="otherPosts">
|
||||
<h2>latest post</h2>
|
||||
@ -330,14 +357,81 @@ async function createSideContent()
|
||||
<p>${featuredPost.abstract}</p>
|
||||
<a href="/blog/post/${featuredPost.title}" class="btn btnPrimary boxShadowIn boxShadowOut">See Post</a>
|
||||
</div>
|
||||
<div class="newsletter">
|
||||
<h3>Sign up to the newsletter</h3>
|
||||
<form action="newsletter.html">
|
||||
<div class="formControl">
|
||||
<label for="email">Email</label>
|
||||
<input type="email" id="email" name="email" placeholder="Email" required>
|
||||
</div>
|
||||
<input type="submit" value="Sign Up">
|
||||
</form>
|
||||
</div>
|
||||
<div class="feeds">
|
||||
<h2>feeds</h2>
|
||||
<div class="icons">
|
||||
<a href="https://rohitpai.co.uk/api/blog/feed/rss" class="btn btnPrimary" title="RSS"><i class="fa-solid fa-rss"></i></a>
|
||||
<a href="https://rohitpai.co.uk/blog/feed/atom" class="btn btnPrimary" title="Atom"><img class="atom" src="/blog/imgs/atomFeed.svg" alt="Atom"></a>
|
||||
<a href="https://rohitpai.co.uk/blog/feed/json" class="btn btnPrimary" title="JSON"><img class="json" src="/blog/imgs/jsonFeed.svg" alt="JSON"></a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="categories">
|
||||
<h2>categories</h2>
|
||||
${categories}
|
||||
</div>
|
||||
|
||||
`;
|
||||
return sideContent;
|
||||
}
|
||||
|
||||
function createMetaTag(nameOrProperty, attribute, value)
|
||||
{
|
||||
let existingTag = document.querySelector(`meta[name="${nameOrProperty}"], meta[property="${nameOrProperty}"]`);
|
||||
|
||||
if (!existingTag)
|
||||
{
|
||||
// If the meta tag doesn't exist, create it
|
||||
let newTag = document.createElement('meta');
|
||||
newTag.setAttribute(nameOrProperty.includes('name') ? 'name' : 'property', nameOrProperty);
|
||||
newTag.setAttribute(attribute, value);
|
||||
document.head.appendChild(newTag);
|
||||
return;
|
||||
}
|
||||
|
||||
existingTag.setAttribute(attribute, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* inserts the meta tags
|
||||
* @param json - the json
|
||||
*/
|
||||
function insertMetaTags(json)
|
||||
{
|
||||
let metaDesc = document.querySelector('meta[name="description"]');
|
||||
metaDesc.setAttribute('content', json.abstract);
|
||||
|
||||
// Twitter meta tags
|
||||
createMetaTag('twitter:title', 'content', json.title);
|
||||
createMetaTag('twitter:description', 'content', json.abstract);
|
||||
createMetaTag('twitter:image', 'content', json.headerImg);
|
||||
|
||||
// Open Graph (Facebook) meta tags
|
||||
createMetaTag('og:title', 'content', json.title);
|
||||
createMetaTag('og:description', 'content', json.abstract);
|
||||
createMetaTag('og:image', 'content', json.headerImg);
|
||||
createMetaTag('og:url', 'content', window.location.href);
|
||||
createMetaTag('og:type', 'content', 'blog');
|
||||
createMetaTag('og:site_name', 'content', 'Rohit Pai\'s Blog');
|
||||
createMetaTag('og:locale', 'content', 'en_GB');
|
||||
|
||||
//Keywords
|
||||
let metKeywords = document.querySelector('meta[name="keywords"]');
|
||||
let keywords = metKeywords.getAttribute('content');
|
||||
keywords += `, ${json.keywords}`;
|
||||
metKeywords.setAttribute('content', keywords);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Trys to load the individual post if not runs the 404 function
|
||||
* @param title
|
||||
@ -355,6 +449,8 @@ async function loadIndividualPost(title)
|
||||
|
||||
await res.json().then(async json =>
|
||||
{
|
||||
//replace meta description
|
||||
insertMetaTags(json);
|
||||
// create the post
|
||||
let post = document.createElement('section');
|
||||
post.classList.add('post');
|
||||
@ -365,8 +461,11 @@ async function loadIndividualPost(title)
|
||||
article.innerHTML = `
|
||||
<h1>${json.title}</h1>
|
||||
<div class="byLine">
|
||||
<h3>Last updated: ${json.dateModified}</h3>
|
||||
<h3>Published: ${createFormattedDate(json.dateCreated)} | Last updated: ${createFormattedDate(json.dateModified)}</h3>
|
||||
<h3>${createButtonCategories([csvToArray(json.categories.replace(/\s*,\s*/g, ','))])}</h3>
|
||||
<div class="sharethis-inline-share-buttons" data-url="https://rohitpai.co.uk/blog/post/${title}"
|
||||
data-title="${json.title}" data-description="${json.abstract}"
|
||||
data-image="https://rohitpai.co.uk/${json.headerImg}" data-username="@rohitpai123"></div>
|
||||
</div>
|
||||
<div class="cover" style="background-image: url('${json.headerImg}')"></div>
|
||||
${json.body}
|
||||
@ -464,6 +563,10 @@ function loadPostsByCategory(category)
|
||||
}));
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the search results
|
||||
* @param searchTerm the search term
|
||||
*/
|
||||
function loadSearchResults(searchTerm)
|
||||
{
|
||||
document.title = 'Rohit Pai - Search Results for ' + decodeURI(searchTerm);
|
||||
@ -492,6 +595,180 @@ function loadSearchResults(searchTerm)
|
||||
}));
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the privacy policy
|
||||
*/
|
||||
function loadPrivacyPolicy()
|
||||
{
|
||||
document.querySelector('#main').innerHTML = `
|
||||
<div class="policy">
|
||||
<h2>Privacy Policy</h2>
|
||||
<p>Last Updated: Nov 12, 2023</p>
|
||||
<p>
|
||||
Thank you for visiting the Privacy Policy of Rohit Pai's Blog. This Privacy Policy explains how I, Rohit Pai, collect, use, and share information about you (“you”, “yours” or “user”) when you access or use my website (“Services”). You are responsible for any third-party data you provide or share through the Services and confirm that you have the third party's consent to provide such data to me.
|
||||
</p>
|
||||
<br>
|
||||
|
||||
<h3>Sources of Information and Tracking Technologies</h3>
|
||||
<p>
|
||||
I collect information that you directly provide to me, such as when you submit a form or send me a message with your information. I may also receive information about you from my partners, including but not limited to distribution partners, data services, and marketing firms. I may combine this information with other information I collect from or about you. In these cases, my Privacy Policy governs the handling of the combined information. I and my partners may collect the information noted in this privacy policy using cookies, web beacons, pixels, and other similar technologies. These technologies are used for authentication, to store your preferences or progress, for analytics, and for advertising and analytics. Cookies are small text files stored on your computer. You can set your browser to reject cookies altogether, to reject my cookies in particular, or to delete cookies. However, this may cause some or all of my Services not to function on your computer or device.
|
||||
</p>
|
||||
<br>
|
||||
<h3>How I Use Your Information</h3>
|
||||
<p>
|
||||
I use information I collect about you to provide, maintain, and improve my Services and other interactions I have with you. For example, I use the information collected to:
|
||||
</p>
|
||||
<ul>
|
||||
<li>Facilitate and improve your online experience;</li>
|
||||
<li>Provide and deliver products and services, perform authentication, process transactions and returns, and send you related information, including confirmations, receipts, invoices, customer experience surveys, and product or Services-related notices;</li>
|
||||
<li>Process and deliver promotions;</li>
|
||||
<li>Respond to your comments and questions and provide customer service;</li>
|
||||
<li>If you have indicated to me that you wish to receive notifications or promotional messages;</li>
|
||||
<li>Detect, investigate and prevent fraudulent transactions and other illegal activities and protect my rights and property and others;</li>
|
||||
<li>Comply with my legal and financial obligations;</li>
|
||||
<li>Monitor and analyze trends, usage, and activities;</li>
|
||||
<li>Provide and allow my partners to provide advertising and marketing targeted toward your interests.</li>
|
||||
</ul>
|
||||
<br>
|
||||
<h3>How I May Share Information</h3>
|
||||
<p>
|
||||
I may share your Personal Information in the following situations:
|
||||
</p>
|
||||
<ul>
|
||||
<li>
|
||||
<strong><em>Third Party Services Providers.</em></strong>
|
||||
I may share data with service providers, vendors, contractors, or agents who complete transactions or perform services on my behalf, such as those that assist me with my business and internal operations like shipping and delivery, payment processing, fraud prevention, customer service, gift cards, experiences, personalization, marketing, and advertising;
|
||||
</li>
|
||||
<li>
|
||||
<strong><em>Change in Business.</em></strong>
|
||||
I may share data in connection with a corporate business transaction, such as a merger or acquisition of all or a portion of my business to another company, joint venture, corporate reorganization, insolvency or bankruptcy, financing or sale of company assets;
|
||||
</li>
|
||||
<li>
|
||||
<strong><em>To Comply with Law.</em></strong>
|
||||
I may share data to facilitate legal process from lawful requests by public authorities, including to meet national security or law enforcement demands as permitted by law.
|
||||
</li>
|
||||
<li>
|
||||
<strong><em>With Your Consent.</em></strong>
|
||||
I may share data with third parties when I have your consent.
|
||||
</li>
|
||||
<li>
|
||||
<strong><em>With Advertising and Analytics Partners.</em></strong>
|
||||
See the section entitled “Advertising and Analytics” below.
|
||||
</li>
|
||||
</ul>
|
||||
<br>
|
||||
<h3>Advertising and Analytics</h3>
|
||||
<p>
|
||||
I use advertising and analytics technologies to better understand your online activity on my Services to provide personalized products and services that may interest you. I may allow third-party companies, including ad networks, to serve advertisements, provide other advertising services, and/or collect certain information when you visit my website. Third-party companies may use pseudonymized personal data (e.g., click stream information, browser type, time and date, subject of advertisements clicked or scrolled over) during your visit to this website in order to provide advertisements about goods and services likely to be of interest to you, on this website and others. To learn more about Interest-Based Advertising or to opt-out of this type of advertising, you can visit <a href="http://optout.aboutads.info/?c=2&lang=EN">AboutAds.info/choices</a> or <a href="http://optout.networkadvertising.org/?c=1">www.networkadvertising.org/choices</a>. Some third-party companies may also use non-cookie technologies, such as statistical IDs. Please keep in mind that your web browser may not permit you to block the use of these non-cookie technologies, and those browser settings that block cookies may have no effect on such techniques. If the third-party company uses the non-cookie technologies for interest-based advertising, you can opt out at <a href="http://optout.networkadvertising.org/?c=1">www.networkadvertising.org/choices</a>. Please note the industry opt out only applies to use for interest-based advertising and may not apply to use for analytics or attribution. Some websites have “do not track” features that allow you to tell a website not to track you. These features are not all uniform. I do not currently respond to those signals.
|
||||
</p>
|
||||
<br>
|
||||
<h3>Data Security</h3>
|
||||
<p>
|
||||
I implement commercially reasonable security measures designed to protect your information. Despite my best efforts, however, no security measures are completely impenetrable.
|
||||
</p>
|
||||
<br>
|
||||
<h3>Data Retention</h3>
|
||||
<p>
|
||||
I store the information I collect about you for as long as necessary for the purpose(s) for which I collected it or for other legitimate business purposes, including to meet my legal, regulatory, or other compliance obligations.
|
||||
</p>
|
||||
<br>
|
||||
|
||||
<h3>EU Privacy Rights</h3>
|
||||
|
||||
<p>Individuals located in certain countries, including the European Economic Area (EEA) and the United Kingdom, have certain statutory rights under the General Data Protection Regulation (GDPR) in relation to their personal data.</p>
|
||||
<p>To the extent information I collect is associated with an identified or identifiable natural person and is protected as personal data under GDPR, it is referred to in this Privacy Policy as “Personal Data”.</p>
|
||||
<p>
|
||||
<strong><em>Data Subject Access Requests</em></strong>
|
||||
</p>
|
||||
<p>
|
||||
Subject to any exemptions provided by law, you may have the right to request:
|
||||
</p>
|
||||
<ul>
|
||||
<li>
|
||||
a copy of the Personal Data I hold about you;
|
||||
</li>
|
||||
<li>
|
||||
to correct the Personal Data I hold about you;
|
||||
</li>
|
||||
<li>
|
||||
to delete your Account or Personal Data;
|
||||
</li>
|
||||
<li>
|
||||
to object to processing of your Personal Data for certain purposes;
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<p>
|
||||
To access your privacy rights, send me an email at rohit@rohitpai.co.uk.
|
||||
</p>
|
||||
<p>
|
||||
I will generally process requests within one month. I may need to request specific information from you to help me confirm your identity and/or the jurisdiction in which you reside. If your request is complicated or if you have made a large number of requests, it may take me longer. I will let you know if I need longer than one month to respond.
|
||||
</p>
|
||||
<p>
|
||||
<strong><em>Legal Bases For Processing Personal Data</em></strong>
|
||||
</p>
|
||||
<p>
|
||||
I may process your Personal Data under applicable data protection law on the following legal grounds:
|
||||
</p>
|
||||
<ul>
|
||||
<li>
|
||||
<strong><em>Contractual Necessity:</em></strong>
|
||||
I may process your Personal Data to enter into or perform a contract with you.
|
||||
</li>
|
||||
<li>
|
||||
<strong><em>Consent:</em></strong>
|
||||
where you have provided consent to process your Personal Data. You may withdraw your consent at any time.
|
||||
</li>
|
||||
<li>
|
||||
<strong><em>Legitimate interest:</em></strong>
|
||||
I process your Personal Data to provide my Services to you such as to provide my online user experience, communicate with you, provide customer service, market, analyze and improve my business, and to protect my Services.
|
||||
</li>
|
||||
</ul>
|
||||
<br>
|
||||
<h3>Age Limitations</h3>
|
||||
<p>
|
||||
My Service is intended for adults ages 18 years and above. I do not knowingly collect personally identifiable information from children. If you are a parent or legal guardian and think your child under 13 has given me information, please email or write to me at the address listed at the end of this Privacy Policy. Please mark your inquiries “COPPA Information Request.”
|
||||
</p>
|
||||
<br>
|
||||
<h3>Changes to this Privacy Policy</h3>
|
||||
<p>
|
||||
Rohit Pai may change this Privacy Policy from time to time. I encourage you to visit this page to stay informed. If the changes are material, I may provide you additional notice to your email address or through my Services. Your continued use of the Services indicates your acceptance of the modified Privacy Policy.
|
||||
</p>
|
||||
<br>
|
||||
<h3>Newsletters</h3>
|
||||
<p>
|
||||
You can opt in to receive my marketing emails and/or newsletters by below. I may still send you transactional messages, which include Services-related communications and responses to your questions.
|
||||
</p>
|
||||
<br>
|
||||
<h3>Storage of Information in the United States</h3>
|
||||
<p>
|
||||
Information I maintain may be stored both within and outside of the United States. If you live outside of the United States, you understand and agree that I may transfer your information to the United States, and that U.S. laws may not afford the same level of protection as those in your country.
|
||||
</p>
|
||||
<br>
|
||||
<h3>Contact Me</h3>
|
||||
<p>
|
||||
If you have questions, comments, or concerns about this Privacy Policy, you may contact me at:
|
||||
</p>
|
||||
<a href="https://rohitpai.co.uk/#contact" class="link">Contact</a>
|
||||
<a href="mailto:rohit@rohitpai.co.uk" class="link">rohit@rohitpai.co.uk</a>
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
|
||||
function loadCookiePolicy()
|
||||
{
|
||||
document.querySelector('#main').innerHTML = `
|
||||
<div class="policy">
|
||||
<h3>Cookies Policy</h3>
|
||||
<p>I only use functional cookies for the blog which includes PHP Session ID, disqus and maybe share this. I think that these are functional cookies, if you don't, you're welcome to exit the site or tell me by emailing me through the email address below, or the contact form on the contact page.</p>
|
||||
<br>
|
||||
<a href="mailto:rohit@rohitpai.co.uk" class="link">rohit@rohitpai.co.uk</a>
|
||||
<br>
|
||||
<a href="https://rohitpai.co.uk/#contact" class="link">contact</a>
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows the 404 page
|
||||
*/
|
||||
|
@ -11,6 +11,28 @@ footer .spacer {
|
||||
margin-right: auto;
|
||||
}
|
||||
|
||||
footer .nav {
|
||||
width: 100%;
|
||||
margin-right: auto;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
footer .nav ul {
|
||||
list-style: none;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: space-around;
|
||||
}
|
||||
|
||||
footer .nav ul a {
|
||||
color: #FFFFFF;
|
||||
}
|
||||
|
||||
footer p {
|
||||
margin: auto;
|
||||
width: 100%;
|
||||
|
@ -19,7 +19,7 @@ nav {
|
||||
width: 100%;
|
||||
transition: background-color 0.4s ease-in;
|
||||
color: #FFFFFF;
|
||||
z-index: 1;
|
||||
z-index: 100000000000000000000000000;
|
||||
}
|
||||
|
||||
nav.scrolled {
|
||||
|
@ -299,6 +299,9 @@ a {
|
||||
text-transform: lowercase;
|
||||
}
|
||||
|
||||
a.link {
|
||||
padding: 0 0.5em;
|
||||
}
|
||||
|
||||
a.link::before,
|
||||
a.link::after {
|
||||
@ -308,12 +311,12 @@ a.link::after {
|
||||
}
|
||||
|
||||
a.link::before {
|
||||
content: '<';
|
||||
content: ' <';
|
||||
margin-left: -0.5em;
|
||||
}
|
||||
|
||||
a.link::after {
|
||||
content: '>';
|
||||
content: '> ';
|
||||
}
|
||||
|
||||
a.link:hover::before,
|
||||
|
Loading…
Reference in New Issue
Block a user