Coffee

An Alfred/Spotlight-inspired quick navigation search box that allows users to rapidly navigate to any admin page or execute commands within Drupal using keyboard shortcuts and autocomplete search.

coffee
36,092 sites
159
drupal.org

インストール

Drupal 11, 10 v2.0.1
composer require 'drupal/coffee:^2.0'
Drupal 9 v8.x-1.4
composer require 'drupal/coffee:8.x-1.4'
Drupal 8 v8.x-1.2
composer require 'drupal/coffee:8.x-1.2'

概要

Coffeeモジュールは、Drupalの管理インターフェース内で高速なナビゲーションを可能にする、Alfred/Spotlight風の強力な検索インターフェースを提供します。管理者やエディターは、複雑なメニュー構造をたどることなく、任意の管理ページへのジャンプ、コンテンツの作成、カスタムコマンドの実行を素早く行えます。

キーボードショートカット(Alt+D)またはツールバーボタンで起動すると、洗練された検索ダイアログが表示され、ページタイトルやパスの一部を入力できます。モジュールは設定されたメニューからマッチする結果を即座にフィルタリングして表示し、数回のキー入力だけでナビゲーションを可能にします。例えば、「ap」と入力してEnterキーを押すと、Appearance管理ページに直接移動します。

Coffeeはhook_coffee_commands() APIを通じて高度に拡張可能で、他のモジュールがカスタムコマンドや検索結果を追加できます。モジュールには:frontでフロントページに移動したり、:addで任意のコンテンツタイプをすばやく作成するなどの組み込みコマンドが用意されています。

Features

  • Alt+Dキーボードショートカットまたはツールバーボタンで起動するクイックナビゲーション検索ボックス
  • 管理メニュー、アカウントメニュー、その他の設定されたメニューを含む複数メニューにわたるリアルタイムオートコンプリートフィルタリング
  • フロントページに素早く移動するための組み込み:frontコマンド
  • すべてのコンテンツタイプに対応した素早いコンテンツ作成のための組み込み:addコマンド(例::add Article)
  • hook_coffee_commands()による拡張性で、モジュールがカスタムコマンドやナビゲーション項目を追加可能
  • 検索結果の数を設定可能(1〜50、デフォルト7)
  • 矢印キーで結果をブラウズし、Enterで選択するキーボードナビゲーションをサポート
  • Ctrl+Enter(Windows)またはCmd+Enter(macOS)で結果を新しいウィンドウで開く
  • マウスユーザー向けの「Go to」ボタンによるシームレスなツールバー統合
  • Coffeeの使用と管理に対する別々の権限によるアクセス制御
  • 自動的なアクセスチェックにより、ユーザーはアクセス権限のあるメニュー項目のみを表示
  • Config Translationが有効な場合、翻訳ページへの追加ナビゲーションを提供するローカルタスクをサポート
  • 利用可能な場合、Configuration Translation ページを検索結果に含む
  • スムーズなトランジションを備えたクリーンなモーダルスタイルのダークUI
  • 安全なナビゲーションのためのCSRFトークン処理

Use Cases

Quick Navigation to Admin Pages

As a site administrator managing a complex Drupal site, you need to frequently access various admin pages like Content, Structure, People, or Reports. Instead of clicking through multiple menu levels, simply press Alt+D, type a few characters (e.g., 'cont' for Content, 'peo' for People, or 'rep' for Reports), and press Enter to navigate instantly.

Rapid Content Creation

Content editors who frequently create new content can use the :add command to quickly access the node creation form. Press Alt+D, type ':add Article' or ':add Page', and press Enter to go directly to the content creation form for that type. This bypasses the Content > Add content menu navigation entirely.

Accessing the Front Page Quickly

When working in the admin area and needing to preview the site's front page, use the :front command. Press Alt+D, type ':front', and press Enter to navigate to the site's front page immediately.

Custom Module Integration

