This is a lightweight clone of Reddit written in Laravel 5. It only has the following features:
- User registration.
- User authentication.
- Registered users are called "Readitors" and they are allowed to post links to the site.
- All users are allowed to see all the links posted by all readitors.
- Only readitors are allowed to upvote and downvote links.
- Readitors can toggle their votes on links at any moment.
- Readitors can also cancel their votes at any moment.
- Links are ranked by votes, most voted links appear at the top.
- Links decrease their rank as time goes by, in order to allow new links to be at the top.
- Every 5 minutes a link decay its rank by one point. A day has
1440minutes, then any link loose
288points daily (
1440/5). If a link was posted yesterday, and it has
300points at this moment, its current rank would be
300 - 288).
In order to run this application locally, you'll need PHP 5.6, MySQL 5.6, and a global installation of Composer.
.envfile, and edit it with your database development values.
$ cp .env.example .env
Install the application.
$ source .env $ make install RUSER="root" RPSWD="root" HOST=$DB_HOST DB=$DB_DATABASE USER=DB_USERNAME PSWD=DB_PASSWORD
Where the values of
RPSWDare the credentials of a user with permissions to create databases and users.
Run the application
$ php artisan serve
Browse to http://localhost:8000/
In order to run the tests you should create a database with the following command. And run the migrations for that database.
make database RUSER="root" RPSWD="root" HOST="localhost" DB="homestead_test" USER="homestead" PSWD="secret" php artisan migrate --database="testing"
RPSWD are the credentials of a user with permissions to create
databases and users. This configuration is also used by Travis.
Features are described using phpspec and there are some integration tests with PHPUnit.
$ bin/phpspec run $ bin/phpunit --testdox
There is room for improvement. This is my first Laravel application, so bear with me.
- Ajax calls to vote a link should be sent through post.
- There should be some more tests and specs.
- There's no code for the case where a guest user tries to vote for a link.
- Password management is not configured.
- There's no captcha to post a links.
Those are the ones I can identify now.