Skip to content

Instantly share code, notes, and snippets.

@belfie13
Last active March 11, 2020 14:20
Show Gist options
  • Save belfie13/dbce6e09208e2c10fd7cb1f17bdc177c to your computer and use it in GitHub Desktop.
Save belfie13/dbce6e09208e2c10fd7cb1f17bdc177c to your computer and use it in GitHub Desktop.
How to implement a 'Gists' type workflow.

Notes

r we sarps to comment extrenuously within these all be it simple collection of text forming idea to get the gist.

  • a gist is a repository
    • a file of any type or a small collection of related or dependant files
    • files link relatively (easily lol) in a gist container
    • has a title or summary
  • can have a gist library
  • can have built in editor
  • can have category tags

Data Model

v0.1 Basics

Repository // the back end functions common to all 'Gists' $working-directory // the gist, no sub-directories // html web form interface (php backend) -> basic file system, git, and text editing functions

Gist // abstract instance metadata and reference point for all files within $name $summary // description $files File[]

File // a component node of data. reps arbitrary file (anything text/source/script/markup/config). $name // $extension -> $path/dir $contents

v0.1 Extended

Repo

  • one master branch
  • auto add/commit on save
  • versions with tags
  • crud files
  • file viewer php
  • file editor php
  • main interface php
    • list files
    • add file
    • delete file
    • edit file
    • list version tags
    • set new version tag
    • checkout version tag
<?php
namespace CIID;
class Gist
{
private $name;
private $summary;
private $files;
}
<?php
namespace CIID;
class HtmlFûčtory
{
// ~~~>>> Basic Element Creation <<<~~~ //
/**
* simples converts arg list into HTML.
* the base function we build on like with {@see createH1Element()} n staffs infarktions.
*
* @param $tagName string The elements entity name.
* @param $attr string|iterable A string or array of key-value pairs to parse.
* @param $contents string|iterable A string or array of elements rep'd by [$tagName, $attr, $contents].
* @return string A HTML rep of the element.
*/
public static function createElement(string $tagName, $attr = null, $contents = null)
{
# start tag
$html = '<';
# valid element names only???
$html.= $tagName;
# MOVE TO buildElementAttributes()
// attributes
if ($attr)
{
if (is_array($attr))
{
$strattr = '';
foreach ($attr as $key => $value)
{
$strattr.= ' '.$key.'="'.$value.'"';
}
$attr = $strattr;
}
elseif (is_string($attr))
{
# check it???
}
$html.= $attr;
}
$html.= '>';
# MOVE TO buildElementContents()
# contents
if ($contents)
{
if (is_array($contents))
{
// recursive element exportz
$strcnt = '';
foreach ($contents as $args)
{
list($tag, $atr, $cnt) = $args;
$strcnt.= __CLASS__::createElement($tag, $atr, $cnt);
}
$contents = $strcnt
}
$html.= $contents;
}
// end tag
# exclude end tag if element is void
$html.= '</'.$tagName.'>';
return $html;
}
public static function buildElementAttributes($attr)
{
# ifs null return an empty string
# ifs string return it
# ifs iterable: concatenate ' '.key-value pairs
# return a string
}
public static function buildElementContents($contents)
{
# ifs null return an empty string
# ifs string return it
# ifs iterable: recursively call createElement()???
# return a string
}
// ~~~>>> Specialized Factory Section <<<~~~ //
public static function createUnorderedListElement(iterable $items, $attr = null)
{
# build list items
foreach ($items as $li => $contents)
{
# /!\ func to return string or parse iterable for key-values or attr to createElement() /!\
}
$html = self::createElement('ol', $attr, $contents);
}
}
<?php
namespace CIID;
class Repo
{
// ~~~>>> Model <<<~~~ //
private $gist;
// ~~~>>> Model Accessors <<<~~~ //
p
// ~~~>>> <<<~~~ //
// ~~~>>> <<<~~~ //
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment