diff options
Diffstat (limited to 'app/controllers/nodes_controller.rb')
| -rw-r--r-- | app/controllers/nodes_controller.rb | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/app/controllers/nodes_controller.rb b/app/controllers/nodes_controller.rb index c1468be..249602d 100644 --- a/app/controllers/nodes_controller.rb +++ b/app/controllers/nodes_controller.rb | |||
| @@ -16,6 +16,8 @@ class NodesController < ApplicationController | |||
| 16 | :revert | 16 | :revert |
| 17 | ] | 17 | ] |
| 18 | 18 | ||
| 19 | around_action :pin_to_default_locale, :only => [:show, :edit, :update, :autosave] | ||
| 20 | |||
| 19 | def index | 21 | def index |
| 20 | @nodes = Node.root.descendants.includes(:head, :draft) | 22 | @nodes = Node.root.descendants.includes(:head, :draft) |
| 21 | .order('id DESC') | 23 | .order('id DESC') |
| @@ -59,9 +61,9 @@ class NodesController < ApplicationController | |||
| 59 | end | 61 | end |
| 60 | 62 | ||
| 61 | def show | 63 | def show |
| 62 | node = Node.find(params[:id]) | 64 | @page = @node.draft || @node.head |
| 63 | node.wipe_draft! | 65 | @default_translation = @page.translations.find_by(:locale => I18n.default_locale) |
| 64 | @page = node.draft || node.head | 66 | @translations = @page.translation_summary |
| 65 | end | 67 | end |
| 66 | 68 | ||
| 67 | def edit | 69 | def edit |
| @@ -248,6 +250,10 @@ class NodesController < ApplicationController | |||
| 248 | end | 250 | end |
| 249 | end | 251 | end |
| 250 | 252 | ||
| 253 | def pin_to_default_locale | ||
| 254 | Globalize.with_locale(I18n.default_locale) { yield } | ||
| 255 | end | ||
| 256 | |||
| 251 | def descendant_counts_for(ordered_with_level) | 257 | def descendant_counts_for(ordered_with_level) |
| 252 | counts = Hash.new(0) | 258 | counts = Hash.new(0) |
| 253 | stack = [] # [node, level, index] | 259 | stack = [] # [node, level, index] |
