aboutsummaryrefslogtreecommitdiffstats
path: root/test.php
diff options
context:
space:
mode:
authorThomas Lange <code@nerdmind.de>2018-12-31 00:23:06 +0100
committerThomas Lange <code@nerdmind.de>2018-12-31 00:23:06 +0100
commita0725d0bf159283e278168e3bd1dc0fe3e6da7ab (patch)
treea7788e618b82c7957cc56e2be3967fcfa8f03df0 /test.php
parentdf4865e7bcc3857be2f4b57d565a501a097b0daa (diff)
downloadbigpipe-a0725d0bf159283e278168e3bd1dc0fe3e6da7ab.tar.gz
bigpipe-a0725d0bf159283e278168e3bd1dc0fe3e6da7ab.tar.xz
bigpipe-a0725d0bf159283e278168e3bd1dc0fe3e6da7ab.zip
Temporary branch: last-pagelet-event-optimizationlast-pagelet-event-optimization
Diffstat (limited to 'test.php')
-rw-r--r--test.php66
1 files changed, 66 insertions, 0 deletions
diff --git a/test.php b/test.php
new file mode 100644
index 0000000..04a674a
--- /dev/null
+++ b/test.php
@@ -0,0 +1,66 @@
+<?php
+# >>> pagelets.php
+#===============================================================================
+# Autoload register for classes
+#===============================================================================
+spl_autoload_register(function($classname) {
+ $classname = str_replace('\\', '/', $classname);
+ require "include/classes/{$classname}.php";
+});
+
+#===============================================================================
+# Enable debugging mode
+#===============================================================================
+Application::$debugging = TRUE;
+
+#===============================================================================
+# Check if BigPipe should be disabled
+#===============================================================================
+if(isset($_GET['bigpipe']) AND $_GET['bigpipe'] === '0') {
+ # You can use this method to disable the pipeline for Googlebot or something
+ # else. If BigPipe is "disabled", then all pagelets will be rendered without
+ # being pipelined through the javascript library. The content of the pagelet
+ # will be present at the original position within the HTML response (and all
+ # external stylesheets and javascripts will be displayed as simple <link> or
+ # <script> elements within the HTML document).
+ BigPipe\BigPipe::enabled(FALSE);
+}
+
+#===============================================================================
+# Initialize pagelet instances
+#===============================================================================
+$DemoPagelet0 = Application::createPagelet('main_pagelet_0');
+$DemoPagelet1 = Application::createPagelet('main_pagelet_1');
+$DemoPagelet2 = Application::createPagelet('main_pagelet_2');
+$DemoPagelet3 = Application::createPagelet('side_pagelet_3');
+
+$Document = new Document();
+
+$Document->addPagelet($DemoPagelet0, function() {
+ return 'I am the first demo pagelet.';
+});
+
+$Document->addPagelet($DemoPagelet1, function() {
+ sleep(1); # simulate long execution of code (database queries, network communication, etc)
+ return 'I am the second demo pagelet and take very long to generate at server.';
+});
+
+$Document->addPagelet($DemoPagelet2, function() {
+ return 'I am the third demo pagelet.';
+});
+
+$Document->addPagelet($DemoPagelet3, function() {
+ sleep(1); # simulate long execution of code (database queries, network communication, etc)
+ return 'I am the fourth demo pagelet and I also take very long to generate at server.';
+});
+
+$content_html = "<ul>
+ <li>DemoPagelet0: {$DemoPagelet0}</li>
+ <li>DemoPagelet1: {$DemoPagelet1}</li>
+ <li>DemoPagelet2: {$DemoPagelet2}</li>
+ </ul>";
+
+$sidebar_html = "{$DemoPagelet3}";
+
+$Document->render($content_html, $sidebar_html);
+?> \ No newline at end of file