Skip to content

Commit

Permalink
Version 1.5.1
Browse files Browse the repository at this point in the history
- [fix] Updated help.php, removed incorrect colorscheme information
- [fix] Typo in text output for goosle-cron.php
- [fix] Various php errors/warnings in goosle-cron.php
- [fix] Url formatting for php function special searches
  • Loading branch information
adegans committed Jun 23, 2024
1 parent a5740b3 commit cb36f0a
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 18 deletions.
2 changes: 1 addition & 1 deletion assets/css/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ button { cursor:pointer; }
a { text-decoration:none; color:var(--link); }
a:hover { text-decoration:underline; }
small { padding:5px 0; color:var(--meta); font-size:.8rem; }

input[type="text"]:invalid ~ input[type="submit"] { opacity:0.5; pointer-events:none; }

input[type="search"]::-webkit-search-cancel-button { -webkit-appearance:none; -webkit-mask-image:url("data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/Pjxzdmcgdmlld0JveD0iMCAwIDI0IDI0IiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjxwYXRoIGQ9Ik0xMy40MSwxMmw0LjMtNC4yOWExLDEsMCwxLDAtMS40Mi0xLjQyTDEyLDEwLjU5LDcuNzEsNi4yOUExLDEsMCwwLDAsNi4yOSw3LjcxTDEwLjU5LDEybC00LjMsNC4yOWExLDEsMCwwLDAsMCwxLjQyLDEsMSwwLDAsMCwxLjQyLDBMMTIsMTMuNDFsNC4yOSw0LjNhMSwxLDAsMCwwLDEuNDIsMCwxLDEsMCwwLDAsMC0xLjQyWiIgZmlsbD0iIzY1NjNmZiIvPjwvc3ZnPg=="); }

