Skip to content

Commit

Permalink
Stop using templates.
Browse files Browse the repository at this point in the history
  • Loading branch information
Danack committed Jun 18, 2021
1 parent b3829fa commit 3084d99
Show file tree
Hide file tree
Showing 17 changed files with 659 additions and 133 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
## Imagick-demos

An example of all the Imagick functions. Or at least most of them. The site is hosted at http://phpimagick.com/

This is currently being refactored to be easier to maintain and add examples to.


## PHPStorm stub file
Expand Down
7 changes: 2 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

"license": "MIT",
"require-dev": {
"mikey179/vfsStream": "1.4.0",
"mikey179/vfsstream": "1.4.0",
"squizlabs/php_codesniffer": "^2.3.3"
},
"require": {
Expand All @@ -23,15 +23,12 @@
"intahwebz/weaver": "~0.4.5",
"intahwebz/configurator": "1.0.0",
"nikic/fast-route": "^1.0",
"oyejorge/less.php": "v1.7.0.5",
"predis/predis": "^1.0.1",
"leafo/lessphp": "0.4.0",
"leafo/scssphp": "0.1.1",
"room11/caching": "^0.0.4",
"room11/http": "^0.2.1",
"danack/var-map": "^0.6.0",
"twig/twig": "^2.11",
"ext-curl": "*"
"ext-curl": "*"
},
"autoload": {
"files": ["src/functions.php"],
Expand Down
Binary file modified composer.phar
Binary file not shown.
2 changes: 1 addition & 1 deletion docker/installer/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@ php ./tool/weaveControls.php
# mkdir -p ./var/cache/less
#php ./tool/compileLess.php

php cli.php clearRedis
# php cli.php clearRedis

echo "Installer is finished, site should be available."
5 changes: 2 additions & 3 deletions docker/php_backend/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,8 @@ php vendor/bin/configurate \
docker/php_backend/config/php.ini \
$ENV_TO_USE




# clear redis here not in installer
php cli.php clearRedis

/usr/sbin/php-fpm7.2 \
--nodaemonize \
Expand Down
17 changes: 11 additions & 6 deletions docker/php_backend_debug/xdebug.ini
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
zend_extension=xdebug.so
xdebug.remote_enable=1
xdebug.remote_port=9000
xdebug.remote_autostart=0
# xdebug.remote_enable=1
xdebug.mode=debug
# xdebug.remote_port=9000
# xdebug.remote_autostart=0
xdebug.start_with_request=yes
; Disable "Break at first line in PHP scripts"

; Remote connect back doesn't work in docker apparently, as the incoming
; request IP doesn't map back to the host properly.
xdebug.remote_connect_back=0
# xdebug.remote_connect_back=0
# xdebug.discover_client_host.

; This needs to be the IP address of the host on its local network
xdebug.remote_host=10.254.254.254
# xdebug.remote_host=host.docker.internal
xdebug.client_host=host.docker.internal

xdebug.overload_var_dump=0
# xdebug.overload_var_dump=0
21 changes: 14 additions & 7 deletions routes/app_routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,33 @@
// an api key, should call an appropriate callable.
return [

[
"/{category:Tutorial}",
'GET',
['ImagickDemo\Controller\Page', 'renderCategoryIndexMoreSane']
],
[
"/{category:Tutorial}/{example:eyeColorResolution}",
'GET',
['ImagickDemo\Controller\Page', 'renderExamplePageMoreSane']
],
[
"/$categories",
'GET',
['ImagickDemo\Controller\Page', 'renderCategoryIndex']
['ImagickDemo\Controller\Page', 'renderCategoryIndexMoreSane']
],

[
"/imagick",
'GET',
['ImagickDemo\Controller\Page', 'renderCategoryIndex']
['ImagickDemo\Controller\Page', 'renderCategoryIndexMoreSane']
],

//Category + example
[
"/$categories/{example:[a-zA-Z]+}",
'GET',
['ImagickDemo\Controller\Page', 'renderExamplePage']
['ImagickDemo\Controller\Page', 'renderExamplePageMoreSane']
],

//Images
Expand Down Expand Up @@ -75,10 +85,7 @@
["/css/{commaSeparatedFilenames}", 'GET', ['ScriptHelper\Controller\ScriptServer', 'serveCSS']],
['/js/{commaSeparatedFilenames}', 'GET', ['ScriptHelper\Controller\ScriptServer', 'serveJavascript']],

['/wat', 'GET', 'Osf\AppControlaler\Pages::index'],
['/wat/', 'GET', 'Osf\AppControasddaller\Pages::index'],

['/', 'GET', ['ImagickDemo\Controller\Page', 'renderTitlePage']],
['/', 'GET', ['ImagickDemo\Controller\Page', 'renderTitlePageMoreSane']],

// // TODO - actually make a 404 page
// ['/{any:.*}', 'GET', 'Osf\AppController\Pages::index'],
Expand Down
7 changes: 7 additions & 0 deletions runLocal.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env bash



docker-compose up --build installer
docker-compose up --build imagick_php_backend imagick_php_backend_debug npm redis web_server workers

73 changes: 60 additions & 13 deletions src/ImagickDemo/Controller/Page.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,78 @@

namespace ImagickDemo\Controller;

use Auryn\Injector;
use ImagickDemo\Navigation\CategoryInfo;
use SlimAuryn\Response\TwigResponse;
use VarMap\VarMap;

use ImagickDemo\Helper\PageInfo;
use ImagickDemo\Navigation\CategoryNav;
use ImagickDemo\NavigationBar;
use ImagickDemo\Example;
use SlimAuryn\RouteParams;
use ImagickDemo\DocHelper;
use ImagickDemo\Control;
use ImagickDemo\Navigation\NullNav;

class Page
{
public function renderTitlePage()
{
return new TwigResponse('title.html');
public function renderTitlePageMoreSane(
PageInfo $pageInfo,
NavigationBar $navBar,
Example $example
) {
$nav = new NullNav();
return renderTitlePage(
$pageInfo,
$nav,
$navBar,
$example
);
}

public function renderExamplePage(VarMap $varMap)
{
$template = 'example.html';
public function renderCategoryIndexMoreSane(
PageInfo $pageInfo,
Example $example,
CategoryNav $nav,
NavigationBar $navBar
) {
return renderCategoryIndexPage(
$pageInfo,
$example,
$nav,
$navBar
);
}

public function renderExamplePageMoreSane(
VarMap $varMap,
CategoryNav $categoryNav,
PageInfo $pageInfo,
NavigationBar $navigationBar,
Control $control,
Example $example,
DocHelper $docHelper
) {
if ($varMap->has('page') === true) {
if ($varMap->get('page') === 'iframe') {
$template = 'example_bare.html';
return renderExampleBare(
$pageInfo,
$categoryNav,
$navigationBar,
$control,
$example
);
}
}

return new TwigResponse($template, ['pageTitle' => "Imagick demos"]);
}

public function renderCategoryIndex()
{
return new TwigResponse('categoryIndex.html', ['pageTitle' => "Imagick demos"]);
return renderPageHtml(
$categoryNav,
$pageInfo,
$navigationBar,
$control,
$example,
$docHelper
);
}
}
2 changes: 1 addition & 1 deletion src/ImagickDemo/HomePageExample.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public function render()
<p>If you find any issues with this site, or if you find any example missing, or think something needs covering in more detail, please raise it as an issue on Github.
</p>
<p>Domain registrar transfer is in progress - if stuff gets weird.....wait a bit and see if it sorts itself out.
<p>
</p>
END;
Expand Down
79 changes: 6 additions & 73 deletions src/ImagickDemo/JigPlugin/ImagickPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,93 +146,26 @@ public function peakMemory($real_usage = false)

public function tagManagerInHead()
{
// Paste this code as high in the <head> of the page as possible:
$HTML = <<< HTML
<!-- Google Tag Manager -->
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','GTM-TPG3RVN');</script>
<!-- End Google Tag Manager -->
HTML;

return $HTML;
throw new \Exception("nope");
}

public function tagManagerInBodyStart()
{
//Additionally, paste this code immediately after the opening <body> tag:
$HTML = <<< HTML
<!-- Google Tag Manager (noscript) -->
<noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-TPG3RVN"
height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
<!-- End Google Tag Manager (noscript) -->
HTML;
return $HTML;
throw new \Exception("nope");
}

public function analytics()
{
$HTML = <<< HTML
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-32004535-2', 'auto');
ga('send', 'pageview');
</script>
HTML;

return $HTML;
throw new \Exception("nope");
}

/**
*
* 728 x 90
* Leaderboard
*/
function adSlotLeaderBoard()
{
$HTML = <<< HTML
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- TestLeaderboardText -->
<ins class="adsbygoogle"
style="display:inline-block;width:728px;height:90px"
data-ad-client="ca-pub-2560334673780653"
data-ad-slot="1471701929"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
HTML;

return $HTML;
throw new \Exception("nope");
}




function responsiveAdSlot()
{
$HTML = <<< HTML
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- TestResponsiveText -->
<ins class="adsbygoogle"
style="display:block"
data-ad-client="ca-pub-2560334673780653"
data-ad-slot="8315154322"
data-ad-format="auto"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
HTML;

return $HTML;
throw new \Exception("nope");
}
}
5 changes: 4 additions & 1 deletion src/ImagickDemo/Navigation/CategoryInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public function getCurrentName(PageInfo $pageInfo)
$exampleList = CategoryInfo::getCategoryList($pageInfo->getCategory());
$currentExample = $pageInfo->getExample();


foreach ($exampleList as $exampleName => $exampleDefinition) {
if (strcasecmp($currentExample, $exampleName) === 0) {
return $exampleName;
Expand Down Expand Up @@ -87,7 +88,9 @@ public static function getDIInfo(PageInfo $pageInfo)
{
$category = $pageInfo->getCategory();
$example = $pageInfo->getExample();




if ($category == null || $example == null) {
return ['ImagickDemo\Control\NullControl', []];
}
Expand Down
15 changes: 8 additions & 7 deletions src/ImagickDemo/Navigation/CategoryNav.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@ public function __construct(PageInfo $pageInfo)
*/
public function renderNav($horizontal = false)
{
echo "<div class='contentPanel navContainer' >";
echo $this->renderSearchBox();
echo $this->renderVertical();
echo "</div>";
$html = "<div class='contentPanel navContainer' >";
$html .= $this->renderSearchBox();
$html .= $this->renderVertical();
$html .= "</div>";

return $html;
}

/**
Expand Down Expand Up @@ -129,7 +131,7 @@ public function renderNextButton()
$nextName = $this->getNextName();

if ($nextName) {
echo "<a href='/".$this->pageInfo->getCategory()."/".$nextName."'>
return "<a href='/".$this->pageInfo->getCategory()."/".$nextName."'>
<button type='button' class='btn btn-primary'>
".$nextName." <span class='glyphicon glyphicon-arrow-right'></span>
</button>
Expand All @@ -147,14 +149,13 @@ public function renderNextLink()
$nextName = $this->getNextName();

if ($nextName) {
echo "<a href='/".$this->pageInfo->getCategory()."/".$nextName."'>
return "<a href='/".$this->pageInfo->getCategory()."/".$nextName."'>
".$nextName." <span class='glyphicon glyphicon-arrow-right'></span>
</a>";
}

return "";
}


/**
*
Expand Down
Loading

0 comments on commit 3084d99

Please sign in to comment.