From 7c475b5ff38dbde353366f3af9562d81640a738e Mon Sep 17 00:00:00 2001 From: Andreas Nedbal Date: Sun, 11 Aug 2024 04:52:21 +0200 Subject: [PATCH] Add advanced frontpage layout config option --- app/controllers/about_controller.rb | 6 +- app/views/about/index.html.haml | 119 ++++++----------------- app/views/about/index_advanced.html.haml | 95 ++++++++++++++++++ config/justask.yml.example | 3 + config/locales/views.en.yml | 3 +- config/locales/voc.en.yml | 1 + lib/retrospring/config.rb | 2 + 7 files changed, 136 insertions(+), 93 deletions(-) create mode 100644 app/views/about/index_advanced.html.haml diff --git a/app/controllers/about_controller.rb b/app/controllers/about_controller.rb index 0b20d1b2..45cd7669 100644 --- a/app/controllers/about_controller.rb +++ b/app/controllers/about_controller.rb @@ -1,7 +1,11 @@ # frozen_string_literal: true class AboutController < ApplicationController - def index; end + def index + if Retrospring::Config.advanced_frontpage_enabled? + render template: "about/index_advanced" + end + end def about @users = Rails.cache.fetch("about_count_users", expires_in: 1.hour) { user_count - current_ban_count } diff --git a/app/views/about/index.html.haml b/app/views/about/index.html.haml index 65536828..7925968e 100644 --- a/app/views/about/index.html.haml +++ b/app/views/about/index.html.haml @@ -1,95 +1,32 @@ -- provide(:title, APP_CONFIG["site_name"]) .container - .card.bg-primary.my-3.text-bg-primary.text-center - .card-body.py-4 - = render "layouts/messages" - %h1= APP_CONFIG["site_name"] - %p= APP_CONFIG["site_tagline"] - - if Retrospring::Config.registrations_enabled? - %p - %a.btn.btn-outline-light.btn-lg{ href: url_for(new_user_registration_path) } - = t(".register") - %small - = t(".already_member") - = link_to t("voc.login"), new_user_session_path - - else - %p - %a.btn.btn-outline-light.btn-lg{ href: url_for(new_user_session_path) } - = t("voc.login") + .py-3.py-sm-5 + .row.d-sm-flex + .col-md-8.align-self-center.text-center.text-md-start + %h1 + - if APP_CONFIG["use_svg_logo"] + .d-inline-block.w-50 + = render inline: Rails.application.config.justask_svg_logo + - else + = APP_CONFIG["site_name"] + - if Rails.env.development? + %span.badge.rounded-pill.bg-warning.text-bg-warning + DEV + %p.lead= APP_CONFIG["site_tagline"] + .col-md-4 + %a.btn.btn-primary.d-grid{ href: url_for(new_user_registration_path) } + = t("voc.register_now") + .d-block.text-center.py-2.text-secondary + = t(".or") + .card + .card-body + = bootstrap_form_for(User.new, as: :user, url: session_path(:user), data: { turbo: false }) do |f| - .row.my-5.my-sm-10 - .col-sm-6.order-5.order-sm-1.text-center.text-sm-right - %h2.mb-4= t(".questions.header") - = t(".questions.body_html", app_name: APP_CONFIG["site_name"]) - .col-sm-6.order-1.order-sm-5 - .text-center.text-primary.d-flex.h-100.justify-content-center.fs-10 - %i.fa.fa-envelope.align-self-center.mb-5.mb-sm-0 + = f.text_field :login, autofocus: true, autocomplete: :username + = f.password_field :password, autocomplete: "current-password" - .row.my-5.my-sm-10 - .col-sm-6 - .text-center.text-primary.d-flex.h-100.justify-content-center.fs-10 - %i.fa.fa-comments.align-self-center.mb-5.mb-sm-0 - .col-sm-6.text-center.text-sm-left - %h2.mb-4= t(".discussions.header") - = t(".discussions.body_html", app_name: APP_CONFIG["site_name"]) + - if Devise.mappings[:user].rememberable? + = f.check_box :remember_me - .row.my-5.my-sm-10 - .col-sm-6.order-5.order-sm-1.text-center.text-sm-right - %h2.mb-4= t(".share.header") - = t(".share.body_html", app_name: APP_CONFIG["site_name"]) - .col-sm-6.order-1.order-sm-5 - .text-center.text-primary.d-flex.h-100.justify-content-center.fs-10 - %i.fa.fa-share.align-self-center.mb-5.mb-sm-0 - - .row.my-5.my-sm-10 - .col-sm-6 - .text-center.text-primary.d-flex.h-100.justify-content-center.fs-10 - %i.fa.fa-paint-brush.align-self-center.mb-5.mb-sm-0 - .col-sm-6.text-center.text-sm-left - %h2.mb-4= t(".customize.header") - = t(".customize.body_html", app_name: APP_CONFIG["site_name"]) - .card - .card-body - .row.mx-n2 - .col.px-2 - .d-grid - %button.btn.btn-success.js-theme-button{ data: { theme: "theme-success" } }= t(".customize.themes.green") - .col.px-2 - .d-grid - %button.btn.btn-warning.js-theme-button{ data: { theme: "theme-warning" } }= t(".customize.themes.orange") - .col.px-2 - .d-grid - %button.btn.btn-danger.js-theme-button{ data: { theme: "theme-danger" } }= t(".customize.themes.red") - .col.px-2 - .d-grid - %button.btn.btn-default.js-theme-button{ data: { theme: "reset" } }= t(".customize.themes.reset") - -.container.text-center - %h2.mb-4= t(".more_features") - .row.my-5 - .col-sm-4 - %h3.mb-3 - %i.fa.fa-fw.fa-globe.text-primary - = t(".open_source.header") - %p= t(".open_source.body", app_name: APP_CONFIG["site_name"]) - .col-sm-4 - %h3.mb-3 - %i.fa.fa-fw.fa-eye-slash.text-primary - = t(".no_ads.header") - %p= t(".no_ads.body") - .col-sm-4 - %h3.mb-3 - %i.fa.fa-fw.fa-user-secret.text-primary - = t(".your_data.header") - %p= t(".your_data.body", app_name: APP_CONFIG["site_name"]) - - - if APP_CONFIG.dig(:features, :registration, :enabled) - .card - .card-body - %h2= t(".prompt.header") - %p= t(".prompt.body") - %p - %a.btn.btn-primary.btn-lg{ href: url_for(new_user_registration_path) } - = t(".register") - -= render "shared/links" + = f.primary t("voc.login"), class: "btn btn-primary d-grid w-100" + + = render "shared/links" diff --git a/app/views/about/index_advanced.html.haml b/app/views/about/index_advanced.html.haml new file mode 100644 index 00000000..b8a6b852 --- /dev/null +++ b/app/views/about/index_advanced.html.haml @@ -0,0 +1,95 @@ +- provide(:title, APP_CONFIG["site_name"]) +.container + .card.bg-primary.my-3.text-bg-primary.text-center + .card-body.py-4 + = render "layouts/messages" + %h1= APP_CONFIG["site_name"] + %p= APP_CONFIG["site_tagline"] + - if Retrospring::Config.registrations_enabled? + %p + %a.btn.btn-outline-light.btn-lg{ href: url_for(new_user_registration_path) } + = t("voc.register_now") + %small + = t(".already_member") + = link_to t("voc.login"), new_user_session_path + - else + %p + %a.btn.btn-outline-light.btn-lg{ href: url_for(new_user_session_path) } + = t("voc.login") + + .row.my-5.my-sm-10 + .col-sm-6.order-5.order-sm-1.text-center.text-sm-right + %h2.mb-4= t(".questions.header") + = t(".questions.body_html", app_name: APP_CONFIG["site_name"]) + .col-sm-6.order-1.order-sm-5 + .text-center.text-primary.d-flex.h-100.justify-content-center.fs-10 + %i.fa.fa-envelope.align-self-center.mb-5.mb-sm-0 + + .row.my-5.my-sm-10 + .col-sm-6 + .text-center.text-primary.d-flex.h-100.justify-content-center.fs-10 + %i.fa.fa-comments.align-self-center.mb-5.mb-sm-0 + .col-sm-6.text-center.text-sm-left + %h2.mb-4= t(".discussions.header") + = t(".discussions.body_html", app_name: APP_CONFIG["site_name"]) + + .row.my-5.my-sm-10 + .col-sm-6.order-5.order-sm-1.text-center.text-sm-right + %h2.mb-4= t(".share.header") + = t(".share.body_html", app_name: APP_CONFIG["site_name"]) + .col-sm-6.order-1.order-sm-5 + .text-center.text-primary.d-flex.h-100.justify-content-center.fs-10 + %i.fa.fa-share.align-self-center.mb-5.mb-sm-0 + + .row.my-5.my-sm-10 + .col-sm-6 + .text-center.text-primary.d-flex.h-100.justify-content-center.fs-10 + %i.fa.fa-paint-brush.align-self-center.mb-5.mb-sm-0 + .col-sm-6.text-center.text-sm-left + %h2.mb-4= t(".customize.header") + = t(".customize.body_html", app_name: APP_CONFIG["site_name"]) + .card + .card-body + .row.mx-n2 + .col.px-2 + .d-grid + %button.btn.btn-success.js-theme-button{ data: { theme: "theme-success" } }= t(".customize.themes.green") + .col.px-2 + .d-grid + %button.btn.btn-warning.js-theme-button{ data: { theme: "theme-warning" } }= t(".customize.themes.orange") + .col.px-2 + .d-grid + %button.btn.btn-danger.js-theme-button{ data: { theme: "theme-danger" } }= t(".customize.themes.red") + .col.px-2 + .d-grid + %button.btn.btn-default.js-theme-button{ data: { theme: "reset" } }= t(".customize.themes.reset") + +.container.text-center + %h2.mb-4= t(".more_features") + .row.my-5 + .col-sm-4 + %h3.mb-3 + %i.fa.fa-fw.fa-globe.text-primary + = t(".open_source.header") + %p= t(".open_source.body", app_name: APP_CONFIG["site_name"]) + .col-sm-4 + %h3.mb-3 + %i.fa.fa-fw.fa-eye-slash.text-primary + = t(".no_ads.header") + %p= t(".no_ads.body") + .col-sm-4 + %h3.mb-3 + %i.fa.fa-fw.fa-user-secret.text-primary + = t(".your_data.header") + %p= t(".your_data.body", app_name: APP_CONFIG["site_name"]) + + - if APP_CONFIG.dig(:features, :registration, :enabled) + .card + .card-body + %h2= t(".prompt.header") + %p= t(".prompt.body") + %p + %a.btn.btn-primary.btn-lg{ href: url_for(new_user_registration_path) } + = t(".register") + += render "shared/links" diff --git a/config/justask.yml.example b/config/justask.yml.example index 86f00197..f6c4fa80 100644 --- a/config/justask.yml.example +++ b/config/justask.yml.example @@ -58,6 +58,9 @@ features: # Registrations registration: enabled: true + # Advanced (marketing) frontpage layout + advanced_frontpage: + enabled: false # Redis redis_url: "redis://localhost:6379" diff --git a/config/locales/views.en.yml b/config/locales/views.en.yml index cb144620..27044c0b 100644 --- a/config/locales/views.en.yml +++ b/config/locales/views.en.yml @@ -2,7 +2,8 @@ en: language: "English" about: index: - register: "Register now" + or: "or" + index_advanced: already_member: "Already a member?" more_features: "But wait, there's more!" questions: diff --git a/config/locales/voc.en.yml b/config/locales/voc.en.yml index 0603cf05..54af769e 100644 --- a/config/locales/voc.en.yml +++ b/config/locales/voc.en.yml @@ -24,6 +24,7 @@ en: subscribe: "Subscribe" unsubscribe: "Unsubscribe" register: "Sign up" + register_now: "Register now" remove: "Remove" report: "Report" terms: "Terms of Service" diff --git a/lib/retrospring/config.rb b/lib/retrospring/config.rb index 3138e762..9ed9dd74 100644 --- a/lib/retrospring/config.rb +++ b/lib/retrospring/config.rb @@ -23,5 +23,7 @@ module Retrospring end def registrations_enabled? = APP_CONFIG.dig(:features, :registration, :enabled) + + def advanced_frontpage_enabled? = APP_CONFIG.dig(:features, :advanced_frontpage, :enabled) end end