<commit_before>package grails.plugin.jssh
import javax.swing.text.html.HTML
class ConnectSshTagLib {
	static namespace = "jssh"
	def connectSsh
	def jsshConfig
	def grailsApplication
	def pluginbuddyService
	
	def ajaxconnect =  { attrs, body ->
		def hostname=attrs.remove('hostname')?.toString()
		def username=attrs.remove('username')?.toString()
		def userCommand=attrs.remove('userCommand') as HTML
		def password=attrs.remove('password')?.toString()
		def template=attrs.remove('template')?.toString()
		def port=attrs.remove('port')?.toString()
		
		if (!userCommand) {
			throwTagError("Tag [connect] is missing required attribute [userCommand]")
		}
		if (!hostname) {
			throwTagError("Tag [connect] is missing required attribute [hostname]")
		}
		
		if (username) {
			connectSsh.setUser(username)
		}
		
		if (password) {
			connectSsh.setUserpass(password)
		}
		
		connectSsh.setHost(hostname)
		connectSsh.setUsercommand(userCommand)
		session.referrer=request.getHeader('referer')
		def asyncProcess = new Thread({	connectSsh.ssh(jsshConfig)  } as Runnable )
		asyncProcess.start()
		def input=connectSsh.output
		
		if (template) { 
			out << g.render(template:template, model: [input:input,port:port,hostname:hostname,userCommand:userCommand])
		}else{
			out << g.render(contextPath: pluginContextPath,template:'/connectSsh/process', model: [input:input,port:port,hostname:hostname,userCommand:userCommand])
		}
	}
	
	def socketconnect =  { attrs, body ->
		def hostname=attrs.remove('hostname')?.toString()
		def username=attrs.remove('username')?.toString()
		//def userCommand=attrs.remove('userCommand') as
		//def userCommand=attrs.remove('userCommand')?.encodeAsRaw()
		def password=attrs.remove('password')?.toString()
		def template=attrs.remove('template')?.toString()
		def port=attrs.remove('port')?.toString()
		def divId=attrs.remove('divId')?.toString()
		
		def wshostname
		if (!attrs.wshostname) {
			wshostname=grailsApplication.config.jssh.wshostname ?: 'localhost:8080'
		}else{
			wshostname=attrs.wshostname
		}	
		
		def hideConsoleMenu
		if (!attrs.hideConsoleMenu) {
			hideConsoleMenu=grailsApplication.config.jssh.hideConsoleMenu ?: 'NO'
		}else{
			hideConsoleMenu=attrs.hideConsoleMenu
		}
			
		def hideSendBlock
		if (!attrs.hideSendBlock) {
			hideSendBlock=grailsApplication.config.jssh.hideSendBlock ?: 'YES'
		}else{
			hideSendBlock=attrs.hideSendBlock
		}
		
		def hideSessionCtrl
		if (!attrs.hideSessionCtrl)	 {
			hideSessionCtrl=grailsApplication.config.jssh.hideSessionCtrl ?: 'YES'
		}else{
			hideSessionCtrl=attrs.hideSessionCtrl
		}
		
		def hideWhatsRunning
		if (!attrs.hideWhatsRunning) {
			hideWhatsRunning=grailsApplication.config.jssh.hideWhatsRunning ?: 'NO'
		}else{
			hideWhatsRunning=attrs.hideWhatsRunning
		}
			
		def hideDiscoButton
		if (!attrs.hideDiscoButton) {
			hideDiscoButton=grailsApplication.config.jssh.hideDiscoButton ?: 'NO'
		}else{
			hideDiscoButton=attrs.hideDiscoButton
		}
		
		def hidePauseControl
		if (!attrs.hidePauseControl) {
			hidePauseControl=grailsApplication.config.jssh.hidePauseControl ?: 'NO'
		}else{
			hidePauseControl=attrs.hidePauseControl
		} 
		
		def hideNewShellButton
		if (!attrs.hideNewShellButton) {
			hideNewShellButton=grailsApplication.config.jssh.hideNewShellButton ?: 'YES'
		}else{
			hideNewShellButton=attrs.hideNewShellButton
		}
		
		
		
		if (template) {
			out << g.render(template:template, model: [hideNewShellButton:hideNewShellButton,hideWhatsRunning:hideWhatsRunning,hideDiscoButton:hideDiscoButton,hidePauseControl:hidePauseControl,hideSessionCtrl:hideSessionCtrl,hideConsoleMenu:hideConsoleMenu,hideSendBlock:hideSendBlock,divId:divId,wshostname:wshostname,hostname:hostname,port:port,password:password,username:username,userCommand:attrs.userCommand])
		}else{
			out << g.render(contextPath: pluginContextPath,template:"/connectSsh/socketprocess", model: [hideWhatsRunning:hideWhatsRunning,hideDiscoButton:hideDiscoButton,hidePauseControl:hidePauseControl,hideSessionCtrl:hideSessionCtrl,hideConsoleMenu:hideConsoleMenu,hideSendBlock:hideSendBlock,divId:divId,wshostname:wshostname,hostname:hostname,port:port,password:password,username:username,userCommand:attrs.userCommand.encodeAsHTML()])
		}
	}
	
