Created feeds and UI for feeds and newsletter
All checks were successful
🚀 Deploy website on push / 🎉 Deploy (push) Successful in 19s

Signed-off-by: rodude123 <rodude123@gmail.com>
This commit is contained in:
Rohit Pai 2023-11-14 01:02:27 +00:00
parent 6cfea3fc98
commit f27a5113b1
32 changed files with 2729 additions and 671 deletions

View File

@ -16,5 +16,11 @@
"tuupola/slim-jwt-auth": "^3.6", "tuupola/slim-jwt-auth": "^3.6",
"ext-dom": "*", "ext-dom": "*",
"ext-libxml": "*" "ext-libxml": "*"
},
"repositories": [
{
"type": "composer",
"url": "https:\/\/www.phpclasses.org\/"
} }
]
} }

349
composer.lock generated
View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "79f27ef0ad8fb8ffff7e6726df8c1f79", "content-hash": "bc139d99ef0f6c0f9868982d540fe1c5",
"packages": [ "packages": [
{ {
"name": "fig/http-message-util", "name": "fig/http-message-util",
@ -121,22 +121,22 @@
}, },
{ {
"name": "guzzlehttp/psr7", "name": "guzzlehttp/psr7",
"version": "2.4.3", "version": "2.6.1",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/guzzle/psr7.git", "url": "https://github.com/guzzle/psr7.git",
"reference": "67c26b443f348a51926030c83481b85718457d3d" "reference": "be45764272e8873c72dbe3d2edcfdfcc3bc9f727"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/guzzle/psr7/zipball/67c26b443f348a51926030c83481b85718457d3d", "url": "https://api.github.com/repos/guzzle/psr7/zipball/be45764272e8873c72dbe3d2edcfdfcc3bc9f727",
"reference": "67c26b443f348a51926030c83481b85718457d3d", "reference": "be45764272e8873c72dbe3d2edcfdfcc3bc9f727",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"php": "^7.2.5 || ^8.0", "php": "^7.2.5 || ^8.0",
"psr/http-factory": "^1.0", "psr/http-factory": "^1.0",
"psr/http-message": "^1.0", "psr/http-message": "^1.1 || ^2.0",
"ralouphie/getallheaders": "^3.0" "ralouphie/getallheaders": "^3.0"
}, },
"provide": { "provide": {
@ -156,9 +156,6 @@
"bamarni-bin": { "bamarni-bin": {
"bin-links": true, "bin-links": true,
"forward-command": false "forward-command": false
},
"branch-alias": {
"dev-master": "2.4-dev"
} }
}, },
"autoload": { "autoload": {
@ -220,7 +217,7 @@
], ],
"support": { "support": {
"issues": "https://github.com/guzzle/psr7/issues", "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": [ "funding": [
{ {
@ -236,7 +233,7 @@
"type": "tidelift" "type": "tidelift"
} }
], ],
"time": "2022-10-26T14:07:24+00:00" "time": "2023-08-27T10:13:57+00:00"
}, },
{ {
"name": "http-interop/http-factory-guzzle", "name": "http-interop/http-factory-guzzle",
@ -298,22 +295,22 @@
}, },
{ {
"name": "laminas/laminas-diactoros", "name": "laminas/laminas-diactoros",
"version": "2.24.0", "version": "2.26.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/laminas/laminas-diactoros.git", "url": "https://github.com/laminas/laminas-diactoros.git",
"reference": "6028af6c3b5ced4d063a680d2483cce67578b902" "reference": "6584d44eb8e477e89d453313b858daac6183cddc"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/laminas/laminas-diactoros/zipball/6028af6c3b5ced4d063a680d2483cce67578b902", "url": "https://api.github.com/repos/laminas/laminas-diactoros/zipball/6584d44eb8e477e89d453313b858daac6183cddc",
"reference": "6028af6c3b5ced4d063a680d2483cce67578b902", "reference": "6584d44eb8e477e89d453313b858daac6183cddc",
"shasum": "" "shasum": ""
}, },
"require": { "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-factory": "^1.0",
"psr/http-message": "^1.0" "psr/http-message": "^1.1"
}, },
"conflict": { "conflict": {
"zendframework/zend-diactoros": "*" "zendframework/zend-diactoros": "*"
@ -328,11 +325,11 @@
"ext-gd": "*", "ext-gd": "*",
"ext-libxml": "*", "ext-libxml": "*",
"http-interop/http-factory-tests": "^0.9.0", "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", "php-http/psr7-integration-tests": "^1.2",
"phpunit/phpunit": "^9.5.27", "phpunit/phpunit": "^9.5.28",
"psalm/plugin-phpunit": "^0.18.4", "psalm/plugin-phpunit": "^0.18.4",
"vimeo/psalm": "^5.4" "vimeo/psalm": "^5.6"
}, },
"type": "library", "type": "library",
"extra": { "extra": {
@ -391,34 +388,34 @@
"type": "community_bridge" "type": "community_bridge"
} }
], ],
"time": "2022-12-20T12:22:40+00:00" "time": "2023-10-29T16:17:44+00:00"
}, },
{ {
"name": "laminas/laminas-httphandlerrunner", "name": "laminas/laminas-httphandlerrunner",
"version": "2.5.0", "version": "2.9.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/laminas/laminas-httphandlerrunner.git", "url": "https://github.com/laminas/laminas-httphandlerrunner.git",
"reference": "7a47834aaad7852816d2ec4fdbb0492163b039ae" "reference": "d3e84755a17e563b1c5f8290cbfb150210501a77"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/laminas/laminas-httphandlerrunner/zipball/7a47834aaad7852816d2ec4fdbb0492163b039ae", "url": "https://api.github.com/repos/laminas/laminas-httphandlerrunner/zipball/d3e84755a17e563b1c5f8290cbfb150210501a77",
"reference": "7a47834aaad7852816d2ec4fdbb0492163b039ae", "reference": "d3e84755a17e563b1c5f8290cbfb150210501a77",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"php": "~8.0.0 || ~8.1.0 || ~8.2.0", "php": "~8.1.0 || ~8.2.0 || ~8.3.0",
"psr/http-message": "^1.0", "psr/http-message": "^1.0 || ^2.0",
"psr/http-message-implementation": "^1.0", "psr/http-message-implementation": "^1.0 || ^2.0",
"psr/http-server-handler": "^1.0" "psr/http-server-handler": "^1.0"
}, },
"require-dev": { "require-dev": {
"laminas/laminas-coding-standard": "~2.4.0", "laminas/laminas-coding-standard": "~2.5.0",
"laminas/laminas-diactoros": "^2.18", "laminas/laminas-diactoros": "^3.0.0",
"phpunit/phpunit": "^9.5.26", "phpunit/phpunit": "^10.1.2",
"psalm/plugin-phpunit": "^0.18.0", "psalm/plugin-phpunit": "^0.18.4",
"vimeo/psalm": "^5.0.0" "vimeo/psalm": "^5.11"
}, },
"type": "library", "type": "library",
"extra": { "extra": {
@ -458,20 +455,20 @@
"type": "community_bridge" "type": "community_bridge"
} }
], ],
"time": "2023-01-05T21:54:03+00:00" "time": "2023-09-04T10:43:03+00:00"
}, },
{ {
"name": "laravel/serializable-closure", "name": "laravel/serializable-closure",
"version": "v1.2.2", "version": "v1.3.2",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/laravel/serializable-closure.git", "url": "https://github.com/laravel/serializable-closure.git",
"reference": "47afb7fae28ed29057fdca37e16a84f90cc62fae" "reference": "076fe2cf128bd54b4341cdc6d49b95b34e101e4c"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/laravel/serializable-closure/zipball/47afb7fae28ed29057fdca37e16a84f90cc62fae", "url": "https://api.github.com/repos/laravel/serializable-closure/zipball/076fe2cf128bd54b4341cdc6d49b95b34e101e4c",
"reference": "47afb7fae28ed29057fdca37e16a84f90cc62fae", "reference": "076fe2cf128bd54b4341cdc6d49b95b34e101e4c",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -518,20 +515,20 @@
"issues": "https://github.com/laravel/serializable-closure/issues", "issues": "https://github.com/laravel/serializable-closure/issues",
"source": "https://github.com/laravel/serializable-closure" "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", "name": "monolog/monolog",
"version": "2.8.0", "version": "2.9.2",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/Seldaek/monolog.git", "url": "https://github.com/Seldaek/monolog.git",
"reference": "720488632c590286b88b80e62aa3d3d551ad4a50" "reference": "437cb3628f4cf6042cc10ae97fc2b8472e48ca1f"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/Seldaek/monolog/zipball/720488632c590286b88b80e62aa3d3d551ad4a50", "url": "https://api.github.com/repos/Seldaek/monolog/zipball/437cb3628f4cf6042cc10ae97fc2b8472e48ca1f",
"reference": "720488632c590286b88b80e62aa3d3d551ad4a50", "reference": "437cb3628f4cf6042cc10ae97fc2b8472e48ca1f",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -546,7 +543,7 @@
"doctrine/couchdb": "~1.0@dev", "doctrine/couchdb": "~1.0@dev",
"elasticsearch/elasticsearch": "^7 || ^8", "elasticsearch/elasticsearch": "^7 || ^8",
"ext-json": "*", "ext-json": "*",
"graylog2/gelf-php": "^1.4.2", "graylog2/gelf-php": "^1.4.2 || ^2@dev",
"guzzlehttp/guzzle": "^7.4", "guzzlehttp/guzzle": "^7.4",
"guzzlehttp/psr7": "^2.2", "guzzlehttp/psr7": "^2.2",
"mongodb/mongodb": "^1.8", "mongodb/mongodb": "^1.8",
@ -608,7 +605,7 @@
], ],
"support": { "support": {
"issues": "https://github.com/Seldaek/monolog/issues", "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": [ "funding": [
{ {
@ -620,7 +617,7 @@
"type": "tidelift" "type": "tidelift"
} }
], ],
"time": "2022-07-24T11:55:47+00:00" "time": "2023-10-27T15:25:26+00:00"
}, },
{ {
"name": "nikic/fast-route", "name": "nikic/fast-route",
@ -674,38 +671,39 @@
}, },
{ {
"name": "nyholm/psr7", "name": "nyholm/psr7",
"version": "1.5.1", "version": "1.8.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/Nyholm/psr7.git", "url": "https://github.com/Nyholm/psr7.git",
"reference": "f734364e38a876a23be4d906a2a089e1315be18a" "reference": "3cb4d163b58589e47b35103e8e5e6a6a475b47be"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/Nyholm/psr7/zipball/f734364e38a876a23be4d906a2a089e1315be18a", "url": "https://api.github.com/repos/Nyholm/psr7/zipball/3cb4d163b58589e47b35103e8e5e6a6a475b47be",
"reference": "f734364e38a876a23be4d906a2a089e1315be18a", "reference": "3cb4d163b58589e47b35103e8e5e6a6a475b47be",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"php": ">=7.1", "php": ">=7.2",
"php-http/message-factory": "^1.0",
"psr/http-factory": "^1.0", "psr/http-factory": "^1.0",
"psr/http-message": "^1.0" "psr/http-message": "^1.1 || ^2.0"
}, },
"provide": { "provide": {
"php-http/message-factory-implementation": "1.0",
"psr/http-factory-implementation": "1.0", "psr/http-factory-implementation": "1.0",
"psr/http-message-implementation": "1.0" "psr/http-message-implementation": "1.0"
}, },
"require-dev": { "require-dev": {
"http-interop/http-factory-tests": "^0.9", "http-interop/http-factory-tests": "^0.9",
"php-http/message-factory": "^1.0",
"php-http/psr7-integration-tests": "^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" "symfony/error-handler": "^4.4"
}, },
"type": "library", "type": "library",
"extra": { "extra": {
"branch-alias": { "branch-alias": {
"dev-master": "1.4-dev" "dev-master": "1.8-dev"
} }
}, },
"autoload": { "autoload": {
@ -735,7 +733,7 @@
], ],
"support": { "support": {
"issues": "https://github.com/Nyholm/psr7/issues", "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": [ "funding": [
{ {
@ -747,26 +745,26 @@
"type": "github" "type": "github"
} }
], ],
"time": "2022-06-22T07:13:36+00:00" "time": "2023-05-02T11:26:24+00:00"
}, },
{ {
"name": "nyholm/psr7-server", "name": "nyholm/psr7-server",
"version": "1.0.2", "version": "1.1.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/Nyholm/psr7-server.git", "url": "https://github.com/Nyholm/psr7-server.git",
"reference": "b846a689844cef114e8079d8c80f0afd96745ae3" "reference": "4335801d851f554ca43fa6e7d2602141538854dc"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/Nyholm/psr7-server/zipball/b846a689844cef114e8079d8c80f0afd96745ae3", "url": "https://api.github.com/repos/Nyholm/psr7-server/zipball/4335801d851f554ca43fa6e7d2602141538854dc",
"reference": "b846a689844cef114e8079d8c80f0afd96745ae3", "reference": "4335801d851f554ca43fa6e7d2602141538854dc",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"php": "^7.1 || ^8.0", "php": "^7.1 || ^8.0",
"psr/http-factory": "^1.0", "psr/http-factory": "^1.0",
"psr/http-message": "^1.0" "psr/http-message": "^1.0 || ^2.0"
}, },
"require-dev": { "require-dev": {
"nyholm/nsa": "^1.1", "nyholm/nsa": "^1.1",
@ -801,7 +799,7 @@
], ],
"support": { "support": {
"issues": "https://github.com/Nyholm/psr7-server/issues", "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": [ "funding": [
{ {
@ -813,20 +811,20 @@
"type": "github" "type": "github"
} }
], ],
"time": "2021-05-12T11:11:27+00:00" "time": "2023-11-08T09:30:43+00:00"
}, },
{ {
"name": "php-di/invoker", "name": "php-di/invoker",
"version": "2.3.3", "version": "2.3.4",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/PHP-DI/Invoker.git", "url": "https://github.com/PHP-DI/Invoker.git",
"reference": "cd6d9f267d1a3474bdddf1be1da079f01b942786" "reference": "33234b32dafa8eb69202f950a1fc92055ed76a86"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/PHP-DI/Invoker/zipball/cd6d9f267d1a3474bdddf1be1da079f01b942786", "url": "https://api.github.com/repos/PHP-DI/Invoker/zipball/33234b32dafa8eb69202f950a1fc92055ed76a86",
"reference": "cd6d9f267d1a3474bdddf1be1da079f01b942786", "reference": "33234b32dafa8eb69202f950a1fc92055ed76a86",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -860,7 +858,7 @@
], ],
"support": { "support": {
"issues": "https://github.com/PHP-DI/Invoker/issues", "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": [ "funding": [
{ {
@ -868,7 +866,7 @@
"type": "github" "type": "github"
} }
], ],
"time": "2021-12-13T09:22:56+00:00" "time": "2023-09-08T09:24:21+00:00"
}, },
{ {
"name": "php-di/php-di", "name": "php-di/php-di",
@ -988,60 +986,6 @@
}, },
"time": "2020-10-12T12:39:22+00:00" "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", "name": "psr/container",
"version": "1.1.2", "version": "1.1.2",
@ -1092,21 +1036,21 @@
}, },
{ {
"name": "psr/http-factory", "name": "psr/http-factory",
"version": "1.0.1", "version": "1.0.2",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/php-fig/http-factory.git", "url": "https://github.com/php-fig/http-factory.git",
"reference": "12ac7fcd07e5b077433f5f2bee95b3a771bf61be" "reference": "e616d01114759c4c489f93b099585439f795fe35"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/php-fig/http-factory/zipball/12ac7fcd07e5b077433f5f2bee95b3a771bf61be", "url": "https://api.github.com/repos/php-fig/http-factory/zipball/e616d01114759c4c489f93b099585439f795fe35",
"reference": "12ac7fcd07e5b077433f5f2bee95b3a771bf61be", "reference": "e616d01114759c4c489f93b099585439f795fe35",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"php": ">=7.0.0", "php": ">=7.0.0",
"psr/http-message": "^1.0" "psr/http-message": "^1.0 || ^2.0"
}, },
"type": "library", "type": "library",
"extra": { "extra": {
@ -1126,7 +1070,7 @@
"authors": [ "authors": [
{ {
"name": "PHP-FIG", "name": "PHP-FIG",
"homepage": "http://www.php-fig.org/" "homepage": "https://www.php-fig.org/"
} }
], ],
"description": "Common interfaces for PSR-7 HTTP message factories", "description": "Common interfaces for PSR-7 HTTP message factories",
@ -1141,31 +1085,31 @@
"response" "response"
], ],
"support": { "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", "name": "psr/http-message",
"version": "1.0.1", "version": "1.1",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/php-fig/http-message.git", "url": "https://github.com/php-fig/http-message.git",
"reference": "f6561bf28d520154e4b0ec72be95418abe6d9363" "reference": "cb6ce4845ce34a8ad9e68117c10ee90a29919eba"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/php-fig/http-message/zipball/f6561bf28d520154e4b0ec72be95418abe6d9363", "url": "https://api.github.com/repos/php-fig/http-message/zipball/cb6ce4845ce34a8ad9e68117c10ee90a29919eba",
"reference": "f6561bf28d520154e4b0ec72be95418abe6d9363", "reference": "cb6ce4845ce34a8ad9e68117c10ee90a29919eba",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"php": ">=5.3.0" "php": "^7.2 || ^8.0"
}, },
"type": "library", "type": "library",
"extra": { "extra": {
"branch-alias": { "branch-alias": {
"dev-master": "1.0.x-dev" "dev-master": "1.1.x-dev"
} }
}, },
"autoload": { "autoload": {
@ -1194,27 +1138,27 @@
"response" "response"
], ],
"support": { "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", "name": "psr/http-server-handler",
"version": "1.0.1", "version": "1.0.2",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/php-fig/http-server-handler.git", "url": "https://github.com/php-fig/http-server-handler.git",
"reference": "aff2f80e33b7f026ec96bb42f63242dc50ffcae7" "reference": "84c4fb66179be4caaf8e97bd239203245302e7d4"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/php-fig/http-server-handler/zipball/aff2f80e33b7f026ec96bb42f63242dc50ffcae7", "url": "https://api.github.com/repos/php-fig/http-server-handler/zipball/84c4fb66179be4caaf8e97bd239203245302e7d4",
"reference": "aff2f80e33b7f026ec96bb42f63242dc50ffcae7", "reference": "84c4fb66179be4caaf8e97bd239203245302e7d4",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"php": ">=7.0", "php": ">=7.0",
"psr/http-message": "^1.0" "psr/http-message": "^1.0 || ^2.0"
}, },
"type": "library", "type": "library",
"extra": { "extra": {
@ -1234,7 +1178,7 @@
"authors": [ "authors": [
{ {
"name": "PHP-FIG", "name": "PHP-FIG",
"homepage": "http://www.php-fig.org/" "homepage": "https://www.php-fig.org/"
} }
], ],
"description": "Common interface for HTTP server-side request handler", "description": "Common interface for HTTP server-side request handler",
@ -1250,28 +1194,27 @@
"server" "server"
], ],
"support": { "support": {
"issues": "https://github.com/php-fig/http-server-handler/issues", "source": "https://github.com/php-fig/http-server-handler/tree/1.0.2"
"source": "https://github.com/php-fig/http-server-handler/tree/master"
}, },
"time": "2018-10-30T16:46:14+00:00" "time": "2023-04-10T20:06:20+00:00"
}, },
{ {
"name": "psr/http-server-middleware", "name": "psr/http-server-middleware",
"version": "1.0.1", "version": "1.0.2",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/php-fig/http-server-middleware.git", "url": "https://github.com/php-fig/http-server-middleware.git",
"reference": "2296f45510945530b9dceb8bcedb5cb84d40c5f5" "reference": "c1481f747daaa6a0782775cd6a8c26a1bf4a3829"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/php-fig/http-server-middleware/zipball/2296f45510945530b9dceb8bcedb5cb84d40c5f5", "url": "https://api.github.com/repos/php-fig/http-server-middleware/zipball/c1481f747daaa6a0782775cd6a8c26a1bf4a3829",
"reference": "2296f45510945530b9dceb8bcedb5cb84d40c5f5", "reference": "c1481f747daaa6a0782775cd6a8c26a1bf4a3829",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"php": ">=7.0", "php": ">=7.0",
"psr/http-message": "^1.0", "psr/http-message": "^1.0 || ^2.0",
"psr/http-server-handler": "^1.0" "psr/http-server-handler": "^1.0"
}, },
"type": "library", "type": "library",
@ -1292,7 +1235,7 @@
"authors": [ "authors": [
{ {
"name": "PHP-FIG", "name": "PHP-FIG",
"homepage": "http://www.php-fig.org/" "homepage": "https://www.php-fig.org/"
} }
], ],
"description": "Common interface for HTTP server-side middleware", "description": "Common interface for HTTP server-side middleware",
@ -1308,9 +1251,9 @@
], ],
"support": { "support": {
"issues": "https://github.com/php-fig/http-server-middleware/issues", "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", "name": "psr/log",
@ -1585,16 +1528,16 @@
}, },
{ {
"name": "slim/psr7", "name": "slim/psr7",
"version": "1.6", "version": "1.6.1",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/slimphp/Slim-Psr7.git", "url": "https://github.com/slimphp/Slim-Psr7.git",
"reference": "3471c22c1a0d26c51c78f6aeb06489d38cf46a4d" "reference": "72d2b2bac94ab4575d369f605dbfafbe168d3163"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/slimphp/Slim-Psr7/zipball/3471c22c1a0d26c51c78f6aeb06489d38cf46a4d", "url": "https://api.github.com/repos/slimphp/Slim-Psr7/zipball/72d2b2bac94ab4575d369f605dbfafbe168d3163",
"reference": "3471c22c1a0d26c51c78f6aeb06489d38cf46a4d", "reference": "72d2b2bac94ab4575d369f605dbfafbe168d3163",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -1613,7 +1556,7 @@
"adriansuter/php-autoload-override": "^1.3", "adriansuter/php-autoload-override": "^1.3",
"ext-json": "*", "ext-json": "*",
"http-interop/http-factory-tests": "^0.9.0", "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": "^1.15",
"phpspec/prophecy-phpunit": "^2.0", "phpspec/prophecy-phpunit": "^2.0",
"phpstan/phpstan": "^1.8", "phpstan/phpstan": "^1.8",
@ -1661,22 +1604,22 @@
], ],
"support": { "support": {
"issues": "https://github.com/slimphp/Slim-Psr7/issues", "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", "name": "slim/slim",
"version": "4.11.0", "version": "4.12.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/slimphp/Slim.git", "url": "https://github.com/slimphp/Slim.git",
"reference": "b0f4ca393ea037be9ac7292ba7d0a34d18bac0c7" "reference": "e9e99c2b24398b967841c6c4c3048622cc7e2b18"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/slimphp/Slim/zipball/b0f4ca393ea037be9ac7292ba7d0a34d18bac0c7", "url": "https://api.github.com/repos/slimphp/Slim/zipball/e9e99c2b24398b967841c6c4c3048622cc7e2b18",
"reference": "b0f4ca393ea037be9ac7292ba7d0a34d18bac0c7", "reference": "e9e99c2b24398b967841c6c4c3048622cc7e2b18",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -1685,26 +1628,26 @@
"php": "^7.4 || ^8.0", "php": "^7.4 || ^8.0",
"psr/container": "^1.0 || ^2.0", "psr/container": "^1.0 || ^2.0",
"psr/http-factory": "^1.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-handler": "^1.0",
"psr/http-server-middleware": "^1.0", "psr/http-server-middleware": "^1.0",
"psr/log": "^1.1 || ^2.0 || ^3.0" "psr/log": "^1.1 || ^2.0 || ^3.0"
}, },
"require-dev": { "require-dev": {
"adriansuter/php-autoload-override": "^1.3", "adriansuter/php-autoload-override": "^1.4",
"ext-simplexml": "*", "ext-simplexml": "*",
"guzzlehttp/psr7": "^2.4", "guzzlehttp/psr7": "^2.5",
"httpsoft/http-message": "^1.0", "httpsoft/http-message": "^1.1",
"httpsoft/http-server-request": "^1.0", "httpsoft/http-server-request": "^1.1",
"laminas/laminas-diactoros": "^2.17", "laminas/laminas-diactoros": "^2.17",
"nyholm/psr7": "^1.5", "nyholm/psr7": "^1.8",
"nyholm/psr7-server": "^1.0", "nyholm/psr7-server": "^1.0",
"phpspec/prophecy": "^1.15", "phpspec/prophecy": "^1.17",
"phpspec/prophecy-phpunit": "^2.0", "phpspec/prophecy-phpunit": "^2.0",
"phpstan/phpstan": "^1.8", "phpstan/phpstan": "^1.10",
"phpunit/phpunit": "^9.5", "phpunit/phpunit": "^9.6",
"slim/http": "^1.2", "slim/http": "^1.3",
"slim/psr7": "^1.5", "slim/psr7": "^1.6",
"squizlabs/php_codesniffer": "^3.7" "squizlabs/php_codesniffer": "^3.7"
}, },
"suggest": { "suggest": {
@ -1778,7 +1721,7 @@
"type": "tidelift" "type": "tidelift"
} }
], ],
"time": "2022-11-06T16:33:39+00:00" "time": "2023-07-23T04:54:29+00:00"
}, },
{ {
"name": "slim/slim-skeleton", "name": "slim/slim-skeleton",
@ -1848,16 +1791,16 @@
}, },
{ {
"name": "symfony/polyfill-php80", "name": "symfony/polyfill-php80",
"version": "v1.27.0", "version": "v1.28.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/polyfill-php80.git", "url": "https://github.com/symfony/polyfill-php80.git",
"reference": "7a6ff3f1959bb01aefccb463a0f2cd3d3d2fd936" "reference": "6caa57379c4aec19c0a12a38b59b26487dcfe4b5"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/7a6ff3f1959bb01aefccb463a0f2cd3d3d2fd936", "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/6caa57379c4aec19c0a12a38b59b26487dcfe4b5",
"reference": "7a6ff3f1959bb01aefccb463a0f2cd3d3d2fd936", "reference": "6caa57379c4aec19c0a12a38b59b26487dcfe4b5",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -1866,7 +1809,7 @@
"type": "library", "type": "library",
"extra": { "extra": {
"branch-alias": { "branch-alias": {
"dev-main": "1.27-dev" "dev-main": "1.28-dev"
}, },
"thanks": { "thanks": {
"name": "symfony/polyfill", "name": "symfony/polyfill",
@ -1911,7 +1854,7 @@
"shim" "shim"
], ],
"support": { "support": {
"source": "https://github.com/symfony/polyfill-php80/tree/v1.27.0" "source": "https://github.com/symfony/polyfill-php80/tree/v1.28.0"
}, },
"funding": [ "funding": [
{ {
@ -1927,7 +1870,7 @@
"type": "tidelift" "type": "tidelift"
} }
], ],
"time": "2022-11-03T14:55:06+00:00" "time": "2023-01-26T09:26:14+00:00"
}, },
{ {
"name": "tuupola/callable-handler", "name": "tuupola/callable-handler",
@ -2060,22 +2003,22 @@
}, },
{ {
"name": "tuupola/slim-jwt-auth", "name": "tuupola/slim-jwt-auth",
"version": "3.7.0", "version": "3.8.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/tuupola/slim-jwt-auth.git", "url": "https://github.com/tuupola/slim-jwt-auth.git",
"reference": "ef05b93d4dac7307ef6ef3b62feaff30c32e82c1" "reference": "7829d4482034e9eb5e051f3a1619db0c704ba7e7"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/tuupola/slim-jwt-auth/zipball/ef05b93d4dac7307ef6ef3b62feaff30c32e82c1", "url": "https://api.github.com/repos/tuupola/slim-jwt-auth/zipball/7829d4482034e9eb5e051f3a1619db0c704ba7e7",
"reference": "ef05b93d4dac7307ef6ef3b62feaff30c32e82c1", "reference": "7829d4482034e9eb5e051f3a1619db0c704ba7e7",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"firebase/php-jwt": "^3.0|^4.0|^5.0", "firebase/php-jwt": "^3.0|^4.0|^5.0",
"php": "^7.2|^8.0", "php": "^7.4|^8.0",
"psr/http-message": "^1.0", "psr/http-message": "^1.0|^2.0",
"psr/http-server-middleware": "^1.0", "psr/http-server-middleware": "^1.0",
"psr/log": "^1.0|^2.0|^3.0", "psr/log": "^1.0|^2.0|^3.0",
"tuupola/callable-handler": "^1.0", "tuupola/callable-handler": "^1.0",
@ -2083,9 +2026,9 @@
}, },
"require-dev": { "require-dev": {
"equip/dispatch": "^2.0", "equip/dispatch": "^2.0",
"laminas/laminas-diactoros": "^2.0", "laminas/laminas-diactoros": "^2.0|^3.0",
"overtrue/phplint": "^1.0", "overtrue/phplint": "^1.0",
"phpstan/phpstan": "^1.8", "phpstan/phpstan": "^1.10",
"phpunit/phpunit": "^7.0|^8.5.30|^9.0", "phpunit/phpunit": "^7.0|^8.5.30|^9.0",
"squizlabs/php_codesniffer": "^3.7" "squizlabs/php_codesniffer": "^3.7"
}, },
@ -2124,15 +2067,9 @@
], ],
"support": { "support": {
"issues": "https://github.com/tuupola/slim-jwt-auth/issues", "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": [ "time": "2023-10-20T09:51:26+00:00"
{
"url": "https://github.com/tuupola",
"type": "github"
}
],
"time": "2022-12-23T11:23:05+00:00"
} }
], ],
"packages-dev": [], "packages-dev": [],
@ -2143,8 +2080,10 @@
"prefer-lowest": false, "prefer-lowest": false,
"platform": { "platform": {
"ext-pdo": "*", "ext-pdo": "*",
"ext-json": "*" "ext-json": "*",
"ext-dom": "*",
"ext-libxml": "*"
}, },
"platform-dev": [], "platform-dev": [],
"plugin-api-version": "2.3.0" "plugin-api-version": "2.6.0"
} }

