@@ -17,6 +17,8 @@ var git = require('git-rev');
1717//--- Controller inclusions
1818
1919//--- Library inclusions
20+ // var documentLib = require('../libs/document');
21+
2022var modelParser = require ( '../libs/modelParser' ) ;
2123
2224var renderMd = require ( '../libs/markdown' ) . renderMd ;
@@ -71,66 +73,62 @@ exports.view = function (aReq, aRes, aNext) {
7173 //--- Tasks
7274
7375 // Read the requested md file contents
74- tasks . push (
75- function ( aCallback ) {
76- fs . readFile ( documentPath + '/' + document + '.md' , 'utf8' , function ( aErr , aData ) {
77- var lines = null ;
78- var matches = null ;
79- var heading = null ;
80- var content = null ;
81-
82- if ( aErr ) {
83- aCallback ( { statusCode : 404 , statusMessage : 'Error retrieving page' } ) ;
84- return ;
85- }
86-
87- // Check if first line is h2 and use for title/heading if present
88- lines = aData . split ( '\n' ) ;
89- matches = lines [ 0 ] . match ( / ^ # # \s ( .* ) $ / ) ;
90- if ( matches ) {
91- heading = lines . shift ( ) . replace ( / ^ # # \s + / , "" ) ;
92- } else {
93- heading = document ;
94- }
95- content = lines . join ( '\n' ) ;
96-
97- // Page metadata
98- pageMetadata ( options , [ heading , 'About' ] ) ;
99-
100- options . pageHeading = heading ;
101- options . pageData = renderMd ( content ) ;
102-
103- aCallback ( null ) ;
104- } ) ;
105- }
106- ) ;
76+ tasks . push ( function ( aCallback ) {
77+ fs . readFile ( documentPath + '/' + document + '.md' , 'utf8' , function ( aErr , aData ) {
78+ var lines = null ;
79+ var matches = null ;
80+ var heading = null ;
81+ var content = null ;
82+
83+ if ( aErr ) {
84+ aCallback ( { statusCode : 404 , statusMessage : 'Error retrieving page' } ) ;
85+ return ;
86+ }
87+
88+ // Check if first line is h2 and use for title/heading if present
89+ lines = aData . split ( '\n' ) ;
90+ matches = lines [ 0 ] . match ( / ^ # # \s ( .* ) $ / ) ;
91+ if ( matches ) {
92+ heading = lines . shift ( ) . replace ( / ^ # # \s + / , "" ) ;
93+ } else {
94+ heading = document ;
95+ }
96+ content = lines . join ( '\n' ) ;
97+
98+ // Page metadata
99+ pageMetadata ( options , [ heading , 'About' ] ) ;
100+
101+ options . pageHeading = heading ;
102+ options . pageData = renderMd ( content ) ;
103+
104+ aCallback ( null ) ;
105+ } ) ;
106+ } ) ;
107107
108108 // Read file listing
109- tasks . push (
110- function ( aCallback ) {
111- fs . readdir ( documentPath , function ( aErr , aFileList ) {
112- var file = null ;
113-
114- if ( aErr || ! aFileList ) {
115- aCallback ( { statusCode : 500 , statusMessage : 'Error retrieving page list' } ) ;
116- return ;
117- }
118-
119- // Dynamically create a file listing of the pages
120- options . fileList = [ ] ;
121- for ( file in aFileList ) {
122- if ( / \. m d $ / . test ( aFileList [ file ] ) ) {
123- options . fileList . push ( {
124- href : aFileList [ file ] . replace ( / \. m d $ / , '' ) ,
125- textContent : aFileList [ file ] . replace ( / \. m d $ / , '' ) . replace ( / - / g, ' ' )
126- } ) ;
127- }
109+ tasks . push ( function ( aCallback ) {
110+ fs . readdir ( documentPath , function ( aErr , aFileList ) {
111+ var file = null ;
112+
113+ if ( aErr || ! aFileList ) {
114+ aCallback ( { statusCode : 500 , statusMessage : 'Error retrieving page list' } ) ;
115+ return ;
116+ }
117+
118+ // Dynamically create a file listing of the pages
119+ options . fileList = [ ] ;
120+ for ( file in aFileList ) {
121+ if ( / \. m d $ / . test ( aFileList [ file ] ) ) {
122+ options . fileList . push ( {
123+ href : aFileList [ file ] . replace ( / \. m d $ / , '' ) ,
124+ textContent : aFileList [ file ] . replace ( / \. m d $ / , '' ) . replace ( / - / g, ' ' )
125+ } ) ;
128126 }
127+ }
129128
130- aCallback ( null ) ;
131- } ) ;
132- }
133- ) ;
129+ aCallback ( null ) ;
130+ } ) ;
131+ } ) ;
134132 }
135133 else {
136134 // Page metadata
@@ -169,16 +167,13 @@ exports.view = function (aReq, aRes, aNext) {
169167 //--- Tasks
170168
171169 // Read git short hash HEAD for current tree
172- tasks . push (
173-
174- function ( aCallback ) {
175- git . short ( function ( aStr ) {
176- options . git . short = aStr ;
170+ tasks . push ( function ( aCallback ) {
171+ git . short ( function ( aStr ) {
172+ options . git . short = aStr ;
177173
178- aCallback ( null ) ;
179- } ) ;
180- }
181- ) ;
174+ aCallback ( null ) ;
175+ } ) ;
176+ } ) ;
182177
183178 // Read git branch name of current tree
184179 tasks . push (
0 commit comments