From 42a0e2f72fed0a947242b004a0fc6eb4a664174b Mon Sep 17 00:00:00 2001 From: Syndamia Date: Sat, 3 Apr 2021 16:04:28 +0300 Subject: Updated all double quotes to single quotes where possible --- src/controllers/BaseController.php | 17 +++++----- src/controllers/CreateOfferController.php | 4 +-- src/controllers/DashboardController.php | 8 ++--- src/controllers/DashboardLoginController.php | 8 ++--- src/controllers/EditOfferController.php | 2 +- src/controllers/LandingController.php | 6 ++-- src/index.php | 18 +++++------ src/models/Company.php | 6 ++-- src/models/DB.php | 46 ++++++++++++++-------------- src/models/DBModel.php | 2 +- src/models/JobOffer.php | 18 +++++------ src/views/edit-offer.php | 2 +- 12 files changed, 68 insertions(+), 69 deletions(-) diff --git a/src/controllers/BaseController.php b/src/controllers/BaseController.php index 2c2a647..f766398 100644 --- a/src/controllers/BaseController.php +++ b/src/controllers/BaseController.php @@ -1,14 +1,14 @@ id] = $company->name; } - include "views/dashboard.php"; + include('views/dashboard.php'); } public static function post() { switch($_POST['_method']) { - case "get": + case 'get': EditOfferController::get(); break; - case "put": + case 'put': EditOfferController::put(); break; - case "delete": + case 'delete': EditOfferController::delete(); break; } diff --git a/src/controllers/DashboardLoginController.php b/src/controllers/DashboardLoginController.php index fe2009b..af1113e 100644 --- a/src/controllers/DashboardLoginController.php +++ b/src/controllers/DashboardLoginController.php @@ -6,20 +6,20 @@ class DashboardLoginController extends BaseController { private static $message; public static function get() { - include "views/dashboard-login.php"; + include('views/dashboard-login.php'); } public static function post() { if (isset($_POST['_method'])) { DashboardController::invoke(); } - else if ($_POST['username'] == "admin" && $_POST['password'] == "admin") { + else if ($_POST['username'] == 'admin' && $_POST['password'] == 'admin') { // Load normal dashboard DashboardController::get(); } else { - self::$message = "Bad credentials!"; - include "views/dashboard-login.php"; + self::$message = 'Bad credentials!'; + include('views/dashboard-login.php'); } } } diff --git a/src/controllers/EditOfferController.php b/src/controllers/EditOfferController.php index ae49c5b..dc9a753 100644 --- a/src/controllers/EditOfferController.php +++ b/src/controllers/EditOfferController.php @@ -11,7 +11,7 @@ class EditOfferController extends BaseController { public static function get() { self::$job = JobOffer::getFromDBById($_POST['jobId']); self::$companies = Company::getAllFromDB(); - include "views/edit-offer.php"; + include('views/edit-offer.php'); } public static function put() { diff --git a/src/controllers/LandingController.php b/src/controllers/LandingController.php index ffa8644..9e81751 100644 --- a/src/controllers/LandingController.php +++ b/src/controllers/LandingController.php @@ -1,7 +1,7 @@ id] = $company->name; } - include "views/landing.php"; + include('views/landing.php'); } } diff --git a/src/index.php b/src/index.php index 8b45dea..be262cd 100644 --- a/src/index.php +++ b/src/index.php @@ -30,9 +30,9 @@ createTable(self::TABLE_NAME, $columns); } diff --git a/src/models/DB.php b/src/models/DB.php index 8174831..0f06573 100644 --- a/src/models/DB.php +++ b/src/models/DB.php @@ -3,34 +3,34 @@ * The model that has the database functionality. DO NOT instantiate this class! If you need an instance, extend the DBModel class! */ class DB { - private static $servername = "localhost"; - private static $username = "root"; - private static $password = "password"; - private static $dbname = "devrix_job_board"; + private static $servername = 'localhost'; + private static $username = 'root'; + private static $password = 'password'; + private static $dbname = 'devrix_job_board'; - public const STRING_TYPE = "VARCHAR(100)"; - public const FLOAT_TYPE = "DOUBLE(16,4)"; - public const INTEGER_TYPE = "INT"; + public const STRING_TYPE = 'VARCHAR(100)'; + public const FLOAT_TYPE = 'DOUBLE(16,4)'; + public const INTEGER_TYPE = 'INT'; private PDO $connection; function __construct() { // Try to connect try { - $this->connection = new PDO("mysql:host=" . self::$servername, self::$username, self::$password); + $this->connection = new PDO('mysql:host=' . self::$servername, self::$username, self::$password); $this->connection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); } catch (PDOException $e) { - echo "[DB Exception]: " . $e->getMessage(); + echo '[DB Exception]: ' . $e->getMessage(); } // Make sure the actual db exists - $createDBQuery = "CREATE DATABASE IF NOT EXISTS " . self::$dbname . ";"; + $createDBQuery = 'CREATE DATABASE IF NOT EXISTS ' . self::$dbname . ';'; $this->connection->exec($createDBQuery); // Connect to the actual database - $this->connection->exec("USE " . self::$dbname); + $this->connection->exec('USE ' . self::$dbname); } /** @@ -63,20 +63,20 @@ class DB { $query .= "{$column}, "; } - $query .= "PRIMARY KEY (id), "; + $query .= 'PRIMARY KEY (id), '; foreach ($foreignKeys as $fk) { $query .= "{$fk}, "; } - $query = rtrim($query, ", "); - $query .= ");"; + $query = rtrim($query, ', '); + $query .= ');'; try { $this->connection->exec($query); } catch (PDOException $e) { - echo "[DB Exception]: " . $e->getMessage(); + echo '[DB Exception]: ' . $e->getMessage(); } } @@ -92,22 +92,22 @@ class DB { $query = "INSERT INTO {$tableName} VALUES(NULL, "; foreach($values as $value) { - if (gettype($value) == "string") { + if (gettype($value) == 'string') { $query .= "'{$value}', "; } else { $query .= "{$value}, "; } } - $query = rtrim($query, ", "); + $query = rtrim($query, ', '); - $query .= ");"; + $query .= ');'; try { $this->connection->exec($query); } catch (PDOException $e) { - echo "[DB Exception]: " . $e->getMessage(); + echo '[DB Exception]: ' . $e->getMessage(); } } @@ -146,9 +146,9 @@ class DB { $query = "UPDATE {$tableName} SET "; for ($i = 0; $i < sizeof($values); $i += 2) { - $query .= "{$values[$i]} = " . (gettype($values[$i+1]) == "string" ? "'{$values[$i+1]}'" : $values[$i+1]) . ", "; + $query .= "{$values[$i]} = " . (gettype($values[$i+1]) == 'string' ? "'{$values[$i+1]}'" : $values[$i+1]) . ', '; } - $query = rtrim($query, ", "); + $query = rtrim($query, ', '); $query .= " WHERE id = {$id};"; @@ -156,7 +156,7 @@ class DB { $this->connection->exec($query); } catch (PDOException $e) { - echo "[DB Exception]: " . $e->getMessage(); + echo '[DB Exception]: ' . $e->getMessage(); } } @@ -170,7 +170,7 @@ class DB { $this->connection->exec("DELETE FROM {$tableName} WHERE id = {$id}"); } catch (PDOException $e) { - echo "[DB Exception]: " . $e->getMessage(); + echo '[DB Exception]: ' . $e->getMessage(); } } } diff --git a/src/models/DBModel.php b/src/models/DBModel.php index 4e10c18..a9f931c 100644 --- a/src/models/DBModel.php +++ b/src/models/DBModel.php @@ -1,5 +1,5 @@ createTable(self::TABLE_NAME, $columns, $foreignKeys); } @@ -77,7 +77,7 @@ class JobOffer extends DBModel { * @param JobOffer $jb */ static function updateFromDB($jb) { - self::$DB->updateById(self::TABLE_NAME, $jb->id, "title", $jb->title, "description", $jb->description, "companyId", $jb->companyId, "salary", $jb->salary); + self::$DB->updateById(self::TABLE_NAME, $jb->id, 'title', $jb->title, 'description', $jb->description, 'companyId', $jb->companyId, 'salary', $jb->salary); } /* Delete */ diff --git a/src/views/edit-offer.php b/src/views/edit-offer.php index 992b08e..2643fce 100644 --- a/src/views/edit-offer.php +++ b/src/views/edit-offer.php @@ -13,7 +13,7 @@ id}\""; - echo (self::$job->companyId == $company->id ? "selected" : "") . ">{$company->name}"; + echo (self::$job->companyId == $company->id ? 'selected' : '') . '>{$company->name}'; } ?> -- cgit v1.3.1-26-gb76a From 9b086f2c849aa765c3e5a72a7063343e7237f030 Mon Sep 17 00:00:00 2001 From: Syndamia Date: Sat, 3 Apr 2021 16:06:33 +0300 Subject: Removed backticks from DB model --- src/models/DB.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/models/DB.php b/src/models/DB.php index 0f06573..db93d32 100644 --- a/src/models/DB.php +++ b/src/models/DB.php @@ -117,7 +117,7 @@ class DB { * Returns the next value that has the given id. */ function getById(string $tableName, int $id) { - $sth = $this->connection->prepare("SELECT * FROM `{$tableName}` WHERE id = {$id}"); + $sth = $this->connection->prepare("SELECT * FROM {$tableName} WHERE id = {$id}"); $sth->execute(); return $sth->fetch(PDO::FETCH_OBJ); @@ -127,7 +127,7 @@ class DB { * Returns all values inside a table. */ function getAllValues(string $tableName) { - $sth = $this->connection->prepare("SELECT * FROM `{$tableName}`"); + $sth = $this->connection->prepare("SELECT * FROM {$tableName}"); $sth->execute(); return $sth->fetchAll(PDO::FETCH_OBJ); -- cgit v1.3.1-26-gb76a From 7ef2ae186ec847d0e8ae82cbfd5117a94687aa70 Mon Sep 17 00:00:00 2001 From: Syndamia Date: Sat, 3 Apr 2021 16:09:59 +0300 Subject: Updated formatting of if-else statements in DB model --- src/models/DB.php | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/models/DB.php b/src/models/DB.php index db93d32..c14b9d3 100644 --- a/src/models/DB.php +++ b/src/models/DB.php @@ -92,12 +92,10 @@ class DB { $query = "INSERT INTO {$tableName} VALUES(NULL, "; foreach($values as $value) { - if (gettype($value) == 'string') { + if (gettype($value) == 'string') $query .= "'{$value}', "; - } - else { + else $query .= "{$value}, "; - } } $query = rtrim($query, ', '); @@ -146,7 +144,14 @@ class DB { $query = "UPDATE {$tableName} SET "; for ($i = 0; $i < sizeof($values); $i += 2) { - $query .= "{$values[$i]} = " . (gettype($values[$i+1]) == 'string' ? "'{$values[$i+1]}'" : $values[$i+1]) . ', '; + $query .= "{$values[$i]} = "; + + if (gettype($values[$i+1]) == 'string') + $query .= "'{$values[$i+1]}'"; + else + $query .= $values[$i+1]; + + $query .= ', '; } $query = rtrim($query, ', '); -- cgit v1.3.1-26-gb76a From 6d9f958082d7c1ebee30b0477bf6446fb3d09abb Mon Sep 17 00:00:00 2001 From: Syndamia Date: Sat, 3 Apr 2021 16:15:30 +0300 Subject: Updated comments and documentation in DB model --- src/models/DB.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/models/DB.php b/src/models/DB.php index c14b9d3..f424334 100644 --- a/src/models/DB.php +++ b/src/models/DB.php @@ -34,6 +34,8 @@ class DB { } /** + * Generates a foreign key string from the given parameters. + * * @return string */ static function genFK(string $currentColumn, string $foreignTable, string $foreignColumn) { @@ -59,10 +61,12 @@ class DB { $query = "CREATE TABLE IF NOT EXISTS {$tableName}( id INT NOT NULL AUTO_INCREMENT, "; + // Create column parts of query string foreach ($columns as $column) { $query .= "{$column}, "; } + // Create key(s) parts of query string $query .= 'PRIMARY KEY (id), '; foreach ($foreignKeys as $fk) { @@ -91,7 +95,9 @@ class DB { function insertValue(string $tableName, ...$values) { $query = "INSERT INTO {$tableName} VALUES(NULL, "; + // Create the values part of the query string foreach($values as $value) { + // In queries, strings must be surrounded in single quotes if (gettype($value) == 'string') $query .= "'{$value}', "; else @@ -143,9 +149,11 @@ class DB { function updateById(string $tableName, int $id, ...$values) { $query = "UPDATE {$tableName} SET "; + // Create the name = value part of query string for ($i = 0; $i < sizeof($values); $i += 2) { $query .= "{$values[$i]} = "; + // In queries, strings must be surrounded in single quotes if (gettype($values[$i+1]) == 'string') $query .= "'{$values[$i+1]}'"; else -- cgit v1.3.1-26-gb76a From 976b399f90fc5c0152f87e474e61e6065c0e7a5f Mon Sep 17 00:00:00 2001 From: Syndamia Date: Sat, 3 Apr 2021 16:25:24 +0300 Subject: Updated the comments and documentation in some controllers --- src/controllers/BaseController.php | 4 ++++ src/controllers/DashboardController.php | 3 +++ src/controllers/DashboardLoginController.php | 3 +++ 3 files changed, 10 insertions(+) diff --git a/src/controllers/BaseController.php b/src/controllers/BaseController.php index f766398..412cf25 100644 --- a/src/controllers/BaseController.php +++ b/src/controllers/BaseController.php @@ -1,5 +1,9 @@ Date: Sat, 3 Apr 2021 16:27:19 +0300 Subject: Fixed single quotes that needed to be double quotes in edit offer view --- src/views/edit-offer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/views/edit-offer.php b/src/views/edit-offer.php index 2643fce..b1961d6 100644 --- a/src/views/edit-offer.php +++ b/src/views/edit-offer.php @@ -13,7 +13,7 @@ id}\""; - echo (self::$job->companyId == $company->id ? 'selected' : '') . '>{$company->name}'; + echo (self::$job->companyId == $company->id ? 'selected' : '') . ">{$company->name}"; } ?> -- cgit v1.3.1-26-gb76a From a6ff5db126f29f2b26161f6df40261e84c58cf3a Mon Sep 17 00:00:00 2001 From: Syndamia Date: Sat, 3 Apr 2021 17:13:55 +0300 Subject: Added setup and a bit of project information to README --- README.md | 31 ++++++++++++++++++++++++++++++- configs/devrix-job-board.conf | 1 - 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 641416b..cdb43fd 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,31 @@ # devrix-job-board -The repository for my solution of DevriX's exam for their internship program + +The repository for my solution of DevriX's exam for their internship program. + +It's an oversimplified job offer website, (roughly) following the MVC design pattern and using the LAMP stack (with MySQL). + +## Contents +- [Getting started](#Getting%20started) +- [Tools](#Tools) + +## Getting started + +1. As previously mentioned, the project uses the LAMP stack. Links on setting it up: [Ubuntu 20.04](https://www.digitalocean.com/community/tutorials/how-to-install-linux-apache-mysql-php-lamp-stack-on-ubuntu-20-04), [Debian 8](https://www.digitalocean.com/community/tutorials/how-to-install-linux-apache-mysql-php-lamp-stack-on-debian-8) or [CentOS 8](https://www.digitalocean.com/community/tutorials/how-to-install-linux-apache-mariadb-php-lamp-stack-on-centos-8). + +2. Currently this repo provides an Apache configuration file (`configs/devrix-job-board.conf`) with the localhost domain `djb.local`. + - To use that domain, you'll also need to open your `/etc/hosts` file and add on a new line line `127.0.0.1 djb.local`, but **be wary**, it will break any other localhost domains you've setup. + - If you wanna use it in a server-hosted environment, update the values of `ServerName` and `ServerAlias` with your desired domain and subdomain. + +3. Finally, we'll need to move the source code to the `/var/www/devrix-job-board/` folder. + - This (and creating the folder if it doesn't exist) can be done automatically, just run with sudo the `move-to-www.sh`: + ``` + sudo ./tools/move-to-www.sh + ``` + +## Tools + +This repo contains some tools that could be useful during setup and development of the app. They're all located in the `tools` folder. + +1. `move-to-www.sh` - moves the source code (located in `src`) to the `/var/www/devrix-job-board/` folder +2. `watch-move-to-www.sh` - does the same thing as `move-to-www.sh`, but does it automatically every time you update a file inside the `src` folder. Especially useful while developing the application. + - Dependencies: [`inotify-tools`](https://pkgs.org/download/inotify-tools) diff --git a/configs/devrix-job-board.conf b/configs/devrix-job-board.conf index 49356f2..88021bc 100644 --- a/configs/devrix-job-board.conf +++ b/configs/devrix-job-board.conf @@ -12,4 +12,3 @@ RewriteRule ^(.+)$ index.php [QSA,L] - -- cgit v1.3.1-26-gb76a From efdeffeba81ba473dbd38aa5466590e306bffdb3 Mon Sep 17 00:00:00 2001 From: Syndamia Date: Sat, 3 Apr 2021 17:52:02 +0300 Subject: Added a lot more information about the project and it's future in the README --- README.md | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 50 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index cdb43fd..a06819e 100644 --- a/README.md +++ b/README.md @@ -4,24 +4,57 @@ The repository for my solution of DevriX's exam for their internship program. It's an oversimplified job offer website, (roughly) following the MVC design pattern and using the LAMP stack (with MySQL). +**CREDENTIALS FOR DASHBOARD** +``` +Username: admin +Password: admin +``` + ## Contents - [Getting started](#Getting%20started) +- [Structure](#Structure) - [Tools](#Tools) +- [Issues and Future](#Issues%20and%20Future) ## Getting started 1. As previously mentioned, the project uses the LAMP stack. Links on setting it up: [Ubuntu 20.04](https://www.digitalocean.com/community/tutorials/how-to-install-linux-apache-mysql-php-lamp-stack-on-ubuntu-20-04), [Debian 8](https://www.digitalocean.com/community/tutorials/how-to-install-linux-apache-mysql-php-lamp-stack-on-debian-8) or [CentOS 8](https://www.digitalocean.com/community/tutorials/how-to-install-linux-apache-mariadb-php-lamp-stack-on-centos-8). -2. Currently this repo provides an Apache configuration file (`configs/devrix-job-board.conf`) with the localhost domain `djb.local`. - - To use that domain, you'll also need to open your `/etc/hosts` file and add on a new line line `127.0.0.1 djb.local`, but **be wary**, it will break any other localhost domains you've setup. +2. You'll need to update the source code with your `MySQL` credentials. In the file `src/models/DB.php`, on lines 6 to 9 you'll find the connection information. You'll need to change the values of `$username` and `$password` with your own. + - If you're connecting to a remote database or have your database at a non-standart port, you'll also need to change `$servername`. Changing the value of `$dbname` is completely up to preference. + - Don't worry if the database doesn't exist, when the app starts it automatically creates the database and tables if they don't exist. + +3. Currently this repo provides an Apache configuration file (`configs/devrix-job-board.conf`) with the localhost domain `djb.local`. + - To use that domain, you'll also need to open your `/etc/hosts` file and add, on a new line, `127.0.0.1 djb.local`. **Be ware**, it will break any other localhost domains you've setup. - If you wanna use it in a server-hosted environment, update the values of `ServerName` and `ServerAlias` with your desired domain and subdomain. -3. Finally, we'll need to move the source code to the `/var/www/devrix-job-board/` folder. +4. Finally, we'll need to move the source code to the `/var/www/devrix-job-board/` folder. - This (and creating the folder if it doesn't exist) can be done automatically, just run with sudo the `move-to-www.sh`: ``` sudo ./tools/move-to-www.sh ``` +## Structure + +This section serves pretty much as a small documentatino of the overall project. + +### Back-end + +For the back-end, it uses pure PHP, without any libraries what so ever. Database access is done with automatically generated queries (see [`DB.php`](https://github.com/Syndamia/devrix-job-board/blob/main/src/models/DB.php)) and URI routing is done, using the `$_SERVER`'s request URI (see [index.php, Line 44](https://github.com/Syndamia/devrix-job-board/blob/67bc860ea4b3db5033a42038ab86d0df955c9295/src/index.php#L44)). + +The database has two tables: `companies` and `job_offers`. Inside `companies` is stored the different company name. `job_offers` contains the actual job offers, where the company is referenced with a foreign key to the `comapnies` table. + +### Front-end + +The front-end is a modified version of the given [template](https://github.com/xavortm/html-template-jobs). I took the CSS and the structure of the HTML files and applied it as closely to the original as I can. + +There are also a few custom stylings I had to make, all located in [`prog.css`](https://github.com/Syndamia/devrix-job-board/blob/main/src/css/prog.css). These are mainly: +- a navigation bar +- form and input styling +- pages that have only a form inside them (for example, the [`create offer`](https://github.com/Syndamia/devrix-job-board/blob/main/src/views/create-offer.php) page) + +**Note**: on the landing page, job offers have a picture to the right side of them. This is by design, since the template originally had them and without them, the job offers look weird/bad. There is no functinality behind them, they're static and purely aesthetical. + ## Tools This repo contains some tools that could be useful during setup and development of the app. They're all located in the `tools` folder. @@ -29,3 +62,17 @@ This repo contains some tools that could be useful during setup and development 1. `move-to-www.sh` - moves the source code (located in `src`) to the `/var/www/devrix-job-board/` folder 2. `watch-move-to-www.sh` - does the same thing as `move-to-www.sh`, but does it automatically every time you update a file inside the `src` folder. Especially useful while developing the application. - Dependencies: [`inotify-tools`](https://pkgs.org/download/inotify-tools) + +## Issues and Future + +The project has the following issues, that the original task description didn't explicitly require to be fixed, but might be a good idea to explore: +- There is no "404 Not-found" page +- There is no system for user accounts (and by extension, no system for accepting/signing up to job offers) +- There is no job offer page (a page for viewing a job offer; currently it only makes sense for sharing, as the landing page shows all job offer information) +- There is no way to practical way to change the Dashboard page credentials or add multiple ones (e.g. they're hard coded) + +These are the following things that might be a good idea to explore, post exam evaluation: +- Actually using proper tools for the job (using an ORM for database queries, using a more fleshed out routing plugin, etc.) +- Adding search functionalities (by words and by tags, like company, date, salary, etc.) +- Either adding more info to job offers or updating the styling to better fit the current job offers +- Have a proper way to add and remove companies -- cgit v1.3.1-26-gb76a From cc35f9a9e7f57e2afc48767a7f392529d448a072 Mon Sep 17 00:00:00 2001 From: Syndamia Date: Sat, 3 Apr 2021 17:56:31 +0300 Subject: By default the company table will now come with three company names --- src/models/Company.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/models/Company.php b/src/models/Company.php index 965531e..58b1734 100644 --- a/src/models/Company.php +++ b/src/models/Company.php @@ -19,6 +19,13 @@ class Company extends DBModel { 'name ' . DB::STRING_TYPE, ); self::$DB->createTable(self::TABLE_NAME, $columns); + + // Since there is no real way to add companies, this serves as the only official way. + if (sizeof(self::getAllFromDB()) == 0) { + self::insertIntoDB(new Company("MegaCorp")); + self::insertIntoDB(new Company("Cool INC.")); + self::insertIntoDB(new Company("Company Awesome Ltd.")); + } } /* Create */ -- cgit v1.3.1-26-gb76a From 434fc21aac69e50634ce69a6131b0b9829cb3d26 Mon Sep 17 00:00:00 2001 From: Syndamia Date: Sat, 3 Apr 2021 17:57:15 +0300 Subject: Fixed readme contents not having the back and front end sub section --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index a06819e..eb9cf60 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,8 @@ Password: admin ## Contents - [Getting started](#Getting%20started) - [Structure](#Structure) + - [Back-end](#Back-end) + - [Front-end](#Front-end) - [Tools](#Tools) - [Issues and Future](#Issues%20and%20Future) -- cgit v1.3.1-26-gb76a From cdffdc8bf0c52806b830ca796c49a6ffc1ab8e73 Mon Sep 17 00:00:00 2001 From: Syndamia Date: Sat, 3 Apr 2021 18:00:08 +0300 Subject: Fixed wording in README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index eb9cf60..62cc190 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,7 @@ Password: admin ## Structure -This section serves pretty much as a small documentatino of the overall project. +This section serves pretty much as the documentation of the overall project. ### Back-end -- cgit v1.3.1-26-gb76a From 56210f7fe7d1994a06a6e1a7e7d93670e937a954 Mon Sep 17 00:00:00 2001 From: Syndamia Date: Sat, 3 Apr 2021 18:04:23 +0300 Subject: Added screenshots --- README.md | 9 +++++++++ screenshots/create-offer.png | Bin 0 -> 22385 bytes screenshots/dashboard-logged-in.png | Bin 0 -> 24299 bytes screenshots/dashboard-login.png | Bin 0 -> 15029 bytes screenshots/edit-offer.png | Bin 0 -> 24981 bytes screenshots/landing-page.png | Bin 0 -> 29352 bytes 6 files changed, 9 insertions(+) create mode 100644 screenshots/create-offer.png create mode 100644 screenshots/dashboard-logged-in.png create mode 100644 screenshots/dashboard-login.png create mode 100644 screenshots/edit-offer.png create mode 100644 screenshots/landing-page.png diff --git a/README.md b/README.md index 62cc190..9589156 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,15 @@ Username: admin Password: admin ``` +
+ Screenshorts of site + + + + + +
+ ## Contents - [Getting started](#Getting%20started) - [Structure](#Structure) diff --git a/screenshots/create-offer.png b/screenshots/create-offer.png new file mode 100644 index 0000000..31e07a4 Binary files /dev/null and b/screenshots/create-offer.png differ diff --git a/screenshots/dashboard-logged-in.png b/screenshots/dashboard-logged-in.png new file mode 100644 index 0000000..cf56610 Binary files /dev/null and b/screenshots/dashboard-logged-in.png differ diff --git a/screenshots/dashboard-login.png b/screenshots/dashboard-login.png new file mode 100644 index 0000000..fa0b16d Binary files /dev/null and b/screenshots/dashboard-login.png differ diff --git a/screenshots/edit-offer.png b/screenshots/edit-offer.png new file mode 100644 index 0000000..8d045c7 Binary files /dev/null and b/screenshots/edit-offer.png differ diff --git a/screenshots/landing-page.png b/screenshots/landing-page.png new file mode 100644 index 0000000..d42302f Binary files /dev/null and b/screenshots/landing-page.png differ -- cgit v1.3.1-26-gb76a From adf879d7d3a6b118117af2482c1545f6f72e0342 Mon Sep 17 00:00:00 2001 From: Syndamia Date: Sat, 3 Apr 2021 18:05:24 +0300 Subject: Fixed screenshots summary in README --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 9589156..9813992 100644 --- a/README.md +++ b/README.md @@ -12,11 +12,11 @@ Password: admin
Screenshorts of site - - - - - + + + + +
## Contents -- cgit v1.3.1-26-gb76a From 2e022c316ebf7f3846188a92d080cef07134e662 Mon Sep 17 00:00:00 2001 From: Syndamia Date: Sat, 3 Apr 2021 18:10:46 +0300 Subject: Fixed typos and bad wording in README --- README.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 9813992..b464099 100644 --- a/README.md +++ b/README.md @@ -33,21 +33,21 @@ Password: admin 2. You'll need to update the source code with your `MySQL` credentials. In the file `src/models/DB.php`, on lines 6 to 9 you'll find the connection information. You'll need to change the values of `$username` and `$password` with your own. - If you're connecting to a remote database or have your database at a non-standart port, you'll also need to change `$servername`. Changing the value of `$dbname` is completely up to preference. - - Don't worry if the database doesn't exist, when the app starts it automatically creates the database and tables if they don't exist. + - Don't worry if the database or tables don't exist, when the app starts it automatically create them. 3. Currently this repo provides an Apache configuration file (`configs/devrix-job-board.conf`) with the localhost domain `djb.local`. - - To use that domain, you'll also need to open your `/etc/hosts` file and add, on a new line, `127.0.0.1 djb.local`. **Be ware**, it will break any other localhost domains you've setup. - - If you wanna use it in a server-hosted environment, update the values of `ServerName` and `ServerAlias` with your desired domain and subdomain. + - To use that domain, you'll also need to open your `/etc/hosts` file and add, on a new line, `127.0.0.1 djb.local`. **Beware**, it will break any other localhost domains you've setup. + - If you wanna use it in a server environment, update the values of `ServerName` and `ServerAlias` with your desired domain and subdomain. 4. Finally, we'll need to move the source code to the `/var/www/devrix-job-board/` folder. - - This (and creating the folder if it doesn't exist) can be done automatically, just run with sudo the `move-to-www.sh`: + - This (and creating the folder if it doesn't exist) can be done automatically, just run with sudo the `move-to-www.sh` script: ``` sudo ./tools/move-to-www.sh ``` ## Structure -This section serves pretty much as the documentation of the overall project. +This section serves as a mini-documentation of the overall project. ### Back-end @@ -57,7 +57,7 @@ The database has two tables: `companies` and `job_offers`. Inside `companies` is ### Front-end -The front-end is a modified version of the given [template](https://github.com/xavortm/html-template-jobs). I took the CSS and the structure of the HTML files and applied it as closely to the original as I can. +The front-end is a modified version of the given [template](https://github.com/xavortm/html-template-jobs). I took the CSS and the structure of the HTML files and applied it to my structure, trying to leave behind as little as possible. There are also a few custom stylings I had to make, all located in [`prog.css`](https://github.com/Syndamia/devrix-job-board/blob/main/src/css/prog.css). These are mainly: - a navigation bar -- cgit v1.3.1-26-gb76a From 7828d17000f2af72e2602c0813844499cba4612f Mon Sep 17 00:00:00 2001 From: Syndamia Date: Sat, 3 Apr 2021 18:13:31 +0300 Subject: Removed static company image from landing page job offers --- README.md | 2 -- screenshots/landing-page.png | Bin 29352 -> 24583 bytes src/views/landing.php | 5 ----- 3 files changed, 7 deletions(-) diff --git a/README.md b/README.md index b464099..6dfef59 100644 --- a/README.md +++ b/README.md @@ -64,8 +64,6 @@ There are also a few custom stylings I had to make, all located in [`prog.css`]( - form and input styling - pages that have only a form inside them (for example, the [`create offer`](https://github.com/Syndamia/devrix-job-board/blob/main/src/views/create-offer.php) page) -**Note**: on the landing page, job offers have a picture to the right side of them. This is by design, since the template originally had them and without them, the job offers look weird/bad. There is no functinality behind them, they're static and purely aesthetical. - ## Tools This repo contains some tools that could be useful during setup and development of the app. They're all located in the `tools` folder. diff --git a/screenshots/landing-page.png b/screenshots/landing-page.png index d42302f..0a76312 100644 Binary files a/screenshots/landing-page.png and b/screenshots/landing-page.png differ diff --git a/src/views/landing.php b/src/views/landing.php index 514e5a7..97b53f7 100644 --- a/src/views/landing.php +++ b/src/views/landing.php @@ -12,11 +12,6 @@ '. $job->description . ' - '; } ?> -- cgit v1.3.1-26-gb76a From 3b0cbc90e3046a8bb979c2b9a17fae5a94bb2707 Mon Sep 17 00:00:00 2001 From: Syndamia Date: Sat, 3 Apr 2021 18:19:20 +0300 Subject: Added database exports --- README.md | 2 +- db-export/devrix_job_board.sql | 111 +++++++++++++++++++++++++++++++++++++++++ db-export/devrix_job_board.xml | 70 ++++++++++++++++++++++++++ 3 files changed, 182 insertions(+), 1 deletion(-) create mode 100644 db-export/devrix_job_board.sql create mode 100644 db-export/devrix_job_board.xml diff --git a/README.md b/README.md index 6dfef59..7003325 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ The repository for my solution of DevriX's exam for their internship program. -It's an oversimplified job offer website, (roughly) following the MVC design pattern and using the LAMP stack (with MySQL). +It's an oversimplified job offer website, (roughly) following the MVC design pattern and using the LAMP stack (with MySQL). In `src` you can find the source code and in `db-export` you can find the export of a very small demo database. **CREDENTIALS FOR DASHBOARD** ``` diff --git a/db-export/devrix_job_board.sql b/db-export/devrix_job_board.sql new file mode 100644 index 0000000..a65dbfd --- /dev/null +++ b/db-export/devrix_job_board.sql @@ -0,0 +1,111 @@ +-- phpMyAdmin SQL Dump +-- version 5.1.0 +-- https://www.phpmyadmin.net/ +-- +-- Host: localhost +-- Generation Time: Apr 03, 2021 at 03:15 PM +-- Server version: 8.0.23 +-- PHP Version: 7.4.16 + +SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; +START TRANSACTION; +SET time_zone = "+00:00"; + + +/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; +/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; +/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; +/*!40101 SET NAMES utf8mb4 */; + +-- +-- Database: `devrix_job_board` +-- + +-- -------------------------------------------------------- + +-- +-- Table structure for table `companies` +-- + +CREATE TABLE `companies` ( + `id` int NOT NULL, + `name` varchar(100) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; + +-- +-- Dumping data for table `companies` +-- + +INSERT INTO `companies` (`id`, `name`) VALUES +(1, 'MegaCorp'), +(2, 'Cool INC.'); + +-- -------------------------------------------------------- + +-- +-- Table structure for table `job_offers` +-- + +CREATE TABLE `job_offers` ( + `id` int NOT NULL, + `title` varchar(100) DEFAULT NULL, + `description` varchar(100) DEFAULT NULL, + `companyId` int DEFAULT NULL, + `salary` double(16,4) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; + +-- +-- Dumping data for table `job_offers` +-- + +INSERT INTO `job_offers` (`id`, `title`, `description`, `companyId`, `salary`) VALUES +(1, 'Programmer', 'Coding', 1, 2000.0000), +(7, 'Test Job', 'Testing', 2, 346.0000); + +-- +-- Indexes for dumped tables +-- + +-- +-- Indexes for table `companies` +-- +ALTER TABLE `companies` + ADD PRIMARY KEY (`id`); + +-- +-- Indexes for table `job_offers` +-- +ALTER TABLE `job_offers` + ADD PRIMARY KEY (`id`), + ADD KEY `fk_companyId_companies` (`companyId`); + +-- +-- AUTO_INCREMENT for dumped tables +-- + +-- +-- AUTO_INCREMENT for table `companies` +-- +ALTER TABLE `companies` + MODIFY `id` int NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3; + +-- +-- AUTO_INCREMENT for table `job_offers` +-- +ALTER TABLE `job_offers` + MODIFY `id` int NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=10; + +-- +-- Constraints for dumped tables +-- + +-- +-- Constraints for table `job_offers` +-- +ALTER TABLE `job_offers` + ADD CONSTRAINT `fk_companyId_companies` FOREIGN KEY (`companyId`) REFERENCES `companies` (`id`); +COMMIT; + +/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; +/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; +/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; diff --git a/db-export/devrix_job_board.xml b/db-export/devrix_job_board.xml new file mode 100644 index 0000000..5f8488a --- /dev/null +++ b/db-export/devrix_job_board.xml @@ -0,0 +1,70 @@ + + + + + + + + + CREATE TABLE `companies` ( + `id` int NOT NULL AUTO_INCREMENT, + `name` varchar(100) DEFAULT NULL, + PRIMARY KEY (`id`) + ) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; + + + CREATE TABLE `job_offers` ( + `id` int NOT NULL AUTO_INCREMENT, + `title` varchar(100) DEFAULT NULL, + `description` varchar(100) DEFAULT NULL, + `companyId` int DEFAULT NULL, + `salary` double(16,4) DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `fk_companyId_companies` (`companyId`), + CONSTRAINT `fk_companyId_companies` FOREIGN KEY (`companyId`) REFERENCES `companies` (`id`) + ) ENGINE=InnoDB AUTO_INCREMENT=10 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; + + + + + + + + + 1 + MegaCorp +
+ + 2 + Cool INC. +
+ + + 1 + Programmer + Coding + 1 + 2000.0000 +
+ + 7 + Test Job + Testing + 2 + 346.0000 +
+
+
\ No newline at end of file -- cgit v1.3.1-26-gb76a