Skip to content

Commit

Permalink
♻️ Favor configurable html head title value
Browse files Browse the repository at this point in the history
Prior to this commit, we hard-coded the page title; this is something
that should be far more configurable.  And this refactor is a step
towards that.

This also allows for downstream implementors to not have to override the
view simply to change the title element.
  • Loading branch information
jeremyf committed Oct 10, 2023
1 parent c114626 commit 2ff5f6c
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!DOCTYPE html>
<html>
<head>
<title>Hyku</title>
<title><%= Hyku::Application.html_head_title %></title>
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
<%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
<%= csrf_meta_tags %>
Expand Down
9 changes: 9 additions & 0 deletions config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,15 @@ def self.utf_8_encode(string)
end

class Application < Rails::Application
##
# @!group Class Attributes
#
# @!attribute html_head_title
# The title to render for the application's HTML > HEAD > TITLE element.
# @return [String]
class_attribute :html_head_title, default: "Hyku", attr_accessor: false
# @!endgroup Class Attributes

# Add this line to load the lib folder first because we need
# IiifPrint::SplitPdfs::AdventistPagesToJpgsSplitter
config.autoload_paths.unshift("#{Rails.root}/lib")
Expand Down
9 changes: 9 additions & 0 deletions spec/config/application_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe Hyku::Application do
describe '.html_head_title' do
it { is_expected.to be_a(String) }
end
end

0 comments on commit 2ff5f6c

Please sign in to comment.