diff --git a/QvitterPlugin.php b/QvitterPlugin.php index 8a14f83..756274b 100644 --- a/QvitterPlugin.php +++ b/QvitterPlugin.php @@ -86,6 +86,8 @@ class QvitterPlugin extends Plugin { $m->connect('api/qvitter/allfollowing/:id.json', array('action' => 'apiqvitterallfollowing', 'id' => Nickname::INPUT_FMT)); + $m->connect('api/qvitter/update_cover_photo.json', + array('action' => 'ApiUpdateCoverPhoto')); $m->connect('api/qvitter/statuses/friends_timeline.json', array('action' => 'apiqvitterfriends')); $m->connect('api/qvitter/statuses/friends_timeline/:id.json', @@ -101,7 +103,6 @@ class QvitterPlugin extends Plugin { $m->connect('main/qlogin', array('action' => 'qvitterlogin')); - // check if we should reroute UI to qvitter $logged_in_user = common_current_user(); $qvitter_enabled_by_user = false; diff --git a/README.md b/README.md index 3facede..c6a067c 100644 --- a/README.md +++ b/README.md @@ -43,21 +43,21 @@ Extras 1. There is a bug in GNUsocial that won't let you see groups' members lists. Replace your actions/apigroupmembership.php file with the one supplied to fix it. -2. If you want notice headers to show which group a notice is posted in, replace your -lib/apiaction.php file. +2. If you want notice headers to show which group a notice is posted in, and if you want +cover photos to work, replace your lib/apiaction.php file. TODO ---- +1. "following you" badge on other peoples profiles + 1. Join _new_ external groups and follow _new_ external users ("New" meaning users/groups that the server don't know yet) 2. Creating groups, make admin, block user 3. Background image uploading/editing -4. Auto suggest mentions - 6. Auto url-shortening setting under queet box 7. Settings (e.g. don't show replies to people I don't follow) diff --git a/actions/apiupdatecoverphoto.php b/actions/apiupdatecoverphoto.php new file mode 100644 index 0000000..f8d898c --- /dev/null +++ b/actions/apiupdatecoverphoto.php @@ -0,0 +1,110 @@ + \\\\_\ · + · \\) \____) · + · · + · · + · Qvitter is free software: you can redistribute it and / or modify it · + · under the terms of the GNU Affero General Public License as published by · + · the Free Software Foundation, either version three of the License or (at · + · your option) any later version. · + · · + · Qvitter is distributed in hope that it will be useful but WITHOUT ANY · + · WARRANTY; without even the implied warranty of MERCHANTABILTY or FITNESS · + · FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for · + · more details. · + · · + · You should have received a copy of the GNU Affero General Public License · + · along with Qvitter. If not, see . · + · · + · Contact h@nnesmannerhe.im if you have any questions. · + · · + · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · */ + + +if (!defined('GNUSOCIAL')) { + exit(1); +} + +class ApiUpdateCoverPhotoAction extends ApiAuthAction +{ + protected $needPost = true; + + /** + * Take arguments for running + * + * @param array $args $_REQUEST args + * + * @return boolean success flag + */ + protected function prepare(array $args=array()) + { + parent::prepare($args); + + $this->user = $this->auth_user; + + $this->cropW = $this->trimmed('cropW'); + $this->cropH = $this->trimmed('cropH'); + $this->cropX = $this->trimmed('cropX'); + $this->cropY = $this->trimmed('cropY'); + $this->img = $this->trimmed('img'); + + return true; + } + + /** + * Handle the request + * + * @return void + */ + protected function handle() + { + parent::handle(); + + $profile = $this->user->getProfile(); + $base64img = $this->img; + if(stristr($base64img, 'image/jpeg')) { + $base64img_mime = 'image/jpeg'; + } + elseif(stristr($base64img, 'image/png')) { + // should convert to jpg here!! + $base64img_mime = 'image/png'; + } + $base64img = str_replace('data:image/jpeg;base64,', '', $base64img); + $base64img = str_replace('data:image/png;base64,', '', $base64img); + $base64img = str_replace(' ', '+', $base64img); + $base64img_hash = md5($base64img); + $base64img = base64_decode($base64img); + $base64img_basename = basename('cover'); + $base64img_filename = File::filename($profile, $base64img_basename, $base64img_mime); + $base64img_path = File::path($base64img_filename); + $base64img_success = file_put_contents($base64img_path, $base64img); + $base64img_mimetype = MediaFile::getUploadedMimeType($base64img_path, $base64img_filename); + $mediafile = new MediaFile($profile, $base64img_filename, $base64img_mimetype); + $imagefile = new ImageFile($mediafile->fileRecord->id, File::path($mediafile->filename)); + $imagefile->resizeTo(File::path($mediafile->filename), $this->cropW, $this->cropH, $this->cropX, $this->cropY, $this->cropW, $this->cropH); + $result['url'] = File::url($mediafile->filename); + + Profile_prefs::setData($profile, 'qvitter', 'cover_photo', $result['url']); + + $this->initDocument('json'); + $this->showJsonObjects($result); + $this->endDocument('json'); + } +} diff --git a/actions/qvitter.php b/actions/qvitter.php index 6899556..c8f6160 100644 --- a/actions/qvitter.php +++ b/actions/qvitter.php @@ -102,7 +102,7 @@ class QvitterAction extends ApiAction <?php print $sitetitle; ?> - + Italiano
  • svenska
  • -