Update for #76 - Beta 2.5.0
# Conflicts: # src/com/actions/PageActions.js # src/com/controllers/PageEditor.js # src/com/controllers/SettingsIndex.js # src/com/ui/TextEditor.js # src/styles/dash.sass # src/styles/main/_colors.sass # src/styles/main/_editor-highlight.sass # src/styles/main/_normalize.sass # src/styles/main/_posts.sassbeta
commit
39c6ff7f11
@ -1 +1,13 @@
|
||||
{ "presets": ["env"] }
|
||||
{
|
||||
"presets": [],
|
||||
"plugins": [
|
||||
[
|
||||
"prismjs",
|
||||
{
|
||||
"languages": ["html", "markdown", "markup"],
|
||||
"theme": "okaidia",
|
||||
"css": false
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
|
@ -0,0 +1,120 @@
|
||||
<?php
|
||||
use League\CommonMark\Environment\Environment;
|
||||
use League\CommonMark\Extension\CommonMark\CommonMarkCoreExtension;
|
||||
use League\CommonMark\Extension\Strikethrough\StrikethroughExtension;
|
||||
use League\CommonMark\Extension\Attributes\AttributesExtension;
|
||||
use League\CommonMark\Extension\FrontMatter\FrontMatterExtension;
|
||||
use League\CommonMark\Extension\FrontMatter\Output\RenderedContentWithFrontMatter;
|
||||
use League\CommonMark\MarkdownConverter;
|
||||
use League\CommonMark\CommonMarkConverter;
|
||||
use function _\orderBy;
|
||||
|
||||
class Contents
|
||||
{
|
||||
public $files = [];
|
||||
public $config = [];
|
||||
public function __construct($folder)
|
||||
{
|
||||
$this->read($folder);
|
||||
}
|
||||
public function read($folder)
|
||||
{
|
||||
$folders = glob("$folder/*", GLOB_ONLYDIR);
|
||||
foreach ($folders as $folder) {
|
||||
//$this->files[] = $folder . "/";
|
||||
$this->read($folder);
|
||||
}
|
||||
$files = array_filter(glob("$folder/*md"), "is_file");
|
||||
foreach ($files as $file) {
|
||||
$this->files[] = $file;
|
||||
}
|
||||
}
|
||||
|
||||
function getAll()
|
||||
{
|
||||
$environment = new Environment($this->config);
|
||||
$environment->addExtension(new CommonMarkCoreExtension());
|
||||
|
||||
// Add the extension
|
||||
$environment->addExtension(new FrontMatterExtension());
|
||||
|
||||
//Add Strikethrough rendering
|
||||
$environment->addExtension(new StrikethroughExtension());
|
||||
|
||||
//add attributes to elements in markdown
|
||||
$environment->addExtension(new AttributesExtension());
|
||||
|
||||
// Instantiate the converter engine and start converting some Markdown!
|
||||
$converter = new MarkdownConverter($environment);
|
||||
|
||||
$contents = [];
|
||||
foreach ($this->files as $file) {
|
||||
//get meta and html from file
|
||||
$result = $converter->convertToHtml(file_get_contents($file));
|
||||
$meta = [];
|
||||
if ($result instanceof RenderedContentWithFrontMatter) {
|
||||
$meta = $result->getFrontMatter();
|
||||
}
|
||||
|
||||
//get raw markdown from file
|
||||
$frontMatterExtension = new FrontMatterExtension();
|
||||
$parsed = $frontMatterExtension
|
||||
->getFrontMatterParser()
|
||||
->parse(file_get_contents($file));
|
||||
|
||||
//never trust the front end. clean it up
|
||||
$sanitizer = HtmlSanitizer\Sanitizer::create([
|
||||
"extensions" => ["basic", "image", "list", "code"],
|
||||
"tags" => [
|
||||
"img" => [
|
||||
"allowed_attributes" => ["src", "alt", "title", "class"],
|
||||
"allowed_hosts" => null,
|
||||
"allow_relative_links" => true,
|
||||
],
|
||||
],
|
||||
]);
|
||||
|
||||
$scrubbed = $sanitizer->sanitize($result->getContent());
|
||||
|
||||
//sort attributes into page object
|
||||
$page = [
|
||||
"id" => $meta["id"],
|
||||
"uuid" => $meta["uuid"],
|
||||
"title" => $meta["title"],
|
||||
"feature" => $meta["feature"],
|
||||
"path" => $meta["path"],
|
||||
"layout" => $meta["layout"],
|
||||
"tags" => $meta["tags"],
|
||||
"author" => $meta["author"],
|
||||
"created" => date("Y M D d", $meta["created"]),
|
||||
"updated" => date("Y M D d", $meta["updated"]),
|
||||
"rawCreated" => $meta["created"],
|
||||
"rawUpdated" => $meta["updated"],
|
||||
"createdYear" => date("Y", $meta["created"]),
|
||||
"createdMonth" => date("m", $meta["created"]),
|
||||
"deleted" => $meta["deleted"],
|
||||
"menu" => $meta["menu"],
|
||||
"featured" => $meta["featured"],
|
||||
"published" => $meta["published"],
|
||||
"slug" => $meta["slug"],
|
||||
"filePath" => $file,
|
||||
"content" => $parsed->getContent(),
|
||||
"html" => $scrubbed,
|
||||
];
|
||||
//checks for duplicates
|
||||
$uuid = $meta["uuid"];
|
||||
$found = current(
|
||||
array_filter($contents, function ($item) use ($uuid) {
|
||||
return isset($item["uuid"]) && $uuid == $item["uuid"];
|
||||
})
|
||||
);
|
||||
|
||||
// if uuid is not present, add it
|
||||
if (!$found) {
|
||||
array_push($contents, $page);
|
||||
}
|
||||
}
|
||||
$contents = orderBy($contents, ["id"], ["desc"]);
|
||||
return $contents;
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,38 @@
|
||||
{
|
||||
"name": "fipamo-dash",
|
||||
"version": "2.5.0",
|
||||
"private": true,
|
||||
"apidoc": {
|
||||
"name": "Fipamo API",
|
||||
"version": "1.0.0",
|
||||
"description": "The most chill API for the most chill blog framework"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/preset-env": "^7.16.5",
|
||||
"babel-cli": "^6.26.0",
|
||||
"eslint": "^8.5.0",
|
||||
"eslint-plugin-babel": "^5.3.1",
|
||||
"parcel": "^2.0.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"@babel/core": "^7.16.5",
|
||||
"@babel/eslint-parser": "^7.16.5",
|
||||
"animejs": "^3.2.1",
|
||||
"babel-plugin-prismjs": "^2.1.0",
|
||||
"babel-preset-env": "^1.7.0",
|
||||
"bulma": "^0.9.3",
|
||||
"caret-pos": "^2.0.0",
|
||||
"jsdoc": "^3.6.7",
|
||||
"minami": "^1.2.3",
|
||||
"prismjs": "^1.25.0",
|
||||
"sass": "^1.45.1",
|
||||
"sortablejs": "^1.14.0"
|
||||
},
|
||||
"license": "UNLICENSED",
|
||||
"author": "Are0h",
|
||||
"scripts": {
|
||||
"watch": "sass --watch src/styles:public/assets/css & npx parcel watch src/com/Start.js --dist-dir public/assets/scripts --public-url /assets/scripts"
|
||||
},
|
||||
"description": "Front end script for the most chill blog framework ever.",
|
||||
"repository": "https://code.playvicio.us/Are0h/Fipamo"
|
||||
}
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue