diff --git a/.gitignore b/.gitignore index 4dfc547..8c12c70 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,4 @@ sessions/* -conf/conf.local.php ignore kanban/ .pi-tasks -docs/framework_review.md diff --git a/README.md b/README.md index e45046a..36f1b16 100644 --- a/README.md +++ b/README.md @@ -22,22 +22,13 @@ ApFab Zap Machine needs some PHP extensions: - CUrl (default installed) - Imagick (Image Magick image processing Class) -You need to acquire the following API key: +You need to acquire the following API key and put it into `conf/conf.php`: 1. **Brave Search API Key** - https://api.search.brave.com/ -Then set up your configuration: +See `conf/conf.php` for the exact constant names to use. -```bash -# Create your local config from the template -cp conf/conf.local.php.dist conf/conf.local.php -# Edit it with your real keys -nano conf/conf.local.php -``` - -`conf/conf.local.php` is gitignored so your secrets stay safe. You can also set the `BRAVE_API_KEY` environment variable as an alternative. - -Adjust permission (chmod 777) for 'sessions' folder, then run index.php in the www/ directory, fill in the form and voila. +Adjust permission (chmod 777) for 'sessions' folder, run index.php in the www/ directory, fill in the form and voila. # yet to come - Logfile also generated in imgProcess Class (0.9.2) diff --git a/conf/conf.local.php.dist b/conf/conf.local.php.dist deleted file mode 100644 index a0c9fdb..0000000 --- a/conf/conf.local.php.dist +++ /dev/null @@ -1,10 +0,0 @@ - environment variable > placeholder - */ -define('BRAVE_API_KEY', 'your-real-api-key-here'); \ No newline at end of file diff --git a/conf/conf.php b/conf/conf.php index 801c3e6..f213c65 100755 --- a/conf/conf.php +++ b/conf/conf.php @@ -13,13 +13,12 @@ define('ZAP_CANVAS_NAME', 'collage'); define('ZAP_DELETE_SOURCE', false); define('ZAP_ADULT', false); define('ZAP_LOG', true); -define('ZAP_DEBUG', false); +define('ZAP_DEBUG', true); // Brave Search API // Get your API key: https://api.search.brave.com/ -// Put your key in conf/conf.local.php (gitignored) or set BRAVE_API_KEY env var -// See conf/conf.local.php.dist for a template +define('BRAVE_API_KEY', 'your api key'); define('BRAVE_BASE', 'https://api.search.brave.com/res/v1/images/search'); $search_engines = array('brave'); diff --git a/conf/init.php b/conf/init.php index 717c6f8..ed0dbc1 100755 --- a/conf/init.php +++ b/conf/init.php @@ -1,17 +1,6 @@ engine); $search = new $clazz(); - $search->setQuery($this->word); + $search->setQuery(urlencode($this->word)); $search->setParam('start', $this->hitPosition); $search->setParam('size', $this->numberResults); diff --git a/resource/Brave.class.php b/resource/Brave.class.php index 74e727e..a55f164 100644 --- a/resource/Brave.class.php +++ b/resource/Brave.class.php @@ -21,20 +21,8 @@ class Brave implements Search { public function setQuery($word) { $this->word = $word; - } - public function getData() { - $this->buildRequest(); - $return_array = $this->prepareData(); - return $return_array; - } - - /** - * Build the request URL and cURL handle after all setParam() calls have been made. - * This ensures start/offset and size are available when constructing the URL. - */ - private function buildRequest() { - $request = $this->q_prefix . urlencode($this->word); + $request = $this->q_prefix . urlencode($word); if (isset($this->start)) { $request .= '&offset=' . $this->start; } @@ -50,6 +38,11 @@ class Brave implements Search { $this->$key = $value; } + public function getData() { + $return_array = $this->prepareData(); + return $return_array; + } + /** * Prepare a project wide universal array with results */