Skip to content

Commit

Permalink
Merge branch 'master' into feature/372-rewrite
Browse files Browse the repository at this point in the history
# Conflicts:
#	code/site/components/com_pages/dispatcher/http.php
#	code/site/components/com_pages/resources/config/site.php
  • Loading branch information
johanjanssens committed Jun 18, 2020
2 parents c79c0e5 + 29e50b3 commit 1da63a1
Show file tree
Hide file tree
Showing 72 changed files with 1,547 additions and 1,097 deletions.
70 changes: 70 additions & 0 deletions .github/workflows/.build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@

name: Build package

on:
repository_dispatch:

push:
tags:
- v*
branches: # Add your feature branch here if you want a release and package generated for it
- master
- develop
- feature/370-mason

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Inject slug/short variables
uses: rlespinasse/[email protected]

- name: Figure out tag name (v1.x.y or dev-branch)
id: tagname
run: |
if [[ "${REF:0:1}" == "v" ]];
then
echo "::set-output name=tag::$REF";
else
echo "::set-output name=tag::dev-$REF";
fi;
env:
REF: ${{ env.GITHUB_REF_SLUG }}

- name: Use Node.js
uses: actions/setup-node@v1
with:
node-version: 12.x

- run: npm i -g @joomlatools/mason

- run: mason bundle --config.githubToken=${{ secrets.JOOMLATOOLS_BUILDS_GITHUB_TOKEN }} --verbose --debug

- run: mason buildExtensions --verbose --debug

- name: Create release
uses: meeDamian/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
token: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ steps.tagname.outputs.tag }}
name: ${{ env.GITHUB_REF_SLUG }}
allow_override: true

- name: Upload package to release
uses: svenstaro/upload-release-action@v1-release
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ steps.tagname.outputs.tag }}
file: ${{ github.workspace }}/com_pages*.zip
file_glob: true
overwrite: true

# Uncomment this to set up an SSH connection to the workflow
# - name: Setup tmate SSH session
# uses: mxschmitt/action-tmate@v2
22 changes: 0 additions & 22 deletions .travis.yml

This file was deleted.

