test harness is back, and pages fixed after refactor

This commit is contained in:
2022-12-08 17:16:29 +02:00
parent a8aa16170a
commit 308b9e1d2e
22 changed files with 257 additions and 23 deletions

View File

@ -1 +1 @@
//= link ../stylesheets/merged .css
//= link_directory ../stylesheets/merged .css

View File

@ -859,6 +859,18 @@ select {
height: 6rem;
}
.h-60 {
height: 15rem;
}
.h-40 {
height: 10rem;
}
.h-32 {
height: 8rem;
}
.w-6 {
width: 1.5rem;
}

View File

@ -2,8 +2,8 @@ module Merged
class StylesController < MergedController
def index
@sections = Style.sections
@cards = Style.cards
@sections = SectionStyle.sections
@cards = CardStyle.cards
end
end

View File

@ -20,8 +20,20 @@ module Merged
text
end
end
def button(text , url , color)
link_to(url) do
content_tag(:button , class: color + " " + button_classes ) do
text
end
end
end
def button_classes
"mr-3 inline-block rounded-lg px-4 py-3 text-md font-medium text-white"
end
# section should be hash with at least 'template' key
def find_template(section)
"merged/view/" + section.template
end
end
end

View File

@ -2,10 +2,6 @@ module Merged
module ViewHelper
include OptionsHelper
include MergedHelper
# section should be hash with at least 'template' key
def find_template(section)
"merged/view/" + section.template
end
# background image as inline style
def bg(section , clazz = "")
@ -27,13 +23,5 @@ module Merged
image_tag("#{Image.image_root}/#{element.image}" , class: classes)
end
def button(text , url , color)
link_to(url) do
content_tag(:button , class: color + " " + button_classes ) do
text
end
end
end
end
end

View File

@ -60,7 +60,7 @@ module Merged
end
def template_style
Style.cards[ section.card_template ]
CardStyle.cards[ section.card_template ]
end
def allowed_fields
template_style.fields
@ -68,7 +68,7 @@ module Merged
def self.build_data(card_template)
data = { "id" => SecureRandom.hex(10) }
Style.cards[ card_template ].fields.each do |key|
CardStyle.cards[ card_template ].fields.each do |key|
data[key] = key.upcase
end
data

View File

@ -1,6 +1,8 @@
module Merged
class Option
@@options = {}
attr_reader :name , :default , :description
def initialize(options)
@ -30,6 +32,10 @@ module Merged
@values.split(" ")
end
def self.options
@@options
end
def self.load(yaml)
yaml.each do |content|
option = Option.new(content)

View File

@ -49,7 +49,7 @@ module Merged
end
def template_style
Style.sections[ template ]
SectionStyle.sections[ template ]
end
def allowed_fields

View File

@ -27,9 +27,9 @@
%h3.mt-4.text-lg.font-bold Header
%p= section.header
%h3.mt-4.text-lg.font-bold Text
%p= section.text[0..100] + " ..."
%p= section.text[0..100] + " ..." if section.text
.relative.block.border.border-gray-100.p-4
- if section.cards?
- if section.has_cards?
%h3.mt-4.text-lg.font-bold #{section.content['cards'].length} Cards
=link_to section_cards_url(section.id) do
=card_preview(section , class: "w-full object-contain")
@ -37,7 +37,7 @@
= link_to(section_select_image_url(section.id)) do
%h3.mt-4.text-lg.font-bold Image
-if section.image
= image_tag "cms/" + section.image
= image_tag( "cms/" + section.image , class: "h-40")
-else
%p No image
.relative.block.border.border-gray-100.p-4

View File

@ -40,7 +40,7 @@
= red_button( "Remove image", section_set_image_path( @section.id , image: ""))
.grid.grid-cols-3.gap-2.m-8
- if( @section.cards? )
- if( @section.has_cards? )
.relative.block.border.border-gray-100
%h3.mt-4.text-lg.font-bold Card Template #{@section.card_template}
=card_preview(@section , class: "w-full object-contain")

View File

@ -22,7 +22,7 @@
%h3.text-lg.font-medium.text-gray-900
Cards
%p.mt-2.text-sm.leading-relaxed.text-gray-500.line-clamp-3
-if(style.cards?)
-if(style.has_cards?)
Section may include cards. See card styles below
-else
Section may not include cards