Quellcode durchsuchen

WIP, mostly cleanup, probably broken state atm

Andy Baugh vor 9 Jahren
Ursprung
Commit
62dcd2f07a

+ 1 - 0
.gitignore

@@ -1,3 +1,4 @@
 *.swp
 *.swo
 favicon.ico
+dist/

+ 6 - 0
CHANGELOG

@@ -1,3 +1,9 @@
+Version 2.0 IRONMAN SLOG development notes [ALPHA]:
+* tCMS now has an installer in bin/installer.
+* Fixed a bug where "" encapsulated titles in microblog editor would get baleeted on load.
+* Changed up the directory structure somewhat, mostly due to needing privately stored items.
+* Added an SVG logo.
+
 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.

+ 6 - 1
TODO

@@ -6,4 +6,9 @@ tCMS2 still left undone (will add to as I think of em)
 * Un-Stubbify first time run wizard
 * Make config page in Admin work right
 
-*SINGLE USER INSTALL INFO TO MANUAL, MULTI-USER INSTALL INFO TO MANUAL
+* SINGLE USER INSTALL INFO TO MANUAL, MULTI-USER INSTALL INFO TO MANUAL
+* CRYPTO LOGIN YOU BAG BITER
+
+`make dist` to make release tarball
+
+Check licensing on all files, make sure all stuff we made is CC0, all stuff from external has proper attribs, etc.

+ 14 - 3
bin/install

@@ -28,16 +28,17 @@ if( $private_base != $user_info['dir'] . "/.tCMS" ) {
     echo "        wish to prevent this information disclosure. Please press [enter] to continue.";
     get_string_from_stdin(); # Mostly just to make the user confirm they read this.
 }
+#TODO Add question here asking for administrator user setup. DO NOT ALLOW DEFAULT VALUES
 $wd = realpath( dirname( __FILE__ ) . "/../" );
 echo "[INFO] Installing private data to $private_base now...\n";
 $files = [ 'lib', 'templates' ];
 install( $private_base, $wd, $files );
-foreach ( [ "$private_base/blog", "$private_base/microblog" ] as $dir ) {
-    if ( !file_exists( $dir ) ) mkdir( $dir );
-}
+ensure_directories_exist( [ "$private_base/blog", "$private_base/microblog", "$private_base/conf" ] );
+#TODO Generate private/public keypair with passphrase of user entered credentials.
 echo "[INFO] Installing public data to $public_base now...\n";
 $files = [ 'css', 'fileshare', 'img', 'index.php', 'sys' ];
 install( $public_base, $wd, $files );
+ensure_directories_exist( [ "$public_base/css/custom", "$public_base/img/icon/custom" ] );
 if( $private_base != $user_info['dir'] . "/.tCMS" ) {
     file_put_contents( "$public_base/basedir", $private_base );
 }
@@ -68,4 +69,14 @@ function install( $to, $from, $files2copy ) {
     }
     return;
 }
+
+function ensure_directories_exist( $dirs ) {
+    foreach ( $dirs as $dir ) {
+        if ( !file_exists( $dir ) ) {
+            echo "exec `/bin/mkdir '$dir'`\n";
+            mkdir( $dir );
+        }
+    }
+    return;
+}
 ?>

+ 0 - 6
css/compat/ie.css

@@ -1,6 +0,0 @@
-a.rss, a.logo, a.usericon, a.avatar {
- background-image: none !important;
-}
-p#linkcontainer {
- width: 6em;
-}

+ 0 - 30
css/compat/ie6-7.css

@@ -1,30 +0,0 @@
-div.linkbar {
- float: left;
- clear: none;
-}
-div.kontent {
- float: right;
- clear: none;
-}
-img.titlebar {
-}
-a.logo {
- font-size: 1.5em;
- font-family: courier;
- color: white;
- text-decoration: none;
-}
-a.logo:hover {
- text-decoration: underline;
-}
-#lefttitle {
- visibility: hidden;
- display: none;
-}
-#midtitle {
- float: left;
- vertical-align: middle;
-}
-#righttitle {
- float: right;
-}

+ 0 - 14
css/compat/ie6.css

@@ -1,14 +0,0 @@
-body {
- height: 100%;
- overflow-y: auto;
-}
-div.topbar {
- position: absolute;
-}
-#lefttitle {
- visibility: hidden;
- display: none;
-}
-#midtitle {
- float: left;
-}

+ 0 - 1
css/custom/.gitignore

@@ -1 +0,0 @@
-*.css

Datei-Diff unterdrückt, da er zu groß ist
+ 112 - 0
img/icon/tCMS.svg


+ 30 - 67
index.php

@@ -1,95 +1,58 @@
 <?php
+# Get protocol bits, etc.
 $protocol = ( !empty($_SERVER["HTTPS"] ) ) ? 'https'       : 'http';
 $nav      = ( !empty($_GET['nav'] ) )      ? $_GET['nav']  : '';
 $post     = ( !empty($_GET['post'] ) )     ? $_GET['post'] : '';
+$docroot  = $_SERVER['DOCUMENT_ROOT'];
 