View File

@ -2,13 +2,18 @@
namespace api\blog; namespace api\blog;
use api\utils\feedGenerator\FeedWriter;
use api\utils\imgUtils; use api\utils\imgUtils;
use DOMDocument; use DOMDocument;
use PDO; use PDO;
use Psr\Http\Message\UploadedFileInterface; use Psr\Http\Message\UploadedFileInterface;
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/config.php";
require_once __DIR__ . "/../utils/imgUtils.php"; require_once __DIR__ . "/../utils/imgUtils.php";
require_once __DIR__ . "/../utils/feedGenerator/FeedWriter.php";
/** /**
* Blog Data Class * Blog Data Class
@ -18,12 +23,15 @@ class blogData
{ {
/** /**
* Get all blog posts * 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 public function getBlogPosts(): array
{ {
$conn = dbConn(); $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, folderID FROM blog ORDER BY featured DESC,
dateCreated DESC;");
$stmt->execute(); $stmt->execute();
// set the resulting array to associative // set the resulting array to associative
@ -40,12 +48,15 @@ class blogData
/** /**
* Get a blog post with the given ID * Get a blog post with the given ID
* @param string $title - Title of the blog post * @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 public function getBlogPost(string $title): array
{ {
$conn = dbConn(); $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, folderID FROM blog WHERE
title = :title;");
$stmt->bindParam(":title", $title); $stmt->bindParam(":title", $title);
$stmt->execute(); $stmt->execute();
@ -67,7 +78,10 @@ class blogData
public function getLatestBlogPost(): array public function getLatestBlogPost(): array
{ {
$conn = dbConn(); $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, folderID FROM blog ORDER BY
dateCreated DESC LIMIT 1;");
$stmt->execute(); $stmt->execute();
// set the resulting array to associative // set the resulting array to associative
@ -88,7 +102,9 @@ class blogData
public function getFeaturedBlogPost(): array public function getFeaturedBlogPost(): array
{ {
$conn = dbConn(); $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, folderID FROM blog WHERE featured = 1;");
$stmt->execute(); $stmt->execute();
$result = $stmt->fetch(PDO::FETCH_ASSOC); $result = $stmt->fetch(PDO::FETCH_ASSOC);
@ -399,13 +415,12 @@ class blogData
if (!in_array($from . $file, $srcList)) if (!in_array($from . $file, $srcList))
{ {
unlink($from . $file); unlink($from . $file);
continue;
} }
else
{
rename($from . $file, $to . $file); rename($from . $file, $to . $file);
} }
} }
}
$newBody = ''; $newBody = '';
foreach ($doc->childNodes as $node) foreach ($doc->childNodes as $node)
@ -418,7 +433,7 @@ class blogData
/** /**
* Get all posts with the given category * Get all posts with the given category
* @param string $category - Category of the post * @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 public function getPostsByCategory(string $category): array
{ {
@ -432,7 +447,7 @@ class blogData
/** /**
* Search for a blog post with the given search term * Search for a blog post with the given search term
* @param string $searchTerm - 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 public function searchBlog(string $searchTerm): array
{ {
@ -527,4 +542,109 @@ class blogData
return $result; 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;
}
} }

View File

@ -4,6 +4,7 @@ namespace api\blog;
require_once __DIR__ . "/../utils/routesInterface.php"; require_once __DIR__ . "/../utils/routesInterface.php";
require_once "blogData.php"; require_once "blogData.php";
use api\utils\routesInterface; use api\utils\routesInterface;
use Psr\Http\Message\ResponseInterface as Response; use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request; use Psr\Http\Message\ServerRequestInterface as Request;
@ -80,8 +81,12 @@ class blogRoutes implements routesInterface
$app->get("/blog/post/{type}", function (Request $request, Response $response, $args) $app->get("/blog/post/{type}", function (Request $request, Response $response, $args)
{ {
if ($args["type"] != null) if ($args["type"] == null)
{ {
$response->getBody()->write(json_encode(array("error" => "Please provide a title")));
return $response->withStatus(400);
}
if ($args["type"] == "latest") if ($args["type"] == "latest")
{ {
$post = $this->blogData->getLatestBlogPost(); $post = $this->blogData->getLatestBlogPost();
@ -117,16 +122,54 @@ class blogRoutes implements routesInterface
$response->getBody()->write(json_encode($post)); $response->getBody()->write(json_encode($post));
return $response; 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);
} }
$response->getBody()->write(json_encode(array("error" => "Please provide a title"))); $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); return $response->withStatus(400);
}); });
$app->get("/blog/search/{searchTerm}", function (Request $request, $response, $args) $app->get("/blog/search/{searchTerm}", function (Request $request, $response, $args)
{ {
if ($args["searchTerm"] != null) if ($args["searchTerm"] == null)
{ {
$response->getBody()->write(json_encode(array("error" => "Please provide a search term")));
return $response->withStatus(400);
}
$posts = $this->blogData->searchBlog($args["searchTerm"]); $posts = $this->blogData->searchBlog($args["searchTerm"]);
$json = json_encode($posts); $json = json_encode($posts);
@ -139,17 +182,18 @@ class blogRoutes implements routesInterface
} }
return $response; return $response;
}
$response->getBody()->write(json_encode(array("error" => "Please provide a search term")));
return $response->withStatus(400);
}); });
$app->patch("/blog/post/{id}", function (Request $request, Response $response, $args) $app->patch("/blog/post/{id}", function (Request $request, Response $response, $args)
{ {
$data = $request->getParsedBody(); $data = $request->getParsedBody();
if ($args["id"] != null) if ($args["id"] == null)
{ {
$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"])) 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 // uh oh sent some empty data
@ -190,16 +234,16 @@ class blogRoutes implements routesInterface
$response->withStatus(201); $response->withStatus(201);
return $response; return $response;
}
$response->getBody()->write(json_encode(array("error" => "Please provide an ID")));
return $response->withStatus(400);
}); });
$app->delete("/blog/post/{id}", function (Request $request, Response $response, $args) $app->delete("/blog/post/{id}", function (Request $request, Response $response, $args)
{ {
if ($args["id"] != null) if ($args["id"] == null)
{ {
$response->getBody()->write(json_encode(array("error" => "Please provide an ID")));
return $response->withStatus(400);
}
$message = $this->blogData->deletePost($args["id"]); $message = $this->blogData->deletePost($args["id"]);
if ($message === "post not found") if ($message === "post not found")
@ -223,10 +267,6 @@ class blogRoutes implements routesInterface
return $response->withStatus(409); return $response->withStatus(409);
} }
return $response; return $response;
}
$response->getBody()->write(json_encode(array("error" => "Please provide an ID")));
return $response->withStatus(400);
}); });
$app->post("/blog/post", function (Request $request, Response $response) $app->post("/blog/post", function (Request $request, Response $response)
@ -290,8 +330,12 @@ class blogRoutes implements routesInterface
{ {
$files = $request->getUploadedFiles(); $files = $request->getUploadedFiles();
if ($args["id"] != null) if ($args["id"] == null)
{ {
$response->getBody()->write(json_encode(array("error" => "Please provide an ID")));
return $response->withStatus(400);
}
if (empty($files)) if (empty($files))
{ {
// uh oh sent some empty data // uh oh sent some empty data
@ -308,10 +352,6 @@ class blogRoutes implements routesInterface
$response->getBody()->write(json_encode($message)); $response->getBody()->write(json_encode($message));
return $response->withStatus(201); return $response->withStatus(201);
}
$response->getBody()->write(json_encode(array("error" => "Please provide an ID")));
return $response->withStatus(400);
}); });
} }
} }

View File

@ -17,7 +17,7 @@ class projectData
{ {
/** /**
* Get all project data * 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 public function getProjectData(): array
{ {

View File

@ -50,8 +50,12 @@ class projectRoutes implements routesInterface
$app->patch("/projectData/{id}", function (Request $request, Response $response, array $args) $app->patch("/projectData/{id}", function (Request $request, Response $response, array $args)
{ {
$data = $request->getParsedBody(); $data = $request->getParsedBody();
if ($args["id"] != null) if ($args["id"] == null)
{ {
$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"])) if (empty($data["title"]) || empty($data["isMainProject"]) || empty($data["information"]) || empty($data["gitLink"]))
{ {
// uh oh sent some empty data // uh oh sent some empty data
@ -84,16 +88,16 @@ class projectRoutes implements routesInterface
} }
return $response; return $response;
}
$response->getBody()->write(json_encode(array("error" => "Please provide an ID")));
return $response->withStatus(400);
}); });
$app->delete("/projectData/{id}", function (Request $request, Response $response, array $args) $app->delete("/projectData/{id}", function (Request $request, Response $response, array $args)
{ {
if ($args["id"] != null) if ($args["id"] == null)
{ {
$response->getBody()->write(json_encode(array("error" => "Please provide an ID")));
return $response->withStatus(400);
}
$message = $this->projectData->deleteProjectData($args["id"]); $message = $this->projectData->deleteProjectData($args["id"]);
if ($message === "project not found") if ($message === "project not found")
@ -118,10 +122,6 @@ class projectRoutes implements routesInterface
} }
return $response; return $response;
}
$response->getBody()->write(json_encode(array("error" => "Please provide an ID")));
return $response->withStatus(400);
}); });
$app->post("/projectData", function (Request $request, Response $response) $app->post("/projectData", function (Request $request, Response $response)

View File

@ -14,7 +14,7 @@ class timelineData
{ {
/** /**
* Get all education data * 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 public function getEduData(): array
{ {

View 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);
}
}

View 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';

View File

@ -65,7 +65,12 @@ class middleware
$app->add(function ($request, $handler) $app->add(function ($request, $handler)
{ {
$response = $handler->handle($request); $response = $handler->handle($request);
$contentType = $response->getHeaderLine("Content-Type");
if (empty($contentType) || $contentType === "text/html")
{
return $response->withHeader("Content-Type", "application/json"); return $response->withHeader("Content-Type", "application/json");
}
return $response;
}); });
} }

File diff suppressed because one or more lines are too long

197
dist/blog/imgs/atomFeed.svg vendored Normal file
View 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
View 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

View File

@ -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>&copy; <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>&copy; <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>

File diff suppressed because one or more lines are too long

2
dist/css/main.css vendored

File diff suppressed because one or more lines are too long

View File

@ -2,13 +2,18 @@
namespace api\blog; namespace api\blog;
use api\utils\feedGenerator\FeedWriter;
use api\utils\imgUtils; use api\utils\imgUtils;
use DOMDocument; use DOMDocument;
use PDO; use PDO;
use Psr\Http\Message\UploadedFileInterface; use Psr\Http\Message\UploadedFileInterface;
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/config.php";
require_once __DIR__ . "/../utils/imgUtils.php"; require_once __DIR__ . "/../utils/imgUtils.php";
require_once __DIR__ . "/../utils/feedGenerator/FeedWriter.php";
/** /**
* Blog Data Class * Blog Data Class
@ -18,12 +23,15 @@ class blogData
{ {
/** /**
* Get all blog posts * 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 public function getBlogPosts(): array
{ {
$conn = dbConn(); $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, folderID FROM blog ORDER BY featured DESC,
dateCreated DESC;");
$stmt->execute(); $stmt->execute();
// set the resulting array to associative // set the resulting array to associative
@ -40,12 +48,15 @@ class blogData
/** /**
* Get a blog post with the given ID * Get a blog post with the given ID
* @param string $title - Title of the blog post * @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 public function getBlogPost(string $title): array
{ {
$conn = dbConn(); $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, folderID FROM blog WHERE
title = :title;");
$stmt->bindParam(":title", $title); $stmt->bindParam(":title", $title);
$stmt->execute(); $stmt->execute();
@ -67,7 +78,10 @@ class blogData
public function getLatestBlogPost(): array public function getLatestBlogPost(): array
{ {
$conn = dbConn(); $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, folderID FROM blog ORDER BY
dateCreated DESC LIMIT 1;");
$stmt->execute(); $stmt->execute();
// set the resulting array to associative // set the resulting array to associative
@ -88,7 +102,9 @@ class blogData
public function getFeaturedBlogPost(): array public function getFeaturedBlogPost(): array
{ {
$conn = dbConn(); $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, folderID FROM blog WHERE featured = 1;");
$stmt->execute(); $stmt->execute();
$result = $stmt->fetch(PDO::FETCH_ASSOC); $result = $stmt->fetch(PDO::FETCH_ASSOC);
@ -399,13 +415,12 @@ class blogData
if (!in_array($from . $file, $srcList)) if (!in_array($from . $file, $srcList))
{ {
unlink($from . $file); unlink($from . $file);
continue;
} }
else
{
rename($from . $file, $to . $file); rename($from . $file, $to . $file);
} }
} }
}
$newBody = ''; $newBody = '';
foreach ($doc->childNodes as $node) foreach ($doc->childNodes as $node)
@ -418,7 +433,7 @@ class blogData
/** /**
* Get all posts with the given category * Get all posts with the given category
* @param string $category - Category of the post * @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 public function getPostsByCategory(string $category): array
{ {
@ -432,7 +447,7 @@ class blogData
/** /**
* Search for a blog post with the given search term * Search for a blog post with the given search term
* @param string $searchTerm - 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 public function searchBlog(string $searchTerm): array
{ {
@ -527,4 +542,109 @@ class blogData
return $result; 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;
}
} }

View File

@ -4,6 +4,7 @@ namespace api\blog;
require_once __DIR__ . "/../utils/routesInterface.php"; require_once __DIR__ . "/../utils/routesInterface.php";
require_once "blogData.php"; require_once "blogData.php";
use api\utils\routesInterface; use api\utils\routesInterface;
use Psr\Http\Message\ResponseInterface as Response; use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request; use Psr\Http\Message\ServerRequestInterface as Request;
@ -80,8 +81,12 @@ class blogRoutes implements routesInterface
$app->get("/blog/post/{type}", function (Request $request, Response $response, $args) $app->get("/blog/post/{type}", function (Request $request, Response $response, $args)
{ {
if ($args["type"] != null) if ($args["type"] == null)
{ {
$response->getBody()->write(json_encode(array("error" => "Please provide a title")));
return $response->withStatus(400);
}
if ($args["type"] == "latest") if ($args["type"] == "latest")
{ {
$post = $this->blogData->getLatestBlogPost(); $post = $this->blogData->getLatestBlogPost();
@ -117,16 +122,54 @@ class blogRoutes implements routesInterface
$response->getBody()->write(json_encode($post)); $response->getBody()->write(json_encode($post));
return $response; 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);
} }
$response->getBody()->write(json_encode(array("error" => "Please provide a title"))); $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); return $response->withStatus(400);
}); });
$app->get("/blog/search/{searchTerm}", function (Request $request, $response, $args) $app->get("/blog/search/{searchTerm}", function (Request $request, $response, $args)
{ {
if ($args["searchTerm"] != null) if ($args["searchTerm"] == null)
{ {
$response->getBody()->write(json_encode(array("error" => "Please provide a search term")));
return $response->withStatus(400);
}
$posts = $this->blogData->searchBlog($args["searchTerm"]); $posts = $this->blogData->searchBlog($args["searchTerm"]);
$json = json_encode($posts); $json = json_encode($posts);
@ -139,17 +182,18 @@ class blogRoutes implements routesInterface
} }
return $response; return $response;
}
$response->getBody()->write(json_encode(array("error" => "Please provide a search term")));
return $response->withStatus(400);
}); });
$app->patch("/blog/post/{id}", function (Request $request, Response $response, $args) $app->patch("/blog/post/{id}", function (Request $request, Response $response, $args)
{ {
$data = $request->getParsedBody(); $data = $request->getParsedBody();
if ($args["id"] != null) if ($args["id"] == null)
{ {
$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"])) 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 // uh oh sent some empty data
@ -190,16 +234,16 @@ class blogRoutes implements routesInterface
$response->withStatus(201); $response->withStatus(201);
return $response; return $response;
}
$response->getBody()->write(json_encode(array("error" => "Please provide an ID")));
return $response->withStatus(400);
}); });
$app->delete("/blog/post/{id}", function (Request $request, Response $response, $args) $app->delete("/blog/post/{id}", function (Request $request, Response $response, $args)
{ {
if ($args["id"] != null) if ($args["id"] == null)
{ {
$response->getBody()->write(json_encode(array("error" => "Please provide an ID")));
return $response->withStatus(400);
}
$message = $this->blogData->deletePost($args["id"]); $message = $this->blogData->deletePost($args["id"]);
if ($message === "post not found") if ($message === "post not found")
@ -223,10 +267,6 @@ class blogRoutes implements routesInterface
return $response->withStatus(409); return $response->withStatus(409);
} }
return $response; return $response;
}
$response->getBody()->write(json_encode(array("error" => "Please provide an ID")));
return $response->withStatus(400);
}); });
$app->post("/blog/post", function (Request $request, Response $response) $app->post("/blog/post", function (Request $request, Response $response)
@ -290,8 +330,12 @@ class blogRoutes implements routesInterface
{ {
$files = $request->getUploadedFiles(); $files = $request->getUploadedFiles();
if ($args["id"] != null) if ($args["id"] == null)
{ {
$response->getBody()->write(json_encode(array("error" => "Please provide an ID")));
return $response->withStatus(400);
}
if (empty($files)) if (empty($files))
{ {
// uh oh sent some empty data // uh oh sent some empty data
@ -308,10 +352,6 @@ class blogRoutes implements routesInterface
$response->getBody()->write(json_encode($message)); $response->getBody()->write(json_encode($message));
return $response->withStatus(201); return $response->withStatus(201);
}
$response->getBody()->write(json_encode(array("error" => "Please provide an ID")));
return $response->withStatus(400);
}); });
} }
} }

View File

@ -17,7 +17,7 @@ class projectData
{ {
/** /**
* Get all project data * 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 public function getProjectData(): array
{ {

View File

@ -50,8 +50,12 @@ class projectRoutes implements routesInterface
$app->patch("/projectData/{id}", function (Request $request, Response $response, array $args) $app->patch("/projectData/{id}", function (Request $request, Response $response, array $args)
{ {
$data = $request->getParsedBody(); $data = $request->getParsedBody();
if ($args["id"] != null) if ($args["id"] == null)
{ {
$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"])) if (empty($data["title"]) || empty($data["isMainProject"]) || empty($data["information"]) || empty($data["gitLink"]))
{ {
// uh oh sent some empty data // uh oh sent some empty data
@ -84,16 +88,16 @@ class projectRoutes implements routesInterface
} }
return $response; return $response;
}
$response->getBody()->write(json_encode(array("error" => "Please provide an ID")));
return $response->withStatus(400);
}); });
$app->delete("/projectData/{id}", function (Request $request, Response $response, array $args) $app->delete("/projectData/{id}", function (Request $request, Response $response, array $args)
{ {
if ($args["id"] != null) if ($args["id"] == null)
{ {
$response->getBody()->write(json_encode(array("error" => "Please provide an ID")));
return $response->withStatus(400);
}
$message = $this->projectData->deleteProjectData($args["id"]); $message = $this->projectData->deleteProjectData($args["id"]);
if ($message === "project not found") if ($message === "project not found")
@ -118,10 +122,6 @@ class projectRoutes implements routesInterface
} }
return $response; return $response;
}
$response->getBody()->write(json_encode(array("error" => "Please provide an ID")));
return $response->withStatus(400);
}); });
$app->post("/projectData", function (Request $request, Response $response) $app->post("/projectData", function (Request $request, Response $response)

View File

@ -14,7 +14,7 @@ class timelineData
{ {
/** /**
* Get all education data * 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 public function getEduData(): array
{ {

View 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);
}
}

View 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';

View File

@ -65,7 +65,12 @@ class middleware
$app->add(function ($request, $handler) $app->add(function ($request, $handler)
{ {
$response = $handler->handle($request); $response = $handler->handle($request);
$contentType = $response->getHeaderLine("Content-Type");
if (empty($contentType) || $contentType === "text/html")
{
return $response->withHeader("Content-Type", "application/json"); return $response->withHeader("Content-Type", "application/json");
}
return $response;
}); });
} }

View File

@ -133,7 +133,7 @@ div.authorInfo h3 {
grid-column: span 2; grid-column: span 2;
} }
div.otherPosts { div.otherPosts, div.newsletter, div.feeds {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
justify-content: flex-start; justify-content: flex-start;
@ -143,10 +143,35 @@ div.otherPosts {
width: 100%; width: 100%;
} }
div.otherPosts a { div.otherPosts a, div.feeds a {
padding: 0.5em 1em; 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;
}
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 { div.categories {
display: flex; display: flex;
flex-direction: column; flex-direction: column;

View File

@ -10,6 +10,18 @@
@import "category.css"; @import "category.css";
@import "prism.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 *****/ /**** Media Queries *****/
@ -78,27 +90,46 @@
align-items: stretch; align-items: stretch;
justify-content: space-around; justify-content: space-around;
border-bottom: 5px solid var(--mutedGrey); border-bottom: 5px solid var(--mutedGrey);
} flex-wrap: wrap;
div.otherPosts, div.authorInfo {
border-bottom: none;
} }
aside.sideContent > div.authorInfo { 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 { aside.sideContent > div.authorInfo .picture {
grid-row: 1; grid-row: span 3;
grid-column: 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 { 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; justify-content: space-between;
width: 50%;
} }
aside.sideContent > div { aside.sideContent > div {
@ -125,43 +156,19 @@
} }
/***** Individual Blog Posts ***/ /***** Individual Blog Posts ***/
aside.sideContent {
flex-wrap: wrap;
}
aside.sideContent > div.authorInfo { aside.sideContent > div.authorInfo {
grid-template-columns: 2fr 1fr; grid-template-columns: 2fr 1fr 1fr;
border-bottom: 5px solid var(--mutedGrey); grid-template-rows: 1fr 1fr;
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;
} }
aside.sideContent > div.authorInfo h3 { aside.sideContent > div.authorInfo h3 {
grid-column: span 2; grid-row: 2;
} }
aside.sideContent > div.categories { div.feeds .icons {
flex-basis: 100%; flex-wrap: wrap;
} }
aside.sideContent > div.otherPosts {
border-bottom: 5px solid var(--mutedGrey);
}
} }
@media screen and (max-width: 30em) { @media screen and (max-width: 30em) {
@ -183,6 +190,7 @@
aside.sideContent > div.authorInfo { aside.sideContent > div.authorInfo {
grid-template-columns: 1fr 1fr 1fr; grid-template-columns: 1fr 1fr 1fr;
grid-template-rows: repeat(3, auto);
border-top: 5px solid var(--mutedGrey); border-top: 5px solid var(--mutedGrey);
} }
@ -194,4 +202,8 @@
aside.sideContent > div.authorInfo h3 { aside.sideContent > div.authorInfo h3 {
grid-column: span 3; grid-column: span 3;
} }
div.otherPosts, div.newsletter, div.feeds {
width: 100%;
}
} }

