Skip to content

Commit

Permalink
Merge pull request #1 from n0nag0n/patch-1
Browse files Browse the repository at this point in the history
Convert docs site to use Markdown
  • Loading branch information
amirfaramarzi authored Oct 19, 2024
2 parents 93e130c + b203bb2 commit fd5d856
Show file tree
Hide file tree
Showing 10 changed files with 2,426 additions and 1,966 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@ Fomo is very fast, simple and for use in large scales (Of course, it still has f

## Contributing

Thank you for considering contributing to the Fomo framework! The contribution guide can be found in the [Fomo documentation](https://github.com/fomo-framework).
The process to build to this documentation site is very simple and straightforward. First you'll need to make sure `composer` is installed and run `composer install` to install the dependencies.

Any new changes to content can be edited in the `content.md` file. After you have updated the content, you need to run `php build_docs.php` to generate the new `index.html` file. You can then open the `index.html` file in your browser to see the changes.

Thank you for considering contributing to the Fomo framework! The contribution guide can be found in the [Fomo documentation](https://fomo-framework.github.io/docs/).

## Security Vulnerabilities

Expand Down
2 changes: 1 addition & 1 deletion assets/css/styles.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 32 additions & 0 deletions assets/includes/footer.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
</div><!--//doc-body-->
</div><!--//container-->
</div><!--//doc-wrapper-->

</div><!--//page-wrapper-->

<footer id="footer" class="footer text-center">
<div class="container">
<!--/* This template is free as long as you keep the footer attribution link. If you'd like to use the template without the attribution link, you can buy the commercial license via our website: themes.3rdwavemedia.com Thank you for your support. :) */-->
<small class="copyright">Designed with <span class="sr-only">love</span><i class="fas fa-heart"></i> by <a
href="https://themes.3rdwavemedia.com/" target="_blank">Xiaoying Riley</a> for developers</small>

</div><!--//container-->
</footer><!--//footer-->


<!-- Main Javascript -->
<script src="assets/plugins/bootstrap/js/bootstrap.min.js"></script>
<script src="assets/plugins/stickyfill/dist/stickyfill.min.js"></script>
<script src="assets/plugins/gumshoe/gumshoe.polyfills.min.js"></script>
<script src="assets/plugins/simplelightbox/simple-lightbox.min.js"></script>
<script src="assets/js/main.js"></script>
<script src="assets/plugins/highlight/highlight.min.js"></script>
<script src="assets/plugins/highlight/languages/bash.min.js"></script>
<script src="assets/plugins/highlight/languages/xml.min.js"></script>
<script src="assets/plugins/highlight/languages/php.min.js"></script>
<script src="assets/plugins/highlight/languages/javascript.min.js"></script>
<script>hljs.highlightAll();</script>

</body>
</html>

38 changes: 38 additions & 0 deletions assets/includes/header.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>Fomo documentation</title>
<!-- Meta -->
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">
<link rel="shortcut icon" href="favicon.ico">
<link href='https://fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,800italic,400,300,600,700,800'
rel='stylesheet' type='text/css'>
<!-- FontAwesome JS -->
<script defer src="assets/fontawesome/js/all.js"></script>
<!-- Global CSS -->
<link rel="stylesheet" href="assets/plugins/bootstrap/css/bootstrap.min.css">
<!-- Plugins CSS -->
<link rel="stylesheet" href="assets/plugins/elegant_font/css/style.css">
<link rel="stylesheet" href="assets/plugins/simplelightbox/simple-lightbox.min.css">
<!-- Theme CSS -->
<link id="theme-style" rel="stylesheet" href="assets/css/styles.css">
<link rel="stylesheet" href="assets/plugins/highlight/styles/base16/material-palenight.min.css">

</head>

<body class="body-green">
<div class="page-wrapper">
<div class="doc-wrapper">
<div class="container">
<div id="doc-header" class="doc-header text-center">
<img src="assets/images/logo.png" width="300px">
</div><!--//doc-header-->
<div class="doc-body row">
<div class="doc-content col-md-9 col-12 order-1">
<div class="content-inner">
<section class="doc-section">
<div>
24 changes: 24 additions & 0 deletions assets/includes/sidebar.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
</div>
</section>
</div><!--//content-inner-->
</div><!--//doc-content-->
<div class="doc-sidebar col-md-3 col-12 order-0 d-none d-md-flex">
<div id="doc-nav" class="doc-nav">
<nav id="doc-menu" class="nav doc-menu flex-column sticky">
<?php foreach($headings as $h1_id_tag => $h1_data) { ?>
<li class="nav-item">
<a class="nav-link scrollto" href="#<?php echo $h1_id_tag; ?>"><?php echo $h1_data['text']; ?></a>
</li>
<?php if(!empty($h1_data['children'])) { ?>
<nav class="nav doc-sub-menu nav flex-column">
<?php foreach($h1_data['children'] as $h2_id_tag) { ?>
<li class="nav-item">
<a class="nav-link scrollto" href="#<?php echo $h2_id_tag['id']; ?>"><?php echo $h2_id_tag['text']; ?></a>
</li>
<?php } ?>
</nav>
<?php } ?>
<?php } ?>
</nav><!--//doc-menu-->
</div>
</div><!--//doc-sidebar-->
44 changes: 44 additions & 0 deletions build_docs.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php

ob_start();

require __DIR__ . '/vendor/autoload.php';

require __DIR__ . '/assets/includes/header.html';

$markdown = file_get_contents(__DIR__ . '/docs.md');

// Convert the markdown to HTML
$Parsedown = new Parsedown();
$html = $Parsedown->text($markdown);

// find all <h2> tags and add an id attribute, class, and necessary tags with the text content
$headings = [];
$last_h1_tag = '';
$html = preg_replace_callback('/<(h1|h2)>(.*?)<\/(h1|h2)>/', function($matches) use (&$headings, &$last_h1_tag) {
$raw_text = $matches[2];
// make the id seo friendly
$id = strtolower(str_replace(' ', '-', $matches[2]));
$id = preg_replace('/[^a-z0-9-]/', '', $id);
$tag = $matches[1];
// h1 gets treated differently than h2
if($tag === 'h1') {
$headings[$id] = [ 'text' => $raw_text, 'children' => [] ];
$last_h1_tag = $id;
} else {
$headings[$last_h1_tag]['children'][] = [ 'text' => $raw_text, 'id' => $id ];
}
return "</div></section><section class=\"doc-section\"><{$matches[1]} class=\"section-title\" id=\"$id\">{$matches[2]}</{$matches[1]}><div class=\"section-block\">";
}, $html);

// add a class="table table-bordered" to all tables
$html = str_replace('<table>', '<table class="table table-bordered">', $html);

echo $html;

// This will add the $headings array to the sidebar to be foreached
require __DIR__ . '/assets/includes/sidebar.php';

require __DIR__ . '/assets/includes/footer.html';

file_put_contents(__DIR__ . '/index.html', ob_get_clean());
5 changes: 5 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"require": {
"erusev/parsedown": "^1.7"
}
}
69 changes: 69 additions & 0 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit fd5d856

Please sign in to comment.