Verified Commit e01eeef1 authored by David Libeau's avatar David Libeau
Browse files

Add head, foot, nav. Modify CSS. Add lib.

parent 5cfc37bb
......@@ -21,3 +21,8 @@
## Catchword
> Easy self-hosted, ActivityPub, Markdown, PHP, NoSQL, fully customisable blog engine for noob web devs and others!
## Installation instructions
1. Download all the repository and upload it to your Apache web server
2. Modify the file `fedidata/serverConfig.xml` with your own config.
\ No newline at end of file
......@@ -5,6 +5,8 @@ function autoloader($class) {
require_once("controllers/".$class.".php");
}
require_once("../fedilib/Parsedown.php");
require_once("../fedilib/ParsedownExtra.php");
require_once("../fedilib/ParsedownExtraPlugin.php");
require_once("../fedilib/mime_content_type_modified.php");
}
spl_autoload_register('autoloader');
......
......@@ -115,7 +115,7 @@ class Content{
return(
'<entry>
<id>http://'.Server::get("domain").'/'.$this->id.'</id>
<title>Test article</title>
<title>'.$this->data["title"].'</title>
<published>'.$this->data["publishedDate"].'</published>
<updated>'.$this->data["updatedDate"].'</updated>
<author id="'.$this->data["author"].'">
......
......@@ -199,7 +199,7 @@ $feed='<?xml version="1.0" encoding="utf-8"?>
<uri>http://'.Server::get("domain")."/".Server::get("route/User","/").Server::get("admin/id").'</uri>
</author>
<updated>2003-12-13T18:30:02Z</updated>
<rights>'.Server::get("licence").' '.Server::get("admin/name").' '.date("Y").'</rights>
<rights>'.Server::get("license").' '.Server::get("admin/name").' '.date("Y").'</rights>
<link rel="self" href="/feed" />
'.$this->list("all","Article","atom").'
......
......@@ -14,15 +14,15 @@ class View{
var_dump($object);
break;
case "json":
header('Content-type: application/json;charset=utf-8');
header("Content-type: application/json;charset=utf-8");
echo(json_encode($object));
break;
case "activityjson":
header('Content-type: application/activity+json');
header("Content-type: application/activity+json");
echo(json_encode($object));
break;
case "image":
header('Content-type: image/jpeg;charset=utf-8');
header("Content-type: image/jpeg;charset=utf-8");
echo($object);
break;
case "atom":
......@@ -42,7 +42,7 @@ echo('<?xml version="1.0" encoding="utf-8"?>
<uri>http://'.Server::get("domain")."/".Server::get("route/User")."/".Server::get("admin/id").'</uri>
</author>
<updated>2003-12-13T18:30:02Z</updated>
<rights>'.Server::get("licence").' '.Server::get("admin/name").' '.date("Y").'</rights>
<rights>'.Server::get("license").' '.Server::get("admin/name").' '.date("Y").'</rights>
<link rel="self" href="/feed" />
'.$object->exportAtom().'
</feed>');
......@@ -51,8 +51,17 @@ echo('<?xml version="1.0" encoding="utf-8"?>
$render="<a href=\"/".Server::get("route/Content/".$object->get("type"))."/".$object->get("id")."\">".$object->get("id")."</a>";
break;
case "markdown":
$Parsedown = new Parsedown();
$render=$Parsedown->text($object->get("content"));
$parser = new ParsedownExtra();
/*$parser->abbreviations = array(
"CSS" => "Cascading Style Sheet",
"HTML" => "Hyper Text Markup Language",
"JS" => "JavaScript"
);
$parser->links_external_attr = array(
"rel" => "nofollow",
"target" => "_blank"
);*/
$render=$parser->text($object->get("content"));
break;
default :
/*$render=file_get_contents("views/".$viewName.".xml");
......@@ -110,5 +119,20 @@ echo('<?xml version="1.0" encoding="utf-8"?>
}
}
public static function displayStatic($object=""){
$object=strtolower($object);
switch($object){
case "":
break;
case "head":
case "nav":
case "foot":
ob_start();
include "views/".$object.".php";
$render=ob_get_clean();
echo(Secure::that($render));
break;
}
}
}
?>
\ No newline at end of file
......@@ -2,16 +2,13 @@
<html lang="en">
<head>
<meta charset="utf-8" />
<?php View::displayStatic("head"); ?>
<title><?php echo($fediview->get("data")["title"]); ?> - Article - <?php Server::display("url"); ?></title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<meta name="theme-color" content="#0070C0">
<link rel="stylesheet" href="https://dav.li/forkawesome/1.0.11/css/fork-awesome.min.css"/>
<link rel="stylesheet" href="/general.css" type="text/css"/>
<link rel="stylesheet" href="/article.css" type="text/css"/>
<link rel="stylesheet" href="/user-card.css" type="text/css"/>
</head>
<body>
<?php View::displayStatic("nav"); ?>
<div class="content">
<header>
<div class="banner" style="background-image:url(<?php echo(Server::get("route/Content/Article")); ?>/<?php $fediview->display("id"); ?>/header.jpg)"></div>
......@@ -21,11 +18,12 @@
<?php View::render("markdown",$fediview); ?>
</main>
<footer>
<h2>The author :</h2>
<p>Article published the <span title="Published date"><?php echo(date_format(new DateTime($fediview->get("data")["publishedDate"]), 'l jS \of F Y \a\t H:i')); ?></span> by <a href="/<?php Server::display("route/User","/"); echo($fediview->get("data")["author"]); ?>" title="Author">@<?php echo($fediview->get("data")["author"]); ?>@<?php Server::display("domain"); ?></a>.</p>
<div id="author">
<?php View::render("user-card",new User($fediview->get("data")["author"])); ?>
</div>
</footer>
</div>
<?php View::displayStatic("foot"); ?>
</body>
</html>
\ No newline at end of file
<div id="fedifoot" class="content">
<p>Website powered by <a href="https://fedi.blog">Fediblog<img class="logo" src="/logo.svg" alt="Fediblog logo"/></a></p>
<p><?php Server::display("license"); ?> <a href="/<?php Server::display("route/User","/"); Server::display("admin"); ?>">@<?php Server::display("admin"); ?>@<?php Server::display("domain"); ?></a></p>
</div>
<script src="http://dav.li/jquery/3.1.1.min.js"></script>
<script>
$(document).ready(function(){
$("#fediloader").hide();
});
$("a").click(function(evt){
$("#fediloader").show();
});
</script>
\ No newline at end of file
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<meta name="theme-color" content="#0070C0">
<link rel="stylesheet" href="https://dav.li/forkawesome/1.0.11/css/fork-awesome.min.css"/>
<link rel="stylesheet" href="/general.css" type="text/css"/>
<nav id="fedinav">
<ol class="content">
<li><a href="/" title="Home"><i class="fa fa-home" aria-hidden="true"></i></a></li>
<li><a href="/about" title="About"><i class="fa fa-question-circle-o" aria-hidden="true"></i></a></li>
</ol>
</nav>
<div id="fediloader">
<i class="fa fa-cog fa-spin fa-3x fa-fw"></i>
</div>
\ No newline at end of file
......@@ -2,15 +2,12 @@
<html lang="en">
<head>
<meta charset="utf-8" />
<?php View::displayStatic("head"); ?>
<title>@<?php $fediview->display("id"); ?> - <?php Server::display("url"); ?></title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<meta name="theme-color" content="#0070C0">
<link rel="stylesheet" href="https://dav.li/forkawesome/1.0.11/css/fork-awesome.min.css"/>
<link rel="stylesheet" href="/general.css" type="text/css"/>
<link rel="stylesheet" href="/user.css" type="text/css"/>
</head>
<body>
<?php View::displayStatic("nav"); ?>
<div class="content">
<header>
<div class="banner" style="background-image:url(/<?php echo(Server::get("route/User","/")); $fediview->display("id"); ?>/header.jpg)"></div>
......@@ -20,5 +17,6 @@
<p><?php $fediview->display("description"); ?></p>
</header>
</div>
<?php View::displayStatic("foot"); ?>
</body>
</html>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<view>
<head>
<title>User : @{{$id}}</title>
</head>
<body>
<h1>{{$name}}</h1>
<h2>@{{$id}}</h2>
<p>{{$description}}</p>
</body>
</view>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<serverConfig>
<url>dev.fedi.blog</url>
<admin>david</admin>
<title>Dev blog for Fedi.blog</title>
<url>your.fedi.blog</url>
<admin>testuser</admin>
<title>My Fediblog!</title>
<subtitle>We are all now connected by the Internet, like neurons in a giant brain.</subtitle>
<licence>CC-BY</licence>
<license>CC-BY</license>
<defaultPublishing>
<author>david</author>
<author>testuser</author>
<visibility>unlisted</visibility>
</defaultPublishing>
<customPath>
<object>
<id>user</id>
<id>User</id>
<route>user</route>
<path>
<data>fedidata/user</data>
</path>
</object>
<object>
<id>content/article</id>
<id>Content/Article</id>
<route>article</route>
<path>
<data>fedidata/content/article</data>
<content>article</content>
<content>/</content>
</path>
</object>
<object>
<id>content/static</id>
<id>Content/Static</id>
<route>/</route>
<path>
<data>fedidata/content/static</data>
......@@ -34,7 +34,7 @@
</path>
</object>
<object>
<id>content/media</id>
<id>Content/Media</id>
<route>media</route>
<path>
<data>fedidata/content/media</data>
......
<?xml version="1.0" encoding="UTF-8"?>
<user>
<id>david</id>
<name>David Libeau</name>
<description>Hi there!</description>
</user>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<user>
<id>testuser</id>
<name>Test user</name>
<description>This is a test user of Fediblog. Delete me!</description>
</user>
\ No newline at end of file
This diff is collapsed.
<?php
#
#
# Parsedown Extra
# https://github.com/erusev/parsedown-extra
#
# (c) Emanuil Rusev
# http://erusev.com
#
# For the full license information, view the LICENSE file that was distributed
# with this source code.
#
#
class ParsedownExtra extends Parsedown
{
# ~
const version = '0.8.0-beta-1';
# ~
function __construct()
{
if (version_compare(parent::version, '1.7.1') < 0)
{
throw new Exception('ParsedownExtra requires a later version of Parsedown');
}
$this->BlockTypes[':'] []= 'DefinitionList';
$this->BlockTypes['*'] []= 'Abbreviation';
# identify footnote definitions before reference definitions
array_unshift($this->BlockTypes['['], 'Footnote');
# identify footnote markers before before links
array_unshift($this->InlineTypes['['], 'FootnoteMarker');
}
#
# ~
function text($text)
{
$Elements = $this->textElements($text);
# convert to markup
$markup = $this->elements($Elements);
# trim line breaks
$markup = trim($markup, "\n");
# merge consecutive dl elements
$markup = preg_replace('/<\/dl>\s+<dl>\s+/', '', $markup);
# add footnotes
if (isset($this->DefinitionData['Footnote']))
{
$Element = $this->buildFootnoteElement();
$markup .= "\n" . $this->element($Element);
}
return $markup;
}
#
# Blocks
#
#
# Abbreviation
protected function blockAbbreviation($Line)
{
if (preg_match('/^\*\[(.+?)\]:[ ]*(.+?)[ ]*$/', $Line['text'], $matches))
{
$this->DefinitionData['Abbreviation'][$matches[1]] = $matches[2];
$Block = array(
'hidden' => true,
);
return $Block;
}
}
#
# Footnote
protected function blockFootnote($Line)
{
if (preg_match('/^\[\^(.+?)\]:[ ]?(.*)$/', $Line['text'], $matches))
{
$Block = array(
'label' => $matches[1],
'text' => $matches[2],
'hidden' => true,
);
return $Block;
}
}
protected function blockFootnoteContinue($Line, $Block)
{
if ($Line['text'][0] === '[' and preg_match('/^\[\^(.+?)\]:/', $Line['text']))
{
return;
}
if (isset($Block['interrupted']))
{
if ($Line['indent'] >= 4)
{
$Block['text'] .= "\n\n" . $Line['text'];
return $Block;
}
}
else
{
$Block['text'] .= "\n" . $Line['text'];
return $Block;
}
}
protected function blockFootnoteComplete($Block)
{
$this->DefinitionData['Footnote'][$Block['label']] = array(
'text' => $Block['text'],
'count' => null,
'number' => null,
);
return $Block;
}
#
# Definition List
protected function blockDefinitionList($Line, $Block)
{
if ( ! isset($Block) or $Block['type'] !== 'Paragraph')
{
return;
}
$Element = array(
'name' => 'dl',
'elements' => array(),
);
$terms = explode("\n", $Block['element']['handler']['argument']);
foreach ($terms as $term)
{
$Element['elements'] []= array(
'name' => 'dt',
'handler' => array(
'function' => 'lineElements',
'argument' => $term,
'destination' => 'elements'
),
);
}
$Block['element'] = $Element;
$Block = $this->addDdElement($Line, $Block);
return $Block;
}
protected function blockDefinitionListContinue($Line, array $Block)
{
if ($Line['text'][0] === ':')
{
$Block = $this->addDdElement($Line, $Block);
return $Block;
}
else
{
if (isset($Block['interrupted']) and $Line['indent'] === 0)
{
return;
}
if (isset($Block['interrupted']))
{
$Block['dd']['handler']['function'] = 'textElements';
$Block['dd']['handler']['argument'] .= "\n\n";
$Block['dd']['handler']['destination'] = 'elements';
unset($Block['interrupted']);
}
$text = substr($Line['body'], min($Line['indent'], 4));
$Block['dd']['handler']['argument'] .= "\n" . $text;
return $Block;
}
}
#
# Header
protected function blockHeader($Line)
{
$Block = parent::blockHeader($Line);
if (preg_match('/[ #]*{('.$this->regexAttribute.'+)}[ ]*$/', $Block['element']['handler']['argument'], $matches, PREG_OFFSET_CAPTURE))
{
$attributeString = $matches[1][0];
$Block['element']['attributes'] = $this->parseAttributeData($attributeString);
$Block['element']['handler']['argument'] = substr($Block['element']['handler']['argument'], 0, $matches[0][1]);
}
return $Block;
}
#
# Markup
protected function blockMarkup($Line)
{
if ($this->markupEscaped or $this->safeMode)
{
return;
}
if (preg_match('/^<(\w[\w-]*)(?:[ ]*'.$this->regexHtmlAttribute.')*[ ]*(\/)?>/', $Line['text'], $matches))
{
$element = strtolower($matches[1]);
if (in_array($element, $this->textLevelElements))
{
return;
}
$Block = array(
'name' => $matches[1],
'depth' => 0,
'element' => array(
'rawHtml' => $Line['text'],
'autobreak' => true,
),
);
$length = strlen($matches[0]);
$remainder = substr($Line['text'], $length);
if (trim($remainder) === '')
{
if (isset($matches[2]) or in_array($matches[1], $this->voidElements))
{
$Block['closed'] = true;
$Block['void'] = true;
}
}
else
{
if (isset($matches[2]) or in_array($matches[1], $this->voidElements))
{
return;
}
if (preg_match('/<\/'.$matches[1].'>[ ]*$/i', $remainder))
{
$Block['closed'] = true;
}
}
return $Block;
}
}
protected function blockMarkupContinue($Line, array $Block)
{
if (isset($Block['closed']))
{
return;
}
if (preg_match('/^<'.$Block['name'].'(?:[ ]*'.$this->regexHtmlAttribute.')*[ ]*>/i', $Line['text'])) # open
{
$Block['depth'] ++;
}
if (preg_match('/(.*?)<\/'.$Block['name'].'>[ ]*$/i', $Line['text'], $matches)) # close
{
if ($Block['depth'] > 0)
{
$Block['depth'] --;
}
else
{
$Block['closed'] = true;
}
}
if (isset($Block['interrupted']))
{
$Block['element']['rawHtml'] .= "\n";
unset($Block['interrupted']);
}
$Block['element']['rawHtml'] .= "\n".$Line['body'];
return $Block;
}
protected function blockMarkupComplete($Block)
{
if ( ! isset($Block['void']))
{
$Block['element']['rawHtml'] = $this->processTag($Block['element'][