Changes for mozo host

This commit is contained in:
2020-03-05 11:36:19 -05:00
parent 02e60c174d
commit 3aa204aa30
7 changed files with 32 additions and 17 deletions
@@ -2,6 +2,7 @@
#= require jquery_ujs
#= require foundation
#= require ace/ace
#= require moment
#= require ace/theme-monokai
#= require ace/mode-coffee
#= require ace/mode-handlebars
@@ -36,3 +37,6 @@ $ ->
iframe.attr 'src', url
$('#preview-modal').foundation('reveal', 'open')
false
$("[data-time]").each ->
$(this).text moment($(this).data("time")).format($(this).data("timeFormat") or "dd D MMM HH:mm")
+11 -8
View File
@@ -31,7 +31,7 @@ module Cmtool
# or normal text behaviour:
# - title "Home"
def title(*args)
content_for :title do
res = content_tag :h1, class: 'page-title' do
if args.first.is_a?(Symbol) && (args[1].respond_to?(:model_name) || args[1].class.respond_to?(:model_name))
model = args[1].respond_to?(:model_name) ? args[1] : args[1].class
if args.first == :index
@@ -40,11 +40,13 @@ module Cmtool
t("cmtool.action.#{args.first}.title", model: model.model_name.human)
end
else
raise 'Imporoper title declaration'
args.first
end
end
content_for :page_title, res
res
end
def are_you_sure(obj = nil)
if name = obj && obj.respond_to?(:name) && obj.name.presence
t('cmtool.general.are_you_sure_with_name', name: name, model: obj.class.model_name.human)
@@ -130,10 +132,10 @@ module Cmtool
controller.respond_to?(:cmtool_user) ? controller.send(:cmtool_user) :nil
end
def edit_td(obj)
path = case obj
def edit_td(obj, options = {})
path = options[:path] || case obj
when Array then edit_polymorphic_path(obj)
when SimplyStored::Couch then edit_polymorphic_path([cmtool, obj])
when SimplyStored::Couch then edit_polymorphic_path([options[:scope] || cmtool, obj])
else obj
end
content_tag(
@@ -143,12 +145,13 @@ module Cmtool
)
end
def destroy_td(obj)
path = case obj
def destroy_td(obj, options = {})
path = options[:path] || case obj
when Array then polymorphic_path(obj)
when SimplyStored::Couch then polymorphic_path([cmtool, obj])
when SimplyStored::Couch then polymorphic_path([options[:scope] || cmtool, obj])
else obj
end
content_tag(
:td,
link_to(content_tag(:span, '', class: [:destroy, 'fa fa-lg fa-trash']), path, method: :delete, class: 'tiny alert button', data: {confirm: are_you_sure(obj) }),
@@ -6,8 +6,8 @@
th= Cmtool::NewsletterSubscription.human_attribute_name(:email)
th= Cmtool::NewsletterSubscription.human_attribute_name(:deactivation_token)
th= Cmtool::NewsletterSubscription.human_attribute_name(:active)
th
th
th.action-header
th.action-header
tbody
- @newsletter_subscriptions.each do |newsletter_subscription|
tr
@@ -39,6 +39,8 @@ html lang="en"
li= link_to 'Wiki', 'https://github.com/bterkuile/cmtool/wiki', target: :_blank
= yield :sidebar
footer
p © Cmtool 2015
p
span © Cmtool
span= Date.today.year
= yield :footer
#hidden-html.hide= yield :hidden_html
+2
View File
@@ -64,9 +64,11 @@ module Cmtool
def flag_locales
[:ad, :ae, :af, :ag, :ai, :al, :am, :an, :ao, :aq, :ar, :as, :at, :au, :aw, :az, :ba, :bb, :bd, :be, :bf, :bg, :bh, :bi, :bj, :bm, :bn, :bo, :br, :bs, :bt, :bw, :by, :bz, :ca, :cd, :cf, :cg, :ch, :ci, :ck, :cl, :cm, :cn, :co, :cr, :cu, :cv, :cy, :cz, :de, :dj, :dk, :dm, :do, :dz, :ec, :ee, :eg, :eh, :en, :er, :es, :et, :fi, :fj, :fm, :fo, :fr, :ga, :gb, :gd, :ge, :gg, :gh, :gi, :gl, :gm, :gn, :gp, :gq, :gr, :gt, :gu, :gw, :gy, :hk, :hn, :hr, :ht, :hu, :id, :ie, :il, :im, :in, :iq, :ir, :is, :it, :je, :jm, :jo, :jp, :ke, :kg, :kh, :ki, :km, :kn, :kp, :kr, :kw, :ky, :kz, :la, :lb, :lc, :li, :lk, :lr, :ls, :lt, :lu, :lv, :ly, :ma, :mc, :md, :me, :mg, :mh, :mk, :ml, :mm, :mn, :mo, :mq, :mr, :ms, :mt, :mu, :mv, :mw, :mx, :my, :mz, :na, :nc, :ne, :ng, :ni, :nl, :no, :np, :nr, :nz, :om, :pa, :pe, :pf, :pg, :ph, :pk, :pl, :pr, :ps, :pt, :pw, :py, :qa, :re, :ro, :rs, :ru, :rw, :sa, :sb, :sc, :sd, :se, :sg, :si, :sk, :sl, :sm, :sn, :so, :sr, :st, :sv, :sy, :sz, :tc, :td, :tg, :th, :tj, :tl, :tm, :tn, :to, :tr, :tt, :tv, :tw, :tz, :ua, :ug, :us, :uy, :uz, :va, :vc, :ve, :vg, :vi, :vn, :vu, :ws, :ye, :za, :zm, :zw]
end
def locales
Rails.configuration.i18n.available_locales.presence || []
end
def default_locale
:en
end
+8 -4
View File
@@ -141,18 +141,22 @@ module Cmtool
def engine
return @options[:engine] if @options[:engine].present?
base = @options[:scope].presence
base ||= @resource.name.split('::').first if @resource.name.index('::')
if @options[:scope].present?
base = options[:scope].to_s.camelize
else
base = @resource.name.split('::').first if @resource.name.index('::')
end
return Rails.application unless base
return base if base.is_a?(Rails::Engine)
return base if base.is_a?(Rails::Engine) # WTF?
if e = "#{base}::Engine".safe_constantize
return e
end
return Rails.application
end
def nested_controller_name
if @options[:scope].present?
"#{@options[:scope]}::#{@resource.name.split('::').last}".underscore.pluralize
"#{@options[:scope].to_s.camelize}::#{@resource.name.split('::').last}".underscore.pluralize
else
@resource.name.underscore.pluralize
end