|
@@ -10,14 +10,32 @@ module.exports = LabelsHandler =
|
|
|
ProjectEntityHandler.getAllDocs projectId, (err, docs) ->
|
|
ProjectEntityHandler.getAllDocs projectId, (err, docs) ->
|
|
|
if err?
|
|
if err?
|
|
|
return callback(err)
|
|
return callback(err)
|
|
|
- LabelsHandler.extractLabelsFromDocs docs, (err, projectLabels) ->
|
|
|
|
|
|
|
+ LabelsHandler.extractLabelsFromProjectDocs docs, (err, projectLabels) ->
|
|
|
if err?
|
|
if err?
|
|
|
return callback(err)
|
|
return callback(err)
|
|
|
callback(null, projectLabels)
|
|
callback(null, projectLabels)
|
|
|
|
|
|
|
|
- extractLabelsFromDocs: (docs, callback=(err, projectLabels)->) ->
|
|
|
|
|
|
|
+ getLabelsForDoc: (projectId, docId, callback=(err, docLabels)->) ->
|
|
|
|
|
+ ProjectEntityHandler.getDoc projectId, docId, (err, lines, rev) ->
|
|
|
|
|
+ if err?
|
|
|
|
|
+ return callback(err)
|
|
|
|
|
+ LabelsHandler.extractLabelsFromDoc lines, (err, docLabels) ->
|
|
|
|
|
+ if err?
|
|
|
|
|
+ return callback(err)
|
|
|
|
|
+ callback(null, docLabels)
|
|
|
|
|
+
|
|
|
|
|
+ extractLabelsFromDoc: (lines, callback=(err, docLabels)->) ->
|
|
|
|
|
+ docLabels = []
|
|
|
|
|
+ for line in lines
|
|
|
|
|
+ re = LabelsHandler.labelCaptureRegex()
|
|
|
|
|
+ while (labelMatch = re.exec(line))
|
|
|
|
|
+ if labelMatch[1]
|
|
|
|
|
+ docLabels.push(labelMatch[1])
|
|
|
|
|
+ callback(null, docLabels)
|
|
|
|
|
+
|
|
|
|
|
+ extractLabelsFromProjectDocs: (docs, callback=(err, projectLabels)->) ->
|
|
|
projectLabels = {} # docId => List[Label]
|
|
projectLabels = {} # docId => List[Label]
|
|
|
- for docPath, doc of docs
|
|
|
|
|
|
|
+ for _docPath, doc of docs
|
|
|
docLabels = []
|
|
docLabels = []
|
|
|
for line in doc.lines
|
|
for line in doc.lines
|
|
|
re = LabelsHandler.labelCaptureRegex()
|
|
re = LabelsHandler.labelCaptureRegex()
|