librelist archives

« back to archive

Patch proposal

Patch proposal

From:
William Martin
Date:
2011-03-18 @ 21:00
Hi,

It's will be nice to setup the include path before loading configuration.
So you can use a helper class in the urls.php

  public static function generateURL($sub, $pages, $folder)
   {
       $appFolderName = basename($folder);
       $urls = array();

       foreach ($pages as $p) {
           $urls[] = array('regex' => '#^/(\w+)/'.$p.'$#',
                                      'view' =>
array('\\'.$appFolderName.'\views\Views', $p),
                                      'name' => $appFolderName.'_'.$p);
       }

       return array('regex' => '#^'.$sub.'#',
                    'sub' => $urls);
   }

William

--
---------------------------------------------------------
William MARTIN
wysman @NoSpAm@ gmail @DoT@ com

Re: [photon.users] Patch proposal

From:
Loic d'Anterroches
Date:
2011-03-19 @ 09:16
Hi William,

I understand the patch, but I do not understand your need to have access
to an helper class. Can you detail it a bit more to help me figure out
how you use Photon?

Thanks,
loïc

On 2011-03-18 22:00, William MARTIN wrote:
> Hi,
> 
> It's will be nice to setup the include path before loading configuration.
> So you can use a helper class in the urls.php
> 
>   public static function generateURL($sub, $pages, $folder)
>    {
>        $appFolderName = basename($folder);
>        $urls = array();
> 
>        foreach ($pages as $p) {
>            $urls[] = array('regex' => '#^/(\w+)/'.$p.'$#',
>                                       'view' =>
> array('\\'.$appFolderName.'\views\Views', $p),
>                                       'name' => $appFolderName.'_'.$p);
>        }
> 
>        return array('regex' => '#^'.$sub.'#',
>                     'sub' => $urls);
>    }
> 
> William
> 
> --
> ---------------------------------------------------------
> William MARTIN
> wysman @NoSpAm@ gmail @DoT@ com

Re: [photon.users] Patch proposal

From:
William Martin
Date:
2011-03-19 @ 09:37
Hi loic,

I use it to make a reverse proxy to serve small website with the same
architecture.
Those sites are static but we need to easily update translation on it.

My urls.php file will be like that:
$urls_mapping[] = \webutils\hostwrapper\URL::generateURL(include
__DIR__ . '/apps/www_power_lan_com/config.php');

The config file is like :
return array('authority' => 'www.power-lan.com',
             'pages' => array('home' => 'Home',
                              'services' => 'Services',
                              'opensources' => 'Open sources',
                              'contact' => 'Contact'),
             'title' => 'Power-Lan',
             'language_available' => array('fr', 'en'),
             'folder' => __DIR__,
             );

I attach the app webutils.
In this app, i have a middleware class which tag the path requested.
And i have patched photon to remove this tag when he generate url

    public static function forView($view, $params=array(),
$get_params=array(), $encoded=true)
    {
        $url = self::generate(Conf::f('base_urls') .
                              self::reverse(Conf::f('urls', array()),
$view, $params),
                              $get_params, $encoded);
        $url = substr($url, strpos($url, '/'));
        return $url;
     }


William

On Sat, Mar 19, 2011 at 10:16 AM, Loic d'Anterroches <loic@ceondo.com> wrote:
> Hi William,
>
> I understand the patch, but I do not understand your need to have access
> to an helper class. Can you detail it a bit more to help me figure out
> how you use Photon?
>
> Thanks,
> loïc
>
> On 2011-03-18 22:00, William MARTIN wrote:
>> Hi,
>>
>> It's will be nice to setup the include path before loading configuration.
>> So you can use a helper class in the urls.php
>>
>>   public static function generateURL($sub, $pages, $folder)
>>    {
>>        $appFolderName = basename($folder);
>>        $urls = array();
>>
>>        foreach ($pages as $p) {
>>            $urls[] = array('regex' => '#^/(\w+)/'.$p.'$#',
>>                                       'view' =>
>> array('\\'.$appFolderName.'\views\Views', $p),
>>                                       'name' => $appFolderName.'_'.$p);
>>        }
>>
>>        return array('regex' => '#^'.$sub.'#',
>>                     'sub' => $urls);
>>    }
>>
>> William
>>
>> --
>> ---------------------------------------------------------
>> William MARTIN
>> wysman @NoSpAm@ gmail @DoT@ com
>



