Skip to content

Commit bba8940

Browse files
Add default display method
1 parent 95b791e commit bba8940

File tree

2 files changed

+53
-29
lines changed

2 files changed

+53
-29
lines changed

config/gist_filter.settings.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"_config_name": "gist_filter.settings",
3+
"default_display_method": "embed",
34
"github_token": "",
45
"gist_embed_theme": "default",
56
"enable_noscript_display": 1,

gist_filter.module

Lines changed: 52 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ function gist_filter_filter_info() {
1818
'description' => t('Substitutes [gist:xx] tags with the gist located at https://gist.github.com/user/xx.'),
1919
'process callback' => 'gist_filter_gist_filter_process',
2020
'default settings' => array(
21-
'gist_filter_display_method' => 'embed',
21+
'gist_filter_display_method' => config_get('gist_filter.settings', 'default_display_method'),
2222
),
2323
'settings callback' => 'gist_filter_gist_filter_settings',
2424
'tips callback' => 'gist_filter_filter_tips',
@@ -178,38 +178,26 @@ function gist_filter_config_form($form, &$form_state) {
178178
$form['#config'] = $config_file;
179179
$config = config($config_file);
180180

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>',
189-
theme('item_list', array('items' => $cache_scenarios)),
190-
'<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(
181+
// Container for general settings.
182+
$form['general'] = array(
195183
'#type' => 'details',
196-
'#summary' => t('Cache'),
197-
'#details' => $description,
184+
'#summary' => t('General'),
185+
'#details' => t("Gist Filter enables you easily embed a gist anywhere in a filtered text field."),
198186
'#open' => TRUE,
199187
);
200188

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."),
212-
'#default_value' => $config->get('cache_clear_with_all'),
189+
// Select the default display method for new text formats.
190+
$form['general']['default_display_method'] = array(
191+
'#type' => 'select',
192+
'#title' => 'Default Display Method',
193+
'#options' => array(
194+
'code' => t('Code tags'),
195+
'embed' => t('Embed'),
196+
'link' => t('Link'),
197+
),
198+
'#required' => TRUE,
199+
'#default_value' => $config->get('default_display_method'),
200+
'#description' => t("You can change the default display method and this will affect any new text formats created."),
213201
);
214202

215203
// Container for 'code' display settings.
@@ -281,6 +269,41 @@ function gist_filter_config_form($form, &$form_state) {
281269
'#default_value' => $config->get('enable_noscript_display'),
282270
);
283271

272+
// Container for cache settings.
273+
$cache_scenarios = array(
274+
t("A gist is embedded using the <strong>code</strong> display method."),
275+
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."),
276+
);
277+
$description = array(
278+
'<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>',
279+
'<p>' . t("Gists are saved in the cache in the following scenarios:") . '</p>',
280+
theme('item_list', array('items' => $cache_scenarios)),
281+
'<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>',
282+
'<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>',
283+
);
284+
$description = implode('', $description);
285+
$form['cache'] = array(
286+
'#type' => 'details',
287+
'#summary' => t('Cache'),
288+
'#details' => $description,
289+
'#open' => TRUE,
290+
);
291+
292+
$form['cache']['clear'] = array(
293+
'#type' => 'submit',
294+
'#value' => t('Clear gists cache'),
295+
'#submit' => array('_cache_gists_clear_submit'),
296+
'#description' => t("Don't forget to save any setting changes before clearing the cache."),
297+
);
298+
299+
// Configure whether or not gist cache is cleared when flushing all caches.
300+
$form['cache']['cache_clear_with_all'] = array(
301+
'#type' => 'checkbox',
302+
'#title' => "Clear the gist cache when flushing all caches",
303+
'#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."),
304+
'#default_value' => $config->get('cache_clear_with_all'),
305+
);
306+
284307
return system_settings_form($form);
285308
}
286309

0 commit comments

Comments
 (0)