Browse Source

Ubiquity framework cleaning (#4701)

* [skip ci] remove unused files

* use spaceship operator

* Update nginx.conf

* [skip ci] update README

* remove Twig templating

* [fix] raw protection for messages in Fortunes
jcheron 6 years ago
parent
commit
d010c5ff0f

+ 6 - 0
frameworks/PHP/ubiquity/README.md

@@ -1,4 +1,10 @@
 # Ubiquity Benchmarking Test
 # Ubiquity Benchmarking Test
+![img](https://github.com/phpMv/ubiquity/blob/master/Banner/banner.png?raw=true)
+
+Ubiquity is a full-stack php framework, These tests involve:
+- the ORM part (Full)
+- the JSON serialization (native php)
+- the Twig template engine
 
 
 ## Test Type Implementation Source Code
 ## Test Type Implementation Source Code
 The tests are separated into 4 controllers:
 The tests are separated into 4 controllers:

+ 0 - 26
frameworks/PHP/ubiquity/app/controllers/ControllerBase.php

@@ -1,26 +0,0 @@
-<?php
-namespace controllers;
-
-use Ubiquity\controllers\Controller;
-use Ubiquity\utils\http\URequest;
-
-/**
- * ControllerBase.
- **/
-abstract class ControllerBase extends Controller{
-	protected $headerView = "@activeTheme/main/vHeader.html";
-	protected $footerView = "@activeTheme/main/vFooter.html";
-
-	public function initialize() {
-		if (! URequest::isAjax ()) {
-			$this->loadView ( $this->headerView );
-		}
-	}
-
-	public function finalize() {
-		if (! URequest::isAjax ()) {
-			$this->loadView ( $this->footerView );
-		}
-	}
-}
-

+ 4 - 4
frameworks/PHP/ubiquity/app/controllers/Fortunes.php

@@ -5,12 +5,12 @@ namespace controllers;
 use Ubiquity\controllers\Controller;
 use Ubiquity\controllers\Controller;
 use Ubiquity\controllers\Startup;
 use Ubiquity\controllers\Startup;
 use Ubiquity\orm\DAO;
 use Ubiquity\orm\DAO;
-use Ubiquity\views\engine\Twig;
+use Ubiquity\views\engine\micro\MicroTemplateEngine;
 use models\Fortune;
 use models\Fortune;
 
 
 class Fortunes extends Controller {
 class Fortunes extends Controller {
 	public function initialize(){
 	public function initialize(){
-		Startup::$templateEngine=new Twig(['cache' => true]);
+		Startup::$templateEngine=new MicroTemplateEngine();
 		$config=Startup::getConfig();
 		$config=Startup::getConfig();
 		\Ubiquity\orm\DAO::startDatabase($config);
 		\Ubiquity\orm\DAO::startDatabase($config);
 	}
 	}
@@ -19,9 +19,9 @@ class Fortunes extends Controller {
 		$fortunes = DAO::getAll(Fortune::class,'',false);
 		$fortunes = DAO::getAll(Fortune::class,'',false);
 		$fortunes[] = (new Fortune())->setId(0)->setMessage('Additional fortune added at request time.');
 		$fortunes[] = (new Fortune())->setId(0)->setMessage('Additional fortune added at request time.');
 		usort($fortunes, function($left, $right) {
 		usort($fortunes, function($left, $right) {
-			return strcmp($left->message, $right->message);
+			return $left->message<=>$right->message;
 		});
 		});
-		$this->loadView('Fortunes/index.html',['fortunes' => $fortunes]);
+		$this->loadView('Fortunes/index.php',['fortunes' => $fortunes]);
 	}
 	}
 }
 }
 
 

+ 0 - 30
frameworks/PHP/ubiquity/app/controllers/IndexController.php

@@ -1,30 +0,0 @@
-<?php
-namespace controllers;
-use Ubiquity\core\postinstall\Display;
-use Ubiquity\themes\ThemesManager;
-
-/**
- * Controller IndexController
- **/
-class IndexController extends ControllerBase{
-
-	public function index(){
-		$defaultPage=Display::getDefaultPage();
-		$links=Display::getLinks();
-		$infos=Display::getPageInfos();
-
-		$activeTheme=ThemesManager::getActiveTheme();
-		$themes=Display::getThemes();
-		if(sizeof($themes)>0){
-			$this->loadView('@activeTheme/main/vMenu.html',compact('themes','activeTheme'));
-		}
-		$this->loadView($defaultPage,compact('defaultPage','links','infos','activeTheme'));
-	}
-
-
-	public function ct($theme){
-		$config=ThemesManager::saveActiveTheme($theme);
-		header("Location: ".$config['siteUrl']);
-	}
-
-}

+ 0 - 3
frameworks/PHP/ubiquity/app/views/Fortunes/index.html

@@ -1,3 +0,0 @@
-<!DOCTYPE html><html><head><title>Fortunes</title></head>
-<body><table><tr><th>id</th><th>message</th></tr>{% for fortune in fortunes %}<tr><td>{{ fortune.id }}</td><td>{{ fortune.message }}</td></tr>{% endfor %}</table>
-</body></html>

+ 4 - 0
frameworks/PHP/ubiquity/app/views/Fortunes/index.php

@@ -0,0 +1,4 @@
+<!DOCTYPE html><html><head><title>Fortunes</title></head><body><table><tr><th>id</th><th>message</th></tr>
+<?php foreach ($fortunes as $item) : ?>
+<tr><td><?= $item->id ?></td><td><?= htmlentities($item->message) ?></td></tr>
+<?php endforeach ?></table></body></html>

+ 0 - 9
frameworks/PHP/ubiquity/app/views/main/vFooter.html

@@ -1,9 +0,0 @@
-{% block footer %}
-{% endblock %}
-{% block scripts %}
-{{ js('https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js') }}
-{{ js('https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.4.1/semantic.min.js') }}
-{{ js('https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.3.0/components/state.min.js') }}
-{% endblock %}
-</body>
-</html>

+ 0 - 16
frameworks/PHP/ubiquity/app/views/main/vHeader.html

@@ -1,16 +0,0 @@
-<!DOCTYPE html>
-<html>
-<head>
-{% block header %}
-	<base href="{{config["siteUrl"]}}">
-	<meta charset="UTF-8">
-	<title>ubiquity</title>
-{% endblock %}
-{% block css %}
-	{{ css('https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.4.1/semantic.min.css') }}
-	{{css('css/style.css') | raw}}
-{% endblock %}
-</head>
-<body>
-{% block head %}
-{% endblock %}

+ 0 - 14
frameworks/PHP/ubiquity/app/views/main/vMenu.html

@@ -1,14 +0,0 @@
-<div class="head">
-	<div class="ui container">
-		<div class="ui pointing inverted menu">
-		  <div class="header item">
-		    Themes
-		  </div>
-		  {% for theme in themes %}
-		  <a class="item {{ activeTheme==theme ? 'active' }}" href="IndexController/ct/{{theme}}">
-		    {{theme}}
-		  </a>
-		  {% endfor %}
-		</div>
-	</div>
-</div>

+ 2 - 3
frameworks/PHP/ubiquity/composer.json

@@ -1,12 +1,11 @@
 {
 {
 	"require" : {
 	"require" : {
 		"php" : "^7.1",
 		"php" : "^7.1",
-		"twig/twig" : "^2.0",
-		"mindplay/annotations" : "^1.3",
 		"phpmv/ubiquity" : "dev-master"
 		"phpmv/ubiquity" : "dev-master"
 	},
 	},
 	"require-dev" : {
 	"require-dev" : {
-		"monolog/monolog" : "^1.24"
+		"monolog/monolog" : "^1.24",
+		"mindplay/annotations" : "^1.3"
 	},
 	},
 	"autoload" : {
 	"autoload" : {
 		"psr-4" : {
 		"psr-4" : {

+ 3 - 3
frameworks/PHP/ubiquity/deploy/nginx.conf

@@ -20,14 +20,14 @@ http {
     tcp_nodelay on;
     tcp_nodelay on;
     keepalive_timeout 65;
     keepalive_timeout 65;
     keepalive_disable none;
     keepalive_disable none;
-    keepalive_requests 1000;
+    keepalive_requests 10000;
 
 
     open_file_cache max=2000 inactive=20s;
     open_file_cache max=2000 inactive=20s;
     open_file_cache_valid 60s;
     open_file_cache_valid 60s;
     open_file_cache_min_uses 5;
     open_file_cache_min_uses 5;
     open_file_cache_errors off;
     open_file_cache_errors off;
 
 
-    #FastCGI optimizations
+  #FastCGI optimizations
     fastcgi_buffers 256 16k;
     fastcgi_buffers 256 16k;
     fastcgi_buffer_size 128k;
     fastcgi_buffer_size 128k;
     fastcgi_connect_timeout 30s;
     fastcgi_connect_timeout 30s;
@@ -45,7 +45,7 @@ http {
     }
     }
 
 
     server {
     server {
-        listen       8080;
+        listen       8080 reuseport;
         server_name  localhost;
         server_name  localhost;
 
 
         root /ubiquity/;
         root /ubiquity/;