Skip to content

Commit

Permalink
Added very basic h-entry name validation support — currently just che…
Browse files Browse the repository at this point in the history
…cks to see if the name is shorter than the content or value, seems to work fine in most cases. Closes #10
  • Loading branch information
barnabywalters committed Jan 4, 2014
1 parent 177e37c commit a7f8aca
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
7 changes: 6 additions & 1 deletion templates/validate-h-entry.html.php
@@ -1,4 +1,4 @@
<?php use BarnabyWalters\Mf2 ?>
<?php namespace Indieweb\IndiewebifyMe; use BarnabyWalters\Mf2; ?>

<div class="row demo-row">
<h4>Make sure your <strong>posts/notes</strong> are marked up with <a href="http://microformats.org/wiki/h-entry" target="_blank">h-entry</a>:</h4>
Expand All @@ -16,6 +16,11 @@

<div class="preview-h-entry preview-block">

<?php if (hEntryName($hEntry)): ?>
<p class="property-block-name">Name</p>
<p class="p-name"><?= hEntryName($hEntry) ?></p>
<?php endif ?>

<p class="property-block-name">Author</p>
<?php if (Mf2\hasProp($hEntry, 'author')): $author = $hEntry['properties']['author'][0]; ?>
<?php if (Mf2\isMicroformat($author)): ?>
Expand Down
7 changes: 7 additions & 0 deletions web/index.php
Expand Up @@ -105,6 +105,13 @@ function detectBloggingSoftware($response) {
return null;
}

function hEntryName(array $hEntry) {
$compare = Mf2\hasProp($hEntry, 'content') ? Mf2\getProp($hEntry, 'content') : (isset($hEntry['value']) ? $hEntry['value'] : null);
if (mb_strlen(Mf2\getProp($hEntry, 'name')) < mb_strlen($compare))
return Mf2\getProp($hEntry, 'name');
return null;
}

// Web server setup

// Route static assets from CLI server
Expand Down

0 comments on commit a7f8aca

Please sign in to comment.