Skip to content
Snippets Groups Projects
Commit ab36c768 authored by Brian Canini's avatar Brian Canini
Browse files

Merge branch 'buckeye_bot' into 'main'

Add BuckeyeBot module and add id to the skip to main content element

See merge request !42
parents 63407e2a 4159277a
1 merge request!42Add BuckeyeBot module and add id to the skip to main content element
name: "BuckeyeBot"
type: module
description: "Enable BuckeyeBot from The Ohio State University"
package: ASC Tech
core_version_requirement: ^9 || ^10
buckeye_bot:
version: 1.x
js:
//assets.chat.osu.edu/v1.3.2/scripts.js?all=true&offsetBottom=50px:
{
type: external,
attributes:
{ type: "text/javascript", id: "buckeye-chat-script", defer: true },
}
buckeye_bot.settings:
title: "BuckeyeBot"
description: "BuckeyeBot settings"
parent: system.admin_config_system
route_name: "buckeye_bot.config"
<?php
function buckeye_bot_preprocess_html(&$variables)
{
$is_admin = \Drupal::service('router.admin_context')->isAdminRoute();
if (!$is_admin) {
$config = \Drupal::config('buckeye_bot.buckeye_bot_config');
$buckeye_bot_status = $config->get('buckeye_bot_status');
if ($buckeye_bot_status) {
$variables['#attached']['library'][] = 'buckeye_bot/buckeye_bot';
}
}
}
administer buckeye bot:
title: "Administer BuckeyeBot"
description: "Gives users permissions to manage BuckeyeBot."
buckeye_bot.config:
path: 'admin/config/buckeye_bot'
defaults:
_form: '\Drupal\buckeye_bot\Form\BuckeyeBotConfigurationForm'
_title: 'BuckeyeBot'
requirements:
_permission: 'administer buckeye bot'
\ No newline at end of file
buckeye_bot_status: 0
\ No newline at end of file
<?php
namespace Drupal\buckeye_bot\Form;
use Drupal\Core\Form\ConfigFormBase;
use Drupal\Core\Form\FormStateInterface;
class BuckeyeBotConfigurationForm extends ConfigFormBase {
protected function getEditableConfigNames() {
return ['buckeye_bot.buckeye_bot_config'];
}
public function getFormId() {
return 'buckeye_bot_configuration_form';
}
public function buildForm(array $form, FormStateInterface $form_state) {
$config = $this->config('buckeye_bot.buckeye_bot_config');
$buckeye_bot_status = $config->get('buckeye_bot_status');
$form['intro'] = array(
'#markup' => $this->t('<p>Controls the display of BuckeyeBot.</p>'),
);
$form['buckeye_bot_status'] = array(
'#type' => 'checkbox',
'#title' => $this->t('Activate BuckeyeBot'),
'#default_value' => isset($buckeye_bot_status) ? $buckeye_bot_status : FALSE,
);
return parent::buildForm($form, $form_state);
}
public function submitForm(array &$form, FormStateInterface $form_state) {
$config = $this->config('buckeye_bot.buckeye_bot_config');
$config->set('buckeye_bot_status', $form_state->getValue('buckeye_bot_status'))->save();
parent::submitForm($form, $form_state);
}
public function validateForm(array &$form, FormStateInterface $form_state) {
parent::validateForm($form, $form_state);
}
}
{#
/**
* @file
* Default theme implementation to display the basic html structure of a single
* Drupal page.
*
* Variables:
* - $css: An array of CSS files for the current page.
* - $language: (object) The language the site is being displayed in.
* $language->language contains its textual representation.
* $language->dir contains the language direction. It will either be 'ltr' or
* 'rtl'.
* - $rdf_namespaces: All the RDF namespace prefixes used in the HTML document.
* - $grddl_profile: A GRDDL profile allowing agents to extract the RDF data.
* - $head_title: A modified version of the page title, for use in the TITLE
* tag.
* - $head_title_array: (array) An associative array containing the string parts
* that were used to generate the $head_title variable, already prepared to be
* output as TITLE tag. The key/value pairs may contain one or more of the
* following, depending on conditions:
* - title: The title of the current page, if any.
* - name: The name of the site.
* - slogan: The slogan of the site, if any, and if there is no title.
* - $head: Markup for the HEAD section (including meta tags, keyword tags, and
* so on).
* - $styles: Style tags necessary to import all CSS files for the page.
* - $scripts: Script tags necessary to load the JavaScript files and settings
* for the page.
* - $page_top: Initial markup from any modules that have altered the
* page. This variable should always be output first, before all other dynamic
* content.
* - $page: The rendered page content.
* - $page_bottom: Final closing markup from any modules that have altered the
* page. This variable should always be output last, after all other dynamic
* content.
* - $classes String of classes that can be used to style contextually through
* CSS.
*
* @ingroup templates
*
* @see bootstrap_preprocess_html()
* @see template_preprocess()
* @see template_preprocess_html()
* @see template_process()
*/
#}
{%
set body_classes = [
logged_in ? 'user-logged-in',
not root_path ? 'path-frontpage' : 'path-' ~ root_path|clean_class,
node_type ? 'page-node-type-' ~ node_type|clean_class,
db_offline ? 'db-offline',
theme.settings.navbar_position ? 'navbar-is-' ~ theme.settings.navbar_position,
theme.has_glyphicons ? 'has-glyphicons',
]
%}
<!DOCTYPE html>
<html {{ html_attributes }}>
<head>
<head-placeholder token="{{ placeholder_token|raw }}">
<title>{{ head_title|safe_join(' | ') }}</title>
<css-placeholder token="{{ placeholder_token|raw }}">
<js-placeholder token="{{ placeholder_token|raw }}">
</head>
<body{{ attributes.addClass(body_classes) }}>
<a href="#main-content" id="skip" class="visually-hidden focusable skip-link">
{{ 'Skip to main content'|t }}
</a>
{{ page_top }}
{{ page }}
{{ page_bottom }}
<js-bottom-placeholder token="{{ placeholder_token|raw }}">
</body>
</html>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment