@@ -354,8 +354,13 @@ class Sidebar extends Class
354354 @ updateHtmlTag ()
355355 return false
356356
357- # Sign content.json
358- @tag .find (" #button-sign" ).off (" click touchend" ).on " click touchend" , =>
357+ # Sign and publish content.json
358+ $ (document ).on " click touchend" , =>
359+ @tag .find (" #button-sign-publish-menu" ).removeClass (" visible" )
360+ @tag .find (" .contents + .flex" ).removeClass (" sign-publish-flex" )
361+
362+ menu = new Menu (@tag .find (" #wrapper-sign-publish" ))
363+ menu .addItem " Sign" , =>
359364 inner_path = @tag .find (" #input-contents" ).val ()
360365
361366 wrapper .ws .cmd " fileRules" , {inner_path : inner_path}, (res ) =>
@@ -372,14 +377,47 @@ class Sidebar extends Class
372377 if res == " ok"
373378 wrapper .notifications .add " sign" , " done" , " #{ inner_path} Signed!" , 5000
374379
380+ @tag .find (" .contents + .flex" ).removeClass " active"
381+ menu .hide ()
382+
383+ menu .addItem " Publish" , =>
384+ inner_path = @tag .find (" #input-contents" ).val ()
385+ wrapper .ws .cmd " sitePublish" , {" inner_path" : inner_path, " sign" : false }
386+
387+ @tag .find (" .contents + .flex" ).removeClass " active"
388+ menu .hide ()
389+
390+ @tag .find (" #menu-sign-publish" ).off (" click touchend" ).on " click touchend" , =>
391+ if window .visible_menu == menu
392+ @tag .find (" .contents + .flex" ).removeClass " active"
393+ menu .hide ()
394+ else
395+ @tag .find (" .contents + .flex" ).addClass " active"
396+ @tag .find (" .content-wrapper" ).prop " scrollTop" , 10000
397+ menu .show ()
375398 return false
376399
377- # Publish content.json
378- @tag .find (" #button-publish" ).off (" click touchend" ).on " click touchend" , =>
400+ $ (" body" ).on " click" , =>
401+ @tag .find (" .contents + .flex" ).removeClass " active"
402+
403+ @tag .find (" #button-sign-publish" ).off (" click touchend" ).on " click touchend" , =>
379404 inner_path = @tag .find (" #input-contents" ).val ()
380- @tag .find (" #button-publish" ).addClass " loading"
381- wrapper .ws .cmd " sitePublish" , {" inner_path" : inner_path, " sign" : false }, =>
382- @tag .find (" #button-publish" ).removeClass " loading"
405+
406+ wrapper .ws .cmd " fileRules" , {inner_path : inner_path}, (res ) =>
407+ if wrapper .site_info .privatekey or wrapper .site_info .auth_address in res .signers
408+ # Privatekey stored in users.json
409+ wrapper .ws .cmd " sitePublish" , {privatekey : " stored" , inner_path : inner_path, sign : true }, (res ) =>
410+ if res == " ok"
411+ wrapper .notifications .add " sign" , " done" , " #{ inner_path} Signed and published!" , 5000
412+
413+ else
414+ # Ask the user for privatekey
415+ wrapper .displayPrompt " Enter your private key:" , " password" , " Sign" , " " , (privatekey ) => # Prompt the private key
416+ wrapper .ws .cmd " sitePublish" , {privatekey : privatekey, inner_path : inner_path, sign : true }, (res ) =>
417+ if res == " ok"
418+ wrapper .notifications .add " sign" , " done" , " #{ inner_path} Signed and published!" , 5000
419+
420+ return false
383421
384422 # Close
385423 @tag .find (" .close" ).off (" click touchend" ).on " click touchend" , (e ) =>
0 commit comments