You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
if (db_table_exists('cache_gists') && $clear_with_all) {
92
+
return array('cache_gists');
93
+
}
94
+
}
95
+
96
+
/**
97
+
* Implements hook_admin_bar_cache_info().
98
+
*/
99
+
function gist_filter_admin_bar_cache_info() {
100
+
// Add to the list of caches in the admin menu that can be individually
101
+
// cleared.
102
+
$caches['cache_gists'] = array(
103
+
'title' => t('Gists'),
104
+
'callback' => '_cache_gists_clear',
105
+
);
106
+
return $caches;
107
+
}
108
+
109
+
/**
110
+
* Clear the gists cache.
111
+
*/
112
+
function _cache_gists_clear() {
113
+
// Clear all items from the gists cache.
114
+
cache('cache_gists')->flush();
115
+
// Also clear the entity_node and page caches to remove gists cached within a
116
+
// page.
117
+
cache('cache_entity_node')->flush();
118
+
cache('page')->flush();
119
+
}
120
+
121
+
/**
122
+
* Submit callback; clear gist cache.
123
+
*
124
+
* @ingroup forms
125
+
*/
126
+
function _cache_gists_clear_submit($form, &$form_state) {
127
+
_cache_gists_clear();
128
+
backdrop_set_message(t('Gist, page and entity_node caches cleared.'));
129
+
}
130
+
82
131
/**
83
132
* Implements hook_theme().
84
133
*/
@@ -129,6 +178,40 @@ function gist_filter_config_form($form, &$form_state) {
129
178
$form['#config'] = $config_file;
130
179
$config = config($config_file);
131
180
181
+
// Container for cache settings.
182
+
$cache_scenarios = array(
183
+
t("A gist is embedded using the <strong>code</strong> display method."),
184
+
t("A gist is embedded using the <strong>embed</strong> display method, and the site is set to display using the <strong>code</strong> method if Javascript is disabled."),
185
+
);
186
+
$description = array(
187
+
'<p>' . t("Gist Filter keeps gists saved in the cache if they haven't changed at source. Not only does this help pages with gists on to load faster, but it also reduces the risk of your site exceeding your GitHub API rate limit.") . '</p>',
188
+
'<p>' . t("Gists are saved in the cache in the following scenarios:") . '</p>',
'<p>' . t("Once saved in the cache, a gist by default remains in the cache. If the gist is updated, the cached gist will be updated when the page cache is next cleared.") . '</p>',
191
+
'<p>' . t("If the setting below is enabled, then the gists cache will be cleared when running 'Flush all caches' or 'Page and else'. Otherwise, the gists cache can be cleared by selecting 'Gists' from the 'Flush all caches' submenu or using the button below.") . '</p>',
192
+
);
193
+
$description = implode('', $description);
194
+
$form['cache'] = array(
195
+
'#type' => 'details',
196
+
'#summary' => t('Cache'),
197
+
'#details' => $description,
198
+
'#open' => TRUE,
199
+
);
200
+
201
+
$form['cache']['clear'] = array(
202
+
'#type' => 'submit',
203
+
'#value' => t('Clear gists cache'),
204
+
'#submit' => array('_cache_gists_clear_submit'),
205
+
);
206
+
207
+
// Configure whether or not gist cache is cleared when flushing all caches.
208
+
$form['cache']['cache_clear_with_all'] = array(
209
+
'#type' => 'checkbox',
210
+
'#title' => "Clear the gist cache when flushing all caches",
211
+
'#description' => t("If you have a lot of gists throughout the site displayed as 'code' (or 'embed' with 'code' when Javascript is disabled) and those gists do not change regularly, then disabling the cache clear can avoid you breaching your GitHub API rate limit."),
@@ -138,8 +221,7 @@ function gist_filter_config_form($form, &$form_state) {
138
221
139
222
// Prepare description for GitHub token field.
140
223
$description = array(
141
-
'<p>' . t("Each time a gist is retrieved to display as 'code' (rather than 'link' or 'embed'), GitHub counts this towards your limit. Anonymous users get 60 per hour; authenticated users get 5,000 per hour and Enterprise users get 15,000 per hour.") . '</p>',
142
-
'<p>' . t("If you have a lot of gists displayed as 'code', then each time the page cache expires all the gists will be retrieved at once so you could easily hit the limit without a token.") . '</p>',
224
+
'<p>' . t("Each time a gist is retrieved to display as 'code', GitHub counts this towards your API rate limit. Anonymous users get 60 per hour; authenticated users get 5,000 per hour and Enterprise users get 15,000 per hour. If your number of gists is low, you probably won't need a token.") . '</p>',
143
225
'<p>' . t("If you don't already have a token, you will need to go to <a href='@github-tokens' target='_blank'>your GitHub tokens page</a> and create a token.", array(
'#title' => "Display 'code' version if Javascript is disabled.",
197
-
'#description' => t("If Javascript is disabled, then enabling this option will use 'code' display of the gist. This may cause additional calls to the GitHub API if the gist is not in the cache."),
279
+
'#title' => "Display using 'code' method if Javascript is disabled",
280
+
'#description' => t("Enabling this option will include the 'code' display method of the gistto display if Javascript is disabled."),
0 commit comments