From 4dbea74e5f50fc7d0edfe12dd4c681bc955ff067 Mon Sep 17 00:00:00 2001 From: Joey Kimsey Date: Sun, 2 Feb 2025 07:14:21 -0500 Subject: [PATCH] Cleanup Improved readme removed contributing and code of conduct as they are basically just fluff when no one knows this repo exists removed composer.lock because this repo doesn't install anything to lock update copywrite to 2025 composer update to description comments --- CODE_OF_CONDUCT.md | 46 --------------------- CONTRIBUTING.md | 94 ------------------------------------------ LICENSE | 2 +- README.md | 45 +++++++++++++++++++- bin/autoload.php | 2 +- classes/autoloader.php | 7 +++- composer.json | 2 +- composer.lock | 20 --------- config/constants.php | 1 + functions/redirect.php | 2 +- functions/route.php | 5 ++- 11 files changed, 59 insertions(+), 167 deletions(-) delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 composer.lock diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md deleted file mode 100644 index 2725688..0000000 --- a/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,46 +0,0 @@ -# Contributor Covenant Code of Conduct - -## Our Pledge - -In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation. - -## Our Standards - -Examples of behavior that contributes to creating a positive environment include: - -* Using welcoming and inclusive language -* Being respectful of differing viewpoints and experiences -* Gracefully accepting constructive criticism -* Focusing on what is best for the community -* Showing empathy towards other community members - -Examples of unacceptable behavior by participants include: - -* The use of sexualized language or imagery and unwelcome sexual attention or advances -* Trolling, insulting/derogatory comments, and personal or political attacks -* Public or private harassment -* Publishing others' private information, such as a physical or electronic address, without explicit permission -* Other conduct which could reasonably be considered inappropriate in a professional setting - -## Our Responsibilities - -Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior. - -Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful. - -## Scope - -This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers. - -## Enforcement - -Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at webmaster@thetempusproject.com. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately. - -Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership. - -## Attribution - -This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version] - -[homepage]: http://contributor-covenant.org -[version]: http://contributor-covenant.org/version/1/4/ diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md deleted file mode 100644 index bb75110..0000000 --- a/CONTRIBUTING.md +++ /dev/null @@ -1,94 +0,0 @@ -# Contribution Guidelines for Hermes - -Contributing to Hermes is completely voluntary and should follow all of the guidelines listed here in order to ensure the highest probability of acceptance. It is highly recommended to use a php linter to automate more of this process. The project is maintained on github and all contributions need to be submitted via pull request to their specific repository under the `dev` branch. In order to contribute, simply follow the instructions for [creating a pull request](#creating-a-pull-request) below. - -## Pull Request Requirements - -- All revisions must follow TTP naming conventions (see [Naming Conventions](#naming-conventions) Section) -- Include a clear and concise explanation of the features or changes included in your revision listed by file. -- All code must follow [PSR 2](http://www.php-fig.org/psr/psr-2/) standards -- prefer the use of [] for arrays over array() -- All functions must be documented with the exception of controller methods (see [Documentation](#documentation) Section) -- Controller methods may be doc-blocked when necessary for clarity (see [Documentation](#documentation) Section) -- All new Classes must include a class level doc-block (see [Documentation](#documentation) Section) -- Any new dependencies will have a longer validation process and should be accompanied by the required information (see [Dependencies](#dependencies) Section) - -## Naming Conventions - -- File names are to be lower case -- All class names must be upper case -- Any data being stored as a file must be saved in the `app/` directory, preferably the `app/config/` directory. -- Controllers must have a constructor and destructor incorporating the constructor and destructor in the Resources Controller -- (This will be an interface requirement soon) -- Views must be named using underscores for separation and must be prefixed with view_ - -## Dependencies - -Whenever a dependency is updated or added, pull requests must include a section that answers the following questions. -- Why is this dependency required -- Could this be reasonably accomplished within the app by implementing new features in a later version? explain. -- What is the latest stable version that can be used -- What features are absolutely necessary for your feature or modification to work - -## Documentation - -### Classes - -New classes must be prefaced with a doc-block following this style: -``` -/** - * controllers/admin.php - * - * This is the admin controller. - * - * @version 1.1 - * @author Joey Kimsey - * @link https://TheTempusProject.com/Hermes - * @license https://opensource.org/licenses/MIT [MIT LICENSE] - */ -``` - -From top to bottom: -- Filename on the second line -- A description for the file -- The TTP version this file was built for -`@version 1.0` -- The Authors name or alias and email -`@author first last ` -- A copy of the MIT license -`@license https://opensource.org/licenses/MIT [MIT LICENSE]` -- May include a link for more information -`@link http://link.com` - -### Functions - -Functions must be prefaced with a doc-block following this style: -``` -/** - * Intended as a self-destruct session. If the specified session does not - * exist, it is created. If the specified session does exist, it will be - * destroyed and returned. - * - * @param string $name - Session name to be created or checked - * @param string $string - The string to be used if session needs to be - * created. (optional) - * - * @return bool|string - Returns bool if creating, and a string if the - * check is successful. - */ -``` - -From top to bottom: -- There must be a description of the functions intended usage on the second line -- All parameters should be documented like this -`@param [type] $name - description` -- Any function with a return statement must also be documented as such -`@return [type] - description` - -## Creating a Pull Request -This is a simple explanation of how to create a pull request for changes to Hermes. You can find a detailed walk-through on how to [create a pull request](https://help.github.com/articles/creating-a-pull-request/) on github. - -1. First ensure you have followed all the contributing guidelines -2. Squash your merge into a single revision. This will make it easier to view the changes as a whole. -3. You can submit a pull request [here](https://github.com/TheTempusProject/Hermes/compare) -4. Please submit all pull requests to the dev branch or they will be ignored. \ No newline at end of file diff --git a/LICENSE b/LICENSE index c32ae1d..7c6f5af 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2024 Joey Kimsey +Copyright (c) 2025 Joey Kimsey Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index 70b9abe..5e74d61 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,47 @@ # Hermes -Hermes is a small package to handle routing and autoloading designed in conjunction with [The Tempus Project](https://thetempusproject.com). +Hermes is a small package to handle redirects, routing, and autoloading. This library id developed in conjunction with [The Tempus Project](https://thetempusproject.com). + +## Usage + +Typical usage would be through including the package via composer. + +```php + +require_once VENDOR_DIRECTORY . 'autoload.php'; + +use TheTempusProject\Hermes\Functions\Redirect; + +if ( ! App::$isAdmin ) { + return Redirect::home(); +} + +``` + +If you would like to use hermes own autoloading, simply inclode the constants file and the autoload file inside `/bin/`. + +```php + +use TheTempusProject\Hermes\Functions\Redirect; + +// Hermes Constants +if ( ! defined( 'HERMES_CONSTANTS_LOADED' ) ) { + if ( defined( 'HERMES_CONFIG_DIRECTORY' ) ) { + require_once HERMES_CONFIG_DIRECTORY . 'constants.php'; + } +} + +// Hermes Autoloader (Autoloader) +if ( ! defined( 'HERMES_AUTOLOADED' ) ) { + if ( defined( 'HERMES_ROOT_DIRECTORY' ) ) { + require_once HERMES_ROOT_DIRECTORY . 'bin' . DIRECTORY_SEPARATOR . 'autoload.php'; + } +} + +if ( ! App::$isAdmin ) { + return Redirect::home(); +} + +``` + diff --git a/bin/autoload.php b/bin/autoload.php index 7785a25..01016b7 100644 --- a/bin/autoload.php +++ b/bin/autoload.php @@ -6,7 +6,7 @@ * * @version 1.1 * @author Joey Kimsey - * @link https://TheTempusProject.com/Hermes + * @link https://TheTempusProject.com/libraries/Hermes * @license https://opensource.org/licenses/MIT [MIT LICENSE] */ namespace TheTempusProject\Hermes; diff --git a/classes/autoloader.php b/classes/autoloader.php index c677fe7..eb24afc 100644 --- a/classes/autoloader.php +++ b/classes/autoloader.php @@ -6,7 +6,7 @@ * * @version 1.1 * @author Joey Kimsey - * @link https://TheTempusProject.com/Hermes + * @link https://TheTempusProject.com/libraries/Hermes * @license https://opensource.org/licenses/MIT [MIT LICENSE] */ namespace TheTempusProject\Hermes\Classes; @@ -120,6 +120,11 @@ class Autoloader { } } + /** + * Tests the class to see if it can be loaded. + * + * @param {string} [$class] + */ public static function testLoad( $class ) { $class = trim( $class, '\\' ); $namespace_array = explode( '\\', $class ); diff --git a/composer.json b/composer.json index e0fd86f..58f82c1 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "thetempusproject/hermes", "type": "library", - "description": "Php functions that aid in routing and redirecting; requests and responses.", + "description": "This library handles redirects, provides a common backbone for routing, and can handle autoloading in cases where composer is unavailable.", "license": "MIT", "minimum-stability": "dev", "keywords": diff --git a/composer.lock b/composer.lock deleted file mode 100644 index eca4965..0000000 --- a/composer.lock +++ /dev/null @@ -1,20 +0,0 @@ -{ - "_readme": [ - "This file locks the dependencies of your project to a known state", - "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", - "This file is @generated automatically" - ], - "content-hash": "d82682b62a8e3d58c3b380eee6f344ec", - "packages": [], - "packages-dev": [], - "aliases": [], - "minimum-stability": "dev", - "stability-flags": [], - "prefer-stable": false, - "prefer-lowest": false, - "platform": { - "php": ">=8.1.0" - }, - "platform-dev": [], - "plugin-api-version": "2.3.0" -} diff --git a/config/constants.php b/config/constants.php index 219f574..1e39e15 100644 --- a/config/constants.php +++ b/config/constants.php @@ -13,6 +13,7 @@ if (!defined('HERMES_CLASSES_DIRECTORY')) { if (!defined('HERMES_REDIRECTS_ENABLED')) { define('HERMES_REDIRECTS_ENABLED', true); } + # Tell the app all constants have been loaded. if ( ! defined('HERMES_CONSTANTS_LOADED' ) ) { define( 'HERMES_CONSTANTS_LOADED', true ); diff --git a/functions/redirect.php b/functions/redirect.php index 5910a81..1f91c61 100644 --- a/functions/redirect.php +++ b/functions/redirect.php @@ -6,7 +6,7 @@ * * @version 1.1 * @author Joey Kimsey - * @link https://TheTempusProject.com/Hermes + * @link https://TheTempusProject.com/libraries/Hermes * @license https://opensource.org/licenses/MIT [MIT LICENSE] */ namespace TheTempusProject\Hermes\Functions; diff --git a/functions/route.php b/functions/route.php index d5be5bf..0ff89b0 100644 --- a/functions/route.php +++ b/functions/route.php @@ -6,7 +6,7 @@ * * @version 1.1 * @author Joey Kimsey - * @link https://TheTempusProject.com/Hermes + * @link https://TheTempusProject.com/libraries/Hermes * @license https://opensource.org/licenses/MIT [MIT LICENSE] */ @@ -14,6 +14,7 @@ namespace TheTempusProject\Hermes\Functions; class Route { public static function testRouting() { + // @todo - wtf // $url = Routes::getAddress( true ) . DEFAULT_CONTROLLER_CLASS . '/' . DEFAULT_CONTROLLER_METHOD; // echo '
' . var_export( $url, true ) . '
'; // $host = gethostbyname( $url ); @@ -59,6 +60,7 @@ class Route { } public static function getHost( $internal = false ) { + // @todo - wtf $host = $_SERVER['HTTP_HOST']; if ( true === $internal ) { // if ( 'docker' === getenv( 'APP_ENV' ) ) { @@ -85,6 +87,7 @@ class Route { $route = implode( '/', $fullArray ) . '/'; return $route; } + /** * finds the physical location of the application *