Skip to content

Commit

Permalink
add the layouts folder + in the sidebar, add a shortcut to bring the …
Browse files Browse the repository at this point in the history
…users directly to the list of the content entries if templatized page
  • Loading branch information
did committed May 27, 2015
1 parent b90cac0 commit 2715c8c
Show file tree
Hide file tree
Showing 14 changed files with 46 additions and 130 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ $pt_warning_color: #F89406;
&.folded .folded, &.unfolded .unfolded { display: inline; }
}

&.new-content {
&.new-entry, &.list-entries, &.new-page {
a {
margin-left: 1px;
color: $pt_new_link_color;
Expand Down
6 changes: 0 additions & 6 deletions app/controllers/locomotive/pages_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,6 @@ class PagesController < BaseController

respond_to :json, only: [:sort]

def index
authorize Page
@pages = current_site.all_pages_in_once
respond_with(@pages)
end

def new
authorize Page
@page = current_site.pages.build
Expand Down
4 changes: 4 additions & 0 deletions app/models/locomotive/concerns/page/layout.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ module Layout

end

def is_layout_or_related?
!(self.fullpath =~ /^layouts($|\/)/).nil?
end

private

def set_default_raw_template_if_layout
Expand Down
2 changes: 1 addition & 1 deletion app/models/locomotive/page.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ class Page

include Locomotive::Mongoid::Document

MINIMAL_ATTRIBUTES = %w(_id title slug fullpath position depth published templatized target_klass_name redirect listed response_type parent_id parent_ids site_id created_at updated_at raw_template)
MINIMAL_ATTRIBUTES = %w(_id title slug fullpath position depth published templatized target_klass_name redirect listed response_type parent_id parent_ids site_id created_at updated_at raw_template is_layout)

## concerns ##
include Concerns::Page::Tree
Expand Down
4 changes: 0 additions & 4 deletions app/models/locomotive/site.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,6 @@ class Site

## methods ##

def all_pages_in_once
PageTreeService.new(self).build_tree
end

# Get all the pages in the right order: depth and position, both ASC.
#
# @param [ Hash ] conditions Extra conditions passed to the Mongoid criteria
Expand Down
2 changes: 1 addition & 1 deletion app/services/locomotive/page_tree_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def build_tree
elsif page.index?
# make the index page without children
tree << [page, nil]
else
elsif !page.is_layout_or_related?
tree << _build_tree(page, pages)
end
end
Expand Down
66 changes: 0 additions & 66 deletions app/views/locomotive/pages/_form.html.haml

This file was deleted.

44 changes: 0 additions & 44 deletions app/views/locomotive/pages/_page.html.haml

This file was deleted.

4 changes: 2 additions & 2 deletions app/views/locomotive/pages/form/_main.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@

= f.input :redirect, as: :toggle

= f.input :redirect_url, wrapper_html: { class: "#{'hide' unless @page.redirect?}" }
= f.input :redirect_url, as: :string, wrapper_html: { class: "#{'hide' unless @page.redirect?}" }

= f.input :redirect_type, as: :select, collection: options_for_page_redirect_type, include_blank: false, wrapper_html: {class: "#{'hide' unless @page.redirect?}" }

= f.input :published, as: :toggle

- unless @page.not_found?
- unless @page.not_found? || @page.templatized?

= f.input :listed, as: :toggle

Expand Down
5 changes: 3 additions & 2 deletions app/views/locomotive/pages/form/_tabs.html.haml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
%ul.nav.nav-tabs{ role: 'tablist' }
= form_nav_tab :content do
= link_to t('simple_form.titles.locomotive.content'), editable_elements_path(current_site, @page)
- unless @page.templatized?
= form_nav_tab :content do
= link_to t('simple_form.titles.locomotive.content'), editable_elements_path(current_site, @page)

= form_nav_tab :main, true do
= link_to t('simple_form.titles.locomotive.information'), '#main', role: 'tab', data: { toggle: 'tab' }
Expand Down
7 changes: 6 additions & 1 deletion app/views/locomotive/shared/sidebar/_page.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,12 @@
= render partial: 'locomotive/shared/sidebar/page', collection: page.nodes

- if page.content_type
%li.new-content
%li.list-entries
%i.fa.fa-list-ul.icon
= link_to content_entries_path(current_site, page.templatized_page.content_type.slug) do
%span.text= t(:list_content_entries, name: page.content_type.name.pluralize, scope: 'locomotive.pages.index')

%li.new-entry
%i.fa.fa-plus.icon
= link_to new_content_entry_path(current_site, page.templatized_page.content_type.slug) do
%span.text= t(:new_content_entry, name: page.content_type.name.singularize, scope: 'locomotive.pages.index')
2 changes: 1 addition & 1 deletion app/views/locomotive/shared/sidebar/_pages.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

= render partial: 'locomotive/shared/sidebar/page', collection: nodes

%li.new-content
%li.new-page
%i.fa.fa-plus.icon
= link_to new_page_path(current_site) do
%span.text= t(:new, scope: 'locomotive.pages.index')
2 changes: 1 addition & 1 deletion config/locales/admin_ui.en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,8 @@ en:
help: "Pages are organized as a tree. You can order pages as well as folders"
no_items: "There are no pages for now. Just click <a href=\"%{url}\">here</a> to create the first one."
new: new page
list_content_entries: "List %{name}"
new_content_entry: "New %{name}"
latest_entries: Latest pages
new:
title: New page
help: "Please fill in the below form to create your page. Be careful, by default, the page is not published."
Expand Down
26 changes: 26 additions & 0 deletions spec/models/locomotive/concerns/page/layout_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,30 @@

end

describe '#is_layout_or_related?' do

let(:fullpath) { 'foo' }

before { allow(page).to receive(:fullpath).and_return(fullpath) }

subject { page.is_layout_or_related? }

it { is_expected.to eq false }

context 'page is the layouts folder' do

let(:fullpath) { 'layouts' }
it { is_expected.to eq true }

end

context 'page under layouts' do

let(:fullpath) { 'layouts/foo' }
it { is_expected.to eq true }

end

end

end

0 comments on commit 2715c8c

Please sign in to comment.