From 3aa204aa303c7c0579a00cf0b638e5e733ff8319 Mon Sep 17 00:00:00 2001 From: Benjamin ter Kuile Date: Thu, 5 Mar 2020 11:36:19 -0500 Subject: [PATCH] Changes for mozo host --- .../javascripts/cmtool/application.js.coffee | 4 ++++ app/helpers/cmtool/application_helper.rb | 19 +++++++++++-------- app/views/cmtool/application/_menu.html.slim | 4 ++-- .../newsletter_subscriptions/index.html.slim | 4 ++-- .../layouts/cmtool/application.html.slim | 4 +++- lib/cmtool/includes/page.rb | 2 ++ lib/cmtool/menu.rb | 12 ++++++++---- 7 files changed, 32 insertions(+), 17 deletions(-) diff --git a/app/assets/javascripts/cmtool/application.js.coffee b/app/assets/javascripts/cmtool/application.js.coffee index 45da285..4df08ec 100644 --- a/app/assets/javascripts/cmtool/application.js.coffee +++ b/app/assets/javascripts/cmtool/application.js.coffee @@ -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") diff --git a/app/helpers/cmtool/application_helper.rb b/app/helpers/cmtool/application_helper.rb index a061ec4..470b137 100644 --- a/app/helpers/cmtool/application_helper.rb +++ b/app/helpers/cmtool/application_helper.rb @@ -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) }), diff --git a/app/views/cmtool/application/_menu.html.slim b/app/views/cmtool/application/_menu.html.slim index e771fb1..0a8a050 100644 --- a/app/views/cmtool/application/_menu.html.slim +++ b/app/views/cmtool/application/_menu.html.slim @@ -1,12 +1,12 @@ - user = defined?(cmtool_user) ? cmtool_user : (defined?(current_user) ? current_user : nil) .fixed - nav.top-bar data-topbar="" role="navigation" + nav.top-bar data-topbar="" role="navigation" ul.title-area li.name h1 a href=cmtool.root_path = application_title li.toggle-topbar.menu-icon - a href="#" + a href="#" span Menu section.top-bar-section - if user.present? diff --git a/app/views/cmtool/newsletter_subscriptions/index.html.slim b/app/views/cmtool/newsletter_subscriptions/index.html.slim index e8c8c4d..4f56ce9 100644 --- a/app/views/cmtool/newsletter_subscriptions/index.html.slim +++ b/app/views/cmtool/newsletter_subscriptions/index.html.slim @@ -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 diff --git a/app/views/layouts/cmtool/application.html.slim b/app/views/layouts/cmtool/application.html.slim index 1c0b5e9..8400c8a 100644 --- a/app/views/layouts/cmtool/application.html.slim +++ b/app/views/layouts/cmtool/application.html.slim @@ -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 diff --git a/lib/cmtool/includes/page.rb b/lib/cmtool/includes/page.rb index 5ee3f72..d7ff0e0 100644 --- a/lib/cmtool/includes/page.rb +++ b/lib/cmtool/includes/page.rb @@ -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 diff --git a/lib/cmtool/menu.rb b/lib/cmtool/menu.rb index 388e50d..cc98228 100644 --- a/lib/cmtool/menu.rb +++ b/lib/cmtool/menu.rb @@ -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