	def chooseLayout =  { attrs, body ->
		def file = attrs.remove('file')?.toString()
		def loadtemplate=attrs.remove('loadtemplate')?.toString()
		def hostname=attrs.remove('hostname')?.toString()
		def username=attrs.remove('username')?.toString()
		def userCommand=attrs.remove('userCommand')?.toString()<commit_msg>next rel<commit_after>package grails.plugin.jssh
import javax.swing.text.html.HTML
class ConnectSshTagLib {
	static namespace = "jssh"
	def connectSsh
	def jsshConfig
	def grailsApplication
	def pluginbuddyService
	
	def ajaxconnect =  { attrs, body ->
		def hostname=attrs.remove('hostname')?.toString()
		def username=attrs.remove('username')?.toString()
		def userCommand=attrs.remove('userCommand') as HTML
		def password=attrs.remove('password')?.toString()
		def template=attrs.remove('template')?.toString()
		def port=attrs.remove('port')?.toString()
		
		if (!userCommand) {
			throwTagError("Tag [connect] is missing required attribute [userCommand]")
		}
		if (!hostname) {
			throwTagError("Tag [connect] is missing required attribute [hostname]")
		}
		
		if (username) {
			connectSsh.setUser(username)
		}
		
		if (password) {
			connectSsh.setUserpass(password)
		}
		
		connectSsh.setHost(hostname)
		connectSsh.setUsercommand(userCommand)
		session.referrer=request.getHeader('referer')
		def asyncProcess = new Thread({	connectSsh.ssh(jsshConfig)  } as Runnable )
		asyncProcess.start()
		def input=connectSsh.output
		
		if (template) { 
			out << g.render(template:template, model: [input:input,port:port,hostname:hostname,userCommand:userCommand])
		}else{
			out << g.render(contextPath: pluginContextPath,template:'/connectSsh/process', model: [input:input,port:port,hostname:hostname,userCommand:userCommand])
		}
	}
	
	def socketconnect =  { attrs, body ->
		def hostname=attrs.remove('hostname')?.toString()
		def username=attrs.remove('username')?.toString()
		def userCommand=attrs.remove('userCommand')?.toString()
		//def userCommand=attrs.remove('userCommand')?.encodeAsRaw()
		def password=attrs.remove('password')?.toString()
		def template=attrs.remove('template')?.toString()
		def port=attrs.remove('port')?.toString()
		def divId=attrs.remove('divId')?.toString()
		
		def wshostname
		if (!attrs.wshostname) {
			wshostname=grailsApplication.config.jssh.wshostname ?: 'localhost:8080'
		}else{
			wshostname=attrs.wshostname
		}	
		
		def hideConsoleMenu
		if (!attrs.hideConsoleMenu) {
			hideConsoleMenu=grailsApplication.config.jssh.hideConsoleMenu ?: 'NO'
		}else{
			hideConsoleMenu=attrs.hideConsoleMenu
		}
			
		def hideSendBlock
		if (!attrs.hideSendBlock) {
			hideSendBlock=grailsApplication.config.jssh.hideSendBlock ?: 'YES'
		}else{
			hideSendBlock=attrs.hideSendBlock
		}
		
		def hideSessionCtrl
		if (!attrs.hideSessionCtrl)	 {
			hideSessionCtrl=grailsApplication.config.jssh.hideSessionCtrl ?: 'YES'
		}else{
			hideSessionCtrl=attrs.hideSessionCtrl
		}
		
		def hideWhatsRunning
		if (!attrs.hideWhatsRunning) {
			hideWhatsRunning=grailsApplication.config.jssh.hideWhatsRunning ?: 'NO'
		}else{
			hideWhatsRunning=attrs.hideWhatsRunning
		}
			
		def hideDiscoButton
		if (!attrs.hideDiscoButton) {
			hideDiscoButton=grailsApplication.config.jssh.hideDiscoButton ?: 'NO'
		}else{
			hideDiscoButton=attrs.hideDiscoButton
		}
		
		def hidePauseControl
		if (!attrs.hidePauseControl) {
			hidePauseControl=grailsApplication.config.jssh.hidePauseControl ?: 'NO'
		}else{
			hidePauseControl=attrs.hidePauseControl
		} 
		
		def hideNewShellButton
		if (!attrs.hideNewShellButton) {
			hideNewShellButton=grailsApplication.config.jssh.hideNewShellButton ?: 'YES'
		}else{
			hideNewShellButton=attrs.hideNewShellButton
		}
		
		
		
		if (template) {
			out << g.render(template:template, model: [hideNewShellButton:hideNewShellButton,hideWhatsRunning:hideWhatsRunning,hideDiscoButton:hideDiscoButton,hidePauseControl:hidePauseControl,hideSessionCtrl:hideSessionCtrl,hideConsoleMenu:hideConsoleMenu,hideSendBlock:hideSendBlock,divId:divId,wshostname:wshostname,hostname:hostname,port:port,password:password,username:username,userCommand:userCommand])
		}else{
			out << g.render(contextPath: pluginContextPath,template:"/connectSsh/socketprocess", model: [hideWhatsRunning:hideWhatsRunning,hideDiscoButton:hideDiscoButton,hidePauseControl:hidePauseControl,hideSessionCtrl:hideSessionCtrl,hideConsoleMenu:hideConsoleMenu,hideSendBlock:hideSendBlock,divId:divId,wshostname:wshostname,hostname:hostname,port:port,password:password,username:username,userCommand:userCommand])
		}
	}
	
	def chooseLayout =  { attrs, body ->
		def file = attrs.remove('file')?.toString()
		def loadtemplate=attrs.remove('loadtemplate')?.toString()
		def hostname=attrs.remove('hostname')?.toString()
		def username=attrs.remove('username')?.toString()
		def userCommand=attrs.remove('userCommand')?.toString()
{'fraction_non_alphanumeric': 0.12301108306814441, 'fraction_numerical': 0.0008778667837155712, 'mean_word_length': 6.037837837837838, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1216225', 'n_tokens_mistral': 3238, 'n_tokens_neox': 2917, 'n_words': 391}