Browse Source

Tidied all scripts

Jeroen De Meerleer 6 years ago
parent
commit
d068f3fb89
12 changed files with 248 additions and 216 deletions
  1. 2 1
      .gitignore
  2. 6 9
      config.php
  3. 21 0
      config.sample.php
  4. 0 4
      content/instantbugfix.js
  5. 18 21
      controller.class.php
  6. 28 30
      controllers/apiClass.php
  7. 27 25
      controllers/pageClass.php
  8. 65 35
      database.sql
  9. 66 69
      index.php
  10. 4 4
      models/fix.php
  11. 4 6
      models/page.php
  12. 7 12
      views/index.tpl

+ 2 - 1
.gitignore

@@ -216,4 +216,5 @@ pip-log.txt
 
 ##My Settings
 nbproject
-compiled_templates
+compiled_templates
+config.php

+ 6 - 9
config.php

@@ -1,9 +1,8 @@
 <?php
-
 /*
  * Change this file to suit your needs and rename it to config.php
  */
-
+ 
 /*
  * 
  *   _____       _______       ____           _____ ______ 
@@ -15,10 +14,8 @@
  *                                                                                                             
  * 
  */
-
-define('DB_HOST', 'localhost');
-define('DB_USER', 'root');
-define('DB_PASS', 'letmein');
-define('DB_NAME', 'instantbugfix');
-define('DB_PREFIX', 'ibf_');
-
+	define('DB_HOST', 'localhost');
+	define('DB_USER', 'root');
+	define('DB_PASS', 'letmein');
+	define('DB_NAME', 'instantbugfix');
+	define('DB_PREFIX', 'ibf_');

+ 21 - 0
config.sample.php

@@ -0,0 +1,21 @@
+<?php
+/*
+ * Change this file to suit your needs and rename it to config.php
+ */
+ 
+/*
+ * 
+ *   _____       _______       ____           _____ ______ 
+ *  |  __ \   /\|__   __|/\   |  _ \   /\    / ____|  ____|
+ *  | |  | | /  \  | |  /  \  | |_) | /  \  | (___ | |__   
+ *  | |  | |/ /\ \ | | / /\ \ |  _ < / /\ \  \___ \|  __|  
+ *  | |__| / ____ \| |/ ____ \| |_) / ____ \ ____) | |____ 
+ *  |_____/_/    \_\_/_/    \_\____/_/    \_\_____/|______|
+ *                                                                                                             
+ * 
+ */
+	define('DB_HOST', 'localhost');
+	define('DB_USER', 'root');
+	define('DB_PASS', 'letmein');
+	define('DB_NAME', 'instantbugfix');
+	define('DB_PREFIX', 'ibf_');

+ 0 - 4
content/instantbugfix.js

