This commit is contained in:
Liang Ding 2014-10-12 22:00:26 +08:00
parent 3b421b5d0b
commit 05c296e723
13 changed files with 126 additions and 62 deletions

View File

@ -21,10 +21,9 @@
"D:\\GoGoGo\\src\\github.com\\b3log\\wide\\data\\user_workspaces\\admin\\src\\mytest\\time\\pkg"
],
"Files": [
"D:\\GoGoGo\\src\\github.com\\b3log\\wide\\data\\user_workspaces\\admin\\src\\mytest\\time\\main.go",
"D:\\GoGoGo\\src\\github.com\\b3log\\wide\\data\\user_workspaces\\admin\\src\\mytest\\time\\pkg\\time.go"
"D:\\GoGoGo\\src\\github.com\\b3log\\wide\\data\\user_workspaces\\admin\\src\\mytest\\time\\main.go"
],
"CurrentFile": "D:\\GoGoGo\\src\\github.com\\b3log\\wide\\data\\user_workspaces\\admin\\src\\mytest\\time\\pkg\\time.go"
"CurrentFile": "D:\\GoGoGo\\src\\github.com\\b3log\\wide\\data\\user_workspaces\\admin\\src\\mytest\\time\\main.go"
}
}
]

View File

@ -356,6 +356,7 @@ func FindUsagesHandler(w http.ResponseWriter, r *http.Request) {
ch := int(args["cursorCh"].(float64))
offset := getCursorOffset(code, line, ch)
// glog.Infof("offset [%d]", offset)
// TODO: 目前是调用 liteide_stub 工具来查找使用,后续需要重新实现
ide_stub := conf.Wide.GetIDEStub()
@ -391,11 +392,11 @@ func FindUsagesHandler(w http.ResponseWriter, r *http.Request) {
cursorLine, _ := strconv.Atoi(found[cursorSep+1 : strings.LastIndex(found, ":")])
cursorCh, _ := strconv.Atoi(found[strings.LastIndex(found, ":")+1:])
usage := &file.Snippet{Path: path, Line: cursorLine, Ch: cursorCh /* TODO: 获取附近的代码片段 */}
usage := &file.Snippet{Path: path, Line: cursorLine, Ch: cursorCh, Contents: []string{""}}
usages = append(usages, usage)
}
data["usages"] = usages
data["founds"] = usages
}
// 计算光标偏移位置.

View File

@ -44,5 +44,7 @@
"notification": "通知",
"min": "最小化",
"restore_side": "左侧窗口还原",
"usages": "查找使用",
"search_text": "查找文本",
"restore_bottom": "底部窗口还原"
}

22
main.go
View File

