@@ -8,7 +8,6 @@ var program = require('commander');
88const Mustache = require ( 'mustache' ) ;
99var scrawl = require ( './www/scrawl' ) ;
1010var Twitter = require ( 'twitter' ) ;
11- var wp = require ( 'wordpress' ) ;
1211const yaml = require ( 'js-yaml' ) ;
1312
1413program
@@ -18,7 +17,6 @@ program
1817 . option ( '-d, --directory <directory>' , 'The directory to process.' )
1918 // the do something switches
2019 . option ( '-m, --html' , 'If set, write the minutes to an index.html file' )
21- . option ( '-w, --wordpress' , 'If set, publish the minutes to the blog' )
2220 . option ( '-e, --email' , 'If set, publish the minutes to the mailing list' )
2321 . option ( '-t, --twitter' , 'If set, publish the minutes to Twitter' )
2422 . option ( '-g, --google' , 'If set, publish the minutes to G+' )
@@ -45,7 +43,7 @@ if(!program.directory) {
4543 process . exit ( 1 ) ;
4644}
4745
48- if ( ! program . html && ! program . wordpress && ! program . email && ! program . twitter
46+ if ( ! program . html && ! program . email && ! program . twitter
4947 && ! program . google && ! program . index ) {
5048 console . error ( 'Error: Nothing to do...' ) ;
5149 program . outputHelp ( ) ;
@@ -108,64 +106,7 @@ const TWITTER_BODY = ('twitter' in config && 'body' in config.twitter)
108106 : `{{group}} discusses {{message}}:
109107{{{minutes_base_url}}}{{gDate}}/` ;
110108
111- // Mustache template - vars: gDate
112- const WORDPRESS_TITLE = ( 'wordpress' in config && 'title' in config . wordpress )
113- ? config . wordpress . title
114- : 'Meeting Minutes for {{gDate}}' ;
115-
116109/************************* Utility Functions *********************************/
117- function postToWordpress ( username , password , content , callback ) {
118- var client = wp . createClient ( {
119- username : username ,
120- password : password ,
121- url : ''
122- } ) ;
123- // Re-format the HTML for publication to a Wordpress blog
124- var datetime = new Date ( gDate ) ;
125- datetime . setHours ( 37 ) ;
126- var wpSummary = content . post_content ;
127- wpSummary = wpSummary . substring (
128- wpSummary . indexOf ( '<dl>' ) , wpSummary . indexOf ( '</dl>' ) + 5 ) ;
129- wpSummary = wpSummary . replace ( / h r e f = \" # / g,
130- 'href="' + scrawl . minutes_base_url + gDate + '/#' ) ;
131- wpSummary = wpSummary . replace ( / h r e f = \" a u d i o / g,
132- 'href="' + scrawl . minutes_base_url + gDate + '/audio' ) ;
133- wpSummary = wpSummary . replace ( / < d i v > < a u d i o [ \s \S ] * \/ a u d i o > < \/ d i v > / g, '' ) ;
134- wpSummary += '<p>Detailed minutes and recorded audio for this call are ' +
135- '<a href="' + scrawl . minutes_base_url + gDate +
136- '/">available in the archive</a>.</p>' ;
137-
138- // calculate the proper post date
139- var gmtDate = datetime . toISOString ( ) ;
140- gmtDate = gmtDate . replace ( 'T' , ' ' ) ;
141- gmtDate = gmtDate . replace ( / \. [ 0 - 9 ] * Z / , '' ) ;
142-
143- content . post_content = wpSummary ;
144- content . post_date_gmt = gmtDate ;
145- content . terms_names = [ 'Meetings' ] ;
146- content . post_name = gDate + '-minutes' ;
147- content . custom_fields = [ {
148- s2_meta_field : 'no'
149- } ] ;
150-
151- client . newPost ( content , function ( err , data ) {
152- if ( err ) {
153- console . log ( err ) ;
154-
155- console . log ( 'scrawl: You may have to add this information manually:' ) ;
156-
157- console . log ( 'Title:\n' + content . post_title ) ;
158- console . log ( 'Content:\n' + content . post_content ) ;
159- console . log ( 'Slug:\n' + content . post_name ) ;
160- }
161- else {
162- console . log ( data ) ;
163- // Do something.
164- }
165- callback ( ) ;
166- } ) ;
167- }
168-
169110function sendEmail ( username , password , hostname , content , callback ) {
170111 var server = email . server . connect ( {
171112 //user: username,
@@ -504,47 +445,6 @@ Full text of the discussion follows for archival purposes.
504445 } else {
505446 callback ( ) ;
506447 }
507- } , function ( callback ) {
508- // publish the wordpress blog post
509- if ( program . wordpress ) {
510- if ( ! program . quiet ) {
511- console . log ( 'scrawl: Creating new blog post.' ) ;
512- }
513- var content = {
514- post_title : Mustache . render ( WORDPRESS_TITLE , { gDate} ) ,
515- post_content : scrawl . generateMinutes ( gLogData , 'html' , gDate , haveAudio )
516- } ;
517-
518- if ( process . env . SCRAWL_WP_USERNAME && process . env . SCRAWL_WP_PASSWORD ) {
519- postToWordpress (
520- process . env . SCRAWL_WP_USERNAME , process . env . SCRAWL_WP_PASSWORD ,
521- content , callback ) ;
522- } else {
523- var prompt = require ( 'prompt' ) ;
524- prompt . start ( ) ;
525- prompt . get ( {
526- properties : {
527- username : {
528- description : 'Enter the WordPress username' ,
529- pattern : / ^ .{ 4 , } $ / ,
530- message : 'The username must be at least 4 characters.' ,
531- 'default' : 'msporny'
532- } ,
533- password : {
534- description : 'Enter the user\'s password' ,
535- pattern : / ^ .{ 4 , } $ / ,
536- message : 'The password must be at least 4 characters.' ,
537- hidden : true ,
538- 'default' : 'password'
539- }
540- }
541- } , function ( err , results ) {
542- postToWordpress ( results . username , results . password , content , callback ) ;
543- } ) ;
544- }
545- } else {
546- callback ( ) ;
547- }
548448} ] , function ( err ) {
549449 // check to ensure there were no errors
550450 if ( err ) {
0 commit comments