Re: [Radiant] Changing page layout on-the-fly?

2009-07-27 Thread Mamed Mamedov
Hi everybody!

Here how I have resolved my problem with changing page's layout on-the-fly:)
I have created my own extension folder with my namespace-tags for unusual
tasks.

  desc %{
Works like design switcher.
  }
  tag 'gsession:design' do |tag|
  design_type = request.session[gsession_design]
  if design_type == nil
  design_type = GenieSessionExtension.defaults[:design]
  request.session[gsession_design] = design_type
  end
  design_type.strip!
  if layout = Layout.find_by_name(tag.attr[#{design_type}])
  tag.globals.page.layout = layout
  tag.globals.page.render
  end
  end

Usage:
I have created layout named master-index with only one line in it:
r:gsession:design full=full-index light=light-index /

With 2 arguments, which describes layout names for 'full' and 'light'
version of my site. You can define 'gsession_*design*' session variable at
any time by hitting, for example:* /genie/set/design/light*
All my pages have selected 'master-index' layout.
That is all, while page is rendered my tag switches current layout to
'full-index' or 'light-index' named layouts.

Waiting for comments ... Thank you:)


Regards,
Mamed Mamedov




On Thu, Jul 16, 2009 at 6:16 PM, Sean Cribbs seancri...@gmail.com wrote:

 If all of your pages have the same layout at any time, make sure all
 descendant pages have their layout set to inherit and then your extension
 could change the layout on the root page.
 However, it would not be trivial to do this on a per-user basis.  Have you
 considered something like a combination of Javascript and CSS that lets your
 users switch layouts?

 Sean

 Mamed Mamedov wrote:

 Hi everybody!

 I have a little question: how can I change page's layout from within my
 extension?
 Problem is, that I have 2 different page layouts for my site: [
 full-version
 and light-version ].
 I want to write a mini-extension to switch between designs of my site
 throw
 hitting: /design/set/full and /design/set/light or /design/reset
 And I'am saving current design variable in current user's session.

 And now, just need to change current page's layout on the fly accordingly
 to
 session value.
 
 Regards,
 Mamed Mamedov
 ___
 Radiant mailing list
 Post:   Radiant@radiantcms.org
 Search: http://radiantcms.org/mailing-list/search/
 Site:   http://lists.radiantcms.org/mailman/listinfo/radiant




 ___
 Radiant mailing list
 Post:   Radiant@radiantcms.org
 Search: http://radiantcms.org/mailing-list/search/
 Site:   http://lists.radiantcms.org/mailman/listinfo/radiant

___
Radiant mailing list
Post:   Radiant@radiantcms.org
Search: http://radiantcms.org/mailing-list/search/
Site:   http://lists.radiantcms.org/mailman/listinfo/radiant


Re: [Radiant] Changing page layout on-the-fly?

2009-07-27 Thread Jim Gay


On Jul 27, 2009, at 2:24 PM, Mamed Mamedov wrote:


Hi everybody!

Here how I have resolved my problem with changing page's layout on- 
the-fly:)
I have created my own extension folder with my namespace-tags for  
unusual

