|
@@ -2,6 +2,7 @@
|
2
|
2
|
"""
|
3
|
3
|
"""
|
4
|
4
|
import os
|
|
5
|
+import re
|
5
|
6
|
from datetime import datetime
|
6
|
7
|
from hashlib import sha256
|
7
|
8
|
__all__ = ['User', 'Group', 'Permission']
|
|
@@ -195,14 +196,23 @@ class PBNode(object):
|
195
|
196
|
lsTruncatedLabel = self.data_label
|
196
|
197
|
return lsTruncatedLabel
|
197
|
198
|
|
|
199
|
+ def getTagList(self):
|
|
200
|
+ loPattern = re.compile('(^|\s|@)@(\w+)')
|
|
201
|
+ loResults = re.findall(loPattern, self.data_content)
|
|
202
|
+ lsResultList = []
|
|
203
|
+ for loResult in loResults:
|
|
204
|
+ lsResultList.append(loResult[1].replace('@', '').replace('_', ' '))
|
|
205
|
+ return lsResultList
|
|
206
|
+
|
198
|
207
|
@classmethod
|
199
|
208
|
def addTagReplacement(cls, matchobj):
|
200
|
|
- if matchobj.group(0) == '-': return ' '
|
201
|
|
- else: return "<span class='badge'>%s</span>" %(matchobj.group(0))
|
|
209
|
+ return " <span class='badge'>%s</span> " %(matchobj.group(0).replace('@', '').replace('_', ' '))
|
202
|
210
|
|
203
|
211
|
def getContentWithTags(self):
|
204
|
|
- import re
|
205
|
|
- return re.sub('@(\w+)', PBNode.addTagReplacement, self.data_content)
|
|
212
|
+ lsTemporaryResult = re.sub('(^|\s)@@(\w+)', '', self.data_content) # tags with @@ are explicitly removed from the body
|
|
213
|
+ return re.sub('(^|\s)@(\w+)', PBNode.addTagReplacement, lsTemporaryResult) # then, 'normal tags are transformed as labels'
|
|
214
|
+ # FIXME - D.A. - 2013-09-12
|
|
215
|
+ # Does not match @@ at end of content.
|
206
|
216
|
|
207
|
217
|
|
208
|
218
|
|