From 4c29d57aae5b874dba0821ae753ed0b016ca7a7a Mon Sep 17 00:00:00 2001 From: Michael Ball Date: Tue, 14 Jul 2020 17:43:48 -0700 Subject: [PATCH] Add a very basic custom_css property to a conference. It is loaded on all pages for that conference. --- app/controllers/admin/conferences_controller.rb | 2 +- app/views/admin/conferences/edit.html.haml | 5 +++++ app/views/layouts/application.html.haml | 4 ++++ db/migrate/20200715001812_add_custom_css_to_confereneces.rb | 5 +++++ db/schema.rb | 5 +++-- 5 files changed, 18 insertions(+), 3 deletions(-) create mode 100644 db/migrate/20200715001812_add_custom_css_to_confereneces.rb diff --git a/app/controllers/admin/conferences_controller.rb b/app/controllers/admin/conferences_controller.rb index 43a6c125..dc73df87 100644 --- a/app/controllers/admin/conferences_controller.rb +++ b/app/controllers/admin/conferences_controller.rb @@ -182,7 +182,7 @@ module Admin :vpositions_attributes, :use_volunteers, :color, :sponsorship_levels_attributes, :sponsors_attributes, :registration_limit, :organization_id, :ticket_layout, - :booth_limit) + :booth_limit, :custom_css) end end end diff --git a/app/views/admin/conferences/edit.html.haml b/app/views/admin/conferences/edit.html.haml index 456c5f12..de0c5811 100644 --- a/app/views/admin/conferences/edit.html.haml +++ b/app/views/admin/conferences/edit.html.haml @@ -17,6 +17,11 @@ = image_tag @conference.picture.thumb.url = f.input :picture, label: false, hint: 'This will be displayed on the front page.' = f.hidden_field :picture_cache + + = f.input :custom_css, + hint: "Add Custon CSS to the main page. You might find the class '.conference-#{@conference.short_title}' useful.", + input_html: { rows: 5 } + = f.input :ticket_layout, as: :select, collection: Conference.ticket_layouts.keys, hint: "Layout type for tickets of the conference." = f.inputs name: 'Scheduling' do = f.input :timezone, as: :time_zone, hint: 'The conference time zone' diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index df1b9da4..1b5e7574 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -21,6 +21,10 @@ = javascript_include_tag "//cdn.transifex.com/live.js" = yield(:head) + - if @conference && @conference.custom_css? + %style{type: 'text/css'} + = @conference.custom_css + %body{ class: ("conference-#{@conference.short_title}" if @conference) } = render 'layouts/navigation', conference: @conference -# Admin area diff --git a/db/migrate/20200715001812_add_custom_css_to_confereneces.rb b/db/migrate/20200715001812_add_custom_css_to_confereneces.rb new file mode 100644 index 00000000..012c4bc6 --- /dev/null +++ b/db/migrate/20200715001812_add_custom_css_to_confereneces.rb @@ -0,0 +1,5 @@ +class AddCustomCssToConfereneces < ActiveRecord::Migration[5.2] + def change + add_column :conferences, :custom_css, :text + end +end diff --git a/db/schema.rb b/db/schema.rb index f888a737..07effdca 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2020_07_10_215300) do +ActiveRecord::Schema.define(version: 2020_07_15_001812) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -107,6 +107,7 @@ ActiveRecord::Schema.define(version: 2020_07_10_215300) do t.integer "ticket_layout", default: 0 t.string "custom_domain" t.integer "booth_limit", default: 0 + t.text "custom_css" t.index ["organization_id"], name: "index_conferences_on_organization_id" end @@ -406,7 +407,7 @@ ActiveRecord::Schema.define(version: 2020_07_10_215300) do t.string "name", null: false t.integer "size" t.integer "venue_id", null: false - t.string "url" + t.text "url" end create_table "schedules", force: :cascade do |t|