5
3
mirror of https://github.com/tildeverse/lobsters synced 2024-06-20 07:27:05 +00:00

only show title h1 on useful pages

Most pages don't need a big h1 because it's clear from the subnav, clear from
the content, or users use them frequently enough to learn and be comfortable.
This commit is contained in:
Peter Bhat Harkins 2022-02-23 21:18:50 -06:00
parent d88771407d
commit d6cb285df0
25 changed files with 108 additions and 84 deletions

View File

@ -250,11 +250,10 @@ li.story div.details span.link a:visited {
}
h1 {
margin: 0px;
margin-bottom: 0.75em;
padding: 0px;
font-size: 14pt;
font-size: 12pt;
font-weight: bold;
margin: 0.5em 0 1em 0;
padding: 0;
}
h2 {
font-size: 11pt;
@ -530,9 +529,9 @@ header#nav a, header#subnav a {
}
header#subnav {
box-sizing: border-box;
height: 2em;
min-height: 2em;
line-height: 1em;
padding: 0.5em;
padding: 0.5rem 0;
text-align: right;
width: 100%;
}
@ -546,11 +545,14 @@ header#nav #l_holder, header#nav #l_holder ~ a {
header#nav a:last-child {
margin-right: 0;
}
header .inbox_unread {
color: var(--color-fg-accent);
}
#inside {
margin: 0.5rem 0;
}
/* footer */
footer {
@ -1295,13 +1297,6 @@ table.data pre {
/* boxes */
.box h1.title {
margin-bottom: 1em;
padding: 0;
font-weight: bold;
font-size: 11pt;
}
.box label {
display: block;
float: left;
@ -1354,7 +1349,6 @@ table.data pre {
.box span.d label,
.box td label,
.box h1.title label,
.box div.d label {
display: inline;
float: none;
@ -1507,7 +1501,7 @@ div.flash-success h2 {
}
header#nav {
margin: 1em 0 0.5rem;
margin: 1em 0 0.5rem 0;
padding: 5px 10px;
}
header#nav nav.links {
@ -1617,11 +1611,7 @@ div.flash-success h2 {
padding-left: 0;
}
div#inside {
margin: 0 0.5rem;
}
h1.title {
margin-top: 0.5em;
margin: 0.5rem;
}
.comment {

View File

@ -1,5 +1,6 @@
class AboutController < ApplicationController
caches_page :about, :chat, if: CACHE_PAGE
before_action :show_title_h1
def four_oh_four
begin

View File

@ -23,6 +23,11 @@ class ApplicationController < ActionController::Base
status: :bad_request, content_type: 'text/plain'
end
def agent_is_spider?
ua = request.env["HTTP_USER_AGENT"].to_s
(ua == "" || ua.match(/(Google|bing|Slack|Twitter)bot|Slurp|crawler|Feedly|FeedParser|RSS/))
end
def authenticate_user
# eagerly evaluate, in case this triggers an IpSpoofAttackError
request.remote_ip
@ -53,6 +58,12 @@ class ApplicationController < ActionController::Base
true
end
def find_user_from_rss_token
if !@user && request[:format] == "rss" && params[:token].to_s.present?
@user = User.where(:rss_token => params[:token].to_s).first
end
end
def flag_warning
@flag_warning_int = time_interval('1m')
@show_flag_warning = (
@ -66,6 +77,13 @@ class ApplicationController < ActionController::Base
end
end
def prepare_exception_notifier
exception_data = {}
exception_data[:username] = @user.username unless @user.nil?
request.env["exception_notifier.exception_data"] = exception_data
end
# https://web.archive.org/web/20180108083712/http://umaine.edu/lobsterinstitute/files/2011/12/LobsterColorsWeb.pdf
def set_traffic_style
@traffic_intensity = '?'
@ -150,27 +168,13 @@ class ApplicationController < ActionController::Base
return redirect_to "/" if @user
end
def show_title_h1
@title_h1 = true
end
def tags_filtered_by_cookie
@_tags_filtered ||= Tag.where(
:tag => cookies[TAG_FILTER_COOKIE].to_s.split(",")
)
end
def agent_is_spider?
ua = request.env["HTTP_USER_AGENT"].to_s
(ua == "" || ua.match(/(Google|bing|Slack|Twitter)bot|Slurp|crawler|Feedly|FeedParser|RSS/))
end
def find_user_from_rss_token
if !@user && request[:format] == "rss" && params[:token].to_s.present?
@user = User.where(:rss_token => params[:token].to_s).first
end
end
def prepare_exception_notifier
exception_data = {}
exception_data[:username] = @user.username unless @user.nil?
request.env["exception_notifier.exception_data"] = exception_data
end
end

View File

@ -7,6 +7,7 @@ class CommentsController < ApplicationController
:only => [:create, :preview, :upvote, :flag, :unvote]
before_action :require_logged_in_user, :only => [:upvoted]
before_action :flag_warning, only: [:threads]
before_action :show_title_h1
# for rss feeds, load the user's tag filters if a token is passed
before_action :find_user_from_rss_token, :only => [:index]
@ -330,8 +331,7 @@ class CommentsController < ApplicationController
@title = "Threads for #{@showing_user.username}"
@cur_url = "/threads/#{@showing_user.username}"
elsif !@user
# TODO: show all recent threads
return redirect_to "/login"
return redirect_to active_path
else
@showing_user = @user
@title = "Your Threads"

View File

@ -1,12 +1,13 @@
class FiltersController < ApplicationController
before_action :authenticate_user
before_action :show_title_h1
def index
@cur_url = "/filters"
@title = "Filtered Tags"
@categories = Category.all
.order('category asc')
.order('category asc, tags.tag asc')
.eager_load(:tags)
.references(:tags)
.where('tags.active = true')

View File

@ -1,6 +1,7 @@
class HatsController < ApplicationController
before_action :require_logged_in_user, :except => [:index]
before_action :require_logged_in_moderator, :except => [:build_request, :index, :create_request]
before_action :show_title_h1
def build_request
@title = "Request a Hat"

View File

@ -6,7 +6,22 @@ class HomeController < ApplicationController
# for rss feeds, load the user's tag filters if a token is passed
before_action :find_user_from_rss_token, :only => [:index, :newest, :saved, :upvoted]
before_action { @page = page }
before_action :require_logged_in_user, :only => [:upvoted]
before_action :require_logged_in_user, :only => [:hidden, :saved, :upvoted]
before_action :show_title_h1, only: [:top]
def active
@stories, @show_more = get_from_cache(active: true) {
paginate stories.active
}
@title = 'Active Discussions'
@cur_url = '/active'
respond_to do |format|
format.html { render action: :index }
format.json { render json: @stories }
end
end
def hidden
@stories, @show_more = get_from_cache(hidden: true) {
@ -54,20 +69,6 @@ class HomeController < ApplicationController
end
end
def active
@stories, @show_more = get_from_cache(active: true) {
paginate stories.active
}
@title = 'Active Discussions'
@cur_url = '/active'
respond_to do |format|
format.html { render action: :index }
format.json { render json: @stories }
end
end
def newest
@stories, @show_more = get_from_cache(newest: true) {
paginate stories.newest
@ -107,9 +108,7 @@ class HomeController < ApplicationController
@title = "Newest Stories by #{by_user.username}"
@cur_url = "/newest/#{by_user.username}"
@newest = true
@for_user = by_user.username
@newest_by_user = by_user
respond_to do |format|
format.html { render :action => "index" }

View File

@ -1,5 +1,6 @@
class InvitationsController < ApplicationController
before_action :require_logged_in_user, :except => [:build, :create_by_request, :confirm_email]
before_action :show_title_h1
def build
@title = "Request an Invitation"

View File

@ -9,6 +9,7 @@ class LoginController < ApplicationController
before_action :check_for_read_only_mode, :except => [:index]
before_action :require_no_user_or_redirect,
only: [:index, :login, :forgot_password, :reset_password]
before_action :show_title_h1
def logout
if @user

View File

@ -2,6 +2,7 @@ class MessagesController < ApplicationController
before_action :require_logged_in_user
before_action :require_logged_in_moderator, only: [:mod_note]
before_action :find_message, :only => [:show, :destroy, :keep_as_new, :mod_note]
before_action :show_title_h1
def index
@title = "Private Messages"

View File

@ -4,7 +4,7 @@
class ModController < ApplicationController
include IntervalHelper
before_action :require_logged_in_moderator, :default_periods
before_action :require_logged_in_moderator, :default_periods, :show_title_h1
def index
@title = "Activity by Other Mods"

View File

@ -1,6 +1,8 @@
class ModerationsController < ApplicationController
ENTRIES_PER_PAGE = 50
before_action :show_title_h1
def index
@title = "Moderation Log"
@moderators = ['(All)', '(Users)'] + User.moderators.map(&:username)

View File

@ -1,7 +1,7 @@
class RepliesController < ApplicationController
REPLIES_PER_PAGE = 25
before_action :require_logged_in_user, :flag_warning, :set_page
before_action :require_logged_in_user, :flag_warning, :set_page, :show_title_h1
after_action :update_read_ribbons, only: [:unread]
after_action :clear_unread_replies_cache, only: [:comments, :stories]
after_action :zero_unread_replies_cache, only: [:all, :unread]

View File

@ -1,4 +1,6 @@
class SearchController < ApplicationController
before_action :show_title_h1
def index
@title = "Search"
@cur_url = "/search"

View File

@ -1,5 +1,5 @@
class SettingsController < ApplicationController
before_action :require_logged_in_user
before_action :require_logged_in_user, :show_title_h1
TOTP_SESSION_TIMEOUT = (60 * 15)

View File

@ -1,6 +1,6 @@
class SignupController < ApplicationController
before_action :require_logged_in_user, :check_new_users, :check_can_invite, :only => :invite
before_action :check_for_read_only_mode
before_action :check_for_read_only_mode, :show_title_h1
def index
@title = "Create an Account"

View File

@ -9,6 +9,7 @@ class StoriesController < ApplicationController
before_action :find_user_story, :only => [:destroy, :edit, :undelete, :update]
before_action :find_story!, :only => [:suggest, :submit_suggestions]
around_action :track_story_reads, only: [:show], if: -> { @user.present? }
before_action :show_title_h1, only: [:new, :edit, :suggest]
def create
@title = "Submit Story"

View File

@ -1,5 +1,6 @@
class TagsController < ApplicationController
before_action :require_logged_in_admin, except: [:index]
before_action :show_title_h1, only: [:new, :edit]
def index
@cur_url = "/tags"

View File

@ -5,6 +5,7 @@ class UsersController < ApplicationController
before_action :flag_warning, only: [:show]
before_action :require_logged_in_user, only: [:standing]
before_action :only_user_or_moderator, only: [:standing]
before_action :show_title_h1, only: [:show]
def show
@title = @showing_user.username

View File

@ -1,3 +1,5 @@
<%= render partial: 'messages/subnav' %>
<%= render partial: 'users/flag_warning' if @show_flag_warning && @showing_user == @user %>
<% @threads.each do |thread| %>

View File

@ -4,27 +4,34 @@
<% render partial: 'stories/subnav' %>
<% end %>
<% if @cur_url == "/recent" %>
<div class="box">
<em>The <a href="/newest">newest</a> stories that have not yet reached the front page.</em>
</div>
<% if @cur_url == "/active" %>
<p class="hint">
Stories with active discussions.
</p>
<% end %>
<% if @newest_by_user %>
<p>
Newest stories submitted by
<%= link_to @newest_by_user.username, user_path(@newest_by_user) %>.
</p>
<% end %>
<% if @domain.present? %>
<p>
<%= @domain.domain %>:
<%= "#{@domain.stories.count} story".pluralize(@domain.stories.count) %> from
<%= "#{@domain.n_submitters} submitter".pluralize(@domain.n_submitters) %>
</p>
<% if @domain.banned? %>
<div class="box">
<p>
Banned
<%= time_ago_in_words_label(@domain.banned_at) %>
<% if @domain.banned_by_user %>
by <%= link_to @domain.banned_by_user.try(:username), @domain.banned_by_user %>:
<em><%= @domain.banned_reason %></em>
<em><%= @domain.banned_reason %></em>
<% end %>
</div>
</p>
<% end %>
<div class="box">
<%= "#{@domain.stories.count} story".pluralize(@domain.stories.count) %> from
<%= "#{@domain.n_submitters} submitter".pluralize(@domain.n_submitters) %>
</div>
<% end %>
<% if @categories.present? %>
<div class="box">
@ -47,8 +54,6 @@
&ndash; <%= tag.description %>
<% end %>
<% end %>
<%= render(partial: 'tags/multi_tag_tip') if @tags.count == 1 %>
</div>
<% end %>
@ -56,6 +61,14 @@
<%= render partial: "stories/listdetail", collection: @stories, as: :story %>
</ol>
<%= render(partial: 'tags/multi_tag_tip') if @tags && @tags.count == 1 %>
<% if @cur_url == "/recent" %>
<p class="hint">
The <a href="/newest">newest</a> stories that have not yet reached the front page.
</p>
<% end %>
<div class="morelink">
<% if @page && @page > 1 %>
<a href="<%= @cur_url %><%= @cur_url == "/" ? "" : "/" %><%=

View File

@ -94,8 +94,8 @@
<% end %>
<div id="inside">
<% if @title.present? %>
<h1 class="title <%= @title_class %>"><%= @title %></h1>
<% if @title.present? && @title_h1 %>
<h1 class="<%= @title_class %>"><%= @title %></h1>
<% end %>
<% [ :error, :success, :notice ].each do |f| %>

View File

@ -4,6 +4,8 @@
<%= link_to_different_page('Comments', replies_comments_path) %>
<%= link_to_different_page('Stories', replies_stories_path) %>
|
<%= link_to_different_page('Threads', threads_path) %>
|
<%= link_to_different_page 'Messages', messages_path %>
<%= link_to_different_page 'Sent', messages_sent_path %>
<% end %>

View File

@ -1,6 +1,9 @@
<% is_admin = @user.try(:is_admin?) %>
<div class="box wide">
<p>Inactive tags can no longer be used. You can also <a href="/filters">filter out stories by tag</a>, even if you don't have an account.</p>
<p>
You can <a href="/filters">filter out stories by tag</a>, even if you don't have an account.
Inactive tags can no longer be used on new stories.
</p>
<% @categories.each do |category| %>
<h2 id="<%= category.category %>"><%= link_to category.category, category_path(category) %></h2>

View File

@ -1,7 +1,5 @@
<div class="box wide">
<p>
<strong><%= @title %> (<%= number_with_delimiter(@user_count) %>)</strong>
</p>
<h1><%= @title %> (<%= number_with_delimiter(@user_count) %>)</h1>
<% if @newest %>
<p>