2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
![Build package](https://github.com/joomlatools/joomlatools-pages/workflows/Build%20package/badge.svg?branch=master)

# Joomlatools Pages

### What is Joomlatools Pages?
Expand Down
4 changes: 2 additions & 2 deletions code/administrator/components/com_pages/pages.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<extension type="component" version="0.17.1" method="upgrade">
<extension type="component" version="0.18.0-dev" method="upgrade">
<identifier>com:pages</identifier>
<name>com_pages</name>
<author>Joomlatools</author>
Expand All @@ -8,7 +8,7 @@
<license>GNU GPLv3 - http://www.gnu.org/licenses/gpl.html</license>
<authorEmail>[email protected]</authorEmail>
<authorUrl>www.joomlatools.com</authorUrl>
<version>0.17.1</version>
<version>0.18.0-dev</version>
<description>COM_PAGES_XML_DESCRIPTION</description>

<files folder="site/components/com_pages">
Expand Down
2 changes: 1 addition & 1 deletion code/administrator/components/com_pages/version.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
*/
class ComPagesVersion extends KObject
{
const VERSION = '0.17.1';
const VERSION = '0.18.0-dev';

public function getVersion()
{
Expand Down
37 changes: 25 additions & 12 deletions code/site/components/com_pages/class/locator/extension.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@ class ComPagesClassLocatorExtension extends KClassLocatorAbstract

public function locate($classname, $basepath = null)
{
if (substr($classname, 0, 9) === 'Extension')
if (substr($classname, 0, 3) === 'Ext')
{
$result = false;

$word = strtolower(preg_replace('/(?<=\\w)([A-Z])/', ' \\1', $classname));
$parts = explode(' ', $word);

Expand All @@ -28,23 +30,34 @@ public function locate($classname, $basepath = null)
$file = $package;
}

//Switch basepath
if(!$this->getNamespace($namespace)) {
$basepath = $this->getNamespace('\\');
} else {
$basepath = $this->getNamespace($namespace);
}

$path = '';

if (!empty($parts)) {
$path = implode('/', $parts) . '/';
}

$result = $basepath.'/'.$package.'/'.$path . $file.'.php';
$paths = [];

//Namespace paths
if($basepath = $this->getNamespace($namespace))
{
$paths[] = $basepath.'/'.$path . $file.'.php';
$paths[] = $basepath.'/'.$path . $file.'/'.$file.'.php';
}

///Fallback paths (unused)
if($basepath = $this->getNamespace('\\'))
{
$paths[] = $basepath.'/'.strtolower($namespace) .'/'.$path . $file.'.php';
$paths[] = $basepath.'/'.strtolower($namespace) .'/'.$path . $file.'/'.$file.'.php';
}

if(!is_file($result)) {
$result = $basepath.'/'.$package.'/'.$path . $file.'/'.$file.'.php';
foreach($paths as $path)
{
if(is_file($path))
{
$result = $path;
break;
}
}

return $result;
Expand Down
1 change: 1 addition & 0 deletions code/site/components/com_pages/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ protected function _initialize(KObjectConfig $config)
'data_namespaces' => array(),
'data_cache' => true,
'data_cache_path' => $config->site_path ? $config->site_path.'/cache/data' : false,
'data_cache_validation' => true,

'template_cache' => true,
'template_cache_path' => $config->site_path ? $config->site_path.'/cache/templates' : false,
Expand Down
2 changes: 1 addition & 1 deletion code/site/components/com_pages/controller/abstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ protected function _initialize(KObjectConfig $config)
parent::_initialize($config);
}

public function setPage(ComPagesPageObject $page)
public function setPage(ComPagesPageEntity $page)
{
$this->__page = $page;
return $this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ protected function _beforeRender(KControllerContextInterface $context)
if($path = ltrim(str_replace($menu_route->route, '', $page_route), '/'))
{
$pathway = JFactory::getApplication()->getPathway();
$router = $this->getObject('dispatcher')->getRouter();
$router = $this->getObject('router');

$segments = array();
foreach(explode('/', $path) as $segment)
Expand Down
4 changes: 2 additions & 2 deletions code/site/components/com_pages/controller/collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ protected function _initialize(KObjectConfig $config)
public function setModel($model)
{
//Create the collection model
$model = $this->getObject('com://site/pages.model.factory')
->createCollection($this->getPage()->path, $this->getRequest()->query->toArray(), false);
$model = $this->getObject('model.factory')
->createModel($this->getPage()->path, $this->getRequest()->query->toArray(), false);

return parent::setModel($model);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public function getPage()
return KObjectConfig::get('page');
}

public function setPage(ComPagesPageObject $page)
public function setPage(ComPagesPageEntity $page)
{
return KObjectConfig::set('page', $page);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,12 +253,12 @@ public function getCollections()
{
if(!isset($this->__collections))
{
foreach($this->getObject('com://site/pages.model.factory')->getCollections() as $name => $collection)
foreach($this->getObject('model.factory')->getModels() as $name => $model)
{
$this->__collections[] = [
'name' => $name,
'type' => $collection->getType(),
'hash' => $collection->getHash()
'type' => $model->getType(),
'hash' => $model->getHash()
];
}
}
Expand Down Expand Up @@ -358,7 +358,7 @@ public function isValid($page, $collections = array())
//If the collection has a hash validate it
if($collection['hash'])
{
$model = $this->getObject('com://site/pages.model.factory')->createCollection($collection['name']);
$model = $this->getObject('model.factory')->createModel($collection['name']);

if($collection['hash'] != $model->getHash()) {
$valid = false; break;
Expand Down
18 changes: 13 additions & 5 deletions code/site/components/com_pages/dispatcher/behavior/decoratable.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,22 @@ protected function _beforeSend(KDispatcherContextInterface $context)

$controller = $this->getObject('com:koowa.controller.page', array('response' => $response));

$controller->getView()
->setDecorator($decorator)
->setLayout($this->getLayout());
//Configure the page view
$view = $controller->getView();

$content = $controller->render();
//Do not include the style and script filters, keep both inline
if($context->page && $context->page->isDecorator())
{
$view->getConfig()->template_filters = [
'module', 'link', 'meta', 'title', 'message', 'version', 'form', 'asset', 'decorator'
];
}

$view->setDecorator($decorator)
->setLayout($this->getLayout());

//Set the result in the response
$response->setContent($content);
$response->setContent($controller->render());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function getPage()
return KObjectConfig::get('page');
}

public function setPage(ComPagesPageObject $page)
public function setPage(ComPagesPageEntity $page)
{
return KObjectConfig::set('page', $page);
}
Expand Down
39 changes: 30 additions & 9 deletions code/site/components/com_pages/dispatcher/http.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class ComPagesDispatcherHttp extends ComKoowaDispatcherHttp
{
private $__router;
private $__route;
private $__page;

public function __construct( KObjectConfig $config)
{
Expand Down Expand Up @@ -61,18 +62,36 @@ public function getRouter()
return $this->__router;
}

public function getPage()
{
$result = false;

if(!isset($this->__page))
{
if($route = $this->getRoute()) {
$this->__page = $route->getPage();
}
}

if(is_object($this->__page)) {
$result = $this->__page;
}

return $result;
}

public function getRoute()
{
$result = false;

if(!isset($this->__route))
{
$base = $this->getRequest()->getBasePath();
$url = urldecode($this->getRequest()->getUrl()->getPath());
$path = trim(str_replace(array($base, '/index.php'), '', $url), '/');
$base = $this->getRequest()->getBasePath();
$url = urldecode($this->getRequest()->getUrl()->getPath());
$path = trim(str_replace(array($base, '/index.php'), '', $url), '/');
$query = $this->getRequest()->getUrl()->getQuery(true);

$this->__route = $this->getRouter()->resolve('page:'.$path, $this->getRequest()->query->toArray());
$this->__route = $this->getRouter()->resolve('page:'.$path, $query);
}

if(is_object($this->__route)) {
Expand All @@ -86,12 +105,12 @@ public function getHttpMethods()
{
$methods = array('head', 'options');

if( $page = $this->getRoute()->getPage())
if($page = $this->getPage())
{
if($page->isSubmittable())
{
//Do not allow get on empty forms or collection, only used as API endpoints
if($this->getObject('page.registry')->getPageContent($page)) {
if($page->getContent()) {
$methods[] = 'get';
}
}
Expand All @@ -117,7 +136,7 @@ public function getHttpFormats()
{
$formats = array();

if($page = $this->getRoute()->getPage())
if($page = $this->getPage())
{
$formats = (array) $page->format;

Expand All @@ -144,12 +163,14 @@ protected function _beforeDispatch(KDispatcherContextInterface $context)
throw new KHttpExceptionNotFound('Page Not Found');
}


//Set the query in the request
$context->request->setQuery($route->query);

//Set the page in the context
$context->page = $route->getPage();
$context->page = $this->getPage();

//Set the route in the context
$context->route = $this->getRoute();

//Throw 415 if the media type is not allowed
$format = strtolower($context->request->getFormat());
Expand Down
Loading

0 comments on commit 1da63a1

Please sign in to comment.