private function listPosts($page_no = 0)
 {
     $blog = new eatStaticBlog();
     $page = new adminPage('posts.php');
     $page->context['posts'] = $blog->getSlicedPosts($page_no, 100);
     $page->context['title'] = "Posts";
     $page->render();
 }
Ejemplo n.º 2
0
<?php

require EATSTATIC_ROOT . '/eatStaticBlog.class.php';
$blog = new eatStaticBlog();
$blog->post_folder = DATA_ROOT . '/posts/';
$posts = $blog->getRecentPosts();
// translate into RSS object/ items
$feed = new eatStaticBlogFeed();
$feed->blog_title = BLOG_TITLE . ' :: ' . BLOG_TAG_LINE;
$feed->blog_link = 'http://' . $_SERVER['HTTP_HOST'];
if (sizeof($posts) > 0) {
    // get the date of the the most recent item in format Tue, 01 Jun 2010 13:35:09 +0000
    $pub_date = date('D, d M y 00:00:00 +0000', strtotime($posts[0]->date));
    $feed->pub_date = $pub_date;
    foreach ($posts as $post) {
        $item = new eatStaticBlogFeedItem();
        $item->title = $post->title;
        $item->pub_date = date('D, d M y 00:00:00 +0000', strtotime($post->date));
        $item->author = $post->author;
        if (WP_URLS) {
            $date_str = date('Y', strtotime($post->date)) . '-' . date('m', strtotime($post->date)) . '-' . date('d', strtotime($post->date));
            $item->uri = SITE_ROOT . date('Y', strtotime($post->date)) . '/' . date('m', strtotime($post->date)) . '/' . date('d', strtotime($post->date)) . '/' . str_replace($date_str . '-', '', $post->slug) . '/';
        } else {
            $item->uri = SITE_ROOT . 'posts/' . $post->slug . PAGE_EXT;
        }
        $item->url = 'http://' . $_SERVER['HTTP_HOST'] . $item->uri;
        $item->summary = substr($post->body, 0, 200) . '...';
        $item->formatted_body = $post->formatted_body;
        $feed->items[] = $item;
    }
}
Ejemplo n.º 3
0
      * blog post page
      */
 /**
  * blog post page
  */
 case "posts":
     switch ($path[1]) {
         case "all":
             switch ($path[2]) {
                 case "":
                     // probably 404, as we never want to return all posts?
                     break;
                 default:
                     require EATSTATIC_ROOT . '/eatStaticBlog.class.php';
                     // return appropriate slice depending on specified page
                     $blog = new eatStaticBlog();
                     $posts = $blog->getSlicedPosts($path[2] - 1);
                     $page_title = BLOG_TITLE . ' :: ' . BLOG_TAG_LINE;
                     $current_page = $path[2];
                     // set up paginator
                     //$blog->getPostFiles();
                     $paginator = new eatStaticPaginator();
                     $paginator->current = $path[2];
                     $paginator->total = sizeof($blog->post_files);
                     $paginator->pagination_root = 'posts/all/';
                     $stub = "blog_index.php";
                     break;
             }
             break;
         default:
             $stub = "post.php";
Ejemplo n.º 4
0
		<div class="clear"><!-- --></div>
		<?php 
    //echo "here";print_r($gallery->captions);
    ?>
	</div>
	<script type="text/javascript">
	$(function() {
		$('.gallery a.lightbox-<?php 
    echo $post->slug;
    ?>
').lightBox({fixedNavigation:true});
	});
	</script>
	<?php 
}
eatStaticBlog::obsoleteWarning($post->timestamp);
if (sizeof($post->tags) > 0) {
    ?>
	<div class="tags">
		Tags: 
	<?php 
    foreach ($post->tags as $tag) {
        ?>
	<a href="<?php 
        echo SITE_ROOT;
        ?>
category/<?php 
        echo $post->slugify($tag);
        ?>
"><?php 
        echo $tag;
Ejemplo n.º 5
0
<?php

require EATSTATIC_ROOT . '/eatStaticBlog.class.php';
$show_prev_next = false;
$blog = new eatStaticBlog();
$posts = $blog->getArchiveList($slug);
$page_title = BLOG_TITLE . ' :: Archive ' . $slug;
$posts = array_reverse($posts);
eatStatic::template('page_top.php');
eatStatic::template('body_top.php');
foreach ($posts as $post) {
    eatStatic::template('post_item.php');
}
eatStatic::template('body_bottom.php');
eatStatic::template('page_bottom.php');
Ejemplo n.º 6
0
<?php

/**
 * @desc - go through live posts and create an index of tags
 */
require '../eatStatic_config.php';
require_once EATSTATIC_ROOT . "/eatStaticBlog.class.php";
require_once EATSTATIC_ROOT . "/eatStaticTag.class.php";
$blog = new eatStaticBlog();
$blog->getPostFiles();
print_r($blog);
// delete tag cache files
eatStaticTag::deleteAll();
foreach ($blog->post_files as $post_file) {
    $post = new eatStaticBlogPost();
    $post->data_file_path = $post_file;
    $post->hydrate();
    echo $post->title;
    //print_r($post->tags);
    foreach ($post->tags as $tag) {
        // create tag object -> open existing or create new
        $tag_object = new eatStaticTag();
        $tag_object->name = $tag;
        // load existing items if there are any
        $tag_object->load();
        // add data file path to tag items array
        $tag_object->addItem($post->data_file_path);
        // save tag json
        $tag_object->save();
    }
}
Ejemplo n.º 7
0
 function hydrate()
 {
     $this->raw_data = $this->read_file($this->data_file_path);
     if ($this->raw_data == '') {
         // no post content found
     }
     $ext = $this->getExtension($this->data_file_path);
     if ($ext == 'md') {
         $this->source_format = 'markdown';
         require_once LIB_ROOT . "/php-markdown/Markdown.inc.php";
     }
     $parts = explode("\n", $this->raw_data);
     $str = '';
     $format_str = '';
     // get title from first line
     $this->title = $parts[0];
     $body = true;
     $meta = false;
     $raw_body = '';
     $raw_meta = '';
     // the rest is body
     for ($i = 1; $i < sizeof($parts); $i++) {
         $str = $str . $parts[$i];
         if ($i > 1) {
             // the body section can be the rest of the file,
             // or you can mark the end of the body section with --
             // you can then put meta data fields in the file
             if (eatStatic::stripLineBreaks($parts[$i]) == '--' && $meta == false) {
                 $body = false;
                 $meta = true;
             }
             if ($body) {
                 $raw_body = $raw_body . $parts[$i] . "\n";
                 // formatted body - for text format, line breaks need to be replaced with br, but not between html elements
                 if ($this->source_format == 'text') {
                     if (substr($parts[$i], -1) != '>') {
                         $format_str = $format_str . $parts[$i] . "<br />\n";
                     } else {
                         $format_str = $format_str . $parts[$i] . "\n";
                     }
                 }
             }
             // get meta info
             if ($meta && eatStatic::stripLineBreaks($parts[$i]) != '--') {
                 //die('meta:'.$parts[$i]);
                 if ($parts[$i] != '') {
                     $this->handleMeta($parts[$i]);
                     $raw_meta = $raw_meta . $parts[$i] . "\n";
                 }
             }
         }
     }
     if ($this->source_format == 'markdown') {
         // remove hashes from title
         $this->title = str_replace('#', '', $this->title);
         // parse the markdown into HTML
         $this->formatted_body = Michelf\Markdown::defaultTransform($raw_body);
     } else {
         $this->formatted_body = $format_str;
     }
     $this->raw_body = $raw_body;
     $this->raw_meta = $raw_meta;
     $this->body = $str;
     $this->file_name = basename($this->data_file_path);
     if ($this->source_format == 'markdown') {
         $this->slug = str_replace('.md', '', $this->file_name);
     } else {
         $this->slug = str_replace('.txt', '', $this->file_name);
     }
     $this->date = substr($this->file_name, 0, 10);
     $this->slug_trimmed = str_replace($this->date . '-', '', $this->slug);
     $this->nice_date = date(NICE_DATE_FORMAT, strtotime($this->date));
     $this->timestamp = strtotime($this->date);
     // get gallery items if there are any
     $gallery = new eatStaticGallery($this->slug . '/');
     $this->gallery_items = $gallery->gallery_items;
     // set up the URI
     if (WP_URLS) {
         $date_str = date('Y', strtotime($this->date)) . '-' . date('m', strtotime($this->date)) . '-' . date('d', strtotime($this->date));
         $this->uri = SITE_ROOT . date('Y', strtotime($this->date)) . '/' . date('m', strtotime($this->date)) . '/' . date('d', strtotime($this->date)) . '/' . str_replace($date_str . '-', '', $this->slug) . '/';
     } else {
         $this->uri = SITE_ROOT . 'posts/' . $this->slug . PAGE_EXT;
     }
     // get the next and previous urls
     $blog = new eatStaticBlog();
     $blog->getPostFiles();
     foreach ($blog->post_files as $key => $val) {
         if ($val == $this->data_file_path) {
             if ($key > 0) {
                 $this->prev_url = $this->uriFromFilename(basename($blog->post_files[$key - 1]));
             }
             if ($key < count($blog->post_files) - 1) {
                 $this->next_url = $this->uriFromFilename(basename($blog->post_files[$key + 1]));
             }
         }
     }
 }