From f6b6d8d4024e2116dd8239b2dfb63efda30c0db0 Mon Sep 17 00:00:00 2001 From: Aidan Cornelius-Bell Date: Mon, 18 Nov 2024 16:25:28 +1030 Subject: [PATCH] Added promo messages to join; rewrote join page --- app/assets/stylesheets/application.css | 5 ++++ app/controllers/pubview_controller.rb | 31 ++++++++++++++------- app/views/layouts/_home_post_links.html.erb | 5 ++-- app/views/pubview/index.html.erb | 4 +++ app/views/pubview/join.html.erb | 17 +++++++---- app/views/pubview/post.html.erb | 5 +++- 6 files changed, 48 insertions(+), 19 deletions(-) diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css index e1982d3..21cc74d 100644 --- a/app/assets/stylesheets/application.css +++ b/app/assets/stylesheets/application.css @@ -281,6 +281,11 @@ footer p { font-size: 0.8rem; } +.lead { + font-size: 1.1em; + text-align: center; +} + .porter { max-width: 170px; float: right; diff --git a/app/controllers/pubview_controller.rb b/app/controllers/pubview_controller.rb index e947fcb..c97cbb6 100644 --- a/app/controllers/pubview_controller.rb +++ b/app/controllers/pubview_controller.rb @@ -1,16 +1,17 @@ class PubviewController < ApplicationController - - def index + before_action :set_promo, only: [:index, :post] + + def index @per_page = 15 @page = params[:page].to_i || 1 @filter = params[:filter] || 'all' - + @items = Post.get_posts_and_bookmarks_with_pagination(@page, @per_page, @filter) @total_pages = @items.total_pages @current_page = @items.current_page end - - def show_public + + def show_public if current_user&.admin? @page = Page.find_by(slug: params[:slug], visibility: ['visible', 'user_only', 'admin_only']) elsif current_user @@ -25,17 +26,17 @@ class PubviewController < ApplicationController render 'error/error', status: :not_found end end - + def join - + end def post start_date = Date.new(params[:year].to_i, 1, 1) end_date = Date.new(params[:year].to_i, 12, 31) - + @post = Post.find_by(slug: params[:slug], published_at: start_date..end_date) - + if @post @reading_time = calculate_reading_time(@post.content) @excerpt = @post.generate_excerpt @@ -53,7 +54,7 @@ class PubviewController < ApplicationController format.rss { render layout: false } end end - + def dispatches_rss @posts = Post.dispatches.order(published_at: :desc).limit(20) respond_to do |format| @@ -63,6 +64,16 @@ class PubviewController < ApplicationController private + def set_promo + @promo_strings = [ + "Join mind reader’s free community of radical thinkers analysing capitalism’s contradictions and imagining better futures.", + "Like what you’re reading? Join mind reader (free) to get fresh critical analysis delivered directly to you.", + "Support independent radical thought. Join mind reader’s growing community of readers thinking deeply about social transformation.", + "Want more analysis like this? Join mind reader (free) to never miss a dispatch.", + "Be part of the conversation. Join mind reader’s free community of readers analysing capitalism, technology and social change." + ] + end + def calculate_reading_time(content) word_count = content.split.size (word_count / 200.0).ceil diff --git a/app/views/layouts/_home_post_links.html.erb b/app/views/layouts/_home_post_links.html.erb index 0d43f21..066ea83 100644 --- a/app/views/layouts/_home_post_links.html.erb +++ b/app/views/layouts/_home_post_links.html.erb @@ -1,8 +1,9 @@ <% if !@post&.short_dispatch? %> <% if @post&.title? %>

Follow via RSS, Email or Membership...

<% end %> -

→ Prefer email or want to sponsor? Learn about supporting my work and joining the free mailing list <%= link_to "right here ↙︎".html_safe, "/join/" %>.

+

→ Want an email for each new post? Join the mailing list for free <%= link_to "right here ↙︎".html_safe, "/join/" %>.

+

→ Like this work and want to support it? Get started <%= link_to " here ↙︎".html_safe, "/join/" %>.

→ Prefer RSS? you can subscribe to a combined <%= link_to "bookmarks+dispatches feed here ↙︎".html_safe, rss_path %> or <%= link_to "full text dispatches only feed here ↗︎".html_safe, dispatches_rss_path %>.

<% end %> <% if @post %>

<%= link_to "↑ Back to top", "#top" %> or <%= link_to "↼ Back to some other dispatches...", "#{root_path}?filter=posts" %>

-<% end %> \ No newline at end of file +<% end %> diff --git a/app/views/pubview/index.html.erb b/app/views/pubview/index.html.erb index f7c5167..f2431e1 100644 --- a/app/views/pubview/index.html.erb +++ b/app/views/pubview/index.html.erb @@ -8,6 +8,10 @@ <%= render partial: "layouts/navigation_buttons" %> +<% if !current_user %> +

<%= @promo_strings.sample %> <%= link_to "Start right now", join_path %>.

+<% end %> +
-- 2.39.5