From 1980d43ecfb7f30f2904eb924319d5c6aff0e4ac Mon Sep 17 00:00:00 2001 From: Arun SAG Date: Sun, 18 Sep 2011 01:22:20 +0530 Subject: Add autolinking settings to conf/markup.py - See #607 for more details on this feature - We use regex to match a pattern and autolink it --- askbot/conf/markup.py | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/askbot/conf/markup.py b/askbot/conf/markup.py index 026c5536..9eeb3149 100644 --- a/askbot/conf/markup.py +++ b/askbot/conf/markup.py @@ -15,6 +15,13 @@ MARKUP = ConfigurationGroup( _('Markup formatting') ) +AUTOLINK = ConfigurationGroup( + 'AUTOLINK', + _('Auto link a pattern to an URL') + +) + + settings.register( BooleanValue( MARKUP, @@ -63,3 +70,51 @@ settings.register( default = '' ) ) + + +settings.register( + BooleanValue( + AUTOLINK, + 'ENABLE_AUTO_LINK', + description=_('Enable autolinking a specifc pattern'), + help_text=_( + 'If you enable this feature, ' + 'the application will be able to ' + 'detect patterns and auto link to URLs' + ), + + default = False + ) + ) + + +settings.register( + StringValue( + AUTOLINK, + 'Pattern', + description=_('Regex to detect the pattern'), + help_text=_( + 'Enter a valid regular expression to' + 'detect the pattern. For example to' + 'detect something like #rhbz 637402 ' + 'use a regular expression like r"#rhbz\s(\d+)"' + ), + default = '' + ) + ) + +settings.register( + StringValue( + AUTOLINK, + 'AutoLinkURL', + description=_('URL for autolinking'), + help_text=_( + 'Let us assume that to detect a pattern #rhbz 637402' + ' the regex is r"#rhbz\s(\d+)" ' + 'then the autolink URL should be https://bugzilla.redhat.com/show_bug.cgi?id=\\1' + ' Where \\1 is the saved match from the regular expression' + ), + default = '' + ) + ) + -- cgit v1.2.3-1-g7c22