function fetchOne($filePath, $output) { if (is_file($filePath)) { $fileData = file_get_contents($filePath); // Pulls details from .org file header. $regex = '/^#\\+\\w*:(.*)/m'; preg_match_all($regex, $fileData, $matches); $title = trim($matches[1][0]); $author = trim($matches[1][1]); $date = trim($matches[1][2]); $dateTime = date('c', cleanDate($date)); $dateNice = date('F d, Y', cleanDate($date)); $description = trim($matches[1][3]); $body = preg_replace('/^(.*\\n){7}/', '', $fileData); // Removes the header from file. If you add or remove lines you need to change the number. $orgURL = 'http://' . SITEURL . '/' . $filePath; $orgLink = '<a href="' . $orgURL . '" title="' . $title . ' .org file.">' . $orgURL . '</a>'; $articleURL = 'http://' . SITEURL . '/' . substr($filePath, 0, -4) . '/'; $permalink = '<a rel="bookmark" href="' . $articleURL . '" title="' . $title . '">' . $title . '</a>'; if ($output == 'orgile') { $body = orgile($body); } $content = '<article class="hentry"><header><h3 class="entry-unrelated">' . $dateNice . '</h3><h1 class="entry-title">' . $title . '</h1></header><div class="entry-content">' . $body . '<br><hr></div><aside><h3>' . $title . '</h3><p class="small"><strong>published: </strong>' . $dateNice . '<br><strong>permalink: </strong>' . $permalink . '<br><strong>citing: </strong><span class="byline author vcard"><a class="email fn" href="mailto:' . EMAIL . '">' . $author . '</a></span>. <i>' . $title . '</i> <time class="updated" datetime="' . $dateTime . '" pubdate>' . $dateNice . '</time>. ' . $articleURL . '.<br><span class="source-org vcard copyright"><strong>copyright: </strong>Unless otherwise indicated, this article is licensed under a <a rel="license" href="' . LICENSEURL . '" title="Unless otherwise indicated, this article is licensed under a ' . LICENSE . '">' . LICENSE . '</a> (cc) 2012 <a class="url org fn" href="http://' . SITEURL . '">' . SITETITLE . '</a></p><a class="gototop" href="#top">return to top</a></p></aside></article>'; print $content; } }
#!/usr/bin/env php <? require_once('orgile/www/site/orgile/orgile.php'); $fp = fopen('php://stdin', 'r'); $cont=''; while ($line = fgets($fp)) { $cont.= $line; } $op = orgile($cont); echo $op; ?>