13 Commits

Author SHA1 Message Date
8ce95a06d9 Add article.php
The new location for text size buttons and other article specific elements.
2022-07-17 17:51:59 -04:00
fb1c649580 Update index.php to use the function
Also seperates the HTML used for just articles from the Markdown parsing.
2022-07-17 17:50:02 -04:00
3a2dc7651a Fix output 2022-07-17 17:42:39 -04:00
d719bcf101 Place Markdown parsing in a function 2022-07-17 17:27:08 -04:00
b4c852a3c1 Style the author pfp 2022-07-15 22:01:27 -04:00
849d5a25b6 Add author pfp to list 2022-07-15 21:47:26 -04:00
4d4ce6f0a5 Add author pfp 2022-07-15 21:24:36 -04:00
340997fa89 Add generic author index.php 2022-07-15 21:14:27 -04:00
4929ea5eb8 Remove formatting from directory list 2022-07-15 21:09:05 -04:00
1cf4ffface Add <a> tags to better format list. 2022-07-15 21:00:46 -04:00
17cf1d28f0 Update authors/index.php 2022-07-15 20:51:23 -04:00
f57ace3bad Add /blog/authors/ directory 2022-07-15 20:29:37 -04:00
1da2fe8358 Merge pull request 'Update to upstream master' (#2) from 20xd6/simple_blog:master into master
Reviewed-on: manfromhuh/simple_blog#2
2022-07-15 19:47:37 -04:00
6 changed files with 134 additions and 37 deletions

67
blog/authors/index.php Normal file
View File

@@ -0,0 +1,67 @@
<?php
include ($_SERVER['DOCUMENT_ROOT'].'/common/php/header.php');
include_once ($_SERVER['DOCUMENT_ROOT'].'/common/php/menu.php');
?>
<h1>Authors</h1>
<nav id="body_nav" class="jmenu">
<div class="pmenu">
<ul><li><a href=/>Home</a></li></ul>
<?php
include_once ($_SERVER['DOCUMENT_ROOT'].'/common/php/get_month_name.php');
//Removes the number used to keep articles in post order from the displayed title.
function remove_sorting_number($link_title){
$first_three = mb_substr($link_title, 0, 3,"UTF-8");
if ( preg_match( '/[0-9][0-9] /', $first_three) ){
$link_title = mb_substr($link_title,3);
}
return $link_title;
}
$dir = '.';
// Check if the directory exists
if (file_exists($dir) && is_dir($dir) ) {
// Get the files of the directory as an array
$scan_arr = scandir($dir);
$files_arr = array_diff($scan_arr, array('.','..','index.php','common','.htaccess') );
// echo "<pre>"; print_r( $files_arr ); echo "</pre>";
// Get each files of our directory with line break
foreach ($files_arr as $file) {
//Get the file path
$file_path = "./".$file;
// Get the file extension
$file_ext = pathinfo($file_path, PATHINFO_EXTENSION);
if ($file_ext == "") {
$file_array[] = $file;
}
}
if (sizeof($file_array) != 0){
foreach($file_array as $file) {//Renders the folder names as more readable titles.
$link_title = str_replace('_',' ',$file);//Remove undersores and replace them with spaces
$link_title = str_replace($_replace,'',$link_title);
if (file_exists($file."/pfp.png")){
$pfp_path = "$file/pfp.png";
echo("<ul><li><img src=\"$pfp_path\" class=\"pfp\" name=\"$file pfp\"><a href='$file'> $link_title </a></li></ul>\n");//Output the result.
} else {
echo("<ul><li><a href='$file'> $link_title </a></li></ul>\n");//Output the result.
}
}
} else {
echo "<ul><li><a>No Authors<a></li></ul>";
}
}
else {
echo "Directory does not exists";
}
echo("<ul><li><a href='..'>Back</a></li></ul>\n");
?>
</div><!--end of pmenu-->
</nav>
<br>
<?php
include ($_SERVER['DOCUMENT_ROOT'].'/common/php/footer.php');
?>

14
common/authors/index.php Normal file
View File

@@ -0,0 +1,14 @@
<?php
//The common file used to render pages on the blog.
include_once ($_SERVER['DOCUMENT_ROOT'].'/common/php/header.php');
include_once ($_SERVER['DOCUMENT_ROOT'].'/common/php/menu.php');
//Looks for an article.md to see if the current directory is an article or not
//If it is not then it is a menu page.
if (file_exists('byline.md')){
include_once ($_SERVER['DOCUMENT_ROOT'].'/common/php/md_read.php');
}
if (file_exists('author.md')){
include_once ($_SERVER['DOCUMENT_ROOT'].'/common/php/md_read.php');
}
include_once ($_SERVER['DOCUMENT_ROOT'].'/common/php/footer.php');
?>

View File

@@ -125,6 +125,14 @@ img{
img.center_align{
vertical-align:middle;
}
img.pfp {
vertical-align: middle;
width: 25px;
height: 25px;
border-radius: 25px;
border-style: solid;
border-width: 1px;
}
.top{
max-width: 100vw;
float: left;

35
common/php/article.php Normal file
View File

@@ -0,0 +1,35 @@
<?php
include_once ($_SERVER['DOCUMENT_ROOT'].'/common/php/md_read.php');
echo "<article id=\"article\">\n" . /* Adds the option to change the font size of the article text. */
"<div id=\"font_btns\">
Text Size:
<button id=\"btn_sml\" type=\"button\" onclick=\"font_set('small')\">a</button>
<button id=\"btn_mid\" type=\"button\" onclick=\"font_set('medium')\">A</button>
<button id=\"btn_lrg\" type=\"button\" onclick=\"font_set('25px')\">A</button>
</div><!--End of font_btns-->
<input type=\"button\" onclick=\"printDiv('print-content')\" title=\"Print this article\" value=\"Print\"/>
<div id=\"print-content\">\n
<nav class=\"jmenu\">
<label for=\"menu-btn\" class=\"jm-menu-btn\">Download</label>
<input type=\"checkbox\" id=\"menu-btn\" class=\"jm-menu-btn\"/>
<ul class=\"jm-collapse\">
</ul>
<li><a>PDF</a></li>
<li><a href=\"article.md\" title=\"Download \">MD</a></li>
</nav>
".
read_md("article.md") . "\n</article>";
echo "\n</div><!--End of print-content div-->\n";
echo("<nav class=\"jmenu\"><div class=\"pmenu\"><ul id=\"back_btn\"><li><a href='..'>Back</a></li></ul></div></nav>\n");
if ($tag_data != NULL){
$page_tags = str_getcsv($tag_data);
natcasesort($page_tags);
echo "<div id=\"tags\"><h2>Tags</h2>\n<ul>\n";
foreach ($page_tags as $tag){
echo "<li><a href=\"/blog/by_tag/#" . $tag . "\">" . $tag . "</a></li>\n";
}
echo "</ul>\n</div>\n";
}
include_once ($_SERVER['DOCUMENT_ROOT'].'/common/php/modal.php');
?>

View File

@@ -5,7 +5,7 @@
//Looks for an article.md to see if the current directory is an article or not
//If it is not then it is a menu page.
if (file_exists('article.md')){
include_once ($_SERVER['DOCUMENT_ROOT'].'/common/php/md_read.php');
include_once ($_SERVER['DOCUMENT_ROOT'].'/common/php/article.php');
} else {
include_once ($_SERVER['DOCUMENT_ROOT'].'/common/php/h1_month.php');
include_once ($_SERVER['DOCUMENT_ROOT'].'/common/php/page_menu.php');

View File

@@ -1,41 +1,14 @@
<?php
#Markdown parser dependancy
require ($_SERVER['DOCUMENT_ROOT'].'/common/vendor/autoload.php');
#Markdown parseing code.
$MD_Parser = new ParsedownExtra();
$MD_Path = "article.md";
$MD_File = fopen($MD_Path, "r") or die("File not found.");
$MD_Text = fread($MD_File, filesize($MD_Path));
echo "<article id=\"article\">\n" . /* Adds the option to change the font size of the article text. */
"<div id=\"font_btns\">
Text Size:
<button id=\"btn_sml\" type=\"button\" onclick=\"font_set('small')\">a</button>
<button id=\"btn_mid\" type=\"button\" onclick=\"font_set('medium')\">A</button>
<button id=\"btn_lrg\" type=\"button\" onclick=\"font_set('25px')\">A</button>
</div><!--End of font_btns-->
<input type=\"button\" onclick=\"printDiv('print-content')\" title=\"Print this article\" value=\"Print\"/>
<div id=\"print-content\">\n
<nav class=\"jmenu\">
<label for=\"menu-btn\" class=\"jm-menu-btn\">Download</label>
<input type=\"checkbox\" id=\"menu-btn\" class=\"jm-menu-btn\"/>
<ul class=\"jm-collapse\">
</ul>
<li><a>PDF</a></li>
<li><a href=\"article.md\" title=\"Download \">MD</a></li>
</nav>
".
$MD_Parser->text($MD_Text) . "\n</article>";
fclose($MD_File);
echo "\n</div><!--End of print-content div-->\n";
echo("<nav class=\"jmenu\"><div class=\"pmenu\"><ul id=\"back_btn\"><li><a href='..'>Back</a></li></ul></div></nav>\n");
if ($tag_data != NULL){
$page_tags = str_getcsv($tag_data);
natcasesort($page_tags);
echo "<div id=\"tags\"><h2>Tags</h2>\n<ul>\n";
foreach ($page_tags as $tag){
echo "<li><a href=\"/blog/by_tag/#" . $tag . "\">" . $tag . "</a></li>\n";
}
echo "</ul>\n</div>\n";
function read_md($MD_Path){
#Markdown parseing code.
echo $md_path;
$MD_Parser = new ParsedownExtra();
#$MD_Path = $md_path;
$MD_File = fopen($MD_Path, "r") or die("File not found.");
$MD_Text = fread($MD_File, filesize($MD_Path));
return $MD_Parser->text($MD_Text);
fclose($MD_File);
}
include_once ($_SERVER['DOCUMENT_ROOT'].'/common/php/modal.php');
?>