generated from kevinlin1/just-the-class
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #33 from berkeley-cdss/minor-a11y-templates
A11Y + Template Enhancements
- Loading branch information
Showing
51 changed files
with
32,234 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,4 +11,5 @@ _site/ | |
|
||
node_modules/ | ||
vendor/ | ||
!assets/vendor/ | ||
tmp/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
require: | ||
- rubocop-rspec | ||
- rubocop-capybara | ||
|
||
AllCops: | ||
NewCops: enable |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<!-- This file comes from Just The Docs. | ||
This footer should be included on all EECS/DS sites. | ||
--> | ||
|
||
{%- if site.footer_content and site.footer_content != true -%} | ||
<p class="text-small text-grey-dk-100 m-0">{{ site.footer_content }}</p> | ||
{%- endif -%} | ||
|
||
<p class="text-small text-grey-dk-100 my-1"> | ||
<a rel="nofollow noopener" href="https://dap.berkeley.edu/get-help/report-web-accessibility-issue" target="_blank" class="pr-2">Accessibility <i class="fa-solid fa-external-link" aria-hidden=true></i></a> | ||
<a rel="nofollow noopener" href="https://ophd.berkeley.edu/policies-and-procedures/nondiscrimination-policy-statement" target="_blank" class="px-2">Nondiscrimination <i class="fa-solid fa-external-link" aria-hidden=true></i></a> | ||
</p> | ||
|
||
<!-- Use this to add additional content. --> | ||
<p class="text-small text-grey-dk-100 m-0"> | ||
Copyright ©{{ "now" | date: "%Y" }}, Regents of the University of Californa and respective authors. | ||
</p> | ||
|
||
<p class="fs-1 text-grey-dk-100 my-1"> | ||
This site is built following the <a href="https://github.com/just-the-docs/just-the-docs" target="_bank" rel="noopener">Berkeley Class Site <i class="fa-solid fa-external-link" aria-hidden=true></i></a> template, which is generously based on the <a href="https://github.com/kevinl/just-the-class" target="_bank" rel="noopener">Just the Class <i class="fa-solid fa-external-link" aria-hidden=true></i></a>, and <a href="https://github.com/just-the-docs/just-the-docs" target="_bank" rel="noopener">Just the Docs <i class="fa-solid fa-external-link" aria-hidden=true></i></a> templates. | ||
</p> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<!-- Use this to add global CSS/JS utitlties. --> | ||
|
||
<!-- Loading the v6 core styles and the Solid and Brands styles --> | ||
<link href="{{ site.baseurl }}/assets/vendor/fontawesome/css/fontawesome.css" rel="stylesheet" /> | ||
<link href="{{ site.baseurl }}/assets/vendor/fontawesome/css/brands.css" rel="stylesheet" /> | ||
<link href="{{ site.baseurl }}/assets/vendor/fontawesome/css/solid.css" rel="stylesheet" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<!-- This file adds links at the bottom of the sidebar on the left. --> | ||
|
||
{% if site.class_archive_path %} | ||
<footer class="site-footer"> | ||
<a href="{{ site.class_archive_path }}" | ||
target="_blank" rel="noopener nofollow">View all course offerings | ||
<i class="fa-solid fa-external-link" aria-hidden="true"></i></a> | ||
</footer> | ||
{% endif %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
# frozen_string_literal: true | ||
|
||
# A UC Berkeley-specific validator for Jekyll sites | ||
# This class validates the following options: | ||
# 1) Ensures required attributes are present in the config file. | ||
# 2) Ensures the baseurl is a consistent format based on the semester | ||
# 3) Uses a `course_department` config to implement some shared styling/language. | ||
# Future config validations might make sense, like footer/a11y/etc. | ||
|
||
# Implement additional validations by registering an entry in `KEY_VALIDATIONS` | ||
# This is a key_name => function_name map. | ||
# function_name should be defined in the ConfigValidator class, and is called with | ||
# the *value* of the config. | ||
# Note that Jekyll parses the YAML file such that the config keys are *strings* not symbols. | ||
|
||
# A simple class for nicer error message formatting. | ||
class ConfigValidationError < StandardError | ||
attr_reader :errors | ||
|
||
def initialize(errors) | ||
super | ||
@errors = errors | ||
end | ||
|
||
def message | ||
"The config file contained validation errors:\n\t#{errors.join('\n\t')}\n\n" | ||
end | ||
end | ||
|
||
module Jekyll | ||
# Jekyll::ConfigValidator class definition (see docs at the top of file) | ||
class ConfigValidator | ||
SEMESTER_REGEXP = /(wi|sp|su|fa)\d\d$/ | ||
VALID_DEPTS = %w[eecs dsus stat].freeze | ||
KEY_VALIDATIONS = { | ||
url: :validate_clean_url, | ||
baseurl: :validate_semester_format, | ||
course_department: :validate_department | ||
}.freeze | ||
|
||
attr_accessor :config, :errors | ||
|
||
def initialize(config) | ||
@config = config | ||
@errors = [] | ||
end | ||
|
||
def validate | ||
validate_keys! | ||
|
||
KEY_VALIDATIONS.each do |key, validator| | ||
send(validator, config[key.to_s]) if @config.key?(key.to_s) | ||
end | ||
|
||
raise ConfigValidationError, errors if errors.length.positive? | ||
|
||
puts 'Passed Berkeley YAML Config Validations' | ||
end | ||
|
||
def validate_keys! | ||
required_keys = %i[baseurl course_department] | ||
required_keys.each do |key| | ||
errors << "#{key} is missing from site config" unless @config.key?(key.to_s) | ||
end | ||
end | ||
|
||
private | ||
|
||
def validate_clean_url(url) | ||
errors << '`url` should not end with a `/`' if url.end_with?('/') | ||
errors << '`url` should contain a protocol' unless url.match?(%r{https?://}) | ||
end | ||
|
||
def validate_semester_format(baseurl) | ||
# This is just for consistency of URL presentation. | ||
errors << '`baseurl` must start with a `/`.' unless baseurl.match?(%r{^/}) | ||
# skip, just for the template. | ||
return if baseurl == '/berkeley-class-site' | ||
|
||
return if baseurl.match?(SEMESTER_REGEXP) | ||
|
||
errors << "`baseurl` must be a valid semester (faXX, spXX, suXX or wiXX), not #{baseurl}" | ||
end | ||
|
||
def validate_department(dept) | ||
errors << "`course_department` must be one of #{VALID_DEPTS} (not '#{dept}')" unless VALID_DEPTS.include?(dept) | ||
end | ||
end | ||
end | ||
|
||
Jekyll::Hooks.register [:site], :after_init do |site| | ||
break if ENV['JEKYLL_ENV'] == 'production' | ||
|
||
Jekyll::ConfigValidator.new(site.config).validate | ||
end |
Oops, something went wrong.