diff --git a/README.md b/README.md index 87f9e70..c272dad 100644 --- a/README.md +++ b/README.md @@ -33,13 +33,13 @@ If a token endpoint is found, get an access token from it. If no token endpoint is found, verify the code with indieauth.com and create an account for the user. -### /post/new +### /new The signed-in view used to post new content. Show the list of drinks that can be posted. -### /post/submit +### /post The form submits here. Saves the post in the database, then tries to make a micropub request if necessary. If the micropub request succeeds, updates the post with the canonical URL in the response. @@ -48,6 +48,11 @@ The form submits here. Saves the post in the database, then tries to make a micr Show feed of the user's recent posts. Posts include a link to the canonical URL if appropriate. +### /{domain}/{entry} + +Permalinks for individual entries. + + ### /signout Destroy session. diff --git a/composer.json b/composer.json index 1f54cc8..88d96e8 100644 --- a/composer.json +++ b/composer.json @@ -3,7 +3,7 @@ "slim/slim": "2.2.*", "saltybeagle/savant3": "dev-master", "j4mie/idiorm": "1.4.*", - "mf2/mf2": "0.1.*", + "mf2/mf2": "0.2.*", "indieweb/date-formatter": "0.1.*", "indieauth/client": "0.1.*", "mpratt/relativetime": ">=1.0", diff --git a/composer.lock b/composer.lock index 9430624..56fd90b 100644 --- a/composer.lock +++ b/composer.lock @@ -3,7 +3,7 @@ "This file locks the dependencies of your project to a known state", "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file" ], - "hash": "9bb0e458422964208f350c0332e251c9", + "hash": "da493f8238b017e74269bc3cdeba5e92", "packages": [ { "name": "firebase/php-jwt", @@ -51,20 +51,21 @@ }, { "name": "indieauth/client", - "version": "0.1.3", + "version": "0.1.4", "source": { "type": "git", "url": "https://github.com/indieweb/indieauth-client-php.git", - "reference": "d0a9748aa643d826616ec1b02fb121f4aba0c9fc" + "reference": "ecb74843c5c01ca49f118480d068087b5477e4f9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/indieweb/indieauth-client-php/zipball/d0a9748aa643d826616ec1b02fb121f4aba0c9fc", - "reference": "d0a9748aa643d826616ec1b02fb121f4aba0c9fc", + "url": "https://api.github.com/repos/indieweb/indieauth-client-php/zipball/ecb74843c5c01ca49f118480d068087b5477e4f9", + "reference": "ecb74843c5c01ca49f118480d068087b5477e4f9", "shasum": "" }, "require": { "indieweb/link-rel-parser": "0.1.1", + "mf2/mf2": "0.2.*", "php": ">5.3.0" }, "type": "library", @@ -84,7 +85,7 @@ } ], "description": "IndieAuth Client Library", - "time": "2014-03-02 21:07:38" + "time": "2014-08-15 18:03:06" }, { "name": "indieweb/date-formatter", @@ -235,16 +236,16 @@ }, { "name": "mf2/mf2", - "version": "v0.1.23", + "version": "v0.2.9", "source": { "type": "git", "url": "https://github.com/indieweb/php-mf2.git", - "reference": "9094e4f7ad535e0796f5a384dec42bab81393e0e" + "reference": "ad1ee037555be7f3b2ea1d99e063e56207cf2a1d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/indieweb/php-mf2/zipball/9094e4f7ad535e0796f5a384dec42bab81393e0e", - "reference": "9094e4f7ad535e0796f5a384dec42bab81393e0e", + "url": "https://api.github.com/repos/indieweb/php-mf2/zipball/ad1ee037555be7f3b2ea1d99e063e56207cf2a1d", + "reference": "ad1ee037555be7f3b2ea1d99e063e56207cf2a1d", "shasum": "" }, "require": { @@ -256,11 +257,15 @@ "suggest": { "barnabywalters/mf-cleaner": "To more easily handle the canonical data php-mf2 gives you" }, + "bin": [ + "bin/fetch-mf2", + "bin/parse-mf2" + ], "type": "library", "autoload": { - "psr-0": { - "mf2\\Parser": "" - } + "files": [ + "Mf2/Parser.php" + ] }, "notification-url": "https://packagist.org/downloads/", "license": [ @@ -272,14 +277,15 @@ "homepage": "http://waterpigs.co.uk" } ], - "description": "A pure (generic) microformats-2 parser", + "description": "A pure, generic microformats2 parser — makes HTML as easy to consume as a JSON API", "keywords": [ + "html", "microformats", "microformats 2", "parser", "semantic" ], - "time": "2013-10-20 12:25:50" + "time": "2014-07-23 09:37:36" }, { "name": "mpratt/relativetime", diff --git a/controllers/controllers.php b/controllers/controllers.php index 57a4e51..d7014d0 100644 --- a/controllers/controllers.php +++ b/controllers/controllers.php @@ -127,8 +127,6 @@ $app->post('/post', function() use($app) { return $v !== ''; }); - print_r($params); - // Store the post in the database $entry = ORM::for_table('entries')->create(); $entry->user_id = $user->id; @@ -188,3 +186,42 @@ $app->post('/post', function() use($app) { } }); +$app->get('/:domain', function($domain) use($app) { + $user = ORM::for_table('users')->where('url', $domain)->find_one(); + if(!$user) { + $app->notFound(); + return; + } + + $entries = ORM::for_table('entries')->where('user_id', $user->id)->find_many(); + + $html = render('entries', array( + 'title' => 'Teacup', + 'entries' => $entries, + 'user' => $user + )); + $app->response()->body($html); +}); + + +$app->get('/:domain/:entry', function($domain, $entry_id) use($app) { + $user = ORM::for_table('users')->where('url', $domain)->find_one(); + if(!$user) { + $app->notFound(); + return; + } + + $entry = ORM::for_table('entries')->where('user_id', $user->id)->where('id', $entry_id)->find_one(); + if(!$entry) { + $app->notFound(); + return; + } + + $html = render('entry', array( + 'title' => 'Teacup', + 'entry' => $entry, + 'user' => $user + )); + $app->response()->body($html); +}); + diff --git a/lib/helpers.php b/lib/helpers.php index dcc6b33..2fb8d7c 100644 --- a/lib/helpers.php +++ b/lib/helpers.php @@ -187,6 +187,17 @@ function relative_time($date) { return $rel->timeAgo($date); } +function entry_url($entry, $user) { + return $entry->canonical_url ?: Config::$base_url . $user->url . '/' . $entry->id; +} + +function entry_date($entry, $user) { + $date = new DateTime($entry->published); + $tz = new DateTimeZone($entry->timezone); + $date->setTimeZone($tz); + return $date; +} + function caffeine_options() { return array( 'Coffee', diff --git a/public/css/style.css b/public/css/style.css index c005a30..7dee754 100644 --- a/public/css/style.css +++ b/public/css/style.css @@ -202,3 +202,73 @@ body { .caffeine li input, .alcohol li input { width: 100%; } + + + +/** + entries + */ + +ul.entries { + list-style-type: none; + padding-left: 0; +} +ul.entries li { + margin-left: 0; + margin-bottom: 20px; + -webkit-box-shadow: 0px 0px 8px 0px rgba(0,0,0,0.5); + -moz-box-shadow: 0px 0px 8px 0px rgba(0,0,0,0.5); + box-shadow: 0px 0px 8px 0px rgba(0,0,0,0.5); +} + +ul.entries .author { + background-color: #e3f0d0; + border-bottom: 1px #d1e4b6 solid; + display: block; +} + +ul.entries .author { + padding: 12px; +} +ul.entries .content { + padding: 12px 12px 4px 12px; +} +ul.entries .date, ul.entries .location { + padding-left: 12px; +} +ul.entries .date { + padding-bottom: 12px; +} + +ul.entries .author .photo { + float: left; +} +ul.entries .author .photo img { + border: 1px #91af67 solid; + -webkit-border-radius: 5px; + -moz-border-radius: 5px; + border-radius: 5px; + margin-right: 7px; +} +ul.entries .author .name { + font-weight: bold; +} +ul.entries .author a { + color: #67863c; +} +ul.entries .author .url { + color: #777; + display: block; +} + +ul.entries .location { + color: #999; +} + +ul.entries .date a { + color: #999; +} + +ul.entries .content { + font-size: 22px; +} diff --git a/views/entries.php b/views/entries.php new file mode 100644 index 0000000..4ca9856 --- /dev/null +++ b/views/entries.php @@ -0,0 +1,10 @@ +
+ +
+ + +
\ No newline at end of file diff --git a/views/entry.php b/views/entry.php new file mode 100644 index 0000000..5f59b11 --- /dev/null +++ b/views/entry.php @@ -0,0 +1,8 @@ +
+ +
+ + +
\ No newline at end of file diff --git a/views/layout.php b/views/layout.php index f7453d2..21bf081 100644 --- a/views/layout.php +++ b/views/layout.php @@ -18,6 +18,7 @@ + @@ -48,7 +49,11 @@
- fetch($this->page . '.php') ?> + fetch($this->page . '.php') ?> +
+ +
+