/* Page structure */
Expand Down
2 changes: 1 addition & 1 deletion engines/special/definition.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function parse_results($response) {
if(empty($json_response)) return $engine_result;

// No results
if(array_key_exists('title', $json_response)) return $engine_result;
if(!array_key_exists('title', $json_response)) return $engine_result;

// Grab first result if there are multiple
$result = $json_response[0];
Expand Down
6 changes: 4 additions & 2 deletions engines/special/php.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@
class PHPnetRequest extends EngineRequest {
public function get_request_url() {
$query = str_replace('%22', '\"', $this->query);

// Format query/url for php.net
$query = str_replace('php ', '', $query);
$query = str_replace('_', '-', $query);

// Is there no query left? Bail!
if(empty($query)) return false;

$url = 'https://www.php.net/manual/function.'.urlencode($query);
$url = 'https://www.php.net/manual/function.'.urlencode($query).'.php';

unset($query);

Expand Down Expand Up @@ -61,7 +63,7 @@ public function parse_results($response) {
// Required
'title' => "Function: ".sanitize($title),
'text' => "<p><em><small>".sanitize($php_versions)."</small></em></p><p>".sanitize($purpose)."</p><p>".highlight_string("<?php ".sanitize($usage)." ?>", 1)."</p><p>".$summary."</p>",
'source' => "https://www.php.net/manual/function.".urlencode($query)
'source' => "https://www.php.net/manual/function.".urlencode($query).".php"
);
}
unset($response, $xpath, $scrape);
Expand Down
7 changes: 5 additions & 2 deletions functions/tools-update.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ function check_update() {
$cache_file = ABSPATH.'cache/version.data';

// Currently installed version
$current_version = "1.5";
$current_version = "1.5.1";

if(!is_file($cache_file)) {
// Create update cache file if it doesn't exist
Expand All @@ -28,6 +28,9 @@ function check_update() {
$version = unserialize(file_get_contents($cache_file));
}

// TODO: Remove in a future version
if(!isset($version['current'])) $version['current'] = "1.5.1";

// Update check, every week
if($version['checked'] < time() - 604800) {
$response = do_curl_request(
Expand Down Expand Up @@ -58,7 +61,7 @@ function show_version() {
$version = unserialize(file_get_contents($cache_file));

// TODO: Remove in a future version
if(!isset($version['current'])) $version['current'] = "1.5";
if(!isset($version['current'])) $version['current'] = "1.5.1";

// Format current version for footer
$show_version = "<a href=\"https://github.com/adegans/Goosle/\" target=\"_blank\">Goosle ".$version['current']."</a>.";
Expand Down
24 changes: 16 additions & 8 deletions goosle-cron.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
if(verify_hash($opts->hash_auth, $opts->hash, $auth)) {
// Check for updates
check_update();
echo "Update cached updated!<br />";
echo "Update cache updated!<br />";

// Clear out old cached files?
if($opts->cache_type == 'file') {
Expand All @@ -45,19 +45,27 @@

// Is the token expired?
if($registration['expires'] < time()) {
$new_token = do_curl_request(
$response = do_curl_request(
'https://api.openverse.org/v1/auth_tokens/token/', // (string) Where?
array('Accept: application/json, */*;q=0.8', 'User-Agent: '.$opts->user_agents[0].';', 'Authorization: Bearer'.$registration['client_id']), // (array) Headers
'post', // (string) post/get
array('grant_type' => 'client_credentials', 'client_id' => $registration['client_id'], 'client_secret' => $registration['client_secret']) // (assoc array) Post body
);
$new_token = json_decode($new_token, true);
$json_response = json_decode($response, true);

$new_token['expires_in'] = time() + ($new_token['expires_in'] - 3600);

oauth_store_token($token_file, 'openverse', array('client_id' => $registration['client_id'], 'client_secret' => $registration['client_secret'], 'access_token' => $new_token['access_token'], 'expires' => $new_token['expires_in']));

echo "New Openverse token stored!<br />";
// Got a response
if(!empty($json_response)) {
// Got some data?
if(array_key_exists('access_token', $json_response)) {

$json_response['expires_in'] = time() + ($json_response['expires_in'] - 3600);

oauth_store_token($token_file, 'openverse', array('client_id' => $registration['client_id'], 'client_secret' => $registration['client_secret'], 'access_token' => $json_response['access_token'], 'expires' => $json_response['expires_in']));

echo "New Openverse token stored!<br />";
}
}
unset($response, $json_response);
}
}
}
Expand Down
3 changes: 1 addition & 2 deletions help.php
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,7 @@
<p>Most browsers ask that you add <strong>%s</strong> for the search query as shown in the examples. If your browser has a different value for this simply replace %s with what your browser requires.

<h2>Colorschemes</h2>
<p>Goose comes with several colorschemes. If you don't like the selected colorscheme you can override it with the <strong>c</strong> argument in your search url. For example: <strong>https://example.com/?c=dark</strong>.</p>
<p>You can add this to your bookmark too to always override the colorscheme.</p>
<p>Goose comes with several colorschemes, configurable through the config.php file.</p>

<h3>Available colorschemes are:</h3>
<ol>
Expand Down
2 changes: 1 addition & 1 deletion index.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
<h1><span class="goosle-g">G</span>oosle</h1>

<form action="results.php" method="get" autocomplete="off">
<input tabindex="10" type="search" class="search-field" name="q" autofocus />
<input tabindex="10" type="search" class="search-field" name="q" required autofocus />
<input type="hidden" name="a" value="<?php echo $opts->hash; ?>"/>

<div class="search-buttons">
Expand Down
8 changes: 7 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,13 @@ You can post your questions on Github Discussions or say hi on [Mastodon](https:
- Sometimes TV Show episodes on the box office are not properly merged despite all required data matching.

## Changelog
1.5 - June ??, 2024
1.5.1 - June 22, 2024
- [fix] Updated help.php, removed incorrect colorscheme information
- [fix] Typo in text output for goosle-cron.php
- [fix] Various php errors/warnings in goosle-cron.php
- [fix] Url formatting for php function special searches

1.5 - June 19, 2024
- NOTICE: config.default.php has changed, re-create your config.php!!
- [fix] No longer caches empty results
- [fix] No longer make a request if the search query is empty
Expand Down

0 comments on commit cb36f0a

Please sign in to comment.