예제 #1
0
파일: button.go 프로젝트: keysonZZZ/kmg
// 一个发起Post请求的按钮
// url: 将把url转化为表单并使用Post方法提交
// title: 按钮上面的字
// 在当前页面打开连接
//不支持一个 key 里塞多个 value 的 url
func NewPostButton(urlStr string, title string) kmgView.HtmlRenderer {
	formAction, err := url.Parse(urlStr)
	kmgErr.PanicIfError(err)
	query, err := url.ParseQuery(formAction.RawQuery)
	kmgErr.PanicIfError(err)
	formAction.RawQuery = ""
	id := kmgRand.MustCryptoRandToReadableAlphaNum(10)
	form := Form{
		Id:        id,
		NoSubmit:  true,
		Url:       formAction.String(),
		InputList: []kmgView.HtmlRenderer{},
		IsHidden:  true,
	}
	for k, v := range query {
		form.InputList = append(form.InputList, InputHidden{
			Name:  k,
			Value: v[0],
		})
	}
	button := Button{
		FormId:  id,
		Type:    ButtonTypeButton,
		Content: kmgView.String(title),
		Size:    ButtonSizeExtraSmall,
		Color:   ButtonColorInfo,
	}
	return kmgView.Html(form.HtmlRender() + button.HtmlRender())
}
예제 #2
0
파일: sshCopyId.go 프로젝트: keysonZZZ/kmg
func RunCmdWithPassword(cmd, password string) {
	cmdTpl := `#!/usr/bin/expect -f
spawn %s
expect "assword:"
send "%s\r"
interact`
	cmd = fmt.Sprintf(cmdTpl, cmd, password)
	tmpName := kmgRand.MustCryptoRandToReadableAlphaNum(5)
	tmpPath := "/tmp/" + tmpName
	kmgFile.MustAppendFile(tmpPath, []byte(cmd))
	defer kmgFile.MustDelete(tmpPath)
	os.Setenv("HOME", kmgSys.GetCurrentUserHomeDir())
	kmgCmd.CmdSlice([]string{tmpPath}).MustStdioRun()
}
예제 #3
0
파일: Dialog.go 프로젝트: keysonZZZ/kmg
func (config DialogOpenWithButton) HtmlRender() string {
	targetId := "dialog_" + kmgRand.MustCryptoRandToReadableAlphaNum(10)
	return `<button type="button" class="btn btn-primary btn-lg" data-toggle="modal" data-target="#` + targetId + `">
` + kmgXss.H(config.ButtonTitle) + `
</button>
<div class="modal fade" id="` + targetId + `" tabindex="-1" role="dialog">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
      </div>
      <div class="modal-body">
        ` + config.DialogContent.HtmlRender() + `
      </div>
    </div>
  </div>
</div>
`
}
예제 #4
0
파일: dropDown.go 프로젝트: keysonZZZ/kmg
func (d DropDown) HtmlRender() string {
	if d.id == "" {
		d.id = kmgRand.MustCryptoRandToReadableAlphaNum(20)
	}
	return tplDropDown(d)
}
예제 #5
0
파일: tmpPath.go 프로젝트: keysonZZZ/kmg
// 返回一个新的临时文件目录,保证父级目录存在,保证文件不存在.
func NewTmpFilePath() string {
	return "/tmp/kmg_" + kmgRand.MustCryptoRandToReadableAlphaNum(8)
}