-if(file_exists('sys/admin/config/main.json')) {
-	$config = json_decode(file_get_contents('sys/admin/config/main.json'),true);
+# Grab the main configuration file. We need to see where that lives first though.
+if( file_exists( "$docroot/basedir" ) ) {
+    $fh = fopen( "$docroot/basedir" );
+    $basedir = trim(fgets( $fh )); # I only want the first line
+    fclose($fh);
 } else {
+    $basedir = posix_getpwuid(posix_geteuid())['dir'] . "/.tCMS";
+}
+
+if(!file_exists("$basedir/conf/main.json")) {
 	# XXX Need to have manual be hosted in repo under sys/admin/manual
-	include( "templates/default/notconfigured.tmpl" );
+	include( "$basedir/templates/default/notconfigured.tmpl" );
 	die();
 }
+$config = json_decode(file_get_contents("$basedir/conf/main.json"),true);
+// Not sure if I'll ever really even need to localize (see html tag attrs).
 ?>
 <!doctype html>
 <html dir="ltr" lang="en-US">
- <head>
-  <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" />
-  <?php
-    if(file_exists('css/custom/avatars.css')) {
-      echo '<link rel="stylesheet" type="text/css" href="css/custom/avatars.css" />';
-    } else {
-      echo '<link rel="stylesheet" type="text/css" href="css/avatars.css" />';
-    }
-  ?>
-  <!--Compatibility Stylesheets-->
-  <!--[if lte IE 8]>
-   <link rel="stylesheet" type="text/css" href="css/compat/ie.css">
-  <![endif]-->
-  <!--[if lte IE 7]>
-   <link rel="stylesheet" type="text/css" href="css/compat/ie6-7.css">
-  <[endif]-->
-  <!--[if IE 6]>
-   <link rel="stylesheet" type="text/css" href="css/compat/ie6.css">
-  <![endif]-->
-  <?php
-    if(file_exists('css/custom/screen.css')) {
-      echo '<link rel="stylesheet" type="text/css" href="css/custom/screen.css" />';
-    }
-    if(file_exists('css/custom/print.css')) {
-      echo '<link rel="stylesheet" type="text/css" href="css/custom/print.css" />';
-    }
-    if(file_exists('favicon.ico')) {
-      echo '<link rel="icon" type="image/vnd.microsoft.icon" href="favicon.ico" />';
-    } else {
-      echo '<link rel="icon" type="image/vnd.microsoft.icon" href="img/icon/favicon.ico" />';
-    }
-  ?>
-  <title>
-   <?php
-    echo $config['htmltitle'];
-   ?>
-  </title>
- </head>
+ <?php include("$basedir/templates/" . $config['theme'] . "/header.tmpl"); ?>
  <body>
   <div id="topkek">
    <?php
     //Site's Titlebar comes in here
-    include $config['toptitle'];
+    include("$basedir/templates/" . $config['theme'] . "/nav.inc");
    ?>
   </div>
   <div id="littlemenu">
   </div>
   <div id="kontainer">
    <div id="leftbar" class="kontained">
-    <?php
-     include $config['leftbar'];
-    ?>
+    <?php include $config['leftbar']; ?>
    </div>
    <div id="kontent" class="kontained">
    <?php
-/*$kontent basically is just a handler for what PHP include needs to be loaded
-based on the context passed via GET params - if you wanna add another, add an
-elseif case then specify the next number in the nav index along with the
-corresponding file to include above.*/
-$destinations = [
-	$config['home'], $config['fileshare'], $config['microblog'], $config['blog'], $config['about'],
-	$config['postloader'], $config['codeloader'], $config['audioloader'], $config['videoloader'],
-	$config['imgloader'], $config['docloader']
-];
-if ( empty($nav) ) $nav = 0;
-if ( $nav === 1 || $nav > 5 ) {
-	$pwd = $post;
-	include 'sys/fileshare/sanitize.inc';
-}
-$kontent = $destinations[$nav];
-//Main Content Display Frame goes below
-include $kontent;
+    //XXX fileshare, etc. shouldn't be a config value. Home should refer to a template.
+    $destinations = [
+        $config['home'], $config['fileshare'], $config['microblog'], $config['blog'], $config['postloader'],
+        $config['codeloader'], $config['audioloader'], $config['videoloader'], $config['imgloader'],
+        $config['docloader']
+    ];
+    if ( empty($nav) ) $nav = 0;
+    if ( $nav === 1 || $nav > 4 ) {
+        $pwd = $post;
+        include 'sys/fileshare/sanitize.inc';
+    }
+    //Main Content Display Frame goes below
+    include $destinations[$nav];
    ?>
    </div>
    <div id="rightbar" class="kontained">

+ 0 - 1
templates/custom/.gitignore

@@ -1 +0,0 @@
-[^.]*

+ 0 - 1
templates/default/about.inc

@@ -1 +0,0 @@
-This is supposed to be a page all about the author(s) of this website. Nothing is here yet though.

+ 20 - 0
templates/default/header.tmpl

@@ -0,0 +1,20 @@
+ <head>
+  <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" />
+  <?php
+    foreach ( [ 'avatars', 'screen', 'print', 'favicon.ico' ] as $file ) {
+        $rel  = ( $file == 'favicon.ico' )    ? "icon"                     : "stylesheet";
+        $type = ( $file == 'favicon.ico' )    ? "image/vnd.microsoft.icon" : "text/css"; 
+        $dir  = ( $file == 'favicon.ico' )    ? "img/icon"                 : "css";
+        $href = ( file_exists( "$dir/$file" ) ? "$dir/custom/$file"        : "$dir/$file";
+        echo "<link rel=\"$rel\" type=\"$type\" href=\"$href\" />";
+    }
+  ?>
+  <title>
+   <?php echo $config['htmltitle']; ?>
+  </title>
+ </head>

+ 0 - 14
templates/default/title.inc

@@ -1,14 +0,0 @@
-<div id="lefttitle" class="toplel">
- <?php
-  echo $config['htmltitle'];
- ?>
-</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>

Einige Dateien werden nicht angezeigt, da zu viele Dateien in diesem Diff geändert wurden.