Compare commits

...

21 Commits

Author SHA1 Message Date
7734de9fa4 Merge pull request 'Fix issues #25 and #26' (#27) from issue#26 into master
Reviewed-on: 20xd6/simple_blog#27
2022-08-09 14:15:37 -04:00
470773721a Stop parsing if the author isn't found 2022-08-09 14:10:44 -04:00
5d7b4cc121 Add a size check before attempting to parse the author
The author file is now checked to insure it's non-zero before attempting
to parse it for the author who's byline will be displayed at the bottom
of the post.
2022-08-09 14:07:40 -04:00
efe61157e8 Merge pull request 'Cleanup header.php' (#22) from issue#10 into master
Reviewed-on: 20xd6/simple_blog#22
2022-07-31 17:12:49 -04:00
5016fa8ce8 Cleanup header.php
Cleanup debugging code for issue #10
2022-07-31 17:10:41 -04:00
206f94f5db Fix variable being tested for empty file in PR #21 2022-07-27 22:11:36 -04:00
7ff2cf1d0f Resolve issue #9 (#21) 2022-07-27 20:17:34 -04:00
f80bc8dafa File permissions change, check for non-zero tags.csv for issue #9
The tags index.php file now checks for the tags.csv to be non-zero as
well as existing.
Updated the permission of the generated tags.csv file to allow the CMS
to updated it with out requiring root/sudo permissions.
2022-07-27 20:08:55 -04:00
32f7d23ee4 Merge pull request 'Merge upstream master' (#4) from 20xd6/simple_blog:master into master
Reviewed-on: #4
2022-07-27 13:02:23 -04:00
015c5ef6db Fix for issue #18
The page generation now checks for the size of $file_arr and only
generates a menu if the size os greater than 0.
2022-07-26 13:33:49 -04:00
4958a76f9a Remove old csv reading code. 2022-07-26 13:29:08 -04:00
b01c237d5d Merge pull request 'Update tags index to handle issue #9' (#20) from issue#9 into master
Reviewed-on: 20xd6/simple_blog#20
2022-07-26 13:10:05 -04:00
dd3405137f Update tags index to handle issue # 9
Now checks for the file and either copies a backup or creates a blank
file.
2022-07-26 13:06:52 -04:00
25f1887590 Merge pull request 'issue #7' (#19) from issue#7 into master
Reviewed-on: 20xd6/simple_blog#19
2022-07-26 11:28:32 -04:00
81629aa133 Remove deperacted CSS for issue #7
The style rules have been moved into the main styles.css
2022-07-26 11:25:03 -04:00
3e169d54ed Remove depracated PHP for issue #7 2022-07-26 11:22:18 -04:00
b7688ae2d4 Removed empty php file 2022-07-26 11:21:52 -04:00
dc66b2db0f Remove depracated JS files for issue #7
The functions in these files have been merged into the main JS file for
page formatting.
2022-07-26 11:20:33 -04:00
88b08fd1fc If not author is identified do nothing 2022-07-26 11:01:36 -04:00
d2861f1203 Merge pull request 'Merge with upstream' (#3) from 20xd6/simple_blog:master into master
Reviewed-on: #3
2022-07-26 10:42:54 -04:00
5e29d1e4d5 add_byline (#17) 2022-07-26 10:33:29 -04:00
9 changed files with 67 additions and 235 deletions

104
blog/by_tag/index.php Normal file → Executable file
View File

@ -4,65 +4,57 @@
echo "<article><h1 id=\"page_title\">Posts by Tag</h1></article>";
echo "<div id=\"search_inputs\"><input type=\"text\" id=\"tag_sort\" onkeyup=\"tag_search()\" placeholder=\"Search Tags...\" title=\"Type a tage to search\"><input id=\"search_toggle\" type=\"button\" value=\"Search Titles\" onclick=\"search_toggle()\"></div><!--End Div Search Inputs-->";
//if(file_exists("tags.csv")){
//echo "<ul id=\"tag_menu\">\n";
//$csv = array_map('str_getcsv', file("tags.csv"));
//array_walk($csv, function(&$a) use ($csv) {
//$a = array_combine($csv[0], $a);
//});
//array_shift($csv); # remove column header
//foreach ($csv as $row){
//$counter = 0;
//foreach ($row as $item){
//$counter++;
//if ($counter == 1){
//echo "\t<li id=\"" . $item . "\">" . $item . " <a id=\"" . $item . "\"></a>\n";
//} elseif ($counter % 2 == 0) {
//if ($item == ""){
//break;
//} else {
//echo "\t\t<ol><a href=\"" . $item . "\">";
//}
//} elseif ($counter % 2 != 0) {
//echo $item . "</a></ol>\n";
//}
//}
//echo "\t</li>\n";
//}
//echo "</ul>\n";
//}
# Tags rewrite
$tags_csv = array_map('str_getcsv', file('tags.csv'));
$tags_rows = sizeof($tags_csv);
$tags_coloums = sizeof($tags_csv[0]);
//echo "<pre>\n";
//print_r($tags_csv);
//echo $tags_coloums . "\n" . $tags_rows . "\n";
//echo "</pre>\n";
echo "<ul id=\"tag_menu\">\n";
$coloum_number = 0;
for ($row_number = 0; $row_number <= $tags_coloums; $row_number++){
//echo $row_number;
$section_title = $tags_csv[0][$coloum_number];
echo "\t<li id=\"" . $section_title . "\"><b>" . $section_title . " </b>\n";
for ($row = 1; $row < $tags_coloums; $row++){
//echo "rn: " . $row . "\ncn:" . $coloum_number ." ";
$tag_content = $tags_csv[$row][$coloum_number];
if ($tag_content == ""){
break;
} else {
if ($row % 2 != 0){
echo "\t\t<ol><a href=\"" . $tag_content . "\">";
} elseif ($row % 2 == 0){
echo $tag_content . "</a></ol>\n";
function read_tags($tags_file){
if (filesize($tags_file) == 0){
echo "<br/>\n<br/>";
return;
}
$tags_csv = array_map('str_getcsv', file('tags.csv'));
$tags_rows = sizeof($tags_csv);
$tags_coloums = sizeof($tags_csv[0]);
//echo "<pre>\n";
//print_r($tags_csv);
//echo $tags_coloums . "\n" . $tags_rows . "\n";
//echo "</pre>\n";
echo "<ul id=\"tag_menu\">\n";
$coloum_number = 0;
for ($row_number = 0; $row_number <= $tags_coloums; $row_number++){
//echo $row_number;
$section_title = $tags_csv[0][$coloum_number];
echo "\t<li id=\"" . $section_title . "\"><b>" . $section_title . " </b>\n";
for ($row = 1; $row < $tags_coloums; $row++){
//echo "rn: " . $row . "\ncn:" . $coloum_number ." ";
$tag_content = $tags_csv[$row][$coloum_number];
if ($tag_content == ""){
break;
} else {
if ($row % 2 != 0){
echo "\t\t<ol><a href=\"" . $tag_content . "\">";
} elseif ($row % 2 == 0){
echo $tag_content . "</a></ol>\n";
}
}
}
echo "\t</li>\n";
$coloum_number++;
}
echo "\t</li>\n";
$coloum_number++;
echo "</ul>\n";
}
# Tags rewrite
if (file_exists('tags.csv')){
read_tags('tags.csv');
} elseif( file_exists('tags.csv.bak') ){
if (copy('tags.csv.bak', './tags.csv')) {
read_tags('tags.csv');
}
}else {
$empty_csv = fopen("tags.csv", "w") or die("Cannot write new tags.csv file.");
fwrite($empty_csv, "");
fclose($empty_csv);
chmod('./tags.csv', 0666);
read_tags('tags.csv');
}
echo "</ul>\n";
include_once ($_SERVER['DOCUMENT_ROOT'].'/common/php/footer.php');
?>

View File

@ -1,79 +0,0 @@
/* Style the Image Used to Trigger the Modal */
#myImg {
border-radius: 5px;
cursor: pointer;
transition: 0.3s;
}
img:hover {opacity: 0.7;}
/* The Modal (background) */
.modal_gal {
display: none; /* Hidden by default */
position: fixed; /* Stay in place */
z-index: 1; /* Sit on top */
padding-top: 100px; /* Location of the box */
left: 0;
top: 0;
width: 100%; /* Full width */
height: 100%; /* Full height */
overflow: auto; /* Enable scroll if needed */
background-color: rgb(0,0,0); /* Fallback color */
background-color: rgba(0,0,0,0.9); /* Black w/ opacity */
}
/* Modal Content (Image) */
.gallery_img {
margin: auto;
display: block;
width: 80%;
max-width: 700px;
}
/* Caption of Modal Image (Image Text) - Same Width as the Image */
#modal_img_caption {
margin: auto;
display: block;
width: 80%;
max-width: 700px;
text-align: center;
color: #ccc;
padding: 10px 0;
height: 150px;
}
/* Add Animation - Zoom in the Modal */
.gallery_img, #caption {
animation-name: zoom;
animation-duration: 0.6s;
}
@keyframes zoom {
from {transform:scale(0)}
to {transform:scale(1)}
}
/* The Close Button */
.close_modal {
position: absolute;
top: 15px;
right: 35px;
color: #00cc00;
font-size: 40px;
font-weight: bold;
transition: 0.3s;
}
.close_modal:hover,
.close_modal:focus {
color: #bbb;
text-decoration: none;
cursor: pointer;
}
/* 100% Image Width on Smaller Screens */
@media only screen and (max-width: 700px){
.gallery_img {
width: 100%;
}
}

View File

@ -1 +0,0 @@

View File

@ -1,32 +0,0 @@
var modalEle = document.querySelector(".modal_gal");
var modalImage = document.querySelector(".gallery_img");
Array.from(document.querySelectorAll(".img_thumb")).forEach(item => {
item.addEventListener("click", event => {
modalEle.style.display = "block";
modalImage.src = event.target.src;
});
});
document.querySelector(".close").addEventListener("click", () => {
modalEle.style.display = "none";
});
function image_modal(document){
// Get the modal
var modal = document.getElementById("modal_gallery");
// Get the image and insert it inside the modal - use its "alt" text as a caption
var img = document.getElementById("myImg");
var modalImg = document.getElementById("modal_img");
var captionText = document.getElementById("modal_img_caption");
img.onclick = function(){
modal.style.display = "block";
modalImg.src = this.src;
captionText.innerHTML = this.alt;
}
// Get the <span> element that closes the modal
var span = document.getElementsByClassName("close_modal")[0];
// When the user clicks on <span> (x), close the modal
span.onclick = function() {
modal.style.display = "none";
}
}

View File

View File

@ -22,22 +22,17 @@
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 (file_exists('author')){
$author_name_raw = fopen('author', 'r');
$author_name = fread($author_name_raw, filesize('author'));
$author_name = str_replace("\n", "", $author_name);
$byline_path = $_SERVER['DOCUMENT_ROOT'].'blog/authors/'.$author_name.'/byline.md';
if (file_exists($byline_path)){
echo "<div class =\"byline\">\n"
. read_md($byline_path)
."</div><!--End byline div-->\n";
} else {
echo "<h2>No byline</h2>";
echo "<p>$byline_path</p>";
}
fclose($author_name_raw);
}else {
echo "<h2>No author</h2>";
if (file_exists('author') && (filesize('author') != 0)){
$author_name_raw = fopen('author', 'r');
$author_name = fread($author_name_raw, filesize('author'));
$author_name = str_replace("\n", "", $author_name);
$byline_path = $_SERVER['DOCUMENT_ROOT'].'blog/authors/'.$author_name.'/byline.md';
if (file_exists($byline_path)){
echo "<div class =\"byline\">\n"
. read_md($byline_path)
."</div><!--End byline div-->\n";
}
fclose($author_name_raw);
}
if ($tag_data != NULL){
$page_tags = str_getcsv($tag_data);

View File

@ -2,20 +2,11 @@
<html lang="en-US">
<?php
//Sets the page title based on the name of the current directory
function Title() {//Needs cleanup.
//~ $new_title = $_SERVER['REQUEST_URI'];
//~ $new_title = preg_replace("/^^\//i", "", $new_title);
//~ $new_title = preg_replace("/\//i", "", $new_title);
//~ $page_title = $_SERVER['REQUEST_URI'];
//~ $page_title = preg_replace("/^(.*)\//i", "", $page_title);
function Title() {
$page_title = basename($_SERVER['SCRIPT_FILENAME'], '.php');
//~ echo($page_title);
if(strtolower($page_title) == 'index'){
parse_str($_SERVER['REQUEST_URI'], $page_uri);
$page_path = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);
//~ echo($page_path);
//~ $folder_name = sizeof($page_path);
$folder_name = explode("/", trim($page_path, "/"));
$page_title = $folder_name[(sizeof($folder_name) - 1)];
} elseif(strtolower($page_title) == 'homepage'){

View File

@ -18,11 +18,12 @@ function remove_sorting_number($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
// 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
if (sizeof($files_arr) != 0 ) {
foreach ($files_arr as $file) {
//Get the file path
$file_path = "./".$file;
@ -41,6 +42,7 @@ if (file_exists($dir) && is_dir($dir) ) {
$link_title = remove_sorting_number($link_title);//Removes the number used to keep articles in post order from the displayed title.
echo("<ul><li><a href='$file'> $link_title </a></li></ul>\n");//Output the result.
}
}
}
else {
echo "Directory does not exists";

View File

@ -1,36 +0,0 @@
<table border="1" class="pmenu">
<tr>
<td><a href=/>Home</a></td>
</tr>
<?php
$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=="php" || $file_ext=="html" || $file_ext=="htm" || $file_ext == "") {
$file_array[] = $file;
}
}
foreach($file_array as $file) {
$_replace = array('.php', '.html', '.htm');
$link_title = str_replace('_',' ',$file);
$link_title = str_replace($_replace,'',$link_title);
$link_title = ucwords($link_title);
echo("<tr><td><a href='$file'> $link_title </a></td></tr>\n");
}
}
else {
echo "Directory does not exists";
}
?>
</table>