Skip to content
Browse files

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
  • Loading branch information...
1 parent 2464b78 commit 1980d43ecfb7f30f2904eb924319d5c6aff0e4ac @sagarun committed Sep 18, 2011
Showing with 55 additions and 0 deletions.
  1. +55 −0 askbot/conf/markup.py
View
55 askbot/conf/markup.py
@@ -15,6 +15,13 @@
_('Markup formatting')
)
+AUTOLINK = ConfigurationGroup(
+ 'AUTOLINK',
+ _('Auto link a pattern to an URL')
+
+)
+
+
settings.register(
BooleanValue(
MARKUP,
@@ -63,3 +70,51 @@
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 = ''
+ )
+ )
+

0 comments on commit 1980d43

Please sign in to comment.
Something went wrong with that request. Please try again.