-- 
---------------------------------------------------------
William MARTIN
wysman @NoSpAm@ gmail @DoT@ com

Re: [photon.users] Patch proposal

From:
Loic d'Anterroches
Date:
2011-03-19 @ 10:06
Hi William,

I must say, I am a bit lost with what you are doing, but, ok I will
apply the patch.

Just one thing with respect to coding standards:

- put a blank line before your "return" statement.

    public static function forView($view, $params=array(),
$get_params=array(), $encoded=true)
    {
        $url = self::generate(Conf::f('base_urls') .
                              self::reverse(Conf::f('urls', array()),
$view, $params),
                              $get_params, $encoded);
        $url = substr($url, strpos($url, '/'));

        return $url;
     }

this makes the "return" pop out.

- put a space around the "." when doing string concatenation:

        foreach (array_keys($config['pages']) as $p) {
            $urls[] = array('regex' => '#^/(\w+)/' . $p . '$#',
                                       'view' =>
array('\webutils\hostwrapper\Views', $p),
                                       'name' => $appFolderName . '_' . $p,
                                       'params' => $config);
        }

I have a good migrena today, so I will wait a bit to apply the patch,
piouPiouM, you can apply it if you have time.

loïc
On 2011-03-19 10:37, William MARTIN wrote:
> Hi loic,
> 
> I use it to make a reverse proxy to serve small website with the same
> architecture.
> Those sites are static but we need to easily update translation on it.
> 
> My urls.php file will be like that:
> $urls_mapping[] = \webutils\hostwrapper\URL::generateURL(include
> __DIR__ . '/apps/www_power_lan_com/config.php');
> 
> The config file is like :
> return array('authority' => 'www.power-lan.com',
>              'pages' => array('home' => 'Home',
>                               'services' => 'Services',
>                               'opensources' => 'Open sources',
>                               'contact' => 'Contact'),
>              'title' => 'Power-Lan',
>              'language_available' => array('fr', 'en'),
>              'folder' => __DIR__,
>              );
> 
> I attach the app webutils.
> In this app, i have a middleware class which tag the path requested.
> And i have patched photon to remove this tag when he generate url
> 
>     public static function forView($view, $params=array(),
> $get_params=array(), $encoded=true)
>     {
>         $url = self::generate(Conf::f('base_urls') .
>                               self::reverse(Conf::f('urls', array()),
> $view, $params),
>                               $get_params, $encoded);
>         $url = substr($url, strpos($url, '/'));
>         return $url;
>      }
> 
> 
> William
> 
> On Sat, Mar 19, 2011 at 10:16 AM, Loic d'Anterroches <loic@ceondo.com> wrote:
>> Hi William,
>>
>> I understand the patch, but I do not understand your need to have access
>> to an helper class. Can you detail it a bit more to help me figure out
>> how you use Photon?
>>
>> Thanks,
>> loïc
>>
>> On 2011-03-18 22:00, William MARTIN wrote:
>>> Hi,
>>>
>>> It's will be nice to setup the include path before loading configuration.
>>> So you can use a helper class in the urls.php
>>>
>>>   public static function generateURL($sub, $pages, $folder)
>>>    {
>>>        $appFolderName = basename($folder);
>>>        $urls = array();
>>>
>>>        foreach ($pages as $p) {
>>>            $urls[] = array('regex' => '#^/(\w+)/'.$p.'$#',
>>>                                       'view' =>
>>> array('\\'.$appFolderName.'\views\Views', $p),
>>>                                       'name' => $appFolderName.'_'.$p);
>>>        }
>>>
>>>        return array('regex' => '#^'.$sub.'#',
>>>                     'sub' => $urls);
>>>    }
>>>
>>> William
>>>
>>> --
>>> ---------------------------------------------------------
>>> William MARTIN
>>> wysman @NoSpAm@ gmail @DoT@ com
>>
> 
> 
> 

Re: [photon.users] Patch proposal

From:
Mehdi Kabab
Date:
2011-03-19 @ 15:16
Hi all,

It's applied in the commit 51d414f.

Thx William.


--
Mehdi Kabab

My french book about Gimp: http://gimp4you.eu.org/livre/
Blog: http://pioupioum.fr/
Twitter: http://twitter.com/piouPiouM

Le 19 mars 2011 à 11:06, Loic d'Anterroches a écrit :

> Hi William,
> 
> I must say, I am a bit lost with what you are doing, but, ok I will
> apply the patch.
> 
> Just one thing with respect to coding standards:
> 
> - put a blank line before your "return" statement.
> 
>    public static function forView($view, $params=array(),
> $get_params=array(), $encoded=true)
>    {
>        $url = self::generate(Conf::f('base_urls') .
>                              self::reverse(Conf::f('urls', array()),
> $view, $params),
>                              $get_params, $encoded);
>        $url = substr($url, strpos($url, '/'));
> 
>        return $url;
>     }
> 
> this makes the "return" pop out.
> 
> - put a space around the "." when doing string concatenation:
> 
>        foreach (array_keys($config['pages']) as $p) {
>            $urls[] = array('regex' => '#^/(\w+)/' . $p . '$#',
>                                       'view' =>
> array('\webutils\hostwrapper\Views', $p),
>                                       'name' => $appFolderName . '_' . $p,
>                                       'params' => $config);
>        }
> 
> I have a good migrena today, so I will wait a bit to apply the patch,
> piouPiouM, you can apply it if you have time.
> 
> loïc
> On 2011-03-19 10:37, William MARTIN wrote:
>> Hi loic,
>> 
>> I use it to make a reverse proxy to serve small website with the same
>> architecture.
>> Those sites are static but we need to easily update translation on it.
>> 
>> My urls.php file will be like that:
>> $urls_mapping[] = \webutils\hostwrapper\URL::generateURL(include
>> __DIR__ . '/apps/www_power_lan_com/config.php');
>> 
>> The config file is like :
>> return array('authority' => 'www.power-lan.com',
>>             'pages' => array('home' => 'Home',
>>                              'services' => 'Services',
>>                              'opensources' => 'Open sources',
>>                              'contact' => 'Contact'),
>>             'title' => 'Power-Lan',
>>             'language_available' => array('fr', 'en'),
>>             'folder' => __DIR__,
>>             );
>> 
>> I attach the app webutils.
>> In this app, i have a middleware class which tag the path requested.
>> And i have patched photon to remove this tag when he generate url
>> 
>>    public static function forView($view, $params=array(),
>> $get_params=array(), $encoded=true)
>>    {
>>        $url = self::generate(Conf::f('base_urls') .
>>                              self::reverse(Conf::f('urls', array()),
>> $view, $params),
>>                              $get_params, $encoded);
>>        $url = substr($url, strpos($url, '/'));
>>        return $url;
>>     }
>> 
>> 
>> William
>> 
>> On Sat, Mar 19, 2011 at 10:16 AM, Loic d'Anterroches <loic@ceondo.com> wrote:
>>> Hi William,
>>> 
>>> I understand the patch, but I do not understand your need to have access
>>> to an helper class. Can you detail it a bit more to help me figure out
>>> how you use Photon?
>>> 
>>> Thanks,
>>> loïc
>>> 
>>> On 2011-03-18 22:00, William MARTIN wrote:
>>>> Hi,
>>>> 
>>>> It's will be nice to setup the include path before loading configuration.
>>>> So you can use a helper class in the urls.php
>>>> 
>>>>  public static function generateURL($sub, $pages, $folder)
>>>>   {
>>>>       $appFolderName = basename($folder);
>>>>       $urls = array();
>>>> 
>>>>       foreach ($pages as $p) {
>>>>           $urls[] = array('regex' => '#^/(\w+)/'.$p.'$#',
>>>>                                      'view' =>
>>>> array('\\'.$appFolderName.'\views\Views', $p),
>>>>                                      'name' => $appFolderName.'_'.$p);
>>>>       }
>>>> 
>>>>       return array('regex' => '#^'.$sub.'#',
>>>>                    'sub' => $urls);
>>>>   }
>>>> 
>>>> William
>>>> 
>>>> --
>>>> ---------------------------------------------------------
>>>> William MARTIN
>>>> wysman @NoSpAm@ gmail @DoT@ com
>>> 
>> 
>> 
>> 

Re: [photon.users] Patch proposal

From:
William Martin
Date:
2011-03-19 @ 16:11
Thanks

On Sat, Mar 19, 2011 at 4:16 PM, Mehdi KABAB <mehdi@pioupioum.fr> wrote:

> Hi all,
>
> It's applied in the commit 51d414f.
>
> Thx William.
>
>
> --
> Mehdi Kabab
>
> My french book about Gimp: http://gimp4you.eu.org/livre/
> Blog: http://pioupioum.fr/
> Twitter: http://twitter.com/piouPiouM
>
> Le 19 mars 2011 à 11:06, Loic d'Anterroches a écrit :
>
> > Hi William,
> >
> > I must say, I am a bit lost with what you are doing, but, ok I will
> > apply the patch.
> >
> > Just one thing with respect to coding standards:
> >
> > - put a blank line before your "return" statement.
> >
> >    public static function forView($view, $params=array(),
> > $get_params=array(), $encoded=true)
> >    {
> >        $url = self::generate(Conf::f('base_urls') .
> >                              self::reverse(Conf::f('urls', array()),
> > $view, $params),
> >                              $get_params, $encoded);
> >        $url = substr($url, strpos($url, '/'));
> >
> >        return $url;
> >     }
> >
> > this makes the "return" pop out.
> >
> > - put a space around the "." when doing string concatenation:
> >
> >        foreach (array_keys($config['pages']) as $p) {
> >            $urls[] = array('regex' => '#^/(\w+)/' . $p . '$#',
> >                                       'view' =>
> > array('\webutils\hostwrapper\Views', $p),
> >                                       'name' => $appFolderName . '_' .
> $p,
> >                                       'params' => $config);
> >        }
> >
> > I have a good migrena today, so I will wait a bit to apply the patch,
> > piouPiouM, you can apply it if you have time.
> >
> > loïc
> > On 2011-03-19 10:37, William MARTIN wrote:
> >> Hi loic,
> >>
> >> I use it to make a reverse proxy to serve small website with the same
> >> architecture.
> >> Those sites are static but we need to easily update translation on it.
> >>
> >> My urls.php file will be like that:
> >> $urls_mapping[] = \webutils\hostwrapper\URL::generateURL(include
> >> __DIR__ . '/apps/www_power_lan_com/config.php');
> >>
> >> The config file is like :
> >> return array('authority' => 'www.power-lan.com',
> >>             'pages' => array('home' => 'Home',
> >>                              'services' => 'Services',
> >>                              'opensources' => 'Open sources',
> >>                              'contact' => 'Contact'),
> >>             'title' => 'Power-Lan',
> >>             'language_available' => array('fr', 'en'),
> >>             'folder' => __DIR__,
> >>             );
> >>
> >> I attach the app webutils.
> >> In this app, i have a middleware class which tag the path requested.
> >> And i have patched photon to remove this tag when he generate url
> >>
> >>    public static function forView($view, $params=array(),
> >> $get_params=array(), $encoded=true)
> >>    {
> >>        $url = self::generate(Conf::f('base_urls') .
> >>                              self::reverse(Conf::f('urls', array()),
> >> $view, $params),
> >>                              $get_params, $encoded);
> >>        $url = substr($url, strpos($url, '/'));
> >>        return $url;
> >>     }
> >>
> >>
> >> William
> >>
> >> On Sat, Mar 19, 2011 at 10:16 AM, Loic d'Anterroches <loic@ceondo.com>
> wrote:
> >>> Hi William,
> >>>
> >>> I understand the patch, but I do not understand your need to have
> access
> >>> to an helper class. Can you detail it a bit more to help me figure out
> >>> how you use Photon?
> >>>
> >>> Thanks,
> >>> loïc
> >>>
> >>> On 2011-03-18 22:00, William MARTIN wrote:
> >>>> Hi,
> >>>>
> >>>> It's will be nice to setup the include path before loading
> configuration.
> >>>> So you can use a helper class in the urls.php
> >>>>
> >>>>  public static function generateURL($sub, $pages, $folder)
> >>>>   {
> >>>>       $appFolderName = basename($folder);
> >>>>       $urls = array();
> >>>>
> >>>>       foreach ($pages as $p) {
> >>>>           $urls[] = array('regex' => '#^/(\w+)/'.$p.'$#',
> >>>>                                      'view' =>
> >>>> array('\\'.$appFolderName.'\views\Views', $p),
> >>>>                                      'name' => $appFolderName.'_'.$p);
> >>>>       }
> >>>>
> >>>>       return array('regex' => '#^'.$sub.'#',
> >>>>                    'sub' => $urls);
> >>>>   }
> >>>>
> >>>> William
> >>>>
> >>>> --
> >>>> ---------------------------------------------------------
> >>>> William MARTIN
> >>>> wysman @NoSpAm@ gmail @DoT@ com
> >>>
> >>
> >>
> >>
>
>


-- 
---------------------------------------------------------
William MARTIN
wysman @NoSpAm@ gmail @DoT@ com