Переглянути джерело

Man, I can't remember half this shit I did

teo greenwood 11 роки тому
батько
коміт
786dfd5b00
7 змінених файлів з 101 додано та 124 видалено
  1. 15 0
      CHANGELOG
  2. 30 2
      css/screen.css
  3. 2 2
      css/structure.css
  4. 0 35
      index.js
  5. 1 1
      index.php
  6. 1 4
      special/title.inc
  7. 52 80
      sys/admin/mbengine.inc

+ 15 - 0
CHANGELOG

@@ -1,3 +1,18 @@
+Version 1.2 "Maxim" Release Notes:
+*General mbengine.inc code cleanup, trying to play better golf while commenting more
+*Made microblogger start writing posts in JSON notation. This will enable posts from here on out to have additional metadata, manipulation ability, etc.
+  -Should mean less HTML knowledge required for editing your microblog postings
+  -Falls back to old display/edit method if posting is not JSON so as not to crap on anything.
+*Blog writer also now uses JSON notation to store data.
+  -Stores poster regardless of filesystem permissions this way
+  -Automatically makes a snippet in linklog pointing to blog post on day of posting
+*No longer using Cortado or audioplayer.js to display audio/video, since HTML5 alternatives work well now
+ -Video type postings can either be embed or the link to an actual file, if so, it'll validate filetype, etc. then display as HTML5 Video
+*Responsive JS waxed, CSS used instead - will make stuff like libreJS and NoScript irrelevant
+
+GITHUGS RELEASE 1.1.2:
+*Bug fixes, code cleanup, mostly making it more friendly to the github platform
+
 BUGFIX RELEASE 1.1.1:
 
 Bug Fixes:

+ 30 - 2
css/screen.css

@@ -9,7 +9,7 @@ body {
  color: black;
  background-color: gray;
  font-family: sans-serif;
- font-size: 150%;
+ font-size: 100%;
 }
 img {
  border: 0px;
@@ -121,10 +121,11 @@ textarea {
  background-size: 3em;
 }
 button#clickme {
- display: inline;
+ display: none;
  float: right;
  box-shadow: 0px 0px 0.5em #66CCFF;
  padding: 0 .25em;
+ margin: .25em;
  font-size: .60em;
  background-color: #333;
  border-radius: .5em;
@@ -237,3 +238,30 @@ p.posteditortitle {
 #newpostlink {
  color: #990000;
 }
+/*Responsive design stuff that used to be in JS, modify as needed*/
+@media (max-width: 1024px) {
+  #lefttitle {
+    width: 100%;
+    max-width: 100%;
+  }  
+  #clickme {
+    display: table-cell !important;
+  }
+  #righttitle {
+    visibility: hidden;
+    position: fixed;
+    top: 2rem;
+    right: 0;
+    min-width: 0;
+    max-width: 100%;
+    background-color: rgba(0,0,0,.75);
+    border-bottom-left-radius: 1em;
+  }
+  #clickme:active ~ #righttitle, #clickme:focus ~ #righttitle, #righttitle:hover, #righttitle a:active  {
+    visibility: visible;
+  }
+  #righttitle a {
+    display: block;
+    border-right: 0;
+  }
+}

+ 2 - 2
css/structure.css

