Skip to content

Commit 23c5c17

Browse files
committed
Update namespace from pkplugins to patternkit
1 parent 6177484 commit 23c5c17

File tree

7 files changed

+139
-124
lines changed

7 files changed

+139
-124
lines changed

README.md

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,39 @@
1-
# pkplugins
1+
# PatternKit
2+
Panels-based plugin that wraps a PatternLab library of components.
3+
4+
This code will parse a pattern library (local or through REST endpoints) to generate a list of "content types" in panels that can be drag/dropped into panel variants.
25

3-
Panels based plugin that wraps a pattern-builder/patternkit library of components.
4-
This code will hit the patternkit RESTful endpoints to generate a list of "content types" in panels that can be drag/dropped into panel variants. The configuration screen is simply an iframe wrapper of a simplified version of the patternkit schema builder.
6+
If enabled, the configuration screen is simply an iframe wrapper of a simplified version of the PatternLab schema builder.
57

68
When pattern configurations are saved, the template is downloaded locally (to mitigate origin failures and lock in version at time of configuration.)
79

810
Rendered twigs may contain drupal tokens, which are then processed in context.
911

1012
## Important Variables
11-
12-
* pkplugins_cache_enabled - Whether or not the metadata and render cache are enabled. (Disable during development)
13-
* pkplugins_pk_host - The scheme://hostname:port/ of the patternkit library host.
14-
* pkplugins_default_module_ttl - How long the rendered pattern should be cached.
15-
* pkplugins_show_errors - Whether or not to display messages on the site.
16-
* pkplugins_log_errors - Whether or not to log errors to php error log.
13+
* patternkit_cache_enabled - Whether or not the metadata and render cache are enabled. (Disable during development)
14+
* patternkit_pl_host - The scheme://hostname:port/ of the PatternLab library host.
15+
* patternkit_default_module_ttl - How long the rendered pattern should be cached.
16+
* patternkit_show_errors - Whether or not to display messages on the site.
17+
* patternkit_log_errors - Whether or not to log errors to php error log.
1718

