How to use Protocol method of html Package

Best K6 code snippet using html.Protocol

module_dept.go

Source:module_dept.go Github

copy

Full Screen

1package handler2import (3 "html/template"4 "jachunPM_http/js"5 "libraries"6 "protocol"7 "strconv"8 "strings"9)10func init() {11 httpHandlerMap["GET"]["/dept/browse"] = get_dept_browse12 httpHandlerMap["POST"]["/dept/updateOrder"] = post_dept_updateOrder13 httpHandlerMap["POST"]["/dept/manageChild"] = post_dept_manageChild14 httpHandlerMap["GET"]["/dept/delete"] = get_dept_delete15 httpHandlerMap["GET"]["/dept/edit"] = get_dept_edit16 httpHandlerMap["POST"]["/dept/edit"] = post_dept_edit17}18func get_dept_browse(data *TemplateData) (err error) {19 ws := data.ws20 deptID, _ := strconv.Atoi(ws.Query("deptID"))21 data.Data["deptID"] = deptID22 if int32(deptID) > 0 {23 getParents := protocol.GET_MSG_USER_Dept_getParents()24 getParents.Id = int32(deptID)25 res, err := dept_getParents(int32(deptID))26 if err != nil {27 return err28 }29 data.Data["parentDepts"] = res30 }31 if data.Data["depts"], err = dept_getTreeMenu(data, 0, dept_createManageLink); err != nil {32 return33 }34 if data.Data["sons"], err = dept_getSons(int32(deptID)); err != nil {35 return36 }37 getDataStructure := protocol.GET_MSG_USER_Dept_getDataStructure()38 getDataStructure.RootDeptID = int32(0)39 var res *protocol.MSG_USER_Dept_getDataStructure_result40 if err = data.SendMsgWaitResultToDefault(getDataStructure, &res); err != nil {41 return42 }43 data.Data["tree"] = res.List44 getDataStructure.Put()45 templateOut("dept.browse.html", data)46 return47}48func dept_getTree(rootDeptId int32) (deptList []*protocol.MSG_USER_Dept_cache, err error) {49 res, err := HostConn.CacheGetPath(protocol.UserServerNo, protocol.PATH_USER_DEPT_CACHE)50 if err != nil {51 return deptList, err52 }53 var deptInfo *protocol.MSG_USER_Dept_cache54 buf := bufpool.Get().(*libraries.MsgBuffer)55 for _, b := range res {56 buf.Reset()57 buf.Write(b)58 if v, ok := protocol.READ_MSG_DATA(buf).(*protocol.MSG_USER_Dept_cache); ok {59 deptList = append(deptList, v)60 if v.Id == rootDeptId {61 deptInfo = v62 }63 }64 }65 buf.Reset()66 bufpool.Put(buf)67 if deptInfo != nil {68 for i := len(deptList) - 1; i >= 0; i-- {69 has := false70 out:71 for _, a := range deptList[i].Path {72 for _, b := range deptInfo.Path {73 if a == b {74 has = true75 break out76 }77 }78 }79 if !has {80 deptList = append(deptList[:i], deptList[i+1:]...)81 deptList[i].Put()82 }83 }84 }85 if len(deptList) > 0 {86 protocol.Order_dept(deptList, func(a, b *protocol.MSG_USER_Dept_cache) bool {87 if a.Grade == b.Grade {88 return a.Order < b.Order89 }90 return a.Grade > b.Grade91 })92 }93 return94}95func dept_getTreeMenu(data *TemplateData, rootDeptId int32, createLink func(data *TemplateData, deptinfo *protocol.MSG_USER_Dept_cache, buf *libraries.MsgBuffer)) (template.HTML, error) {96 deptList, err := dept_getTree(rootDeptId)97 if err != nil {98 return template.HTML(""), err99 }100 var deptMenu = make(map[int32]*libraries.MsgBuffer)101 for _, dept := range deptList {102 if _buf, ok := deptMenu[dept.Id]; ok {103 buf, ok := deptMenu[dept.Parent]104 if !ok {105 buf = bufpool.Get().(*libraries.MsgBuffer)106 deptMenu[dept.Parent] = buf107 }108 buf.WriteString("<li>")109 createLink(data, dept, buf)110 buf.WriteString("<ul>")111 buf.Write(_buf.Bytes())112 buf.WriteString("</ul>\n")113 } else {114 buf, ok := deptMenu[dept.Parent]115 if !ok {116 buf = bufpool.Get().(*libraries.MsgBuffer)117 deptMenu[dept.Parent] = buf118 }119 buf.WriteString("<li>")120 createLink(data, dept, buf)121 buf.WriteString("\n")122 }123 deptMenu[dept.Parent].WriteString("</li>\n")124 }125 buf := bufpool.Get().(*libraries.MsgBuffer)126 buf.Reset()127 buf.WriteString("<ul class='tree' data-ride='tree' data-name='tree-dept'>")128 if v, ok := deptMenu[0]; ok {129 buf.Write(v.Bytes())130 }131 for _, dept := range deptList {132 if _buf, ok := deptMenu[dept.Id]; ok {133 buf.Write(_buf.Bytes())134 }135 dept.Put()136 }137 buf.WriteString("</ul>\n")138 result := buf.String()139 buf.Reset()140 bufpool.Put(buf)141 for _, buf := range deptMenu {142 buf.Reset()143 bufpool.Put(buf)144 }145 return template.HTML(result), err146}147func dept_getSons(deptId int32) (deptList []*protocol.MSG_USER_Dept_cache, err error) {148 res, err := HostConn.CacheGetPath(protocol.UserServerNo, protocol.PATH_USER_DEPT_CACHE)149 if err != nil {150 return nil, err151 }152 buf := bufpool.Get().(*libraries.MsgBuffer)153 for _, b := range res {154 buf.Reset()155 buf.Write(b)156 if v, ok := protocol.READ_MSG_DATA(buf).(*protocol.MSG_USER_Dept_cache); ok {157 if v.Parent == deptId {158 deptList = append(deptList, v)159 } else {160 v.Put()161 }162 }163 }164 buf.Reset()165 bufpool.Put(buf)166 if len(deptList) > 0 {167 protocol.Order_dept(deptList, func(a, b *protocol.MSG_USER_Dept_cache) bool { return a.Order < b.Order })168 }169 return170}171func dept_createManageLink(data *TemplateData, dept *protocol.MSG_USER_Dept_cache, buf *libraries.MsgBuffer) {172 buf.WriteString(dept.Name)173 if hasPriv(data, "dept", "edit") {174 buf.WriteString(" ")175 buf.WriteString(html_a(createLink("dept", "edit", "deptid="+strconv.Itoa(int(dept.Id))), data.Lang["common"]["edit"].(string), "", "data-toggle='modal' data-type='ajax'"))176 }177 if hasPriv(data, "dept", "browse") {178 buf.WriteString(" ")179 buf.WriteString(html_a(createLink("dept", "browse", "deptid="+strconv.Itoa(int(dept.Id))), data.Lang["dept"]["manageChild"].(string)))180 }181 if hasPriv(data, "dept", "delete") {182 buf.WriteString(" ")183 buf.WriteString(html_a(createLink("dept", "delete", "deptid="+strconv.Itoa(int(dept.Id))), data.Lang["common"]["delete"].(string), "hiddenwin"))184 }185 if hasPriv(data, "dept", "updateOrder") {186 buf.WriteString(" ")187 buf.WriteString(html_input("orders["+strconv.Itoa(int(dept.Id))+"]", strconv.Itoa(int(dept.Order)), "style='width:30px;text-align:center'"))188 }189 return190}191func dept_createMemberLink(data *TemplateData, dept *protocol.MSG_USER_Dept_cache, buf *libraries.MsgBuffer) {192 id := strconv.Itoa(int(dept.Id))193 buf.WriteString(html_a(createLink("company", "browse", "dept="+id), dept.Name, "_self", "id='dept"+id+"'"))194 return195}196func post_dept_updateOrder(data *TemplateData) (err error) {197 ws := data.ws198 post := ws.GetAllPost()199 res, err := HostConn.CacheGetPath(protocol.UserServerNo, protocol.PATH_USER_DEPT_CACHE)200 if err != nil {201 ws.WriteString(js.Alert(data.Lang["dept"]["error"].(map[string]string)["ErrDeptInfo"], err))202 return nil203 }204 var m = make(map[int32]*protocol.MSG_USER_Dept_cache)205 buf := bufpool.Get().(*libraries.MsgBuffer)206 for _, b := range res {207 buf.Reset()208 buf.Write(b)209 if v, ok := protocol.READ_MSG_DATA(buf).(*protocol.MSG_USER_Dept_cache); ok {210 m[v.Id] = v211 }212 }213 buf.Reset()214 bufpool.Put(buf)215 update := protocol.GET_MSG_USER_Dept_update()216 for deptId, order := range post {217 id, err := strconv.Atoi(deptId)218 if err != nil {219 ws.WriteString(js.Alert(data.Lang["dept"]["error"].(map[string]string)["ErrDeptIDType"], deptId) + js.Reload("parent"))220 return nil221 }222 o, err := strconv.Atoi(order[0])223 if err != nil {224 ws.WriteString(js.Alert(data.Lang["dept"]["error"].(map[string]string)["ErrOrderType"], deptId, order) + js.Reload("parent"))225 return nil226 }227 if deptinfo, ok := m[int32(id)]; ok {228 if deptinfo.Order != int8(o) {229 deptinfo.Order = int8(o)230 update.List = append(update.List, deptinfo)231 }232 } else {233 ws.WriteString(js.Alert(data.Lang["dept"]["error"].(map[string]string)["ErrDeptInfoDeptID"], deptId) + js.Reload("parent"))234 return nil235 }236 }237 if err = data.SendMsgWaitResultToDefault(update, nil); err != nil {238 ws.WriteString(js.Alert(data.Lang["dept"]["error"].(map[string]string)["ErrUpdate"], err) + js.Reload("parent"))239 return nil240 }241 update.Put()242 ws.WriteString(js.Reload("parent"))243 return nil244}245func post_dept_manageChild(data *TemplateData) (err error) {246 ws := data.ws247 res, err := HostConn.CacheGetPath(protocol.UserServerNo, protocol.PATH_USER_DEPT_CACHE)248 if err != nil {249 ws.WriteString(js.Alert(data.Lang["dept"]["error"].(map[string]string)["ErrDeptInfo"], err))250 return nil251 }252 var m = make(map[int32]*protocol.MSG_USER_Dept_cache)253 buf := bufpool.Get().(*libraries.MsgBuffer)254 maxorder := int8(0)255 maxid := int32(0)256 for _, b := range res {257 buf.Reset()258 buf.Write(b)259 if v, ok := protocol.READ_MSG_DATA(buf).(*protocol.MSG_USER_Dept_cache); ok {260 m[v.Id] = v261 if v.Order > maxorder {262 maxorder = v.Order263 }264 if v.Id > maxid {265 maxid = v.Id266 }267 }268 }269 buf.Reset()270 bufpool.Put(buf)271 grade := int8(1)272 parentDeptID, _ := strconv.Atoi(ws.Post("parentDeptID"))273 parentDept, ok := m[int32(parentDeptID)]274 if ok {275 grade = parentDept.Grade + 1276 }277 update := protocol.GET_MSG_USER_Dept_update()278 for str_id, v := range ws.GetAllPost() {279 if str_id == "0" {280 for _, name := range v {281 if name != "" {282 insert := protocol.GET_MSG_USER_Dept_cache()283 insert.Name = name284 maxorder++285 insert.Order = maxorder286 maxid++287 insert.Id = maxid288 if parentDept != nil {289 insert.Parent = parentDept.Id290 insert.Grade = grade291 parentPath := make([]int32, len(parentDept.Path))292 copy(parentPath, parentDept.Path)293 insert.Path = append(parentPath, insert.Id)294 } else {295 insert.Grade = 1296 insert.Path = []int32{insert.Id}297 }298 update.List = append(update.List, insert)299 }300 }301 } else {302 id, _ := strconv.Atoi(str_id)303 if deptinfo, ok := m[int32(id)]; !ok {304 //ws.WriteString(js.Alert(fmt.Sprintf(data.Lang["dept"]["error"].(map[string]string)["ErrDeptInfoDeptID"], str_id)) + js.Reload("parent"))305 //return306 } else {307 deptinfo.Name = v[0]308 update.List = append(update.List, deptinfo)309 }310 }311 }312 err = data.SendMsgWaitResultToDefault(update, nil)313 update.Put()314 if err != nil {315 ws.WriteString(js.Alert(data.Lang["dept"]["error"].(map[string]string)["ErrUpdate"], err) + js.Reload("parent"))316 return nil317 }318 ws.WriteString(js.Reload("parent"))319 return nil320}321func get_dept_delete(data *TemplateData) (err error) {322 ws := data.ws323 deptid, _ := strconv.Atoi(ws.Query("deptid"))324 if ws.Query("confirm") != "yes" {325 ws.WriteString(js.Confirm(data.Lang["dept"]["confirmDelete"].(string), createLink(`dept`, `delete`, "deptid="+ws.Query("deptid")+"&confirm=yes"), ""))326 return nil327 }328 out := protocol.GET_MSG_USER_Dept_delete()329 out.DeptId = int32(deptid)330 var res *protocol.MSG_USER_Dept_delete_result331 if err := data.SendMsgWaitResultToDefault(out, &res); err != nil {332 ws.WriteString(js.Alert(data.Lang["dept"]["error"].(map[string]string)["ErrUpdate"], err))333 return nil334 }335 out.Put()336 if res.Result != protocol.Success {337 ws.WriteString(js.Alert(data.Lang["dept"]["error"].(map[string]string)[res.Result.String()]) + js.Reload("parent"))338 return nil339 }340 ws.WriteString(js.Reload("parent"))341 return nil342}343func get_dept_edit(data *TemplateData) (err error) {344 deptid, _ := strconv.Atoi(data.ws.Query("deptid"))345 deptinfo, err := HostConn.GetdeptCacheById(int32(deptid))346 if err != nil || deptinfo == nil {347 data.ws.WriteString(js.Alert(data.Lang["dept"]["error"].(map[string]string)["ErrDeptInfoDeptID"], deptid) + js.Reload("parent"))348 return nil349 }350 data.Data["dept"] = deptinfo351 out := protocol.GET_MSG_USER_getDeptUserPairs()352 out.DeptId = int32(deptid)353 var res *protocol.MSG_USER_getDeptUserPairs_result354 err = data.SendMsgWaitResultToDefault(out, &res)355 out.Put()356 if err != nil {357 data.ws.WriteString(js.Alert(data.Lang["dept"]["error"].(map[string]string)["ErrGetDeptUser"], err) + js.Reload("parent"))358 return nil359 }360 var users = []protocol.HtmlKeyValueStr{protocol.HtmlKeyValueStr{"0", ""}}361 for _, v := range res.List {362 users = append(users, protocol.HtmlKeyValueStr{strconv.Itoa(int(v.Id)), v.Realname})363 }364 data.Data["users"] = users365 data.Data["optionMenu"], err = dept_getOptionMenu(0)366 templateOut("dept.edit.html", data)367 return368}369func post_dept_edit(data *TemplateData) (err error) {370 deptid, _ := strconv.Atoi(data.ws.Query("deptid"))371 deptinfo, err := HostConn.GetdeptCacheById(int32(deptid))372 if err != nil || deptinfo == nil {373 data.ws.WriteString(js.Alert(data.Lang["dept"]["error"].(map[string]string)["ErrDeptInfoDeptID"], deptid) + js.Reload("parent"))374 return nil375 }376 manager, _ := strconv.Atoi(data.ws.Post("manager"))377 if manager != 0 {378 managerUser := HostConn.GetUserCacheById(int32(manager))379 if managerUser == nil {380 data.ws.WriteString(js.Alert(data.Lang["dept"]["error"].(map[string]string)["ErrManager"]) + js.Reload("parent"))381 return nil382 }383 deptinfo.Manager = managerUser.Id384 deptinfo.ManagerName = managerUser.Realname385 if deptinfo.ManagerName == "" {386 deptinfo.ManagerName = managerUser.Account387 }388 } else {389 deptinfo.Manager = 0390 deptinfo.ManagerName = ""391 }392 deptinfo.Name = data.ws.Post("name")393 update := protocol.GET_MSG_USER_Dept_update()394 update.List = []*protocol.MSG_USER_Dept_cache{deptinfo}395 err = data.SendMsgWaitResultToDefault(update, nil)396 update.Put()397 if err != nil {398 data.ws.WriteString(js.Alert(data.Lang["dept"]["error"].(map[string]string)["ErrUpdate"], err) + js.Reload("parent"))399 return nil400 }401 data.ws.WriteString(js.Alert(data.Lang["dept"]["successSave"].(string)) + js.Reload("parent"))402 return nil403}404func dept_getOptionMenu(rootDeptID int32) ([]protocol.HtmlKeyValueStr, error) {405 deptlist, err := dept_getTree(rootDeptID)406 if err != nil {407 return nil, err408 }409 res := []protocol.HtmlKeyValueStr{{"0", "/"}}410 for _, dept := range deptlist {411 var deptNames = []string{dept.Name}412 for _, parentDeptID := range dept.Path {413 for _, parent := range deptlist {414 if parent.Id == parentDeptID {415 deptNames = append(deptNames, parent.Name)416 break417 }418 }419 }420 res = append(res, protocol.HtmlKeyValueStr{strconv.Itoa(int(dept.Id)), "/" + strings.Join(deptNames, "/")})421 }422 return res, nil423}424func dept_getAllChildID(deptID int32) (res []int32, err error) {425 if deptID < 0 {426 return nil, nil427 }428 result, err := HostConn.CacheGetPath(protocol.UserServerNo, protocol.PATH_USER_DEPT_CACHE)429 if err != nil {430 return nil, err431 }432 buf := protocol.BufPoolGet()433 for _, b := range result {434 buf.Reset()435 buf.Write(b)436 if v, ok := protocol.READ_MSG_DATA(buf).(*protocol.MSG_USER_Dept_cache); ok {437 for _, id := range v.Path {438 if id == deptID {439 res = append(res, v.Id)440 }441 }442 v.Put()443 }444 }445 buf.Reset()446 protocol.BufPoolPut(buf)447 return res, nil448}449func dept_getParents(deptID int32) (deptList []*protocol.MSG_USER_Dept_cache, err error) {450 res, err := HostConn.CacheGetPath(protocol.UserServerNo, protocol.PATH_USER_DEPT_CACHE)451 if err != nil {452 return deptList, err453 }454 deptMap := map[int32]*protocol.MSG_USER_Dept_cache{}455 var deptInfo *protocol.MSG_USER_Dept_cache456 buf := bufpool.Get().(*libraries.MsgBuffer)457 for _, b := range res {458 buf.Reset()459 buf.Write(b)460 if v, ok := protocol.READ_MSG_DATA(buf).(*protocol.MSG_USER_Dept_cache); ok {461 deptMap[v.Id] = v462 if v.Id == deptID {463 deptInfo = v464 }465 }466 }467 buf.Reset()468 bufpool.Put(buf)469 if deptInfo != nil {470 for _, parentId := range deptInfo.Path {471 if v, ok := deptMap[parentId]; ok {472 deptList = append(deptList, v)473 delete(deptMap, parentId)474 }475 }476 }477 for _, v := range deptMap {478 v.Put()479 }480 return481}482func dept_getPairs(data *TemplateData) (res []protocol.HtmlKeyValueStr, err error) {483 result, err := dept_getAll(data)484 if err != nil {485 return nil, err486 }487 for _, v := range result {488 res = append(res, protocol.HtmlKeyValueStr{strconv.Itoa(int(v.Id)), v.Name})489 }490 return res, nil491}492func dept_getAll(data *TemplateData) (list []*protocol.MSG_USER_Dept_cache, err error) {493 if data.Data["dept_all_cache"] != nil {494 return data.Data["dept_all_cache"].([]*protocol.MSG_USER_Dept_cache), nil495 }496 res, err := HostConn.CacheGetPath(protocol.UserServerNo, protocol.PATH_USER_DEPT_CACHE)497 if err != nil {498 return nil, err499 }500 buf := bufpool.Get().(*libraries.MsgBuffer)501 for _, b := range res {502 buf.Reset()503 buf.Write(b)504 if v, ok := protocol.READ_MSG_DATA(buf).(*protocol.MSG_USER_Dept_cache); ok {505 list = append(list, v)506 }507 }508 buf.Reset()509 bufpool.Put(buf)510 if len(list) > 0 {511 protocol.Order_dept(list, func(a, b *protocol.MSG_USER_Dept_cache) bool { return a.Order < b.Order })512 }513 data.Data["dept_all_cache"] = list514 return515}516func dept_getDeptManagedByMe(uid int32) ([]int32, error) {517 res, err := HostConn.CacheGetPath(protocol.UserServerNo, protocol.PATH_USER_DEPT_CACHE)518 if err != nil {519 return nil, err520 }521 var deptIds []int32522 buf := bufpool.Get().(*libraries.MsgBuffer)523 for _, b := range res {524 buf.Reset()525 buf.Write(b)526 if v, ok := protocol.READ_MSG_DATA(buf).(*protocol.MSG_USER_Dept_cache); ok && v.Manager == uid {527 deptIds = append(deptIds, v.Id)528 v.Put()529 }530 }531 buf.Reset()532 bufpool.Put(buf)533 return deptIds, nil534}...

Full Screen

Full Screen

bucket_website_test.go

Source:bucket_website_test.go Github

copy

Full Screen

...20 <IndexDocument>21 <Suffix>index.html</Suffix>22 </IndexDocument>23 <RedirectAllRequestsTo>24 <Protocol>https</Protocol>25 </RedirectAllRequestsTo>26 <RoutingRules>27 <RoutingRule>28 <Condition>29 <HttpErrorCodeReturnedEquals>404</HttpErrorCodeReturnedEquals>30 </Condition>31 <Redirect>32 <Protocol>https</Protocol>33 <ReplaceKeyWith>404.html</ReplaceKeyWith>34 </Redirect>35 </RoutingRule>36 <RoutingRule>37 <Condition>38 <KeyPrefixEquals>docs/</KeyPrefixEquals>39 </Condition>40 <Redirect>41 <Protocol>https</Protocol>42 <ReplaceKeyPrefixWith>documents/</ReplaceKeyPrefixWith>43 </Redirect>44 </RoutingRule>45 <RoutingRule>46 <Condition>47 <KeyPrefixEquals>img/</KeyPrefixEquals>48 </Condition>49 <Redirect>50 <Protocol>https</Protocol>51 <ReplaceKeyWith>demo.jpg</ReplaceKeyWith>52 </Redirect>53 </RoutingRule>54 </RoutingRules>55</WebsiteConfiguration>`)56 })57 res, _, err := client.Bucket.GetWebsite(context.Background())58 if err != nil {59 t.Fatalf("Bucket.GetWebsite returned error %v", err)60 }61 want := &BucketGetWebsiteResult{62 XMLName: xml.Name{Local: "WebsiteConfiguration"},63 Index: "index.html",64 RedirectProtocol: &RedirectRequestsProtocol{65 "https",66 },67 RoutingRules: &WebsiteRoutingRules{68 Rules: []WebsiteRoutingRule{69 {70 ConditionErrorCode: "404",71 RedirectProtocol: "https",72 RedirectReplaceKey: "404.html",73 },74 {75 ConditionPrefix: "docs/",76 RedirectProtocol: "https",77 RedirectReplaceKeyPrefix: "documents/",78 },79 {80 ConditionPrefix: "img/",81 RedirectProtocol: "https",82 RedirectReplaceKey: "demo.jpg",83 },84 },85 },86 }87 if !reflect.DeepEqual(res, want) {88 t.Errorf("Bucket.GetWebsite returned %+v, want %+v", res, want)89 }90}91func TestBucketService_PutWebsite(t *testing.T) {92 setup()93 defer teardown()94 opt := &BucketPutWebsiteOptions{95 Index: "index.html",96 RedirectProtocol: &RedirectRequestsProtocol{97 "https",98 },99 Error: &ErrorDocument{100 "Error.html",101 },102 RoutingRules: &WebsiteRoutingRules{103 []WebsiteRoutingRule{104 {105 ConditionErrorCode: "404",106 RedirectProtocol: "https",107 RedirectReplaceKey: "404.html",108 },109 {110 ConditionPrefix: "docs/",111 RedirectProtocol: "https",112 RedirectReplaceKeyPrefix: "documents/",113 },114 {115 ConditionPrefix: "img/",116 RedirectProtocol: "https",117 RedirectReplaceKey: "demo.jpg",118 },119 },120 },121 }122 mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {123 testMethod(t, r, "PUT")124 vs := values{125 "website": "",126 }127 testFormValues(t, r, vs)128 body := new(BucketPutWebsiteOptions)129 xml.NewDecoder(r.Body).Decode(body)130 want := opt...

Full Screen

Full Screen

html.go

Source:html.go Github

copy

Full Screen

...15<center>16<table>17<tr>18<td>19<a href="{Protocol}://{Host}/prev"> prev </a>20</td>21<td>22<a href="{Protocol}://{Host}` + tagspattern + `"> tags </a>23</td>24<td>25<a href="{Protocol}://{Host}/random"> rand </a>26</td>27<td>28<a href="{Protocol}://{Host}/next"> next </a>29</td>30</table>31</center>32</div>33<div>34<center>35<a href="{Protocol}://{Host}/random">36<img src="{Protocol}://{Host}/{.repeated section Body}{@}{.end}" alt="{Title}" />37</a>38</center>39</div>40<div> 41<center>42<form action="` + picpattern + `{Title}" method="post"> 43Password: <input type="text" name="password"/> <br>44Tag: <input type="text" name="` + newtag + `"/> 45<input type="submit" value="Tag!"> 46</form>47<form action="` + picpattern + `{Title}" method="post"> 48<input type="hidden" name="` + fullsize + `"/> 49<input type="submit" value="Full size">50</form>51</center>52</div> 53`54 tag_html = `55<h1><center>{Title}</center></h1>56<div>57<center>58<a href="{Protocol}://{Host}` + tagspattern + `"> tags </a>59</center>60</div>61<div>62<center>63{.repeated section Body}64{@}65{.end}66</center>67</div>68`69 tags_html = `70<h1><center>{Title}</center></h1>71<div>72<center>73{.repeated section Body}74<a href="{Protocol}://{Host}` + tagpattern + `{@}">{@}</a>75{.end}76</center>77</div>78`79//TODO: more suitable name for input submit below? probably no?80 upload_html = `81<div> 82<center>83<p>84Upload and optionally tag a file85</p>86</center>87</div>88<div> 89<center>90<form action=` + uploadpattern + ` enctype="multipart/form-data" method="post">91Upload <input type="file" name="upload" size="40"> <br>92Tag <input type="text" name="tag" size="30"> <br>93<input type="submit" value="Upload" >94</form> 95</center>96</div>97<div> 98<center>99<p>100{Title}101</p>102</center>103</div>104`105)106func mkTemplates(dirpath string) os.Error {107 err := mkdir(dirpath)108 if err != nil {109 return err110 }111 if config.Norand {112 randHtml := regexp.MustCompile(`<a href="{Protocol}://{Host}/random">113`)114 pic_html = randHtml.ReplaceAllString(pic_html,115 `<a href="{Protocol}://{Host}/{Title}">116`)117 }118 tmpls := [][2]string{[2]string{pic_html, picName + ".html"}, [2]string{tag_html, tagName + ".html"}, [2]string{tags_html, tagsName + ".html"}, [2]string{upload_html, upName + ".html"}}119 for _, tmpl := range tmpls {120 templ, err := os.Create(path.Join(dirpath, tmpl[1]))121 if err != nil {122 return err123 }124 _, err = templ.WriteString(tmpl[0])125 if err != nil {126 return err127 }128 err = templ.Close()129 if err != nil {...

Full Screen

Full Screen

Protocol

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 if err != nil {4 fmt.Println(err)5 }6 defer resp.Body.Close()7 fmt.Println(resp.Proto)8}9import (10func main() {11 if err != nil {12 fmt.Println(err)13 }14 defer resp.Body.Close()15 fmt.Println(resp.Proto)16}

Full Screen

Full Screen

Protocol

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 if err != nil {4 fmt.Println(err)5 }6 defer resp.Body.Close()7 fmt.Println(resp.Proto)8}

Full Screen

Full Screen

Protocol

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 if err != nil {4 fmt.Println(err)5 }6 defer resp.Body.Close()7 fmt.Println(resp.Proto)8}

Full Screen

Full Screen

Protocol

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 if err != nil {4 fmt.Println(err)5 }6 fmt.Println(resp.Proto)7}

Full Screen

Full Screen

Protocol

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 if err != nil {4 fmt.Println(err)5 } else {6 fmt.Println(resp.Proto)7 }8}

Full Screen

Full Screen

Protocol

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 if err != nil {4 panic(err)5 }6 fmt.Println(u)7 fmt.Println(u.Scheme)8}

Full Screen

Full Screen

Protocol

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 if err != nil {4 fmt.Println(err)5 }6 fmt.Println(u.Scheme)7 fmt.Println(u.Host)8 fmt.Println(u.Path)9 fmt.Println(u.RawQuery)10}

Full Screen

Full Screen

Protocol

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 if err != nil {4 panic(err)5 }6 fmt.Println(u.Scheme)7 fmt.Println(u.Host)8 fmt.Println(u.Path)9 fmt.Println(u.RawQuery)10 fmt.Println(u.Fragment)11}

Full Screen

Full Screen

Protocol

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 if err != nil {4 fmt.Println(err)5 }6 fmt.Println(req.Proto)7}

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run K6 automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Most used method in

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful