Skip to content

Commit

Permalink
Merge pull request #173 from reliefsupports/v.0.2.1
Browse files Browse the repository at this point in the history
v0.2.1
  • Loading branch information
thinkholic authored Jun 4, 2017
2 parents cea3dd1 + 2684a12 commit 551ef04
Show file tree
Hide file tree
Showing 31 changed files with 491 additions and 144 deletions.
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@ INVISIBLE_RECAPTCHA_SECRETKEY=6LfdQSMUAAAAAAT5cKXa7lI3koiFy4c5BP7BX3m8
NOCAPTCHA_SECRET=6LfdQSMUAAAAAAT5cKXa7lI3koiFy4c5BP7BX3m8
NOCAPTCHA_SITEKEY=6LfdQSMUAAAAAOP31dkmdZJeNvDghlBfqJsHT5M-

DISQUS_KEY=c5tMw2uYVH0eFcBiFKha5WvaKnD092vq1G2vR4ybdhp2sVISOAvoea8WndCMhabQ
DISQUS_KEY=reliefsupports-org
30 changes: 29 additions & 1 deletion .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,31 @@
## Contributing to Relief Supports

TODO
Without the support of the community Relief Supports can never achieve its targets. To streamline the process of integrating different inputs from the large number of contributors, we have introduced the following guidelines to follow when opening PRs and reporting issues.

