Browse Source

render posts on permalinks and on the feed for a user page

pull/10/head
Aaron Parecki 9 years ago
parent
commit
b0e01ecd02
10 changed files with 198 additions and 21 deletions
  1. +7
    -2
      README.md
  2. +1
    -1
      composer.json
  3. +21
    -15
      composer.lock
  4. +39
    -2
      controllers/controllers.php
  5. +11
    -0
      lib/helpers.php
  6. +70
    -0
      public/css/style.css
  7. +10
    -0
      views/entries.php
  8. +8
    -0
      views/entry.php
  9. +6
    -1
      views/layout.php
  10. +25
    -0
      views/partials/entry.php

+ 7
- 2
README.md View File

@ -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.

+ 1
- 1
composer.json View File

@ -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",

+ 21
- 15
composer.lock View File

@ -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",

+ 39
- 2
controllers/controllers.php View File

@ -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);
});

+ 11
- 0
lib/helpers.php View File

@ -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',

+ 70
- 0
public/css/style.css View File

@ -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;
}

+ 10
- 0
views/entries.php View File

@ -0,0 +1,10 @@
<div class="narrow">
<?= partial('partials/header') ?>
<br>
<ul class="entries">
<?php foreach($this->entries as $entry): ?>
<?= partial('partials/entry', array('entry' => $entry, 'user' => $this->user)) ?>
<?php endforeach; ?>
</ul>
</div>

+ 8
- 0
views/entry.php View File

@ -0,0 +1,8 @@
<div class="narrow">
<?= partial('partials/header') ?>
<br>
<ul class="entries">
<?= partial('partials/entry', array('entry' => $this->entry, 'user' => $this->user)) ?>
</ul>
</div>

+ 6
- 1
views/layout.php View File

@ -18,6 +18,7 @@
<link rel="stylesheet" href="/bootstrap/css/bootstrap.min.css">
<link rel="stylesheet" href="/bootstrap/css/bootstrap-theme.css">
<link href="/css/font-awesome/css/font-awesome.min.css" rel="stylesheet" media="all">
<link rel="stylesheet" href="/css/style.css">
<link rel="apple-touch-icon" sizes="57x57" href="/images/teacup-icon-57.png">
@ -48,7 +49,11 @@
<div class="page">
<div class="container">
<?= $this->fetch($this->page . '.php') ?>
<?= $html=$this->fetch($this->page . '.php') ?>
</div>
<div class="narrow">
<pre><?= json_encode(Mf2\parse($html), JSON_PRETTY_PRINT) ?></pre>
</div>
<div class="footer">

+ 25
- 0
views/partials/entry.php View File

@ -0,0 +1,25 @@
<li class="h-entry">
<div class="author h-card p-author">
<a class="photo" href="http://<?= $this->user->url ?>"><img src="<?= $this->user->photo_url ?>" class="u-photo" height="50" width="50" alt="<?= $this->user->url ?>"></a>
<a class="name p-name" href="http://<?= $this->user->url ?>"><?= $this->user->name ?></a>
<a class="url u-url" href="http://<?= $this->user->url ?>"><?= $this->user->url ?></a>
<div style="clear:both;"></div>
</div>
<div class="content e-content p-name"><?= $this->entry->content ?></div>
<?php if($this->entry->latitude): ?>
<div class="location">
<div class="p-location h-geo">
<i class="fa fa-map-marker"></i>
<data class="p-latitude" value="<?= $this->entry->latitude ?>"><?= $this->entry->latitude ?></data>, <data class="p-longitude" value="<?= $this->entry->longitude ?>"><?= $this->entry->longitude ?></data>
</div>
</div>
<?php endif; ?>
<div class="date">
<a href="<?= entry_url($this->entry, $this->user) ?>" class="u-url"><time class="dt-published" datetime="<?= entry_date($this->entry, $this->user)->format('c') ?>"><?= entry_date($this->entry, $this->user)->format('F j, Y g:ia T') ?></time></a>
</div>
</li>

Loading…
Cancel
Save