moved base class stuff to merged

This commit is contained in:
Torsten 2022-12-25 23:42:01 +02:00
parent ab05618c45
commit 6fef0adbe7
7 changed files with 13 additions and 17 deletions

1
.rspec
View File

@ -1 +0,0 @@
--require spec_helper

View File

@ -3,15 +3,19 @@ require "redcarpet"
module Merged module Merged
module MergedHelper module MergedHelper
include OptionsHelper include OptionsHelper
@@renderer = nil
def renderer def renderer
return @@renderer unless @@renderer.nil?
options = {hard_wrap: true , autolink: true, no_intra_emphasis: true , options = {hard_wrap: true , autolink: true, no_intra_emphasis: true ,
safe_links_only: true, no_styles: true , safe_links_only: true, no_styles: true ,
link_attributes: { target: '_blank' }} link_attributes: { target: '_blank' }}
html = Redcarpet::Render::HTML.new(options) html = Redcarpet::Render::HTML.new(options)
@@renderer = Redcarpet::Markdown.new(html, options) Redcarpet::Markdown.new(html, options)
end
def markdown(text)
text = text.text unless text.is_a?(String)
return "" if text.blank?
self.renderer.render(text).html_safe
end end
def aspect_ratio image def aspect_ratio image
@ -19,11 +23,6 @@ module Merged
"#{x} / #{y}" "#{x} / #{y}"
end end
def markdown(text)
text = text.text unless text.is_a?(String)
return "" if text.blank?
renderer.render(text).html_safe
end
def field_name(card) def field_name(card)
name = card.header name = card.header
name += "*" unless card.option("compulsory") == "no" name += "*" unless card.option("compulsory") == "no"

View File

@ -1,7 +1,5 @@
require "active_hash" module Merged
class ActiveBase < ActiveYaml::Base
module ActiveYaml
Base.class_eval do
def save def save
super super

View File

@ -1,7 +1,7 @@
require "mini_magick" require "mini_magick"
module Merged module Merged
class Image < ActiveYaml::Base class Image < ActiveBase
set_root_path Rails.root set_root_path Rails.root

View File

@ -1,5 +1,5 @@
module Merged module Merged
class OptionDefinition < ActiveYaml::Base class OptionDefinition < ActiveBase
set_root_path Engine.root + "config" set_root_path Engine.root + "config"
fields :name , :default , :description , :values , :type fields :name , :default , :description , :values , :type

View File

@ -1,5 +1,5 @@
module Merged module Merged
class Style < ActiveYaml::Base class Style < ActiveBase
set_root_path Engine.root + "config" set_root_path Engine.root + "config"

View File

@ -4,7 +4,7 @@ module Merged
# they share the template idea, options , change tracking, # they share the template idea, options , change tracking,
# and the fact that they persist in ActiveYaml # and the fact that they persist in ActiveYaml
class ViewBase < ActiveYaml::Base class ViewBase < ActiveBase
set_root_path Rails.root #ouside engines not necessary set_root_path Rails.root #ouside engines not necessary
include ActiveHash::Associations include ActiveHash::Associations