@@ -16,9 +16,7 @@
  */
 
 $(document).ready(function() {
-
     $(window).resize();
-
     $(window).resize(function() {
         $('#bugfix').css({
             position: 'absolute',
@@ -32,10 +30,8 @@ $(document).ready(function() {
 
 
 function openPage(page) {
-
     history.pushState(null, "About Me", "/page/" + page);
     ibfCall("getPage?slug=" + page);
-
 }
 
 function closePage() {

+ 18 - 21
controller.class.php

@@ -1,5 +1,4 @@
 <?php
-
 /*
  * Copyright (C) 2014 Jeroen De Meerleer <me@jeroened.be>
  *
@@ -16,29 +15,27 @@
  * You should have received a copy of the GNU General Public License
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
-
-/**
+/*
  * Description of model
  *
  * @author Jeroen De Meerleer <me@jeroened.be>
  */
-class controller {
-    
-    public $id;
-    public $controller;
-    public $method;
-    
-    function create_template($template, $model) {
-        $tpl = new SpoonTemplate();
-        $tpl->setForceCompile(true);
-        $tpl->setCompileDirectory('compiled_templates');
+	class controller {
+		public $id;
+		public $controller;
+		public $method;
+		
+		function create_template($template, $model) {
+			$tpl = new SpoonTemplate();
+			$tpl->setForceCompile(true);
+			$tpl->setCompileDirectory('compiled_templates');
+			// assign some variables
+			foreach($model as $key => $value) {
+				$tpl->assign($key, $value);
+			}
 
-        // assign some variables
-        foreach($model as $key => $value) {
-            $tpl->assign($key, $value);
-        }
+			// show the output, using 'template.tpl'
+			$tpl->display("views/" . $template);
+		}
 
-        // show the output, using 'template.tpl'
-        $tpl->display("views/" . $template);
-    }
-}
+	}

+ 28 - 30
controllers/apiClass.php

@@ -1,5 +1,4 @@
 <?php
-
 /*
  * Copyright (C) 2014 Jeroen De Meerleer <me@jeroened.be>
  *
@@ -16,37 +15,36 @@
  * You should have received a copy of the GNU General Public License
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
-
+ 
 /**
  * Description of apiClass
  *
  * @author Jeroen De Meerleer <me@jeroened.be>
  */
-class apiClass {
-    
-    Public function getBugfix() {
-        global $db;
-        $array["type"] = "Bugfix";
-        
-        if(isset($_GET['fix'])) {
-            $array["data"] = $db->getRecord('SELECT * FROM ' . DB_PREFIX . 'fixes WHERE fixID = ? ',$_GET['fix'] );          
-        }else {
-            $array["data"] = $db->getRecord('SELECT * FROM ' . DB_PREFIX . 'fixes ORDER BY RAND() LIMIT 1,1');
-        }
-        echo json_encode($array);
-        exit;
-    }
-    
-    Public Function getPage() {
-        global $db;
-        $slug = $_GET['slug'];
-        $array["type"] = "Page";
-        $array["data"] = $db->getRecord('SELECT * '
-                . 'FROM ' . DB_PREFIX . 'revisions '
-                . 'WHERE pageslug = ? '
-                . 'AND isCurrent = 1', $slug);
-        echo json_encode($array);
-        exit;
-    }
-    
-}
+	class apiClass {
+		Public
+		function getBugfix() {
+			global $db;
+			$array["type"] = "Bugfix";
+			
+			if(isset($_GET['fix'])) {
+				$array["data"] = $db->getRecord('SELECT * FROM ' . DB_PREFIX . 'fixes WHERE fixID = ? ',$_GET['fix'] );
+			} else {
+				$array["data"] = $db->getRecord('SELECT * FROM ' . DB_PREFIX . 'fixes ORDER BY RAND() LIMIT 1,1');
+			}
+
+			echo json_encode($array);
+			exit;
+		}
+
+		Public
+		Function getPage() {
+			global $db;
+			$slug = $_GET['slug'];
+			$array["type"] = "Page";
+			$array["data"] = $db->getRecord('SELECT * '                . 'FROM ' . DB_PREFIX . 'revisions '                . 'WHERE pageslug = ? '                . 'AND isCurrent = 1', $slug);
+			echo json_encode($array);
+			exit;
+		}
+
+	}

+ 27 - 25
controllers/pageClass.php

@@ -1,6 +1,5 @@
 <?php
-
-/*
+	/*
  * Copyright (C) 2014 Jeroen De Meerleer <me@jeroened.be>
  *
  * This program is free software: you can redistribute it and/or modify
@@ -16,29 +15,32 @@
  * You should have received a copy of the GNU General Public License
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
-
-/**
- * Description of homeClass
+	/**
+ * Description of pageClass
  *
  * @author Jeroen De Meerleer <me@jeroened.be>
  */
-class pageClass extends controller{
-    
-    public function index() {
-        $model = new page();
-        $model->apiCall[]["call"] = "getBugFix";
-        $this->create_template("index.tpl", $model);
-    }
-    
-    public function about() {
-        $model = new page();
-        $model->apiCall[]["call"] = "getBugFix";
-        $model->apiCall[]["call"] = "getPage?slug=about";
-        $this->create_template("index.tpl", $model);
-    }
-    public function fix() {
-        $model = new page();
-        $model->apiCall[]["call"] = "getBugFix?fix=" . $this->id;
-        $this->create_template("index.tpl", $model);
-    }
-}
+	class pageClass extends controller{
+		public
+		function index() {
+			$model = new page();
+			$model->apiCall[]["call"] = "getBugFix";
+			$this->create_template("index.tpl", $model);
+		}
+
+		public
+		function about() {
+			$model = new page();
+			$model->apiCall[]["call"] = "getBugFix";
+			$model->apiCall[]["call"] = "getPage?slug=about";
+			$this->create_template("index.tpl", $model);
+		}
+
+		public
+		function fix() {
+			$model = new page();
+			$model->apiCall[]["call"] = "getBugFix?fix=" . $this->id;
+			$this->create_template("index.tpl", $model);
+		}
+
+	}

File diff suppressed because it is too large
+ 65 - 35
database.sql


+ 66 - 69
index.php

@@ -1,5 +1,4 @@
 <?php
-
 /* 
  * Copyright (C) 2014 Jeroen De Meerleer <me@jeroened.be>
  *
@@ -15,79 +14,77 @@
  *
  * You should have received a copy of the GNU General Public License
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-
+ */	
 // define location of your library
 //define('PATH_LIBRARY', dirname(__FILE__) . "/spoon");
-error_reporting(E_ALL);
-ini_set('display_errors', '1');
-
-// add this to the include path
-//set_include_path(get_include_path() . PATH_SEPARATOR . PATH_LIBRARY);
-// Initialize framework
-require_once 'spoon/spoon.php';
-
-// Add required shizzle
-require_once "config.php";
-require_once "controller.class.php";
-require_once "controllers.php";
-require_once "models.php";
-require_once "dbcon.php";
+	error_reporting(E_ALL);
+	ini_set('display_errors', '1');
+	// add this to the include path
+	//set_include_path(get_include_path() . PATH_SEPARATOR . PATH_LIBRARY);
+	// Initialize framework
+	require_once 'spoon/spoon.php';
+	// Add required shizzle
+	require_once "config.php";
+	require_once "controller.class.php";
+	require_once "controllers.php";
+	require_once "models.php";
+	require_once "dbcon.php";
+	// Let's hit the road
+	$site = new init();
+	class init {
+		public $working_dir;
+		public $controller = "pageClass";
+		public $method = "index";
+		public $id = "0";
+		public
+		function __construct() {
+			$this->working_dir = $this->get_working_directory();
+			$this->controller = $this->get_controller();
+			$this->method = $this->get_method();
+			$this->id = $this->get_id();
+			// Hit that monster
+			$monster = new $this->controller();
+			$monster->controller = $this->controller;
+			$monster->method = $this->method;
+			$monster->id = $this->id;
+			$monster->{
+				$this->method}
 
+			();
+		}
 
+		public
+		function get_controller() {
+			$query_array = explode('/', $_SERVER['REQUEST_URI']);
+			$controller = (!empty($query_array[1])) ? $query_array[1] :
+			"page";
+			$r_value = $controller . "Class";
+			return $r_value;
+		}
 
-// Let's hit the road
-$site = new init();
+		public
+		function get_method() {
+			$query = explode('?', $_SERVER['REQUEST_URI']);
+			$query_array = explode('/', $query[0]);
+			$r_value = (!empty($query_array[2])) ? $query_array[2] :
+			"index";
+			return $r_value;
+		}
 
-class init {
-    
-    public $working_dir;
-    public $controller = "pageClass";
-    public $method = "index";
-    public $id = "0";
-    
-    public function __construct() {
-        $this->working_dir = $this->get_working_directory();
-        $this->controller = $this->get_controller();
-        $this->method = $this->get_method();
-        $this->id = $this->get_id();
-        
-        // Hit that monster
-        $monster = new $this->controller();
-        $monster->controller = $this->controller;
-        $monster->method = $this->method;
-        $monster->id = $this->id;
-        $monster->{$this->method}();
-        
-    }
-    
-    public function get_controller() {
-        $query_array = explode('/', $_SERVER['REQUEST_URI']);
-        $controller = (!empty($query_array[1])) ? $query_array[1] : "page";
-        $r_value = $controller . "Class";
-        return $r_value;
-    }
-    
-    public function get_method() {
-        $query = explode('?', $_SERVER['REQUEST_URI']);
-        $query_array = explode('/', $query[0]);
-        $r_value = (!empty($query_array[2])) ? $query_array[2] : "index";
-        return $r_value;
-    } 
-    
-    public function get_id() {
-        $query_array = explode('/', $_SERVER['REQUEST_URI']);
-        $r_value = (!empty($query_array[3])) ? $query_array[3] : -1;
-        return $r_value;
-    }
-    
-    public function get_working_directory() {
-        $value_r = explode('/', $_SERVER['REQUEST_URI']);
-        unset($value_r[count($value_r)-1]);
-        $r_value = implode('/', $value_r);
-        return $r_value . '/';
-    }
-    
-}
+		public
+		function get_id() {
+			$query_array = explode('/', $_SERVER['REQUEST_URI']);
+			$r_value = (!empty($query_array[3])) ? $query_array[3] :
+			-1;
+			return $r_value;
+		}
 
+		public
+		function get_working_directory() {
+			$value_r = explode('/', $_SERVER['REQUEST_URI']);
+			unset($value_r[count($value_r)-1]);
+			$r_value = implode('/', $value_r);
+			return $r_value . '/';
+		}
 
+	}

+ 4 - 4
models/fix.php

@@ -23,7 +23,7 @@
  *
  * @author Jeroen
  */
-class fix {
-    public $fixID;
-    public $fixText;
-}
+	class fix {
+		public $fixID;
+		public $fixText;
+	}

+ 4 - 6
models/page.php

@@ -18,12 +18,10 @@
  */
 
 /**
- * Description of fixModel
+ * Description of page
  *
  * @author Jeroen De Meerleer <me@jeroened.be>
  */
-class page {
-    
-    Public $apiCall;
-    
-}
+	class page {
+		Public $apiCall;
+	}

+ 7 - 12
views/index.tpl

@@ -20,15 +20,15 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 <head>
     <title>Instant Bug Fix</title>
     <link href="/content/style.css" media="screen" rel="stylesheet" type="text/css">
-	<link rel="icon" type="image/png" href="/favicon.ico">
+    <link href="/favicon.ico" rel="icon" type="image/png">
     <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.js"></script>
     <script src="/content/instantbugfix.js" type="text/javascript"></script>
     <meta charset="UTF-8">
     <meta content="width=device-width" name="viewport">
     <script type="text/javascript">
-        {iteration:apiCall}
-                ibfCall("{$apiCall.call}");
-            {/iteration:apiCall}
+{iteration:apiCall}
+        ibfCall("{$apiCall.call}");
+    {/iteration:apiCall}
     </script>
 </head>
 
@@ -42,20 +42,15 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
     </div>
 
     <div id="permalink">
-        <a href="#" onclick=
-        "prompt('Copy this and share the bugfix', 'http://instantbugfix.jeroened.be/page/fix/%id%');">
-        Permalink</a>
+        <a href="#" onclick="prompt('Copy this and share the bugfix', 'http://instantbugfix.jeroened.be/page/fix/%id%');">Permalink</a>
     </div>
 
     <div id="tweetthis">
-        <a href=
-        "https://twitter.com/intent/tweet?text=%fix%&amp;url=http%3A%2F%2Finstantbugfix.jeroened.be%2Fpage%2Ffix%2F%id%"
-        target="_blank">Tweet</a>
+        <a href="https://twitter.com/intent/tweet?text=%fix%&amp;url=http%3A%2F%2Finstantbugfix.jeroened.be%2Fpage%2Ffix%2F%id%" target="_blank">Tweet</a>
     </div>
 
     <div id="badge">
-        <a href="http://www.jeroened.be" target="_blank"><img alt=
-        "created by Jeroen De Meerleer" src="/content/images/jeroenED.png"></a>
+        <a href="http://www.jeroened.be" target="_blank"><img alt="created by Jeroen De Meerleer" src="/content/images/jeroenED.png"></a>
     </div>
 
     <div id="container"></div>