Skip to content

Commit

Permalink
Base64 decode added and fix filter columns tabs can't display, remove…
Browse files Browse the repository at this point in the history
… useless JavaScript code and format code.
  • Loading branch information
xuri committed Oct 12, 2016
1 parent 0a78854 commit 3d270a0
Show file tree
Hide file tree
Showing 10 changed files with 49 additions and 39 deletions.
1 change: 1 addition & 0 deletions cookies.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ func readCookies(r *http.Request) {
selfConf.IsDisabledJSONDecode = readIntCookie(r, `isDisabledJsonDecode`, 0)
selfConf.IsDisabledUnserialization = readIntCookie(r, `isDisabledUnserialization`, 0)
selfConf.IsDisabledJobDataHighlight = readIntCookie(r, `isDisabledJobDataHighlight`, 0)
selfConf.IsEnabledBase64Decode = readIntCookie(r, `isEnabledBase64Decode`, 0)
selfConf.TubePauseSeconds = readIntCookie(r, `tubePauseSeconds`, -1)
selfConf.AutoRefreshTimeoutMs = readIntCookie(r, `autoRefreshTimeoutMs`, 500)
selfConf.SearchResultLimit = readIntCookie(r, `searchResultLimit`, 25)
Expand Down
19 changes: 3 additions & 16 deletions currentTubeJobsShowcase.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package main
import (
"fmt"
"html"
"strings"

"github.com/kr/beanstalk"
)
Expand Down Expand Up @@ -95,11 +94,7 @@ func currentTubeJobsShowcaseReadySection(server string, tube string) string {
</div>`, int(jobID), server, tube, server, tube, moveAllReadyTo, server, tube, server, tube, server, tube, int(jobID))
}
if jobBody != nil {
if selfConf.IsDisabledJSONDecode != 1 {
jobBodyStr = html.EscapeString(strings.Trim(string(prettyJSON(jobBody)), `'`))
} else {
jobBodyStr = html.EscapeString(strings.Trim(string(jobBody), `'`))
}
jobBodyStr = preformat(jobBody)
}

if jobBody != nil {
Expand Down Expand Up @@ -221,11 +216,7 @@ func currentTubeJobsShowcaseDelayedSection(server string, tube string) string {
</div>`, int(jobID), server, tube, server, tube, moveAllDelayedTo, server, tube, server, tube, server, tube, int(jobID))
}
if jobBody != nil {
if selfConf.IsDisabledJSONDecode != 1 {
jobBodyStr = html.EscapeString(strings.Trim(string(prettyJSON(jobBody)), `'`))
} else {
jobBodyStr = html.EscapeString(strings.Trim(string(jobBody), `'`))
}
jobBodyStr = preformat(jobBody)
}

if jobBody != nil {
Expand Down Expand Up @@ -340,11 +331,7 @@ func currentTubeJobsShowcaseBuriedSection(server string, tube string) string {
</div>`, int(jobID), server, tube, server, tube, moveAllBuriedTo, server, tube, server, tube, int(jobID))
}
if jobBody != nil {
if selfConf.IsDisabledJSONDecode != 1 {
jobBodyStr = html.EscapeString(strings.Trim(string(prettyJSON(jobBody)), `'`))
} else {
jobBodyStr = html.EscapeString(strings.Trim(string(jobBody), `'`))
}
jobBodyStr = preformat(jobBody)
}

if jobBody != nil {
Expand Down
9 changes: 0 additions & 9 deletions public/assets/vendor/vue/vue.js

This file was deleted.

2 changes: 2 additions & 0 deletions public/js/customer.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ $(document).ready(
}
if (jQuery.inArray(this.id, ['isDisabledUnserialization', 'isDisabledJsonDecode', 'isDisabledJobDataHighlight']) >= 0)
val = $(this).is(':checked') ? null : 1;
if (jQuery.inArray(this.id, ['isEnabledBase64Decode']) >= 0)
val = $(this).is(':checked') ? 1 : null;
$.cookie(this.id, val, {expires: 365});
});