Developers can extend Coffee by implementing hook_coffee_commands() in their modules. For example, a custom dashboard module could add commands like ':dashboard' to jump to a custom admin dashboard, or ':reports' to access custom reporting pages. This makes module-specific functionality easily accessible through Coffee.

Multi-Menu Search Setup

For sites using multiple menus (e.g., admin, main navigation, footer), administrators can configure Coffee to search across all of them. This allows editors to find any linked page on the site quickly, not just admin pages. Enable additional menus at /admin/config/user-interface/coffee.

Opening Admin Pages in New Tabs

When you need to open multiple admin pages simultaneously (e.g., comparing configurations or editing content while referencing another page), use Coffee with Ctrl+Enter (Windows) or Cmd+Enter (Mac) to open results in new browser tabs without leaving your current page.

Integrating with Devel Module

When the Devel module is installed, its menu items become searchable through Coffee. Type 'clear' to find and navigate to the cache clearing page (devel/cache/clear) or 'phpinfo' to access the PHP info page, streamlining developer workflows.

Tips

  • Use short, memorable search terms - Coffee matches against page titles, paths, and commands, so typing just 2-3 characters is often enough
  • Prefix commands with a colon (:) for built-in commands like :front and :add
  • Configure fewer menus for faster, more focused results when you primarily need admin navigation
  • Increase max_results in configuration if you frequently need to see more options before making a selection
  • Combine Coffee with the Devel module for quick access to developer tools and cache clearing
  • Remember that Coffee respects access permissions - users will only see menu items they have permission to access
  • Use the escape key to quickly close the Coffee dialog if you change your mind

Technical Details

Admin Pages 1
Coffee configuration /admin/config/user-interface/coffee

Configure which menus Coffee should search through and how many results to display in the autocomplete dropdown.

権限 2
Access Coffee

Access the Coffee search box to navigate fast between admin pages. Users with this permission can use the Alt+D keyboard shortcut or toolbar button to open the Coffee search interface.

Administer Coffee

Administer the Coffee search module. Users with this permission can access the configuration page to select which menus are searched and how many results are displayed.

Hooks 1
hook_coffee_commands

Extend the Coffee functionality with custom commands and navigation items. This hook allows modules to add their own searchable items to the Coffee interface, enabling quick navigation to custom pages or execution of module-specific commands.

Troubleshooting 5
Coffee search box doesn't appear when pressing Alt+D

Ensure the user has the 'Access Coffee' permission. Check that the coffee library is being loaded by inspecting the page source for coffee.js. Clear all caches and try again.

Search results are empty or show no items

Verify that at least one menu is selected in the Coffee configuration at /admin/config/user-interface/coffee. Ensure the selected menus contain items and the user has access permissions to those menu items.

Toolbar 'Go to' button is not visible

The toolbar button only appears for users with both 'Access Coffee' and 'Access toolbar' permissions. Install and enable the Toolbar module if not already active, and ensure proper permissions are granted.

Custom commands from hook_coffee_commands() not appearing

Ensure your implementation is in a .coffee.inc file (as defined by hook_hook_info()) or in the main .module file. Clear all caches after adding new commands. Verify the hook returns an array with 'value', 'label', and 'command' keys for each item.

Alt+D shortcut conflicts with browser functionality

In some browsers (particularly Opera and Internet Explorer), use Alt+Shift+D or Alt+Ctrl+D respectively. You can also click the Coffee icon in the toolbar if keyboard shortcuts are problematic.

Security Notes 4
  • Coffee automatically applies access checks to all menu items, ensuring users only see navigation options they have permission to access
  • CSRF tokens are properly handled for routes that require them, preventing potential security vulnerabilities
  • The module creates separate permissions for using (access coffee) and administering (administer coffee) the feature, following Drupal's principle of least privilege
  • All menu item titles are properly escaped using Html::escape() to prevent XSS vulnerabilities