tasks.

 desc %{
   Works like design switcher.
 }
 tag 'gsession:design' do |tag|
 design_type = request.session[gsession_design]
 if design_type == nil
 design_type = GenieSessionExtension.defaults[:design]
 request.session[gsession_design] = design_type
 end
 design_type.strip!
 if layout = Layout.find_by_name(tag.attr[#{design_type}])
 tag.globals.page.layout = layout
 tag.globals.page.render
 end
 end

Usage:
I have created layout named master-index with only one line in it:
r:gsession:design full=full-index light=light-index /

With 2 arguments, which describes layout names for 'full' and 'light'
version of my site. You can define 'gsession_*design*' session  
variable at

any time by hitting, for example:* /genie/set/design/light*
All my pages have selected 'master-index' layout.
That is all, while page is rendered my tag switches current layout to
'full-index' or 'light-index' named layouts.

Waiting for comments ... Thank you:)


Have you disabled caching to do this?




Regards,
Mamed Mamedov




On Thu, Jul 16, 2009 at 6:16 PM, Sean Cribbs seancri...@gmail.com  
wrote:



If all of your pages have the same layout at any time, make sure all
descendant pages have their layout set to inherit and then your  
extension

could change the layout on the root page.
However, it would not be trivial to do this on a per-user basis.   
Have you
considered something like a combination of Javascript and CSS that  
lets your

users switch layouts?

Sean

Mamed Mamedov wrote:


Hi everybody!

I have a little question: how can I change page's layout from  
within my

extension?
Problem is, that I have 2 different page layouts for my site: [
full-version
and light-version ].
I want to write a mini-extension to switch between designs of my  
site

throw
hitting: /design/set/full and /design/set/light or /design/reset
And I'am saving current design variable in current user's session.

And now, just need to change current page's layout on the fly  
accordingly

to
session value.

Regards,
Mamed Mamedov

___
Radiant mailing list
Post:   Radiant@radiantcms.org
Search: http://radiantcms.org/mailing-list/search/
Site:   http://lists.radiantcms.org/mailman/listinfo/radiant


Re: [Radiant] Changing page layout on-the-fly?

2009-07-27 Thread Mamed Mamedov
No, I didn't disabled cache, but I'm using 'translator' extension which
changes behaviour of radiant's caching subsystem.
Here is my some changes to *translate_response_cache.rb*:
  ResponseCache.class_eval {
# in here, we're just adding a two-letter language suffix to cached
pages to make sure that the wrong
# language doesn't get served up because it has been cached
inappropriately. we could change this to
# cache in a separate directory (i.e. en/), but for now, we're just
adding the extension
private
  def translator_path(path)
#path =~ /\.css|\.js$/ ? path :
kk_request.suffixize(kk_request.language)
path =~ /\.css|\.js$/ ? path : [ path,
kk_request.session[gsession_color], kk_request.session[gsession_design],
kk_request.suffixize(kk_request.language)  ].join( _ )
  end
As a result I have this files in my cache folder:
selene# ll
total 28
drwxrwxrwx  2 root  www512 Jul 27 23:22 _css
-rw-rw-rw-  1 root  www  22972 Jul 27 23:22 index_blue_full__az-AZ.data
-rw-rw-rw-  1 root  www185 Jul 27 23:22 index_blue_full__az-AZ.yml

For example, if user requests 'red'  'full' version of site, then
*'index_red_full__az-AZ'
*will be requested. If there is no cached file, then page will be generated
by radiant from db and then cached in this folder.

That is solution, I think. I'am using radiant v0.7.1. My site supports many
colors (design types) languages and light/full-version.

Regards,
Mamed Mamedov

Sent from Baku, Azerbaijan


On Mon, Jul 27, 2009 at 11:27 PM, Jim Gay j...@saturnflyer.com wrote:


 On Jul 27, 2009, at 2:24 PM, Mamed Mamedov wrote:

  Hi everybody!

 Here how I have resolved my problem with changing page's layout
 on-the-fly:)
 I have created my own extension folder with my namespace-tags for unusual
 tasks.

  desc %{
   Works like design switcher.
  }
  tag 'gsession:design' do |tag|
 design_type = request.session[gsession_design]
 if design_type == nil
 design_type = GenieSessionExtension.defaults[:design]
 request.session[gsession_design] = design_type
 end
 design_type.strip!
 if layout = Layout.find_by_name(tag.attr[#{design_type}])
 tag.globals.page.layout = layout
 tag.globals.page.render
 end
  end

 Usage:
 I have created layout named master-index with only one line in it:
 r:gsession:design full=full-index light=light-index /

 With 2 arguments, which describes layout names for 'full' and 'light'
 version of my site. You can define 'gsession_*design*' session variable at
 any time by hitting, for example:* /genie/set/design/light*
 All my pages have selected 'master-index' layout.
 That is all, while page is rendered my tag switches current layout to
 'full-index' or 'light-index' named layouts.

 Waiting for comments ... Thank you:)


 Have you disabled caching to do this?



 
 Regards,
 Mamed Mamedov




 On Thu, Jul 16, 2009 at 6:16 PM, Sean Cribbs seancri...@gmail.com
 wrote:

  If all of your pages have the same layout at any time, make sure all
 descendant pages have their layout set to inherit and then your
 extension
 could change the layout on the root page.
 However, it would not be trivial to do this on a per-user basis.  Have
 you
 considered something like a combination of Javascript and CSS that lets
 your
 users switch layouts?

 Sean

 Mamed Mamedov wrote:

  Hi everybody!

 I have a little question: how can I change page's layout from within my
 extension?
 Problem is, that I have 2 different page layouts for my site: [
 full-version
 and light-version ].
 I want to write a mini-extension to switch between designs of my site
 throw
 hitting: /design/set/full and /design/set/light or /design/reset
 And I'am saving current design variable in current user's session.

 And now, just need to change current page's layout on the fly
 accordingly
 to
 session value.
 
 Regards,
 Mamed Mamedov

 ___
 Radiant mailing list
 Post:   Radiant@radiantcms.org
 Search: http://radiantcms.org/mailing-list/search/
 Site:   http://lists.radiantcms.org/mailman/listinfo/radiant

___
Radiant mailing list
Post:   Radiant@radiantcms.org
Search: http://radiantcms.org/mailing-list/search/
Site:   http://lists.radiantcms.org/mailman/listinfo/radiant


Re: [Radiant] Changing page layout on-the-fly?

2009-07-27 Thread Jim Gay


On Jul 27, 2009, at 2:42 PM, Mamed Mamedov wrote:

No, I didn't disabled cache, but I'm using 'translator' extension  
which

changes behaviour of radiant's caching subsystem.
Here is my some changes to *translate_response_cache.rb*:


This won't work in 0.8.0. Rails 2.3 uses Rack::Cache and Radiant 0.8.0  
packages Rails 2.3.2
ResponseCache functions were moved to Radiant::Cache, a subclass of  
Rack::Cache



 ResponseCache.class_eval {
   # in here, we're just adding a two-letter language suffix to cached
pages to make sure that the wrong
   # language doesn't get served up because it has been cached
inappropriately. we could change this to
   # cache in a separate directory (i.e. en/), but for now, we're just
adding the extension
   private
 def translator_path(path)
   #path =~ /\.css|\.js$/ ? path :
kk_request.suffixize(kk_request.language)
   path =~ /\.css|\.js$/ ? path : [ path,
kk_request.session[gsession_color],  
kk_request.session[gsession_design],

kk_request.suffixize(kk_request.language)  ].join( _ )
 end
As a result I have this files in my cache folder:
selene# ll
total 28
drwxrwxrwx  2 root  www512 Jul 27 23:22 _css
-rw-rw-rw-  1 root  www  22972 Jul 27 23:22 index_blue_full__az- 
AZ.data

-rw-rw-rw-  1 root  www185 Jul 27 23:22 index_blue_full__az-AZ.yml

For example, if user requests 'red'  'full' version of site, then
*'index_red_full__az-AZ'
*will be requested. If there is no cached file, then page will be  
generated

by radiant from db and then cached in this folder.

That is solution, I think. I'am using radiant v0.7.1. My site  
supports many

colors (design types) languages and light/full-version.

Regards,
Mamed Mamedov

Sent from Baku, Azerbaijan


On Mon, Jul 27, 2009 at 11:27 PM, Jim Gay j...@saturnflyer.com wrote:



On Jul 27, 2009, at 2:24 PM, Mamed Mamedov wrote:

Hi everybody!


Here how I have resolved my problem with changing page's layout
on-the-fly:)
I have created my own extension folder with my namespace-tags for  
unusual

tasks.

desc %{
 Works like design switcher.
}
tag 'gsession:design' do |tag|
   design_type = request.session[gsession_design]
   if design_type == nil
   design_type = GenieSessionExtension.defaults[:design]
   request.session[gsession_design] = design_type
   end
   design_type.strip!
   if layout = Layout.find_by_name(tag.attr[#{design_type}])
   tag.globals.page.layout = layout
   tag.globals.page.render
   end
end

Usage:
I have created layout named master-index with only one line in it:
r:gsession:design full=full-index light=light-index /

With 2 arguments, which describes layout names for 'full' and  
'light'
version of my site. You can define 'gsession_*design*' session  
variable at

any time by hitting, for example:* /genie/set/design/light*
All my pages have selected 'master-index' layout.
That is all, while page is rendered my tag switches current layout  
to

'full-index' or 'light-index' named layouts.

Waiting for comments ... Thank you:)



Have you disabled caching to do this?





Regards,
Mamed Mamedov




On Thu, Jul 16, 2009 at 6:16 PM, Sean Cribbs seancri...@gmail.com
wrote:

If all of your pages have the same layout at any time, make sure all

descendant pages have their layout set to inherit and then your
extension
could change the layout on the root page.
However, it would not be trivial to do this on a per-user basis.   
Have

you
considered something like a combination of Javascript and CSS  
that lets

your
users switch layouts?

Sean

Mamed Mamedov wrote:

Hi everybody!


I have a little question: how can I change page's layout from  
within my

extension?
Problem is, that I have 2 different page layouts for my site: [
full-version
and light-version ].
I want to write a mini-extension to switch between designs of my  
site

throw
hitting: /design/set/full and /design/set/light or /design/reset
And I'am saving current design variable in current user's session.

And now, just need to change current page's layout on the fly
accordingly
to
session value.

Regards,
Mamed Mamedov


___

Radiant mailing list
Post:   Radiant@radiantcms.org
Search: http://radiantcms.org/mailing-list/search/
Site:   http://lists.radiantcms.org/mailman/listinfo/radiant


___
Radiant mailing list
Post:   Radiant@radiantcms.org
Search: http://radiantcms.org/mailing-list/search/
Site:   http://lists.radiantcms.org/mailman/listinfo/radiant


___
Radiant mailing list
Post:   Radiant@radiantcms.org
Search: http://radiantcms.org/mailing-list/search/
Site:   http://lists.radiantcms.org/mailman/listinfo/radiant


Re: [Radiant] Changing page layout on-the-fly?

2009-07-27 Thread Mamed Mamedov
Yes, it is true. Therefore I'am using radiant v0.7.1 and rails2.1.2 for this
site :)
I have no time to do it better now ;(

Regards,
Mamed Mamedov

Sent from Baku, Azerbaijan


On Mon, Jul 27, 2009 at 11:51 PM, Jim Gay j...@saturnflyer.com wrote:


 On Jul 27, 2009, at 2:42 PM, Mamed Mamedov wrote:

  No, I didn't disabled cache, but I'm using 'translator' extension which
 changes behaviour of radiant's caching subsystem.
 Here is my some changes to *translate_response_cache.rb*:


 This won't work in 0.8.0. Rails 2.3 uses Rack::Cache and Radiant 0.8.0
 packages Rails 2.3.2
 ResponseCache functions were moved to Radiant::Cache, a subclass of
 Rack::Cache


   ResponseCache.class_eval {
   # in here, we're just adding a two-letter language suffix to cached
 pages to make sure that the wrong
   # language doesn't get served up because it has been cached
 inappropriately. we could change this to
   # cache in a separate directory (i.e. en/), but for now, we're just
 adding the extension
   private
 def translator_path(path)
   #path =~ /\.css|\.js$/ ? path :
 kk_request.suffixize(kk_request.language)
   path =~ /\.css|\.js$/ ? path : [ path,
 kk_request.session[gsession_color],
 kk_request.session[gsession_design],
 kk_request.suffixize(kk_request.language)  ].join( _ )
 end
 As a result I have this files in my cache folder:
 selene# ll
 total 28
 drwxrwxrwx  2 root  www512 Jul 27 23:22 _css
 -rw-rw-rw-  1 root  www  22972 Jul 27 23:22 index_blue_full__az-AZ.data
 -rw-rw-rw-  1 root  www185 Jul 27 23:22 index_blue_full__az-AZ.yml

 For example, if user requests 'red'  'full' version of site, then
 *'index_red_full__az-AZ'
 *will be requested. If there is no cached file, then page will be
 generated
 by radiant from db and then cached in this folder.

 That is solution, I think. I'am using radiant v0.7.1. My site supports
 many
 colors (design types) languages and light/full-version.
 
 Regards,
 Mamed Mamedov

 Sent from Baku, Azerbaijan


 On Mon, Jul 27, 2009 at 11:27 PM, Jim Gay j...@saturnflyer.com wrote:


 On Jul 27, 2009, at 2:24 PM, Mamed Mamedov wrote:

 Hi everybody!


 Here how I have resolved my problem with changing page's layout
 on-the-fly:)
 I have created my own extension folder with my namespace-tags for
 unusual
 tasks.

 desc %{
  Works like design switcher.
 }
 tag 'gsession:design' do |tag|
   design_type = request.session[gsession_design]
   if design_type == nil
   design_type = GenieSessionExtension.defaults[:design]
   request.session[gsession_design] = design_type
   end
   design_type.strip!
   if layout = Layout.find_by_name(tag.attr[#{design_type}])
   tag.globals.page.layout = layout
   tag.globals.page.render
   end
 end

 Usage:
 I have created layout named master-index with only one line in it:
 r:gsession:design full=full-index light=light-index /

 With 2 arguments, which describes layout names for 'full' and 'light'
 version of my site. You can define 'gsession_*design*' session variable
 at
 any time by hitting, for example:* /genie/set/design/light*
 All my pages have selected 'master-index' layout.
 That is all, while page is rendered my tag switches current layout to
 'full-index' or 'light-index' named layouts.

 Waiting for comments ... Thank you:)


 Have you disabled caching to do this?



  
 Regards,
 Mamed Mamedov




 On Thu, Jul 16, 2009 at 6:16 PM, Sean Cribbs seancri...@gmail.com
 wrote:

 If all of your pages have the same layout at any time, make sure all

 descendant pages have their layout set to inherit and then your
 extension
 could change the layout on the root page.
 However, it would not be trivial to do this on a per-user basis.  Have
 you
 considered something like a combination of Javascript and CSS that lets
 your
 users switch layouts?

 Sean

 Mamed Mamedov wrote:

 Hi everybody!


 I have a little question: how can I change page's layout from within
 my
 extension?
 Problem is, that I have 2 different page layouts for my site: [
 full-version
 and light-version ].
 I want to write a mini-extension to switch between designs of my site
 throw
 hitting: /design/set/full and /design/set/light or /design/reset
 And I'am saving current design variable in current user's session.

 And now, just need to change current page's layout on the fly
 accordingly
 to
 session value.
 
 Regards,
 Mamed Mamedov

  ___

 Radiant mailing list
 Post:   Radiant@radiantcms.org
 Search: http://radiantcms.org/mailing-list/search/
 Site:   http://lists.radiantcms.org/mailman/listinfo/radiant

  ___
 Radiant mailing list
 Post:   Radiant@radiantcms.org
 Search: http://radiantcms.org/mailing-list/search/
 Site:   http://lists.radiantcms.org/mailman/listinfo/radiant


 ___
 Radiant mailing list
 Post:   Radiant@radiantcms.org
 Search: 

[Radiant] Changing page layout on-the-fly?

2009-07-16 Thread Mamed Mamedov
Hi everybody!

I have a little question: how can I change page's layout from within my
extension?
Problem is, that I have 2 different page layouts for my site: [ full-version
and light-version ].
I want to write a mini-extension to switch between designs of my site throw
hitting: /design/set/full and /design/set/light or /design/reset
And I'am saving current design variable in current user's session.

And now, just need to change current page's layout on the fly accordingly to
session value.

Regards,
Mamed Mamedov
___
Radiant mailing list
Post:   Radiant@radiantcms.org
Search: http://radiantcms.org/mailing-list/search/
Site:   http://lists.radiantcms.org/mailman/listinfo/radiant


Re: [Radiant] Changing page layout on-the-fly?

2009-07-16 Thread Petrik de Heus

On Jul 16, 2009, at 13:01 , Mamed Mamedov wrote:


Hi everybody!

I have a little question: how can I change page's layout from within  
my

extension?


Something like this:

def activate

  Page.class_eval do
def process_with_session_layout(request, response)
  self.layout = Layout.find(controller.session[:layout_id[)
  process_without_session_layout(request, response)
end
alias_method_chain :process, :session_layout
  end

.end

Problem is, that I have 2 different page layouts for my site: [ full- 
version

and light-version ].
I want to write a mini-extension to switch between designs of my  
site throw

hitting: /design/set/full and /design/set/light or /design/reset
And I'am saving current design variable in current user's session.

And now, just need to change current page's layout on the fly  
accordingly to

session value.

Regards,
Mamed Mamedov
___
Radiant mailing list
Post:   Radiant@radiantcms.org
Search: http://radiantcms.org/mailing-list/search/
Site:   http://lists.radiantcms.org/mailman/listinfo/radiant


___
Radiant mailing list
Post:   Radiant@radiantcms.org
Search: http://radiantcms.org/mailing-list/search/
Site:   http://lists.radiantcms.org/mailman/listinfo/radiant


Re: [Radiant] Changing page layout on-the-fly?

2009-07-16 Thread Sean Cribbs
If all of your pages have the same layout at any time, make sure all 
descendant pages have their layout set to inherit and then your 
extension could change the layout on the root page. 

However, it would not be trivial to do this on a per-user basis.  Have 
you considered something like a combination of Javascript and CSS that 
lets your users switch layouts?


Sean

Mamed Mamedov wrote:

Hi everybody!

I have a little question: how can I change page's layout from within my
extension?
Problem is, that I have 2 different page layouts for my site: [ full-version
and light-version ].
I want to write a mini-extension to switch between designs of my site throw
hitting: /design/set/full and /design/set/light or /design/reset
And I'am saving current design variable in current user's session.

And now, just need to change current page's layout on the fly accordingly to
session value.

Regards,
Mamed Mamedov
___
Radiant mailing list
Post:   Radiant@radiantcms.org
Search: http://radiantcms.org/mailing-list/search/
Site:   http://lists.radiantcms.org/mailman/listinfo/radiant

  


___
Radiant mailing list
Post:   Radiant@radiantcms.org
Search: http://radiantcms.org/mailing-list/search/
Site:   http://lists.radiantcms.org/mailman/listinfo/radiant