Expand Down
2 changes: 1 addition & 1 deletion statik/statik.go

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions structs.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ type SelfConf struct {
IsDisabledJSONDecode int
IsDisabledUnserialization int
IsDisabledJobDataHighlight int
IsEnabledBase64Decode int
AutoRefreshTimeoutMs int
SearchResultLimit int
}
Expand Down
8 changes: 4 additions & 4 deletions tplFilter.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,13 @@ func tplServerFilter() string {
<div class="tab-pane active" id="binlog">
%s
</div>
<div class="tab-pane " id="cmd">
<div class="tab-pane" id="cmd">
%s
</div>
<div class="tab-pane " id="current">
<div class="tab-pane" id="current">
%s
</div>
<div class="tab-pane " id="other">
<div class="tab-pane" id="other">
%s
</div>
</div>
Expand Down Expand Up @@ -182,7 +182,7 @@ func tplTubeFilter() string {
<div class="tab-pane active" id="current">
%s
</div>
<div class="tab-pane " id="other">
<div class="tab-pane" id="other">
%s
</div>
</div>
Expand Down
3 changes: 1 addition & 2 deletions tplMain.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ func tplMain(serverList string, currentServer string) string {
</div>
%s
%s
%s
</div>
<script>
var url = "./index?server=";
Expand All @@ -100,5 +99,5 @@ func tplMain(serverList string, currentServer string) string {
%s
<script src="./js/customer.js"></script>
</body>
</html>`, TplHead, dropDownServer(currentServer), TplLinks, serverList, tplTubeFilter(), tplServerFilter(), dropEditSettings(), isDisabledJobDataHighlight)
</html>`, TplHead, dropDownServer(currentServer), TplLinks, serverList, tplServerFilter(), dropEditSettings(), isDisabledJobDataHighlight)
}
16 changes: 11 additions & 5 deletions tplNav.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,13 +124,16 @@ func dropDownTube(server string, currentTube string) string {

// dropEditSettings render a navigation dropdown menu for set preference.
func dropEditSettings() string {
var isDisabledJSONDecode, isDisabledJobDataHighlight string
var isDisabledJSONDecode, isDisabledJobDataHighlight, isEnabledBase64Decode string
if selfConf.IsDisabledJSONDecode != 1 {
isDisabledJSONDecode = `checked="checked"`
}
if selfConf.IsDisabledJobDataHighlight != 1 {
isDisabledJobDataHighlight = `checked="checked"`
}
if selfConf.IsEnabledBase64Decode != 0 {
isEnabledBase64Decode = `checked="checked"`
}
return fmt.Sprintf(`<div id="settings" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="settings-label" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
Expand All @@ -156,21 +159,24 @@ func dropEditSettings() string {
</div>
<div class="form-group">
<label for="focusedInput"><b>Preferred way to deal with job data</b></label>
<div class="checkbox">
<label>
<input type="checkbox" id="isDisabledJsonDecode" value="1" %s>
before display: json_decode()
</label>
</div>
<div class="checkbox">
<label>
<input type="checkbox" id="isEnabledBase64Decode" value="1" %s>
before display: base64_decode()
</label>
</div>
<div class="checkbox">
<label>
<input type="checkbox" id="isDisabledJobDataHighlight" value="1" %s>
after display: enable highlight
</label>
</div>
</div>
</fieldset>
</div>
Expand All @@ -180,5 +186,5 @@ func dropEditSettings() string {
</div>
</div>
</div>`, selfConf.TubePauseSeconds, selfConf.AutoRefreshTimeoutMs, selfConf.SearchResultLimit, isDisabledJSONDecode, isDisabledJobDataHighlight)
</div>`, selfConf.TubePauseSeconds, selfConf.AutoRefreshTimeoutMs, selfConf.SearchResultLimit, isDisabledJSONDecode, isEnabledBase64Decode, isDisabledJobDataHighlight)
}
27 changes: 25 additions & 2 deletions utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"encoding/json"
"flag"
"fmt"
"html"
"io"
"io/ioutil"
"math/rand"
Expand Down Expand Up @@ -123,6 +124,28 @@ func prettyJSON(b []byte) []byte {
return out.Bytes()
}

// base64Decode provide method get Base64 decode string.
func base64Decode(b string) string {
data, err := base64.StdEncoding.DecodeString(b)
if err != nil {
return string(b)
}
return string(data)
}

// preformat provide method get job body after format with config.
func preformat(jobBody []byte) string {
var job string
if selfConf.IsDisabledJSONDecode != 1 {
job = string(prettyJSON(jobBody))
}
if selfConf.IsEnabledBase64Decode != 0 {
job = base64Decode(job)
}
job = html.EscapeString(job)
return job
}

// parseFlags parse flags of program.
func parseFlags() {
configPtr := flag.String("c", "", "Use config file.")
Expand All @@ -135,11 +158,11 @@ func parseFlags() {
ConfigFile = *configPtr
}
if *verPtr == true {
fmt.Println("aurora version: 0.1")
fmt.Println("aurora version: 1.1")
os.Exit(1)
}
if *helpPtr == true {
fmt.Println("aurora version: 0.1\r\nCopyright (c) 2016 Ri Xu https://xuri.me \r\n\r\nUsage: aurora [OPTIONS] [cmd [arg ...]]\n -c <filename> Use config file. (default: aurora.toml)\r\n -h \t\t Output this help and exit.\r\n -v \t\t Output version and exit.")
fmt.Println("aurora version: 1.1\r\nCopyright (c) 2016 Ri Xu https://xuri.me \r\n\r\nUsage: aurora [OPTIONS] [cmd [arg ...]]\n -c <filename> Use config file. (default: aurora.toml)\r\n -h \t\t Output this help and exit.\r\n -v \t\t Output version and exit.")
os.Exit(1)
}
}
Expand Down

0 comments on commit 3d270a0

Please sign in to comment.