1819
## TODOs
19-
20+
* https://github.com/drupal-pattern-lab/roadmap/issues/8 Solve the problem of mapping Drupal fields to pattern Variables.
2021
* Error handling.
2122
* Better information about available tokens.
2223
* More investigation into the appropriate handling of web component configuration.
2324
* Finalize the CSS/JS management strategy.
2425
More documentation will be added.
26+
27+
## Dependencies
28+
[PatternLab](https://github.com/pattern-lab/starterkit-twig-drupal-minimal)
29+
* Schema display support requires: https://github.com/pattern-lab/patternlab-php-core/issues/117
30+
*
31+
32+
# Proposed V2 Ecosystem
33+
* Exists to solve this issue: https://github.com/drupal-pattern-lab/roadmap/issues/8
34+
* PatternLAB with Restful Extensions provides library + endpoints (Ported from PatternKit)
35+
* PatternKit provides Drupal endpoint consumer (renamed from PKPlugins)
36+
37+
# Legacy Ecosystem
38+
* PatternKit provides library + RESTful endpoints
39+
* PKPlugins provides Drupal endpoint consumer

composer.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
2-
"name": "customer-portal/pkplugins",
2+
"name": "cybtachyon/patternkit",
33
"authors": [
44
{
5-
"name": "Red Hat Customer Portal",
6-
"email": "cp-[email protected]"
5+
"name": "Red Hat Inc.",
6+
"email": "[email protected]"
77
}
88
],
99
"require": {},
File renamed without changes.

patternkit.install

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
3+
/**
4+
* @file
5+
* Install file for patternkit module.
6+
*/
7+
8+
/**
9+
* Add Schema for cache data.
10+
*/
11+
function patternkit_schema() {
12+
$schema = array();
13+
14+
// Add the caching table.
15+
$schema['cache_patternkit'] = drupal_get_schema_unprocessed('system', 'cache');
16+
17+
return $schema;
18+
}

pkplugins/pkplugins.module renamed to patternkit.module

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
/**
99
* Implements hook_ctools_plugin_directory().
1010
*/
11-
function pkplugins_ctools_plugin_directory($owner, $plugin) {
11+
function patternkit_ctools_plugin_directory($owner, $plugin) {
1212
if ($owner == 'ctools') {
1313
return 'plugins/' . $plugin;
1414
}
@@ -19,17 +19,17 @@ function pkplugins_ctools_plugin_directory($owner, $plugin) {
1919
/**
2020
* Implements hook_flush_caches().
2121
*/
22-
function pkplugins_flush_caches() {
23-
return array('cache_pkplugins');
22+
function patternkit_flush_caches() {
23+
return array('cache_patternkit');
2424
}
2525

2626
/**
2727
* Implements hook_admin_menu_cache_info().
2828
*/
29-
function pkplugins_admin_menu_cache_info() {
30-
$caches['pkplugins'] = array(
29+
function patternkit_admin_menu_cache_info() {
30+
$caches['patternkit'] = array(
3131
'title' => t('Flush Patternkit caches'),
32-
'callback' => 'pkplugins_cache_clear_all',
32+
'callback' => 'patternkit_cache_clear_all',
3333
);
3434

3535
return $caches;
@@ -38,17 +38,17 @@ function pkplugins_admin_menu_cache_info() {
3838
/**
3939
* Callback for hook_admin_menu_cache_info() to clear all of the caches.
4040
*/
41-
function pkplugins_cache_clear_all() {
42-
foreach (pkplugins_flush_caches() as $cache_bin) {
41+
function patternkit_cache_clear_all() {
42+
foreach (patternkit_flush_caches() as $cache_bin) {
4343
cache_clear_all('*', $cache_bin, TRUE);
4444
}
4545
}
4646

4747
/**
48-
* Flush the pkplugins metadata cache.
48+
* Flush the patternkit metadata cache.
4949
*/
50-
function pkplugins_flush_metadata_cache() {
51-
cache_clear_all('pkplugins_pk_metadata', 'cache', FALSE);
50+
function patternkit_flush_metadata_cache() {
51+
cache_clear_all('patternkit_pk_metadata', 'cache', FALSE);
5252
}
5353

5454
/**
@@ -62,18 +62,18 @@ function pkplugins_flush_metadata_cache() {
6262
* @return array|object
6363
* Array of metadata objects found or object if specific module requested.
6464
*/
65-
function _pkplugins_get_metadata($subtype = NULL, $reset = FALSE) {
65+
function _patternkit_get_metadata($subtype = NULL, $reset = FALSE) {
6666
$cached_metadata = &drupal_static(__FUNCTION__);
6767

6868
// If the static cache doesn't exist, or we've called with reset, rebuild.
6969
if (!isset($cached_metadata) || $reset) {
70-
$pkplugins_cache_enabled = variable_get('pkplugins_cache_enabled', TRUE);
70+
$patternkit_cache_enabled = variable_get('patternkit_cache_enabled', TRUE);
7171
// If cache is enabled, attempt to load from cache.
72-
if ($pkplugins_cache_enabled && ($cache = cache_get('pkplugins_pk_metadata'))) {
72+
if ($patternkit_cache_enabled && ($cache = cache_get('patternkit_pk_metadata'))) {
7373
$cached_metadata = $cache->data;
7474
}
7575
else {
76-
$patternkit_host = variable_get('pkplugins_pk_host', 'http://10.254.254.254:8080');
76+
$patternkit_host = variable_get('patternkit_pl_host', 'http://localhost:9001');
7777

7878
$patterns = drupal_http_request(
7979
$patternkit_host . '/api/patterns',
@@ -87,12 +87,12 @@ function _pkplugins_get_metadata($subtype = NULL, $reset = FALSE) {
8787

8888
// Cache the data so that we don't have to build it again.
8989
// (if cache enabled, otherwise just a slow, redundant memcache set).
90-
if ($pkplugins_cache_enabled == TRUE) {
91-
cache_set('pkplugins_pk_metadata', $cached_metadata, 'cache', CACHE_PERMANENT);
90+
if ($patternkit_cache_enabled == TRUE) {
91+
cache_set('patternkit_pk_metadata', $cached_metadata, 'cache', CACHE_PERMANENT);
9292
}
9393
}
9494
else {
95-
_pkplugins_show_error(
95+
_patternkit_show_error(
9696
'Patternkit failed to load metadata from service (%service_uri): %error',
9797
array(
9898
'%service_uri' => $patternkit_host . '/api/patterns',
@@ -112,7 +112,7 @@ function _pkplugins_get_metadata($subtype = NULL, $reset = FALSE) {
112112
return $cached_metadata[strtolower($lookup)];
113113
}
114114
else {
115-
_pkplugins_show_error(
115+
_patternkit_show_error(
116116
'Patternkit module does not appear to exist (%module), verify module info/usage.',
117117
array('%module' => $lookup)
118118
);
@@ -125,7 +125,7 @@ function _pkplugins_get_metadata($subtype = NULL, $reset = FALSE) {
125125
}
126126

127127
/**
128-
* Utility function to display pkplugins error messages.
128+
* Utility function to display patternkit error messages.
129129
*
130130
* Checks if permissions and configuration allow showing error, then displays.
131131
*
@@ -136,11 +136,11 @@ function _pkplugins_get_metadata($subtype = NULL, $reset = FALSE) {
136136
* @param string $status
137137
* Status for the error message. Passed to drupal_set_message.
138138
*/
139-
function _pkplugins_show_error($msg, array $vars = array(), $status = 'error') {
140-
if (variable_get('pkplugins_show_errors', FALSE) && user_is_logged_in()) {
139+
function _patternkit_show_error($msg, array $vars = array(), $status = 'error') {
140+
if (variable_get('patternkit_show_errors', FALSE) && user_is_logged_in()) {
141141
drupal_set_message(format_string($msg, $vars), $status);
142142
}
143-
if (variable_get('pkplugins_log_errors', FALSE)) {
144-
watchdog('pkplugins', $msg, $vars, WATCHDOG_ERROR);
143+
if (variable_get('patternkit_log_errors', FALSE)) {
144+
watchdog('patternkit', $msg, $vars, WATCHDOG_ERROR);
145145
}
146146
}

pkplugins/pkplugins.install

Lines changed: 0 additions & 18 deletions
This file was deleted.

0 commit comments

Comments
 (0)