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

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.
This diff is collapsed.
This diff is collapsed.
# Fedilib
> Libraries used by Fediblog
The files in the Fedilib folder are belonging to his respective owners and may be published in a different license.
- [Parsedown](http://parsedown.org/) - [MIT](https://github.com/erusev/parsedown/blob/master/LICENSE.txt)
- [Parsedown Extra](https://github.com/erusev/parsedown-extra) - [MIT](https://github.com/erusev/parsedown-extra/blob/master/LICENSE.txt)
- [Parsedown Extra Plugin](https://github.com/tovic/parsedown-extra-plugin) - [MIT](https://github.com/tovic/parsedown-extra-plugin/blob/master/LICENSE)
- mime_content_type_modified - CC0
\ No newline at end of file
<?php
function mime_content_type_modified($filename) {
$mime_types = array(
'txt' => 'text/plain',
'htm' => 'text/html',
'html' => 'text/html',
'php' => 'text/html',
'css' => 'text/css',
'js' => 'application/javascript',
'json' => 'application/json',
'xml' => 'application/xml',
'swf' => 'application/x-shockwave-flash',
'flv' => 'video/x-flv',
// images
'png' => 'image/png',
'jpe' => 'image/jpeg',
'jpeg' => 'image/jpeg',
'jpg' => 'image/jpeg',
'gif' => 'image/gif',
'bmp' => 'image/bmp',
'ico' => 'image/vnd.microsoft.icon',
'tiff' => 'image/tiff',
'tif' => 'image/tiff',
'svg' => 'image/svg+xml',
'svgz' => 'image/svg+xml',
// archives
'zip' => 'application/zip',
'rar' => 'application/x-rar-compressed',
'exe' => 'application/x-msdownload',
'msi' => 'application/x-msdownload',
'cab' => 'application/vnd.ms-cab-compressed',
// audio/video
'mp3' => 'audio/mpeg',
'qt' => 'video/quicktime',
'mov' => 'video/quicktime',
// adobe
'pdf' => 'application/pdf',
'psd' => 'image/vnd.adobe.photoshop',
'ai' => 'application/postscript',
'eps' => 'application/postscript',
'ps' => 'application/postscript',
// ms office
'doc' => 'application/msword',
'rtf' => 'application/rtf',
'xls' => 'application/vnd.ms-excel',
'ppt' => 'application/vnd.ms-powerpoint',
// open office
'odt' => 'application/vnd.oasis.opendocument.text',
'ods' => 'application/vnd.oasis.opendocument.spreadsheet',
);
$explode=explode('.',$filename);
$ext = strtolower(array_pop($explode));
if (array_key_exists($ext, $mime_types)) {
return $mime_types[$ext];
}
elseif (function_exists('finfo_open')) {
$finfo = finfo_open(FILEINFO_MIME);
$mimetype = finfo_file($finfo, $filename);
finfo_close($finfo);
return $mimetype;
}
else {
return 'application/octet-stream';
}
}
?>
\ No newline at end of file
## Hello world
This is a *test article*. You can write in Markdown Extra[^1] and it **render** in HTML !
This is code :
```
console.log("yes");
```
And here is a [link](/user/testuser) to the profil of the test user.
> This is a quote.
>
> – [David Libeau](https://davidlibeau.fr)
[^1]: Fediblog is using [Parsedown Extra](https://github.com/erusev/parsedown-extra), an extension of [Parsedown](http://parsedown.org/) that adds support for [Markdown Extra](https://michelf.ca/projects/php-markdown/extra/).
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment