Merge pull request 'Merge upstream master' (#4) from 20xd6/simple_blog:master into master

Reviewed-on: #4
This commit is contained in:
manfromhuh 2022-07-27 13:02:23 -04:00
commit 32f7d23ee4
8 changed files with 49 additions and 211 deletions

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

@ -4,36 +4,7 @@
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
function read_tags($tags_file){
$tags_csv = array_map('str_getcsv', file('tags.csv'));
$tags_rows = sizeof($tags_csv);
$tags_coloums = sizeof($tags_csv[0]);
@ -64,5 +35,20 @@
$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);
}
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

@ -36,8 +36,6 @@
echo "<p>$byline_path</p>";
}
fclose($author_name_raw);
}else {
echo "<h2>No author</h2>";
}
if ($tag_data != NULL){
$page_tags = str_getcsv($tag_data);

View File

@ -23,6 +23,7 @@ if (file_exists($dir) && is_dir($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;
@ -42,6 +43,7 @@ if (file_exists($dir) && is_dir($dir) ) {
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>