199
src/blog/imgs/atomFeed.svg Normal file
View 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

View 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

View File

@ -17,6 +17,9 @@
<meta name="author" content="Rohit Pai"> <meta name="author" content="Rohit Pai">
<link rel="stylesheet" href="/blog/css/main.css"> <link rel="stylesheet" href="/blog/css/main.css">
<script src="https://kit.fontawesome.com/ed3c25598e.js" crossorigin="anonymous"></script> <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> </head>
<body> <body>
<nav> <nav>
@ -70,7 +73,12 @@
</main> </main>
<footer class="flexRow"> <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>&copy; <span id="year"></span> Rohit Pai all rights reserved</p> <p>&copy; <span id="year"></span> Rohit Pai all rights reserved</p>
<div class="button"> <div class="button">
<button id="goBackToTop"><i class="fa-solid fa-chevron-up"></i></button> <button id="goBackToTop"><i class="fa-solid fa-chevron-up"></i></button>

View File

@ -68,6 +68,21 @@ function goToURL(url)
return; return;
} }
if (urlArray[2] === 'policy')
{
if (urlArray[3] === 'privacy')
{
loadPrivacyPolicy();
return;
}
if (urlArray[3] === 'cookie')
{
loadCookiePolicy();
return;
}
}
show404(); 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 * Creates a large post element
* @param post the post object * @param post the post object
@ -124,10 +150,11 @@ function createLargePost(post)
{ {
categories = categories.substring(0, categories.length - 2); categories = categories.substring(0, categories.length - 2);
} }
let dateModifiedString = createFormattedDate(post.dateModified);
postContent.innerHTML = ` postContent.innerHTML = `
<h2>${post.title}</h2> <h2>${post.title}</h2>
<h3>Last updated: ${post.dateModified} | ${categories}</h3> <h3>Last updated: ${dateModifiedString} | ${categories}</h3>
<p>${post.abstract}</p> <p>${post.abstract}</p>
<a href="/blog/post/${post.title}#disqus_thread" class="btn btnPrimary">See Post</a> <a href="/blog/post/${post.title}#disqus_thread" class="btn btnPrimary">See Post</a>
`; `;
@ -315,8 +342,8 @@ async function createSideContent()
</g> </g>
</svg> </svg>
</a> </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>
<div class="otherPosts"> <div class="otherPosts">
<h2>latest post</h2> <h2>latest post</h2>
@ -330,10 +357,29 @@ async function createSideContent()
<p>${featuredPost.abstract}</p> <p>${featuredPost.abstract}</p>
<a href="/blog/post/${featuredPost.title}" class="btn btnPrimary boxShadowIn boxShadowOut">See Post</a> <a href="/blog/post/${featuredPost.title}" class="btn btnPrimary boxShadowIn boxShadowOut">See Post</a>
</div> </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"> <div class="categories">
<h2>categories</h2> <h2>categories</h2>
${categories} ${categories}
</div> </div>
`; `;
return sideContent; return sideContent;
} }
@ -365,8 +411,9 @@ async function loadIndividualPost(title)
article.innerHTML = ` article.innerHTML = `
<h1>${json.title}</h1> <h1>${json.title}</h1>
<div class="byLine"> <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> <h3>${createButtonCategories([csvToArray(json.categories.replace(/\s*,\s*/g, ','))])}</h3>
<div class="sharethis-inline-share-buttons"></div>
</div> </div>
<div class="cover" style="background-image: url('${json.headerImg}')"></div> <div class="cover" style="background-image: url('${json.headerImg}')"></div>
${json.body} ${json.body}
@ -464,6 +511,10 @@ function loadPostsByCategory(category)
})); }));
} }
/**
* Loads the search results
* @param searchTerm the search term
*/
function loadSearchResults(searchTerm) function loadSearchResults(searchTerm)
{ {
document.title = 'Rohit Pai - Search Results for ' + decodeURI(searchTerm); document.title = 'Rohit Pai - Search Results for ' + decodeURI(searchTerm);
@ -492,6 +543,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&amp;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 * Shows the 404 page
*/ */

View File

@ -11,6 +11,28 @@ footer .spacer {
margin-right: auto; 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 { footer p {
margin: auto; margin: auto;
width: 100%; width: 100%;

View File

@ -19,7 +19,7 @@ nav {
width: 100%; width: 100%;
transition: background-color 0.4s ease-in; transition: background-color 0.4s ease-in;
color: #FFFFFF; color: #FFFFFF;
z-index: 1; z-index: 100000000000000000000000000;
} }
nav.scrolled { nav.scrolled {