Compare commits

..

No commits in common. "master" and "issue#7" have entirely different histories.

4 changed files with 85 additions and 67 deletions

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

@ -4,57 +4,65 @@
echo "<article><h1 id=\"page_title\">Posts by Tag</h1></article>"; 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-->"; 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-->";
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 "</ul>\n";
}
//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 rewrite
if (file_exists('tags.csv')){ $tags_csv = array_map('str_getcsv', file('tags.csv'));
read_tags('tags.csv'); $tags_rows = sizeof($tags_csv);
} elseif( file_exists('tags.csv.bak') ){ $tags_coloums = sizeof($tags_csv[0]);
if (copy('tags.csv.bak', './tags.csv')) { //echo "<pre>\n";
read_tags('tags.csv'); //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";
}
}
} }
}else { echo "\t</li>\n";
$empty_csv = fopen("tags.csv", "w") or die("Cannot write new tags.csv file."); $coloum_number++;
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'); include_once ($_SERVER['DOCUMENT_ROOT'].'/common/php/footer.php');
?> ?>

View File

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

View File

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

View File

@ -18,12 +18,11 @@ function remove_sorting_number($link_title){
$dir = '.'; $dir = '.';
// Check if the directory exists // Check if the directory exists
if (file_exists($dir) && is_dir($dir) ) { if (file_exists($dir) && is_dir($dir) ) {
// Get the files of the directory as an array // Get the files of the directory as an array
$scan_arr = scandir($dir); $scan_arr = scandir($dir);
$files_arr = array_diff($scan_arr, array('.','..','index.php','common','.htaccess') ); $files_arr = array_diff($scan_arr, array('.','..','index.php','common','.htaccess') );
// echo "<pre>"; print_r( $files_arr ); echo "</pre>"; // echo "<pre>"; print_r( $files_arr ); echo "</pre>";
// Get each files of our directory with line break // Get each files of our directory with line break
if (sizeof($files_arr) != 0 ) {
foreach ($files_arr as $file) { foreach ($files_arr as $file) {
//Get the file path //Get the file path
$file_path = "./".$file; $file_path = "./".$file;
@ -42,7 +41,6 @@ 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. $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. echo("<ul><li><a href='$file'> $link_title </a></li></ul>\n");//Output the result.
} }
}
} }
else { else {
echo "Directory does not exists"; echo "Directory does not exists";