@ -149,9 +149,11 @@ func indexHandler(w http.ResponseWriter, r *http.Request) {
t.Execute(w, model)
}
// favicon.ico 请求处理.
func faviconHandler(w http.ResponseWriter, r *http.Request) {
// TODO: favicon.ico 请求处理
// 单个文件资源请求处理.
func serveSingle(pattern string, filename string) {
http.HandleFunc(pattern, func(w http.ResponseWriter, r *http.Request) {
http.ServeFile(w, r, filename)
})
}
// 主程序入口.
@ -160,17 +162,17 @@ func main() {
defer glog.Flush()
// 静态资源
http.Handle("/static/", http.StripPrefix("/static/", http.FileServer(http.Dir("static"))))
http.HandleFunc("/favicon.ico", handlerWrapper(faviconHandler))
// 库资源
http.Handle("/data/", http.StripPrefix("/data/", http.FileServer(http.Dir("data"))))
// IDE
http.HandleFunc("/login", handlerWrapper(loginHandler))
http.HandleFunc("/", handlerWrapper(indexHandler))
// 静态资源
http.Handle("/static/", http.StripPrefix("/static/", http.FileServer(http.Dir("static"))))
serveSingle("/favicon.ico", "./static/favicon.ico")
// 库资源
http.Handle("/data/", http.StripPrefix("/data/", http.FileServer(http.Dir("data"))))
// 会话
http.HandleFunc("/session/ws", handlerWrapper(session.WSHandler))
http.HandleFunc("/session/save", handlerWrapper(session.SaveContent))

View File

@ -3,8 +3,10 @@
width: 980px;
}
.header h1 {
margin: 0;
.header .logo {
float: left;
height: 32px;
margin-top: 3px;
}
.header {

View File

@ -280,6 +280,31 @@
width: 50px;
padding: 0 5px;
}
.bottom-window-group .search li {
cursor: pointer;
line-height: 20px;
padding: 0 3px;
word-wrap: normal;
word-break: normal;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.bottom-window-group .search li.selected {
background-color: #3875d7;
color: #FFF;
}
.bottom-window-group .search .path {
color: #999;
font-size: 12px;
}
.bottom-window-group .search li.selected .path {
color: #FFF;
}
/* end bottom-window-group */
/* start footer */

BIN
static/favicon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

BIN
static/images/wide-logo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

View File

@ -259,38 +259,69 @@ var editors = {
return;
}
var usagesHTML = '<ul>';
for (var i = 0, ii = data.usages.length; i < ii; i++) {
usagesHTML += '<li>' + data.usages[i].path
+ '</li>';
}
usagesHTML += '</ul>';
editors.appendSearch(usagesHTML);
editors.appendSearch(data.founds, 'usages', '');
}
});
};
},
appendSearch: function (html) {
var $usages = $('.bottom-window-group .search');
if ($usages.find("ul").length === 0) {
wide.usagesTab = new Tabs({
appendSearch: function (data, type, key) {
var searcHTML = '<ul>';
for (var i = 0, ii = data.length; i < ii; i++) {
var contents = data[i].contents[0],
index = contents.indexOf(key);
contents = contents.substring(0, index)
+ '<b>' + key + '</b>'
+ contents.substring(index + key.length);
searcHTML += '<li title="' + data[i].path + '">'
+ contents + "&nbsp;&nbsp;&nbsp;&nbsp;<span class='path'>" + data[i].path
+ '<i class="position" data-line="'
+ data[i].line + '" data-ch="' + data[i].ch + '"> (' + data[i].line + ':'
+ data[i].ch + ')</i></span></li>';
}
searcHTML += '</ul>';
var $search = $('.bottom-window-group .search'),
title = config.label.usages;
if (type === "founds") {
title = config.label.search_text;
}
if ($search.find("ul").length === 0) {
wide.searchTab = new Tabs({
id: ".bottom-window-group .search",
removeAfter: function (id, prevId) {
if ($usages.find("ul").length === 1) {
$usages.find(".tabs").hide();
if ($search.find("ul").length === 1) {
$search.find(".tabs").hide();
}
}
});
$usages.find(".tabs-panel > div").append(html);
} else if ($usages.find("ul").length === 1) {
$usages.find(".tabs").show();
wide.usagesTab.add({
id: "b",
"title": 'Usages of ',
"content": html + 1
$search.on("click", "li", function () {
$search.find("li").removeClass("selected");
$(this).addClass("selected");
});
$search.on("dblclick", "li", function () {
var $it = $(this),
tId = tree.getTIdByPath($it.attr("title"));
tree.openFile(tree.fileTree.getNodeByTId(tId));
tree.fileTree.selectNode(wide.curNode);
var cursor = CodeMirror.Pos($it.find(".position").data("line") - 1, $it.find(".position").data("ch") - 1);
wide.curEditor.setCursor(cursor);
wide.curEditor.focus();
});
$search.find(".tabs-panel > div").append(searcHTML);
$search.find(".tabs .first").text(title);
} else {
$search.find(".tabs").show();
wide.searchTab.add({
"id": "search" + (new Date()).getTime(),
"title": title,
"content": searcHTML
});
}

View File

@ -213,8 +213,8 @@ var wide = {
$("#dialogSearchForm").dialog({
"height": 52,
"width": 260,
"title": config.label.create_dir,
"okText": config.label.create,
"title": config.label.search,
"okText": config.label.search,
"cancelText": config.label.cancel,
"afterOpen": function () {
$("#dialogSearchForm > input:eq(0)").val('').focus();
@ -234,16 +234,9 @@ var wide = {
if (!data.succ) {
return;
}
var searcHTML = '<ul>';
for (var i = 0, ii = data.founds.length; i < ii; i++) {
searcHTML += '<li>' + data.founds[i].path
+ '</li>';
}
searcHTML += '</ul>';
editors.appendSearch(searcHTML);
$("#dialogSearchForm").dialog("close");
editors.appendSearch(data.founds, 'founds', request.text);
}
});
}

View File

@ -15,6 +15,8 @@
<link rel="stylesheet" href="{{.conf.StaticServer}}/static/css/base.css?{{.conf.StaticResourceVersion}}">
<link rel="stylesheet" href="{{.conf.StaticServer}}/static/css/wide.css?{{.conf.StaticResourceVersion}}">
<link rel="stylesheet" href="{{.conf.StaticServer}}/static/css/side.css?{{.conf.StaticResourceVersion}}">
<link rel="icon" type="image/x-icon" href="/favicon.ico" />
</head>
<body>
<!-- 主菜单 -->
@ -155,12 +157,12 @@
<div class="fn-none" data-index="search">
<div tabindex="-1" class="search">
<div class="tabs fn-none">
<div class="current" data-index="a">
<span title="a">a</span><span class="ico-close font-ico"></span>
<div class="current" data-index="first">
<span class="first"></span><span class="ico-close font-ico"></span>
</div>
</div>
<div class="tabs-panel">
<div data-index="a"></div>
<div data-index="first"></div>
</div>
</div>
</div>
@ -216,7 +218,10 @@
"tip": "{{.i18n.tip}}",
"confirm": "{{.i18n.confirm}}",
"build_n_run": "{{.i18n.build_n_run}}",
"stop": "{{.i18n.stop}}"
"stop": "{{.i18n.stop}}",
"usages": "{{.i18n.usages}}",
"search_text": "{{.i18n.search_text}}",
"search": "{{.i18n.search}}"
},
"channel": {
"editor": '{{.conf.EditorChannel}}',

View File

@ -5,11 +5,14 @@
<title>{{.i18n.wide}} - {{.i18n.login}}</title>
<link rel="stylesheet" href="{{.conf.StaticServer}}/static/css/base.css?{{.conf.StaticResourceVersion}}">
<link rel="stylesheet" href="{{.conf.StaticServer}}/static/css/login.css?{{.conf.StaticResourceVersion}}">
<link rel="icon" type="image/x-icon" href="/favicon.ico" />
</head>
<body>
<div class="header">
<div class="wrapper fn-clear">
<h1 class="fn-left"><a href="/login">Wide</a></h1>
<a href="/login">
<img src="{{.conf.StaticServer}}/static/images/wide-logo.png"
class="logo"/></a>
<ul class="fn-right">
<li><a href="https://github.com/b3log/wide" target="_blank">GitHub</a></li>
<li><a href="https://www.gitbook.io/book/88250/wide-user-guide" target="_blank">{{.i18n.help}}</a></li>

View File

@ -4,6 +4,8 @@
<meta charset="UTF-8">
<title>{{.i18n.wide}}</title>
<link rel="stylesheet" href="{{.conf.StaticServer}}/static/css/shell.css?{{.conf.StaticResourceVersion}}">
<link rel="icon" type="image/x-icon" href="/favicon.ico" />
</head>
<body>
<input id="shellInput" placeholder="Command..."/>
@ -14,12 +16,11 @@
<script type="text/javascript">
var config = {
channel: {
shell: '{{.conf.ShellChannel}}'
},
wideSessionId: {{.session.Id}}
};
</script>
channel: {
shell: '{{.conf.ShellChannel}}'
},
wideSessionId: {{.session.Id}}
};</script>
<script type="text/javascript" src="{{.conf.StaticServer}}/static/js/lib/jquery-2.1.1.min.js"></script>
<script type="text/javascript" src="{{.conf.StaticServer}}/static/js/lib/reconnecting-websocket.js"></script>