summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhukl <contact@smyck.org>2009-09-01 11:49:56 +0200
committerhukl <contact@smyck.org>2009-09-01 11:49:56 +0200
commit4aa4a0e4a44735d22ac7f8fd1b12b19699af087b (patch)
tree34c78c00617a504c7d713540fb349fd9af1d0e23
parentc95126d6b6abd6302a07fbb17cd9ad0181e048c7 (diff)
added expirimental routing for image galeries
added plain image gallery template refinements
-rw-r--r--app/controllers/content_controller.rb15
-rw-r--r--app/helpers/content_helper.rb10
-rw-r--r--app/models/page.rb2
-rw-r--r--app/models/related_asset.rb2
-rw-r--r--app/views/custom/page_templates/public/gallery.html.erb5
-rw-r--r--app/views/custom/page_templates/public/standard_template.html.erb1
-rw-r--r--config/routes.rb9
7 files changed, 36 insertions, 8 deletions
diff --git a/app/controllers/content_controller.rb b/app/controllers/content_controller.rb
index d548a34..d1bfa6b 100644
--- a/app/controllers/content_controller.rb
+++ b/app/controllers/content_controller.rb
@@ -1,14 +1,13 @@
1class ContentController < ApplicationController 1class ContentController < ApplicationController
2 2
3 before_filter :find_page
4
3 # This is the method that renders most of the the public content. It recieves 5 # This is the method that renders most of the the public content. It recieves
4 # a :locale and a :page_path parameter through the params hash. It looks up 6 # a :locale and a :page_path parameter through the params hash. It looks up
5 # the node with the corresponding unique_name attribute. The method doesn't 7 # the node with the corresponding unique_name attribute. The method doesn't
6 # return a node though, the node is really a proxy object for pages. It 8 # return a node though, the node is really a proxy object for pages. It
7 # returns the most recent page associated to this node instead. 9 # returns the most recent page associated to this node instead.
8 def render_page 10 def render_page
9 path = params[:page_path].join('/')
10
11 @page = Node.find_page(path)
12 11
13 if @page and @page.public? 12 if @page and @page.public?
14 template = @page.valid_template 13 template = @page.valid_template
@@ -26,4 +25,14 @@ class ContentController < ApplicationController
26 25
27 end 26 end
28 27
28 def render_gallery
29 @images = @page.assets.images
30 render :file => "custom/page_templates/public/gallery"#, :layout => true
31 end
32
33 private
34 def find_page
35 path = params[:page_path].join('/')
36 @page = Node.find_page(path)
37 end
29end 38end
diff --git a/app/helpers/content_helper.rb b/app/helpers/content_helper.rb
index 6309c8b..8b16462 100644
--- a/app/helpers/content_helper.rb
+++ b/app/helpers/content_helper.rb
@@ -16,6 +16,16 @@ module ContentHelper
16 ) 16 )
17 end 17 end
18 18
19 def headline_image
20 image = @page.assets.images.first
21 if image
22 link_to_path(
23 image_tag(image.upload.url(:headline)),
24 ("galleries/" + @page.node.unique_name)
25 )
26 end
27 end
28
19 29
20 # Returns the published_at attribute of a page if it is not nil, otherwise 30 # Returns the published_at attribute of a page if it is not nil, otherwise
21 # it returns the auto-filled value of the created_at attribute 31 # it returns the auto-filled value of the created_at attribute
diff --git a/app/models/page.rb b/app/models/page.rb
index d697a96..47ecdfd 100644
--- a/app/models/page.rb
+++ b/app/models/page.rb
@@ -31,7 +31,7 @@ class Page < ActiveRecord::Base
31 belongs_to :node 31 belongs_to :node
32 belongs_to :user 32 belongs_to :user
33 has_many :related_assets 33 has_many :related_assets
34 has_many :assets, :through => :related_assets, :order => "position DESC" 34 has_many :assets, :through => :related_assets, :order => "position ASC"
35 35
36 # Filter 36 # Filter
37 before_create :set_page_title 37 before_create :set_page_title
diff --git a/app/models/related_asset.rb b/app/models/related_asset.rb
index dc4dc3d..036e79e 100644
--- a/app/models/related_asset.rb
+++ b/app/models/related_asset.rb
@@ -2,5 +2,5 @@ class RelatedAsset < ActiveRecord::Base
2 belongs_to :page 2 belongs_to :page
3 belongs_to :asset 3 belongs_to :asset
4 4
5 acts_as_list, :scope => :page_id 5 acts_as_list :scope => :page_id
6end \ No newline at end of file 6end \ No newline at end of file
diff --git a/app/views/custom/page_templates/public/gallery.html.erb b/app/views/custom/page_templates/public/gallery.html.erb
new file mode 100644
index 0000000..7511db3
--- /dev/null
+++ b/app/views/custom/page_templates/public/gallery.html.erb
@@ -0,0 +1,5 @@
1<ul>
2 <% @images.each do |image| %>
3 <li><%= image_tag image.upload.url %></li>
4 <% end %>
5</ul> \ No newline at end of file
diff --git a/app/views/custom/page_templates/public/standard_template.html.erb b/app/views/custom/page_templates/public/standard_template.html.erb
index 1822491..6fe7176 100644
--- a/app/views/custom/page_templates/public/standard_template.html.erb
+++ b/app/views/custom/page_templates/public/standard_template.html.erb
@@ -2,6 +2,7 @@
2 <h2><%= @page.title %></h2> 2 <h2><%= @page.title %></h2>
3 <h3><%= date_for_page @page %>, <%= @page.user.try(:login) %></h3> 3 <h3><%= date_for_page @page %>, <%= @page.user.try(:login) %></h3>
4 <hr class="subtitle" /> 4 <hr class="subtitle" />
5 <p><%= headline_image %></p>
5 <p><em><%= @page.abstract %></em></p> 6 <p><em><%= @page.abstract %></em></p>
6 <%= aggregate?(@page.body) %> 7 <%= aggregate?(@page.body) %>
7</div> 8</div>
diff --git a/config/routes.rb b/config/routes.rb
index e1da95c..f94b61c 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -14,7 +14,7 @@ ActionController::Routing::Routes.draw do |map|
14 map.resources :events 14 map.resources :events
15 map.resources :revisions, :member => {:diff => :post, :restore => :put} 15 map.resources :revisions, :member => {:diff => :post, :restore => :put}
16 map.resources :pages, :member => {:preview => :get} 16 map.resources :pages, :member => {:preview => :get}
17 map.resources :nodes, :member => {:publish => :put, :unlock => :put} 17 map.resources :nodes, :member => {:publish => :put, :unlock => :put}
18 map.logout '/logout', :controller => 'sessions', :action => 'destroy' 18 map.logout '/logout', :controller => 'sessions', :action => 'destroy'
19 map.login '/login', :controller => 'sessions', :action => 'new' 19 map.login '/login', :controller => 'sessions', :action => 'new'
20 map.admin_search 'admin/search', :controller => 'admin', :action => 'search' 20 map.admin_search 'admin/search', :controller => 'admin', :action => 'search'
@@ -22,8 +22,11 @@ ActionController::Routing::Routes.draw do |map|
22 map.resources :menu_items, :member => {:sort => :post} 22 map.resources :menu_items, :member => {:sort => :post}
23 map.resource :session 23 map.resource :session
24 24
25 map.connect ':controller/:action/:id' 25 map.connect ':controller/:action/:id'
26 map.connect ':controller/:action/:id.:format' 26 map.connect ':controller/:action/:id.:format'
27
28 map.connect 'galleries/*page_path',
29 :controller => 'content', :action => 'render_gallery'
27 30
28 map.connect '/*page_path', 31 map.connect '/*page_path',
29 :controller => 'content', :action => 'render_page' 32 :controller => 'content', :action => 'render_page'