### Community
Developers can now initiate discussions through [Gitter](https://gitter.im/relief-supports/Lobby). Before starting to work on an issue, please go through the existing [issues](https://github.com/reliefsupports/reliefsupports.org/issues) and pull requests to make sure no one is working on the same issue at the time.

### Task Selection
If you can work on one of the [PRIORITY](https://github.com/reliefsupports/reliefsupports.org/labels/PRIORITY) issues it’ll be great the given the circumstance, but feel free to work on anything you want.

Once you select a task to work on, please mention that in the issue and apply the `In Progress` label for it. If it's a new issue, please [create](https://github.com/reliefsupports/reliefsupports.org/issues/new) an issue and do as same.

See the [milestones](https://github.com/reliefsupports/reliefsupports.org/milestones) page for grasp some idea where the project heading.

Even you can check the [wiki](https://github.com/reliefsupports/reliefsupports.org/wiki) also.

### Pull requests
To start contributing, simply fork the repository, commit and push your changes, and open a Pull Request. We keep `master` branch only for production release and the working branch is always is `dev`. The Pull Requests should **always** be opened against the `dev` branch.

Before you open the Pull Request, please make sure you have checked the following task list.

* Rebased against the latest fetch from the `upstream/dev` branch
* Verified for non conflicts
* Tested for functionality and regressions (preferably on the provided [Docker Test Setup](../docker/README.md) to make sure that there are no hidden dependencies to your change that would not be in the deployment)

When opening the Pull Request, please follow the provided template and provide as many details as possible for other contributors to quickly come up to speed on your contribution. This will greatly improve the chances of the Pull Request being merged quickly. Furthermore, if the change in the Pull Request contains UI changes, please include screenshots of the changed UIs as well.

### Issues
We always welcome suggestions and any bug reports that the community can provide. To organize this input, a template is provided to better describe the issue context.

Before you open an issue, please make sure that it is not reported already. If there are similar issues that do not cover your scenario, please mention them in the new issue so that a potential fix can include all similar scenarios in to one patch.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ npm-debug.log
.env
composer.lock
.DS_Store
.scripts/deploy.sh
28 changes: 28 additions & 0 deletions .scripts/deploy.sh.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash
PUBLIC_KEY_PATH=
USERNAME=
ENV=dev
if [ $ENV = "dev" ]; then
HOST=
else
HOST=
fi

cd ..
sftp -i ${PUBLIC_KEY_PATH} ${USERNAME}@${HOST} <<EOF
pwd
cd /var/www/public
put *.*
put -r app
put -r config
put -r database
put -r public
put -r resources
put -r routes
EOF

ssh -i ${PUBLIC_KEY_PATH} ${USERNAME}@${HOST} <<EOF
cd /var/www/public
rm -rf vendor
composer install
EOF
14 changes: 2 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Even you can check the [wiki](https://github.com/reliefsupports/reliefsupports.o

### Setting up the development environment

Generally speaking, you should fork this repository, make changes in your own fork, and then submit a pull-request. Please include necessary information with pull-request
Generally speaking, you should fork this repository, make changes in your own fork, and then submit a pull-request. Please include necessary information with pull-request

Before send the pull-request, please make sure nothing has broken in the app with the new changes you made.

Expand Down Expand Up @@ -57,17 +57,7 @@ chmod 777 bootstrap/cache
##### Docker

* You need to install [Docker](https://www.docker.com/) on your computer first.
* If Docker is running on your computer without any errors, run following commands accordingly.

```
docker-compose build
docker-compose up -d
docker exec -it reliefsupportsorg_php_1 bash // this may change as you configurations
composer install
chmod -R 777 storage/
chmod 777 bootstrap/cache
```
* If Docker is running on your computer without any errors, follow the [Docker Testing Guide](docker/README.md).

## License

Expand Down
30 changes: 30 additions & 0 deletions app/Http/Controllers/HomeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
use App\Repositories\DonationRepository;
use App\Repositories\NeedsRepository;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Input;
use Illuminate\Support\Facades\DB;

class HomeController extends Controller
{
Expand Down Expand Up @@ -47,4 +49,32 @@ public function emergency()
{
return view('frontend/emergency');
}

/**
* Search Donation or/and Needs
*
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public function searchDonationsOrNeeds(){
DB::enableQueryLog();
$search = Input::get('search');
$searchFor = Input::get('type');
$donations = array();
$needs = array();

if($searchFor == "all" || $searchFor =='donations'){
$donations = $this->donation->searchDonations($search);
}
if($searchFor == "all" || $searchFor == "needs"){
$needs = $this->need->searchNeeds($search);
}

Input::flash();
return view('frontend/home')
->with([
'donations' => ($donations) ? $donations : array(),
'needs' => ($needs) ? $needs : array()
]);

}
}
25 changes: 24 additions & 1 deletion app/Repositories/DonationRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
use App\Donation;
use App\Repositories\Contracts\DonationInterface;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\DB;

/**
* Created by PhpStorm.
Expand Down Expand Up @@ -64,4 +65,26 @@ public function findDonation($id)
return false;
}
}
}

/**
* @param type $search
* @return array
*/
public function searchDonations($search){

$searchParts = explode(" ", str_replace(",", " ", $search));

try {
$query = Donation::query();
if(strlen($search)>0){
foreach($searchParts as $searchPart){
$query = $query->where(DB::Raw('CONCAT_WS(" ",name,telephone,address,city,donation,information) '),"like","%$searchPart%");
}
}
return $query->get();
} catch (\Exception $e) {
Log::error($e->getMessage());
return false;
}
}
}
27 changes: 26 additions & 1 deletion app/Repositories/NeedsRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use App\Need;
use App\Repositories\Contracts\NeedsInterface;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\DB;

class NeedsRepository implements NeedsInterface
{
Expand Down Expand Up @@ -65,4 +66,28 @@ public function findNeed($id)
return false;
}
}
}

/**
*
* @param type $search
* @return boolean
*/
public function searchNeeds($search){

$searchParts = explode(" ", str_replace(",", " ", $search));

try {
$query = Need::query();
if(strlen($search)>0){
foreach($searchParts as $searchPart){
$query = $query->where(DB::Raw('CONCAT_WS(" ",name,telephone,address,city,needs)'),"like","%$searchPart%");
}
}
return $query->get();
} catch (\Exception $e) {
Log::error($e->getMessage());
return false;
}

}
}
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
"type": "project",
"require": {
"php": ">=5.6.4",
"albertcht/invisible-recaptcha": "^1.3",
"laravel/framework": "5.4.*",
"laravel/tinker": "~1.0",
"albertcht/invisible-recaptcha": "^1.3"
"laravelcollective/html": "^5.2.0"
},
"require-dev": {
"fzaninotto/faker": "~1.4",
Expand Down
4 changes: 4 additions & 0 deletions config/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@
// App\Providers\BroadcastServiceProvider::class,
App\Providers\EventServiceProvider::class,
App\Providers\RouteServiceProvider::class,
Collective\Html\HtmlServiceProvider::class,

],

Expand Down Expand Up @@ -226,6 +227,9 @@
'URL' => Illuminate\Support\Facades\URL::class,
'Validator' => Illuminate\Support\Facades\Validator::class,
'View' => Illuminate\Support\Facades\View::class,
'Form' => Collective\Html\FormFacade::class,
'Html' => Collective\Html\HtmlFacade::class,
'Input' => Illuminate\Support\Facades\Input::class,

],

Expand Down
36 changes: 0 additions & 36 deletions docker-compose.yml

This file was deleted.

28 changes: 28 additions & 0 deletions docker/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Docker Based Test Environment

This is a simple Docker based test environment for the ReliefSupports web development. The setup consists of an Apache container with PHP and MariaDB container. The working directory is mounted to the Apache container inside `/var/www/html` folder.

### Usage

To test a particular change, simply run the following command in Bash.

```bash
bash test-deployment.sh up
```
>In Windows the command to run is `docker-compose --file docker-compose.yml --project-name reliefsupportsorg build` followed by `docker-compose --file docker-compose.yml --project-name reliefsupportsorg up -d`.
This command will start the two containers and expose the site through port `8080`. The required Docker images are downloaded from the [public Docker registry](https://hub.docker.com).

Please allow several minutes (longer if a `compose update` was not done on the source already) to start the server. You can use `docker logs -f reliefsupportsorg_website_1` command to check the server logs. Wait until the line ` Command line: 'apache2 -D FOREGROUND'` appears.

To access the page, navigate to [http://localhost:8080](http://localhost:8080). Any change you do on the source while the containers are running are instantly reflected on the server since it's mounted as a volume.

> NOTE: To reiterate, since it's a writable volume mount, any change you do inside the container will be reflected back in the source as well. Be careful of what you do after `docker exec` inside the container.
To stop the test deployment run the following command.

```bash
bash test-deployment.sh down
```

> Please note currently, db migrations is WIP and will not function correctly. This will soon be fixed.
Empty file added docker/db/initdb/.gitkeep
Empty file.
Loading

0 comments on commit 551ef04

Please sign in to comment.