-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from avonderluft/version106
Version106
- Loading branch information
Showing
13 changed files
with
143 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
# ToDos | ||
|
||
- set up CI | ||
- set up Buildkite CI and add build badge to README | ||
- add duplicate page function in admin UI | ||
- add admin content search to list layouts, pages and snippets - see https://blog.robertsj.com/search/ | ||
- add application console for testing | ||
- add feature to resize file_link'd images |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# frozen_string_literal: true | ||
|
||
# Nav Tag for unordered list of links to the children of the current page | ||
# {{ cms:children }} | ||
# {{ cms:children style: "font-weight: bold", exclude: "404-page, search-page" }} | ||
# To customize your children style, add a 'children' id to your CSS, e.g | ||
# #children { | ||
# color: #006633; | ||
# font-size: 90%; | ||
# margin-bottom: 4px; | ||
# font-style: italic; | ||
# } | ||
# and/or pass in style overrides with the 'style' parameter, as above | ||
# | ||
# To exclude children, list their slugs with the 'exclude' parameter | ||
# as comma-delimited string, e.g. as above - exclude: "404-page, search-page" | ||
|
||
class Occams::Content::Tag::Children < Occams::Content::Tag | ||
attr_reader :list, :style, :locals | ||
|
||
def initialize(context:, params: [], source: nil) | ||
super | ||
@locals = params.extract_options! | ||
@style = '' | ||
@style = "<style>#children {#{@locals['style']}}</style>" if @locals['style'] | ||
@exclude = [] | ||
@exclude = @locals['exclude'].split(',') if @locals['exclude'] | ||
@list = '' | ||
# ActiveRecord_Associations_CollectionProxy | ||
page_children = context.children.order(:position).to_ary | ||
page_children.delete_if { |child| @exclude.include? child.slug } | ||
return unless page_children.any? | ||
|
||
@list = '<ul id="children">' | ||
page_children.each do |c| | ||
next if Rails.env == 'production' && !c.is_published | ||
|
||
@list += "<li><a href=#{c.url(relative: true)}>#{c.label}</a></li>" | ||
end | ||
@list += '</ul>' | ||
end | ||
|
||
def content | ||
format("#{@style}#{@list}") | ||
end | ||
end | ||
|
||
Occams::Content::Renderer.register_tag( | ||
:children, Occams::Content::Tag::Children | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
# frozen_string_literal: true | ||
|
||
module Occams | ||
VERSION = '1.0.5' | ||
VERSION = '1.0.6' | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
# frozen_string_literal: true | ||
|
||
require_relative '../../../test_helper' | ||
|
||
class ContentTagsChildrenTest < ActiveSupport::TestCase | ||
setup do | ||
@site = occams_cms_sites(:default) | ||
@layout = occams_cms_layouts(:default) | ||
@page = occams_cms_pages(:default) | ||
@parent = @site.pages.create!(layout: @layout, parent: @page, label: 'Parent', slug: 'parent') | ||
@child1 = @site.pages.create!(layout: @layout, parent: @parent, label: 'Child1', slug: 'child1') | ||
@child2 = @site.pages.create!(layout: @layout, parent: @parent, label: 'Child2', slug: 'child2') | ||
@child3 = @site.pages.create!(layout: @layout, parent: @parent, label: 'Child3', slug: 'child3') | ||
@child4 = @site.pages.create!(layout: @layout, parent: @parent, label: 'Child4', slug: 'child4') | ||
end | ||
|
||
def test_init | ||
tag = Occams::Content::Tag::Children.new( | ||
context: @parent, | ||
params: [] | ||
) | ||
assert_equal ({}), tag.locals | ||
end | ||
|
||
def test_init_with_style | ||
tag = Occams::Content::Tag::Children.new( | ||
context: @parent, | ||
params: [{ 'style' => 'font-weight: bold' }] | ||
) | ||
assert_equal '<style>#children {font-weight: bold}</style>', tag.style | ||
end | ||
|
||
def test_render | ||
tag = Occams::Content::Tag::Children.new( | ||
context: @parent, | ||
params: [{ 'style' => 'font-weight: bold' }] | ||
) | ||
html = "<style>#children {font-weight: bold}</style><ul id=\"children\">\ | ||
<li><a href=/parent/child1>Child1</a></li><li><a href=/parent/child2>Child2</a></li>\ | ||
<li><a href=/parent/child3>Child3</a></li><li><a href=/parent/child4>Child4</a></li></ul>" | ||
assert_equal html, tag.render | ||
end | ||
|
||
def test_render_with_exclusions | ||
tag = Occams::Content::Tag::Children.new( | ||
context: @parent, | ||
params: [{ 'exclude' => 'child2,child3' }] | ||
) | ||
html = "<ul id=\"children\"><li><a href=/parent/child1>Child1</a></li>\ | ||
<li><a href=/parent/child4>Child4</a></li></ul>" | ||
assert_equal html, tag.render | ||
end | ||
|
||
def test_render_with_no_kids | ||
tag = Occams::Content::Tag::Children.new( | ||
context: @child4, | ||
params: [] | ||
) | ||
assert_equal '', tag.render | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters