Skip to content

Instantly share code, notes, and snippets.

@PeeHaa
Created July 9, 2012 12:53
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PeeHaa/3076330 to your computer and use it in GitHub Desktop.
Save PeeHaa/3076330 to your computer and use it in GitHub Desktop.
Blogging software

Blogging system

I hate myself for reinventing the wheel, but I like building stuff myself ;-)

Comments

It should be possible to save and retrieve comments using different storage mechanisms:

  • GitHub repo / gists
  • Database (PDO)
  • XML Files

Functionality of comments:

  • Post comment
  • Edit comment
  • Moderation
  • Replying to comments
  • URL shortener
  • Gravatars

Info of comments:

  • Timestamp
  • Message
  • User / Emailaddress / null
  • Article identifier

Formatting of posts:

  • Markdown
  • Plaintext
  • HTML (check against whitelist of tags)

Storage

  • self hosted
  • disqus
  • login by: name, social media (fb, twitter, g+) or anonymous

Articles

  • Title
  • Timestamp
  • Intro (optional)
  • Message
  • Identifier
  • Tags
  • Article preview

Router

Routes config formats:

  • array
  • yaml
  • xml

ATOM feed

@PeeHaa
Copy link
Author

PeeHaa commented Jul 10, 2012

Retrievable interface

<?php
/**
 * The Retrievable interface. All classes which are able of storing data should implement this interface
 *
 * PHP version 5.3
 *
 * @category   Yadeo
 * @package    Storage
 * @author     Pieter Hordijk <info@pieterhordijk.com>
 * @copyright  Copyright (c) 2012 Pieter Hordijk
 * @license    http://www.opensource.org/licenses/mit-license.html  MIT License
 * @version    0.0.1
 */
namespace Yadeo\Storage;

/**
 * The Retrievable interface. All classes which are able of storing data should implement this interface
 *
 * @category   Yadeo
 * @package    Storage
 * @author     Pieter Hordijk <info@pieterhordijk.com>
 */
interface Retrievable
{
    /**
     * Retrieves data from the storage medium
     *
     * @param mixed $identifier The unique identifier of the item we are going to retrieve
     * @param \Yadeo\Paginator $pagniator A paginator instance
     * @param string $sortField The name of the field on which we are going to sort
     */
    public function get($identifier, \Yadeo\Paginator $paginator, $sortField = 'id');
}

@PeeHaa
Copy link
Author

PeeHaa commented Jul 10, 2012

Article class

<?php
/**
 * The article class. Class for blogposts.
 *
 * PHP version 5.3
 *
 * @category   Yadeo
 * @package    Post
 * @author     Pieter Hordijk <info@pieterhordijk.com>
 * @copyright  Copyright (c) 2012 Pieter Hordijk
 * @license    http://www.opensource.org/licenses/mit-license.html  MIT License
 * @version    0.0.1
 */
namespace Yadeo\Post;

/**
 * The article class. Class for blogposts.
 *
 * @category   Yadeo
 * @package    Post
 * @author     Pieter Hordijk <info@pieterhordijk.com>
 */
class Article implements \Yadeo\Post, \Yadeo\Storage\Storable, \Yadeo\Storage\Retrievable
{
    /**
     * @var \Yadeo\Storage\Storage The storage medium used
     */
    protected $storage;

    /**
     * Creates an instance
     *
     * @param \Yadeo\Storage\Storage $storage The storage medium used
     */
    public function __construct(\Yadeo\Storage\Storage $storage)
    {
        $this->storage = $storage;
    }

    /**
     * Creates an instance
     *
     * @param \Yadeo\Storage\Storage $storage The storage medium used
     *
     * @return mixed The unique identifier of the newly added article
     */
    public function save(array $data)
    {
        return $this->storage->save($data);
    }

    /**
     * Creates an instance
     *
     * @param array $identifiers An array with unique identifiers to retrieve
     * @param string $sortfield The name of the field on which to sort the results
     * @param \Yadeo\Paginator $paginator Instance of a paginator
     */
    public function get(array $identifiers, \Yadeo\Paginator $paginator, $sortField = 'id')
    {
    }
}

@PeeHaa
Copy link
Author

PeeHaa commented Jul 10, 2012

Paginator interface

<?php
/**
 * Provides a paginator
 *
 * PHP version 5.3
 *
 * @category   Yadeo
 * @package    Paginator
 * @author     Pieter Hordijk <info@pieterhordijk.com>
 * @copyright  Copyright (c) 2012 Pieter Hordijk
 * @license    http://www.opensource.org/licenses/mit-license.html  MIT License
 * @version    1.0.0
 */
namespace Yadeo;

/**
 * Provides a paginator
 *
 * @category   Yadeo
 * @package    Paginator
 * @author     Pieter Hordijk <info@pieterhordijk.com>
 */
interface Paginator
{
    /**
     * Gets the current selected page
     *
     * @return int The current selected page
     */
    public function getCurrentPage();

    /**
     * Gets the total number of items
     *
     * @return int The total number of items
     */
    public function getItemCount();

    /**
     * Gets the window size of the paginator. The window size is the number of displayed pages in the paginator
     * E.g. when there are more pages they will be trimmed and displayed as ... or something like that
     *
     * @return int The size of the window
     */
    public function getWindowSize();
}

@PeeHaa
Copy link
Author

PeeHaa commented Jul 10, 2012

Formatable interface

<?php
/**
 * Provides the Formatable interface. Classes which have the option to format text should implement this interface
 *
 * PHP version 5.3
 *
 * @category   Yadeo
 * @package    Format
 * @author     Pieter Hordijk <info@pieterhordijk.com>
 * @copyright  Copyright (c) 2012 Pieter Hordijk
 * @license    http://www.opensource.org/licenses/mit-license.html  MIT License
 * @version    1.0.0
 */
namespace Yadeo\Format;

/**
 * Provides the Formatable interface. Classes which have the option to format text should implement this interface
 *
 * @category   Yadeo
 * @package    Format
 * @author     Pieter Hordijk <info@pieterhordijk.com>
 */
interface Formatable
{
    /**
     * Sets the parserengine used to parse data
     */
    public function setParser(\Yadeo\Format\Parser $parser);

    /**
     * Parses text
     *
     * @param string $data The data to be parsed
     *
     * @return string The parsed data
     */
    public function parse($data);
}

@PeeHaa
Copy link
Author

PeeHaa commented Jul 11, 2012

calendar

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment