[G3/Patch] More flexibility with themes

View: New views
7 Messages — Rating Filter:   Alert me  

[G3/Patch] More flexibility with themes

by Romain LE DISEZ-5 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I didn't found a link to create an account in Trac so I post here...

=====================

Hi all,

when I tried to create a theme to customise the uploader interface, I
found that it was not possible to override the files in core/views/.
It's a problem for a good themability.

Currently G3 looks for views in :
 - core/views/
 - theme/<active theme>/views/
 - module/<module>/views/

The first file found is selected. The first directory can't be changed,
it will always be core/views/.

The patch override_core_views.patch change this directories list to :
 - core/views/
 - theme/<active theme>/views/
 - theme/<default theme>/views/
 - module/<module>/views/

Depending where you are <default theme> is "default" or "admin_default".

If you apply this patch you could move :
 - core/views/admin_*  to   theme/admin_default/views/
 - core/views/*        to   theme/default/views/
   (except form.html.php, this view seems to be a special case)

After the views have been moved, it's easy to customise all parts of G3.
Just create a file theme/mytheme/views/simple_uploader.html.php and it
will override the default uploader. If you don't create one in your
custom theme, it will automatically choose
theme/default/views/simple_uploader.html.php


------------


My goal was just to create a custom uploader so it was not necessary to
have a copy of css/, js/ and image/.

When, in a view, you call $theme->url('myfile'), the method only returns
the URL /theme/<active theme>/myfile

With the second patch (default_theme_content.patch), the method returns
the same URL except if the file doesn't exist AND the same file in the
<default theme> exists.



I'm not sure the second patch is a good idea, there is pro (themes that
use theses scripts will stay up to date) and con could create some
confusion), but I think the first one fixes a serious issue.

Greetings.

[default_theme_content.patch]

Index: core/libraries/Theme_View.php
===================================================================
--- core/libraries/Theme_View.php (révision 20900)
+++ core/libraries/Theme_View.php (copie de travail)
@@ -68,7 +68,17 @@
   }
 
   public function url($path, $absolute_url=false) {
-    $arg = "themes/{$this->theme_name}/$path";
+    $default_theme = (Router::$controller == "admin")
+        ? "admin_default"
+        : "default";
+
+    if (!file_exists(THEMEPATH . "{$this->theme_name}/$path")
+        && file_exists(THEMEPATH . "$default_theme/$path")) {
+      $arg = "themes/$default_theme/$path";
+    } else {
+      $arg = "themes/{$this->theme_name}/$path";
+    }
+    
     return $absolute_url ? url::abs_file($arg) : url::file($arg);
   }
 


[override_core_views.patch]

Index: core/helpers/theme.php
===================================================================
--- core/helpers/theme.php (révision 20900)
+++ core/helpers/theme.php (copie de travail)
@@ -31,8 +31,10 @@
   static function load_themes() {
     $modules = Kohana::config("core.modules");
     if (Router::$controller == "admin") {
+      array_unshift($modules, THEMEPATH . "admin_default");
       array_unshift($modules, THEMEPATH . module::get_var("core", "active_admin_theme"));
     } else {
+      array_unshift($modules, THEMEPATH . "default");
       array_unshift($modules, THEMEPATH . module::get_var("core", "active_site_theme"));
     }
     Kohana::config_set("core.modules", $modules);


------------------------------------------------------------------------------
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT
is a gathering of tech-side developers & brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing, &
iPhoneDevCamp asthey present alongside digital heavyweights like Barbarian
Group, R/GA, & Big Spaceship. http://www.creativitycat.com 
__[ g a l l e r y - d e v e l ]_________________________

[ list info/archive --> http://gallery.sf.net/lists.php ]
[ gallery info/FAQ/download --> http://gallery.sf.net ]

Re: [G3/Patch] More flexibility with themes

by Bharat Mediratta :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Romain LE DISEZ wrote:
> I didn't found a link to create an account in Trac so I post here...

If you create an account on sourceforge.net, you can log in and use that
account to create Trac tickets.  But it's fine to have this discussion here.

> when I tried to create a theme to customise the uploader interface, I
> found that it was not possible to override the files in core/views/.
> It's a problem for a good themability.
>
> Currently G3 looks for views in :
>  - core/views/
>  - theme/<active theme>/views/
>  - module/<module>/views/
>
> The first file found is selected. The first directory can't be changed,
> it will always be core/views/.

Yes, that is a serious problem.  The order I would prefer to see is:
  1) theme/ACTIVE_THEME/views
  2) modules/MODULE_1/views
  3) modules/MODULE_2/views
     ...
  N) core/views

This allows any module to override the core, and the theme to override
everything.  This doesn't solve the problem of conflicting modules
trying to override each other, but I'll save that problem for another day.

The problem as I see it is that Kohana::include_paths() puts APPPATH
first.  I don't understand why it forces that requirement, but since
it's a private member of a final class, they don't make it easy for us
to get around that issue.

So, I changed the Kohana code in r20909 and filed this ticket:
  http://dev.kohanaphp.com/issues/1695

Once you svn up, you should be able to override any view, controller,
library or helper in your theme.  Let me know if this doesn't fully
solve your problem.

-Bharat


------------------------------------------------------------------------------
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT
is a gathering of tech-side developers & brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing, &
iPhoneDevCamp asthey present alongside digital heavyweights like Barbarian
Group, R/GA, & Big Spaceship. http://www.creativitycat.com 
__[ g a l l e r y - d e v e l ]_________________________

[ list info/archive --> http://gallery.sf.net/lists.php ]
[ gallery info/FAQ/download --> http://gallery.sf.net ]

Re: [G3/Patch] More flexibility with themes

by Romain LE DISEZ-5 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Le samedi 23 mai 2009 à 23:47 -0700, Bharat Mediratta a écrit :

> Yes, that is a serious problem.  The order I would prefer to see is:
>   1) theme/ACTIVE_THEME/views
>   2) modules/MODULE_1/views
>   3) modules/MODULE_2/views
>      ...
>   N) core/views
>
> This allows any module to override the core, and the theme to override
> everything.  This doesn't solve the problem of conflicting modules
> trying to override each other, but I'll save that problem for another day.
>
> The problem as I see it is that Kohana::include_paths() puts APPPATH
> first.  I don't understand why it forces that requirement, but since
> it's a private member of a final class, they don't make it easy for us
> to get around that issue.
>
> So, I changed the Kohana code in r20909 and filed this ticket:
>   http://dev.kohanaphp.com/issues/1695
>
> Once you svn up, you should be able to override any view, controller,
> library or helper in your theme.  Let me know if this doesn't fully
> solve your problem.

Your patch doesn't do the same as mine (but they are not incompatible).

My patch was a way to provide inheritance capabilities for the themes.
But the problem with it is that the themes can only inherit of
"default". Inheritance can be generalized by adding a variable to
theme.info :
    parent = <theme name>

But I'm not sure you are interested with that, so I will not waste time
on it unless you ask me. My second patch was also about inheritance...

So for now, with your patch, I can't create a theme with only :
    mytheme/
       theme.info
       views/
          simple_uploader.html.php
(I must copy the default theme and add the file
simple_uploader.html.php)

Greetings.


------------------------------------------------------------------------------
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT
is a gathering of tech-side developers & brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing, &
iPhoneDevCamp asthey present alongside digital heavyweights like Barbarian
Group, R/GA, & Big Spaceship. http://www.creativitycat.com 
__[ g a l l e r y - d e v e l ]_________________________

[ list info/archive --> http://gallery.sf.net/lists.php ]
[ gallery info/FAQ/download --> http://gallery.sf.net ]

Re: [G3/Patch] More flexibility with themes

by Bharat Mediratta :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Romain LE DISEZ wrote:

> My patch was a way to provide inheritance capabilities for the themes.
> But the problem with it is that the themes can only inherit of
> "default". Inheritance can be generalized by adding a variable to
> theme.info :
>     parent = <theme name>
>
> But I'm not sure you are interested with that, so I will not waste time
> on it unless you ask me. My second patch was also about inheritance...
>
> So for now, with your patch, I can't create a theme with only :
>     mytheme/
>        theme.info
>        views/
>           simple_uploader.html.php
> (I must copy the default theme and add the file
> simple_uploader.html.php)

We made a decision early on that we'd try to avoid things like theme
inheritance because we were afraid that added complexity here would be
difficult to explain to themers.  Instead we opted for what I believe to
be a more commonplace theming approach: cut and paste.  I figure that it
is trivial for a themer to just make a new variant of a theme with the
one or two changes that they want, and if we make cloning themes really
easy then we'll have a proliferation of simpler themes to work with.

thoughts?

------------------------------------------------------------------------------
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT
is a gathering of tech-side developers & brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing, &
iPhoneDevCamp as they present alongside digital heavyweights like Barbarian
Group, R/GA, & Big Spaceship. http://p.sf.net/sfu/creativitycat-com 
__[ g a l l e r y - d e v e l ]_________________________

[ list info/archive --> http://gallery.sf.net/lists.php ]
[ gallery info/FAQ/download --> http://gallery.sf.net ]

Re: [G3/Patch] More flexibility with themes

by Chad Kieffer :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On May 26, 2009, at 11:14 AM, Bharat Mediratta <bharat@...>  
wrote:

> Romain LE DISEZ wrote:
>> My patch was a way to provide inheritance capabilities for the  
>> themes.
>> But the problem with it is that the themes can only inherit of
>> "default". Inheritance can be generalized by adding a variable to
>> theme.info :
>>    parent = <theme name>
>>
>> But I'm not sure you are interested with that, so I will not waste  
>> time
>> on it unless you ask me. My second patch was also about  
>> inheritance...
>>
>> So for now, with your patch, I can't create a theme with only :
>>    mytheme/
>>       theme.info
>>       views/
>>          simple_uploader.html.php
>> (I must copy the default theme and add the file
>> simple_uploader.html.php)
>
> We made a decision early on that we'd try to avoid things like theme
> inheritance because we were afraid that added complexity here would be
> difficult to explain to themers.  Instead we opted for what I  
> believe to
> be a more commonplace theming approach: cut and paste.  I figure  
> that it
> is trivial for a themer to just make a new variant of a theme with the
> one or two changes that they want, and if we make cloning themes  
> really
> easy then we'll have a proliferation of simpler themes to work with.
>
> thoughts?

I still believe this is the right choice and inline with current CMS  
theming systems. I believe copy/paste approach reaches the largest  
segment  of themers.

Setting up inheritance complicated themes for end users by adding  
dependencies. This may be okay for module developers to work with but  
I'm certain it'll be a turnoff to designers.

------------------------------------------------------------------------------
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT
is a gathering of tech-side developers & brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing, &
iPhoneDevCamp as they present alongside digital heavyweights like Barbarian
Group, R/GA, & Big Spaceship. http://p.sf.net/sfu/creativitycat-com 
__[ g a l l e r y - d e v e l ]_________________________

[ list info/archive --> http://gallery.sf.net/lists.php ]
[ gallery info/FAQ/download --> http://gallery.sf.net ]

Re: [G3/Patch] More flexibility with themes

by Gaynor McCartney :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Chad wrote:-
>This may be okay for module developers to work with but I'm certain it'll
>be a turnoff to designers<

Sounds like Chad is considering people like me - I have found Gallery a
wonderul place to start learning to play with the way my galleries look and
work. I don;t have formal computing training, and yet have learned a lot
here.

(My localserver problams seem to be solved do I am getting back to this
again).
I enjoyed the earlier versions of Gallery where there were straightforward
instructions "How to change a theme", easy to follow without a lot of geek
knowledge - easy for Grandma with Windows OS and just a little ftp etc
knowledge to Change the header, general appearance and colours.

To my mind, Gallery does a great service to people like me, giving us an
opportunity to advance our knowledge and feel proud of our achievement.

Thanks Chad and others for keeping us in mind.

Gaynor - (old woman, amateur geek)


----- Original Message -----
From: "Chad Kieffer" <chad@...>
To: "Bharat Mediratta" <bharat@...>
Cc: "Gallery Community" <gallery-devel@...>
Sent: Wednesday, May 27, 2009 5:55 AM
Subject: Re: [Gallery-devel] [G3/Patch] More flexibility with themes


> On May 26, 2009, at 11:14 AM, Bharat Mediratta <bharat@...>
> wrote:
>
>> Romain LE DISEZ wrote:
>>> My patch was a way to provide inheritance capabilities for the
>>> themes.
>>> But the problem with it is that the themes can only inherit of
>>> "default". Inheritance can be generalized by adding a variable to
>>> theme.info :
>>>    parent = <theme name>
>>>
>>> But I'm not sure you are interested with that, so I will not waste
>>> time
>>> on it unless you ask me. My second patch was also about
>>> inheritance...
>>>
>>> So for now, with your patch, I can't create a theme with only :
>>>    mytheme/
>>>       theme.info
>>>       views/
>>>          simple_uploader.html.php
>>> (I must copy the default theme and add the file
>>> simple_uploader.html.php)
>>
>> We made a decision early on that we'd try to avoid things like theme
>> inheritance because we were afraid that added complexity here would be
>> difficult to explain to themers.  Instead we opted for what I
>> believe to
>> be a more commonplace theming approach: cut and paste.  I figure
>> that it
>> is trivial for a themer to just make a new variant of a theme with the
>> one or two changes that they want, and if we make cloning themes
>> really
>> easy then we'll have a proliferation of simpler themes to work with.
>>
>> thoughts?
>
> I still believe this is the right choice and inline with current CMS
> theming systems. I believe copy/paste approach reaches the largest
> segment  of themers.
>
> Setting up inheritance complicated themes for end users by adding
> dependencies. This may be okay for module developers to work with but
> I'm certain it'll be a turnoff to designers.
>
> ------------------------------------------------------------------------------
> Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT
> is a gathering of tech-side developers & brand creativity professionals.
> Meet
> the minds behind Google Creative Lab, Visual Complexity, Processing, &
> iPhoneDevCamp as they present alongside digital heavyweights like
> Barbarian
> Group, R/GA, & Big Spaceship. http://p.sf.net/sfu/creativitycat-com
> __[ g a l l e r y - d e v e l ]_________________________
>
> [ list info/archive --> http://gallery.sf.net/lists.php ]
> [ gallery info/FAQ/download --> http://gallery.sf.net ]


------------------------------------------------------------------------------
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT
is a gathering of tech-side developers & brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing, &
iPhoneDevCamp as they present alongside digital heavyweights like Barbarian
Group, R/GA, & Big Spaceship. http://p.sf.net/sfu/creativitycat-com 
__[ g a l l e r y - d e v e l ]_________________________

[ list info/archive --> http://gallery.sf.net/lists.php ]
[ gallery info/FAQ/download --> http://gallery.sf.net ]

Re: [G3/Patch] More flexibility with themes

by Romain LE DISEZ-5 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Le mardi 26 mai 2009 à 11:55 -0600, Chad Kieffer a écrit :
> Setting up inheritance complicated themes for end users by adding  
> dependencies. This may be okay for module developers to work with but  
> I'm certain it'll be a turnoff to designers.

That's a strong point. Without a "themes installer" with a central repo,
installation of a theme that inherits of an other will be more
complicated.


------------------------------------------------------------------------------
OpenSolaris 2009.06 is a cutting edge operating system for enterprises
looking to deploy the next generation of Solaris that includes the latest
innovations from Sun and the OpenSource community. Download a copy and
enjoy capabilities such as Networking, Storage and Virtualization.
Go to: http://p.sf.net/sfu/opensolaris-get
__[ g a l l e r y - d e v e l ]_________________________

[ list info/archive --> http://gallery.sf.net/lists.php ]
[ gallery info/FAQ/download --> http://gallery.sf.net ]