diff --git a/composer.json b/composer.json index 7e5d35a..b6c4dc4 100644 --- a/composer.json +++ b/composer.json @@ -3,6 +3,7 @@ "php": ">=5.5", "mf2/mf2": "0.2.*", "indieweb/mention-client": "1.*", + "indieweb/representative-h-card": "0.1.*", "indieauth/client": "0.1.*", "firebase/php-jwt": "~3.0", "league/route": "~1.2", diff --git a/composer.lock b/composer.lock index e84bf6f..e1b6de1 100644 --- a/composer.lock +++ b/composer.lock @@ -4,8 +4,8 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "b33b0001cd49507ca593b5ac7a1c7f62", - "content-hash": "d16bb0e3e3c4ada5c5eb9cb1eb603d15", + "hash": "f093ab92ae4ced25546dcff30639c5d9", + "content-hash": "61bdf94447ac95a334eb26e591a7b4e3", "packages": [ { "name": "barnabywalters/mf-cleaner", @@ -217,6 +217,51 @@ "homepage": "https://github.com/indieweb/mention-client-php", "time": "2015-12-22 23:40:11" }, + { + "name": "indieweb/representative-h-card", + "version": "0.1.2", + "source": { + "type": "git", + "url": "https://github.com/indieweb/representative-h-card-php.git", + "reference": "b70b01bd0dd7f2a940602137335dbf46ab6e2e38" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/indieweb/representative-h-card-php/zipball/b70b01bd0dd7f2a940602137335dbf46ab6e2e38", + "reference": "b70b01bd0dd7f2a940602137335dbf46ab6e2e38", + "shasum": "" + }, + "require": { + "php": ">=5.4" + }, + "require-dev": { + "mf2/mf2": "0.2.*", + "phpunit/phpunit": "*" + }, + "type": "library", + "autoload": { + "files": [ + "src/mf2/representative-h-card.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "authors": [ + { + "name": "Aaron Parecki", + "homepage": "http://aaronparecki.com" + } + ], + "keywords": [ + "h-card", + "indieweb", + "mf2", + "microformats" + ], + "time": "2015-12-23 18:11:19" + }, { "name": "j4mie/idiorm", "version": "v1.5.1", diff --git a/controllers/Auth.php b/controllers/Auth.php index d6e0b85..9081f8b 100644 --- a/controllers/Auth.php +++ b/controllers/Auth.php @@ -140,6 +140,8 @@ class Auth { $user->save(); } + q()->queue('Telegraph\ProfileFetcher', 'fetch', [$user->id]); + session_start(); $_SESSION['user_id'] = $user->id; $response->setStatusCode(302); diff --git a/controllers/Controller.php b/controllers/Controller.php index 4b04161..ba1a005 100644 --- a/controllers/Controller.php +++ b/controllers/Controller.php @@ -42,12 +42,22 @@ class Controller { } } - $site = ORM::for_table('sites')->where_id_is($role->site_id); + $site = ORM::for_table('sites')->where_id_is($role->site_id)->find_one(); + + $webmentions = []; + foreach(ORM::for_table('webmentions')->where('site_id', $site->id)->find_many() as $m) { + $webmentions[] = [ + 'webmention' => $m, + 'statuses' => ORM::for_table('webmention_status')->where('webmention_id', $m->id)->order_by_desc('created_at')->find_many() + ]; + } $response->setContent(view('dashboard', [ 'title' => 'Telegraph Dashboard', 'user' => $this->_user(), - 'accounts' => $this->_accounts() + 'accounts' => $this->_accounts(), + 'site' => $site, + 'webmentions' => $webmentions ])); return $response; } diff --git a/lib/Telegraph/ProfileFetcher.php b/lib/Telegraph/ProfileFetcher.php new file mode 100644 index 0000000..d63a1ef --- /dev/null +++ b/lib/Telegraph/ProfileFetcher.php @@ -0,0 +1,27 @@ +where_id_is($id)->find_one(); + echo "Looking for representative h-card for ".$user->url."\n"; + $data = HTTP::get($user->url); + $parsed = Mf2\parse($data['body']); + $representative = Mf2\HCard\representative($parsed, $user->url); + if($representative) { + echo "Found it!\n"; + print_r($representative); + if(array_key_exists('name', $representative['properties'])) { + $user->name = $representative['properties']['name'][0]; + } + if(array_key_exists('photo', $representative['properties'])) { + $user->photo = $representative['properties']['photo'][0]; + } + $user->save(); + } + } + +} diff --git a/public/assets/default-user.jpg b/public/assets/default-user.jpg new file mode 100644 index 0000000..817cd8f Binary files /dev/null and b/public/assets/default-user.jpg differ diff --git a/views/dashboard.php b/views/dashboard.php index 653e19c..b6610ec 100644 --- a/views/dashboard.php +++ b/views/dashboard.php @@ -1 +1,17 @@ layout('layout-loggedin', ['title' => $title, 'accounts' => $accounts, 'user' => $user]); ?> + +
+ + + + + + + + + + + + +
DateSource & Target
created_at ?>e($mention['webmention']->source) ?>
e($mention['webmention']->target) ?>
+
diff --git a/views/layout-loggedin.php b/views/layout-loggedin.php index 8e76389..9500ab3 100644 --- a/views/layout-loggedin.php +++ b/views/layout-loggedin.php @@ -9,15 +9,17 @@ Dashboard API