@@ -18,7 +18,7 @@ body {
  z-index: 2;
  top: 0;
  width: 100%;
- height: 1.5em;
+ height: 2rem;
 }
 .toplel {
  display: table-cell;
@@ -69,7 +69,7 @@ body {
  padding-right: .5em;
 }
 #kontent {
- padding: 2em .5em .5em .5em;
+ padding: 3em .5em .5em .5em;
  min-height: 50%;
  max-width: 100%;
  margin-top: 0px;

+ 0 - 35
index.js

@@ -1,35 +0,0 @@
-window.onload = navResize;
-window.onresize = navResize;
-
-function navResize() {
-	if (window.innerWidth < 900) {
-		//Hide original div, enable Menu Button 
-		document.getElementById('righttitle').style.display = 'none';
-		document.getElementById('menubutton').style.display = 'table-cell';
-		document.getElementById('leftbar').style.display = 'none';
-                document.getElementById('rightbar').style.display = 'none';
-	} else {
-		//Show original div, hide Menu Button 
-		document.getElementById('righttitle').style.display = '';
-		document.getElementById('leftbar').style.display = '';
-                document.getElementById('rightbar').style.display = '';
-		document.getElementById('menubutton').style.display = 'none';
-		document.getElementById('littlemenu').style.display = 'none';
-	}
-}
-
-function showMenu() {
-	if (document.getElementById('littlemenu').style.display != 'none') {
-		if (document.getElementById('littlemenu').style.display == 'block') {
-			document.getElementById('littlemenu').style.display = '';
-			document.getElementById('leftbar').style.display = 'none';
-                	document.getElementById('rightbar').style.display = 'none';
-			return;
-		}
-		var pasta = document.getElementById('righttitle').innerHTML;
-		document.getElementById('littlemenu').innerHTML = pasta;
-		document.getElementById('littlemenu').style.display = 'block';
-		document.getElementById('leftbar').style.display = '';
-                document.getElementById('rightbar').style.display = '';
-	} 
-}

+ 1 - 1
index.php

@@ -32,6 +32,7 @@
   ?>
   <meta charset="utf-8" />
   <meta name="description" content="A Simple CMS by teodesian.net"/>
+  <meta name="viewport" content="width=device-width">
   <link rel="stylesheet" type="text/css" href="css/structure.css" />
   <link rel="stylesheet" type="text/css" href="css/screen.css" media="screen" />
   <link rel="stylesheet" type="text/css" href="css/print.css" media="print" />
@@ -47,7 +48,6 @@
    <link rel="stylesheet" type="text/css" href="css/compat/ie6.css">
   <![endif]-->
   <link rel="icon" type="image/vnd.microsoft.icon" href="img/icon/favicon.ico" />
-  <script src="index.js"></script>
   <title>
    <?php
     echo $htmltitle;

+ 1 - 4
special/title.inc

@@ -4,14 +4,11 @@
  ?>
 </div>
 <div id="midtitle" class="toplel">
-
 </div>
+<button title="Menu" id="clickme">&#9776;</button>
 <div id="righttitle" class="toplel">
  <a href="index.php?nav=2" title="Micro Blog" class="topbar">LinkLog</a>
  <a href="index.php?nav=3" title="Blog" class="topbar">Blog</a>
  <a href="index.php?nav=1&amp;dir=fileshare" title="File Share" class="topbar">Fileshare</a>
  <a href="index.php?nav=4" title="About" class="topbar">About</a>
 </div>
-<div id="menubutton" style="display: none;">
- <button title="Menu" id="clickme" onclick="showMenu();return false;">&#9776;</button>
-</div>

+ 52 - 80
sys/admin/mbengine.inc

@@ -1,85 +1,57 @@
 <?php
-include "config/users.inc";
-$badpost=false;
-$errmsg = array();
-if (isset($_POST["title"]) && $_POST["title"] != "") {
-	if (!isset($_POST['URL']) || $_POST["URL"] == "") {
-		$badpost = true;
-		$errmsg[] = "<em style=\"color: red\">* No url provided.</em><br />";
-	}
-	$url=stripslashes($_POST["URL"]);
-	//Error catching below
-	if (!filter_var($url,FILTER_VALIDATE_URL)) {
-		$badpost = true;
-		$errmsg[] = "<em style=\"color: red;\">* \"$url\" is not a valid ASCII URL.</em><br />";
-	}
-	if (!empty($_POST["IMG"]) && !filter_var(stripslashes($_POST["IMG"]),FILTER_VALIDATE_URL)) {
-    		$badpost = true;
-		$errmsg[] = "<em style=\"color: red;\">* Image \"$url\" is not a valid ASCII URL.</em><br />";
-  	}
-  	if (!empty($_POST["AUD"]) && !filter_var(stripslashes($_POST["AUD"]),FILTER_VALIDATE_URL)) {
-    		$badpost = true;
-		$errmsg[] = "<em style=\"color: red;\">* Audio \"$url\" is not a valid ASCII URL.</em><br />";
-  	}
-  	if (!isset($_POST["comment"]) || $_POST["comment"] == '') {
-    		$badpost = true;
-		$errmsg[] = "<em style=\"color: red;\">* Comment is blank.</em><br />";
-  	}
-	if (!$badpost) { 
-    		$title = stripslashes($_POST["title"]);
-    		$image = stripslashes($_POST["IMG"]);
-    		$audio = urlencode(stripslashes($_POST["AUD"]));
-    		$audiosrc = stripslashes($_POST["AUD"]);
-    		$comment = stripslashes($_POST["comment"]);
-    		$news2write = "<h3 class=\"blogtitles\"><a href=\"".$url."\">".$title."</a>";
-    		$news2write = $news2write."<a class=\"usericon ".$poster."\" href=\"index.php?nav=4\" title=\"Posted by ".$poster."\"></a>";
-    		$news2write = $news2write."</h3>";
-    		if ($image != "") {
-      			$news2write = $news2write."<img class=\"mblogimg\" src=\"".$image."\" />";
-    		}
-    		if ($audio != "") {
-      			$curlurl = "http://".$_SERVER["SERVER_NAME"]."/".$basedir.$microblog;
-      			$ch = curl_init($cur_url);
-      			curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
-      			curl_setopt($ch,CURLOPT_HEADER,false);
-      			$page_content = curl_exec($ch);
-      			$matches = array();
-      			preg_match('/audioplayer_[0-9]*/',$page_content,$matches);
-      			$numfound = count($matches);
-      			$audioinc = $numfound;
-      			++$audioinc;
-      			$news2write = $news2write."<p id=\"audioplayer_$audioinc\">Download Audio <a href=\"$audiosrc\">Here</a>.</p><script type=\"text/javascript\">AudioPlayer.embed(\"audioplayer_$audioinc\", {soundFile: \"$audio\"});</script><br />";
-    		};
-    		$news2write = $news2write.$comment."<hr />";
-		$tdtime = new DateTime(null, new DateTimeZone($timezone));
-    		$today = $tdtime->format('m.d.y');
-    		$now = $tdtime->format('H:i:s');
-    		$newsdir = $_SERVER["DOCUMENT_ROOT"].'/'.$basedir.$microblogdir;
-    		@mkdir($newsdir.$today);
-    		$fh = fopen($newsdir.$today."/".$now, 'w');
-		if (!$fh) die("ERROR: couldn't write $newsdir$today/$now to $newsdir$today, check permissions");
-		fwrite($fh,$news2write);
-		fclose($fh);
-	} else {
-		print "Could not post due to errors:<br />";
-		foreach ($errmsg as $err) {echo $err;}
-		print "POST Variable Dump below:<br /><em style=\"color: red\">";
-		var_dump($_POST);
-		print "</em>";
-	}
-} elseif ($_POST["id"] != "") {
-	if ($_POST["content"] == "") {
-		$res = unlink($_POST["id"]);
-		if (!$res) die("ERROR: couldn't delete ".$_POST['id'].", check permissions");
-		echo "Deleted ".$_POST["id"]."<br />";
-  } else {
-		$fh = fopen($_POST["id"], 'w');
-		if (!$fh) die("ERROR: couldn't write to ".$_POST['id'].", check permissions");
-    fwrite($fh,stripslashes($_POST["content"]));
-    fclose($fh);
-		echo "Edited ".$_POST["id"]."<br />";
+  //TODO have include file here for string size validation function
+  //Microblog Posting engine - also used to display a form for submitting stories
+  if (!empty($_POST["title"])) {//First check for a title in your POST data. If so, assume we're posting something new
+    $errors = array();//Create empty error array
+    //Validation checks
+    $url = stripslashes($_POST["URL"]);
+    if (empty($_POST['URL'])) {$errors[] = "No url provided.";}
+    else if (!filter_var($url,FILTER_VALIDATE_URL)) {$errors[] = '"'.$url.'" is not a valid ASCII URL.';}
+    if (!empty($_POST["IMG"]) && !filter_var(stripslashes($_POST["IMG"]),FILTER_VALIDATE_URL)) {$errors[] = 'Image "'.$url.'" is not a valid ASCII URL.';}
+    if (!empty($_POST["AUD"]) && !filter_var(stripslashes($_POST["AUD"]),FILTER_VALIDATE_URL)) {$errors[] = 'Audio "'.$url.'" is not a valid ASCII URL.';}
+    if (empty($_POST["comment"]) && empty($_POST["IMG"]) && empty($_POST["AUD"])) {$errors[] = "Post content is blank, Please add a comment or media to the posting.";}
+    //TODO Need to do extra validation here to prevent folks from doing something stupid like inserting executable code or large hex dumps of files
+    if (!count($errors)) {//All POST Vars needed to construct a coherent posting are here, let's format our data and write this thing
+      include_once("config/users.inc");//Import userland functions to figure out who's posting
+      $postBody = array(
+        "title"   => stripslashes($_POST["title"]),
+        "url"     => $url,
+        "image"   => stripslashes($_POST["IMG"]),
+        "audio"   => stripslashes($_POST["AUD"]),
+        "comment" => stripslashes($_POST["comment"]),
+        "poster"  => $poster
+      );
+      $tdtime = new DateTime(null, new DateTimeZone($timezone));
+      $today = $tdtime->format('m.d.y');
+      $now = $tdtime->format('H:i:s');
+      $newsdir = $_SERVER["DOCUMENT_ROOT"].'/'.$basedir.$microblogdir;
+      @mkdir($newsdir.$today);
+      $fh = fopen($newsdir.$today."/".$now, 'w');
+      if (!$fh) die("ERROR: couldn't write $newsdir$today/$now to $newsdir$today, check permissions");
+      fwrite($fh,json_encode($postBody));
+      fclose($fh);
+    } else {//Print errors at the top, since we didn't have what we needed from POST
+      $message = 'Could not post due to errors:<br /><ul style="color: red; list-type: disc;">';
+      foreach ($errors as $err) {$message .= "<li>$err</li>";}
+      $message .= '</ul>POST Variable Dump below:<br /><em style="color: red; font-size: .75em;">'.print_r($_POST, true).'</em>';
+      echo $message;
+    }
+  } elseif (!empty($_POST["id"])) {//If no title is supplied, let's see if we're editing/deleting a post.
+    if (empty($_POST["content"])) {//BLANKING IN PROGRESS
+      $res = unlink($_POST["id"]);
+      if (!$res) die("ERROR: couldn't delete ".$_POST['id'].", check permissions");
+      echo "Deleted ".$_POST["id"]."<br />";
+    } else {//Attempt editing, first detecting whether content is json
+      $fh = fopen($_POST["id"], 'w');
+      if (!$fh) die("ERROR: couldn't write to ".$_POST['id'].", check permissions");
+      if(is_null(json_decode($_POST["content"]))) {$content = stripslashes($_POST["content"]);}//Do some munging if it's just raw text
+      else {$content = $_POST["content"];}//JSON should be formatted correctly already
+      fwrite($fh,$content);//Just write the blob ,TODO validation
+      fclose($fh);
+      echo "Edited ".$_POST["id"]."<br />";
+    }
   }
-}
+  //DOM below
 ?>
 <div style="width: 100%; display: table;">
  <div style="width: 20%; display: table-cell;">