@@ -16,6 +16,7 @@ var exec = require('child_process').exec;
1616var glob = require ( 'glob' ) ;
1717var iprotect = require ( 'iprotect' ) ;
1818var moment = require ( 'momentWithLocale' ) ;
19+ var stripTags = require ( 'textUtil/stripTags' ) ;
1920
2021// Group info for a participant, with user instructions on how to login
2122exports . get = function * ( ) {
@@ -52,12 +53,30 @@ exports.get = function*() {
5253 logs = [ ] ;
5354 }
5455
55- logs = logs . sort ( ) . map ( file => ( {
56- title : file ,
57- link : `/courses/groups/${ group . slug } /logs/${ file . replace ( / \. h t m l $ / , '' ) } `
58- } ) ) ;
56+ logs = logs . sort ( ) ;
5957
60- this . locals . chatLogs = logs ;
58+ let contents = yield logs . map ( file => fs . readFile ( config . jabberLogsRoot + '/' + group . webinarId + '/' + file , { encoding : 'utf8' } ) ) ;
59+
60+ this . locals . chatLogs = [ ] ;
61+ for ( let i = 0 ; i < logs . length ; i ++ ) {
62+ let log = logs [ i ] ;
63+ let content = contents [ i ]
64+ . match ( / < b o d y > ( [ \s \S ] * ?) ( < \/ b o d y > | $ ) / ) [ 0 ]
65+ . replace ( / < f o n t [ \s \S ] * ?< \/ f o n t > / gim, '' )
66+ . replace ( / < a [ \s \S ] * ?< \/ a > / gim, '' )
67+ . replace ( / < d i v [ \s \S ] * ?< \/ d i v > / gim, '' )
68+ . replace ( / < b r .* ?> / gim, '' ) ;
69+ content = stripTags ( content ) ;
70+
71+ content = content . replace ( / \s + / gim, ' ' ) ;
72+
73+ if ( content . length > 1000 ) {
74+ this . locals . chatLogs . push ( {
75+ title : log ,
76+ link : `/courses/groups/${ group . slug } /logs/${ log . replace ( / \. h t m l $ / , '' ) } `
77+ } ) ;
78+ }
79+ }
6180
6281
6382 this . body = this . render ( 'groupMaterials' ) ;
0 commit comments