From 352ff0ea5380b3f07da34f6b4eaea63fa6c884fa Mon Sep 17 00:00:00 2001 From: Django Doucet Date: Fri, 3 Jan 2020 16:32:28 -0500 Subject: [PATCH] Refactor and Fix widget title --- fediembedi-client.php | 52 +- ...pl.php => fediembedi-settings-form.tpl.php | 9 +- fediembedi-widget-template.php | 40 -- fediembedi-widget.php | 53 +- fediembedi.php | 41 +- img/mastodon.svg | 1 + img/{pixelfed-icon-color.svg => pixelfed.svg} | 0 img/pleroma.svg | 93 +++ instanceList.php | 9 - license.txt | 674 ++++++++++++++++++ .../fediembedi-mastodon.tpl.php | 0 mastodon.css => mastodon/mastodon.css | 2 +- .../fediembedi-pixelfed.tpl.php | 0 pixelfed.css => pixelfed/pixelfed.css | 6 +- readme.md | 16 +- readme.txt | 14 +- style.css | 28 + 17 files changed, 896 insertions(+), 142 deletions(-) rename form.tpl.php => fediembedi-settings-form.tpl.php (69%) delete mode 100644 fediembedi-widget-template.php create mode 100644 img/mastodon.svg rename img/{pixelfed-icon-color.svg => pixelfed.svg} (100%) create mode 100644 img/pleroma.svg delete mode 100644 instanceList.php create mode 100644 license.txt rename fediembedi-mastodon.tpl.php => mastodon/fediembedi-mastodon.tpl.php (100%) rename mastodon.css => mastodon/mastodon.css (99%) rename fediembedi-pixelfed.tpl.php => pixelfed/fediembedi-pixelfed.tpl.php (100%) rename pixelfed.css => pixelfed/pixelfed.css (98%) diff --git a/fediembedi-client.php b/fediembedi-client.php index 440edfc..88c47ea 100644 --- a/fediembedi-client.php +++ b/fediembedi-client.php @@ -1,5 +1,8 @@ _post('/api/v1/apps', array( 'client_name' => 'FediEmbedi for WordPress', 'redirect_uris' => $redirect_uri, - 'scopes' => 'read', + 'scopes' => $scopes, 'website' => get_site_url() )); @@ -38,7 +41,7 @@ class Client $params = http_build_query(array( 'response_type' => 'code', 'redirect_uri' => $redirect_uri, - 'scope' => 'read', + 'scope' => $scopes, 'client_id' =>$this->app->client_id )); @@ -131,47 +134,6 @@ class Client return $response; } - public function postStatus($status, $mode, $media = '', $spoiler_text = '') { - - $headers = array( - 'Authorization'=> 'Bearer '.$this->access_token - ); - - $response = $this->_post('/api/v1/statuses', array( - 'status' => $status, - 'visibility' => $mode, - 'spoiler_text' => $spoiler_text, - 'media_ids[]' => $media - ), $headers); - - return $response; - } - - public function create_attachment($media_path) { - - $filename =basename($media_path); - $mime_type = mime_content_type($media_path); - - $boundary ='hlx'.time(); - - $headers = array ( - 'Authorization'=> 'Bearer '.$this->access_token, - 'Content-Type' => 'multipart/form-data; boundary='. $boundary, - ); - - $nl = "\r\n"; - - $data = '--'.$boundary.$nl; - $data .= 'Content-Disposition: form-data; name="file"; filename="'.$filename.'"'.$nl; - $data .= 'Content-Type: '. $mime_type .$nl.$nl; - $data .= file_get_contents($media_path) .$nl; - $data .= '--'.$boundary.'--'; - - $response = $this->_post('/api/v1/media', $data, $headers); - - return $response; - } - private function _post($url, $data = array(), $headers = array()) { return $this->post($this->instance_url.$url, $data, $headers); } diff --git a/form.tpl.php b/fediembedi-settings-form.tpl.php similarity index 69% rename from form.tpl.php rename to fediembedi-settings-form.tpl.php index 2a172b1..1f61391 100644 --- a/form.tpl.php +++ b/fediembedi-settings-form.tpl.php @@ -12,13 +12,16 @@ define("ADVANCED_VIEW",false);
"> - - + -
The currently supported software are Mastodon, Pleroma, Pixelfed. +
The currently supported software are Mastodon, Pleroma, Pixelfed.
+

Don't have an account?

+

Visit joinmastodon.org to find an instance.

+

Visit pixelfed.org/join to find an instance.

">