Skip to content

Commit

Permalink
Merge pull request #9 from solobat/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
tomasy committed Sep 29, 2017
2 parents 19b5e09 + 4e148df commit 4275b95
Show file tree
Hide file tree
Showing 30 changed files with 188 additions and 45 deletions.
Binary file removed .DS_Store
Binary file not shown.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.DS_Store
.DS_Store?
node_modules
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@
<h1 align="center">Steward</h1>
<p align="center">Chrome里的Alfred,命令式管理扩展/应用/书签/历史记录/标签...</p>
<p align="center">
<a href="https://github.com/solobat/Steward/releases"><img src="https://img.shields.io/badge/lastest_version-2.5.3-blue.svg"></a>
<a href="https://github.com/solobat/Steward/releases"><img src="https://img.shields.io/badge/lastest_version-2.5.5-blue.svg"></a>
<a target="_blank" href="https://chrome.google.com/webstore/detail/dnkhdiodfglfckibnfcjbgddcgjgkacd"><img src="https://img.shields.io/badge/download-_chrome_webstore-brightgreen.svg"></a>
<a href="http://owsjc7iz3.bkt.clouddn.com/Steward-2.5.3.crx"><img src="https://img.shields.io/badge/download-_crx-brightgreen.svg"></a>
<a href="http://owsjc7iz3.bkt.clouddn.com/Steward-2.5.5.crx"><img src="https://img.shields.io/badge/download-_crx-brightgreen.svg"></a>
</p>

***

#### 安装:
- [Chrome 应用商店](https://chrome.google.com/webstore/detail/dnkhdiodfglfckibnfcjbgddcgjgkacd)
- [离线下载](http://owsjc7iz3.bkt.clouddn.com/Steward-2.5.3.crx)
- [离线下载](http://owsjc7iz3.bkt.clouddn.com/Steward-2.5.5.crx)

---
#### 功能:
Expand Down Expand Up @@ -44,11 +44,11 @@
[![license-badge]][license-link]

<!-- Link -->
[version-badge]: https://img.shields.io/badge/lastest_version-2.5.3-blue.svg
[version-badge]: https://img.shields.io/badge/lastest_version-2.5.5-blue.svg
[version-link]: https://github.com/solobat/Steward
[chrome-badge]: https://img.shields.io/badge/download-_chrome_webstore-brightgreen.svg
[chrome-link]: https://chrome.google.com/webstore/detail/dnkhdiodfglfckibnfcjbgddcgjgkacd
[offline-badge]: https://img.shields.io/badge/download-_crx-brightgreen.svg
[offline-link]: http://owsjc7iz3.bkt.clouddn.com/Steward-2.5.3.crx
[offline-link]: http://owsjc7iz3.bkt.clouddn.com/Steward-2.5.5.crx
[license-badge]: https://img.shields.io/github/license/mashape/apistatus.svg
[license-link]: https://opensource.org/licenses/MIT
28 changes: 26 additions & 2 deletions _locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@
"history_subtitle": {
"message": "find history and open it"
},
"jenkins_title": {
"message": "Find and open"
},
"jenkins_subtitle": {
"message": "Find and open jenkins jobs"
},
"jenkins_jk_title": {
"message": "Find and open"
},
Expand Down Expand Up @@ -71,6 +77,12 @@
"jenkins_jkset_subtitle": {
"message": "Set jenkins url"
},
"note_title": {
"message": "Add notes"
},
"note_subtitle": {
"message": "The label starts with '#', the label text only supports both English and Chinese characters, and the other characters are automatically marked as the end of the label"
},
"note_note_title": {
"message": "Add notes"
},
Expand Down Expand Up @@ -126,10 +138,22 @@
"message": "add todo item, delete one by click it..."
},
"urlblock_title": {
"message": "block url"
"message": "Block URL"
},
"urlblock_subtitle": {
"message": "block url"
"message": "Block the specified URL"
},
"urlblock_bk_title": {
"message": "Block URL"
},
"urlblock_bk_subtitle": {
"message": "Block the specified URL"
},
"urlblock_bk8_title": {
"message": "Block URL for 8 hours"
},
"urlblock_bk8_subtitle": {
"message": "Block the specified URL for 8 hours"
},
"youdao_title": {
"message": "youdao translator"
Expand Down
24 changes: 24 additions & 0 deletions _locales/zh_CN/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@
"history_subtitle": {
"message": "查找历史记录并打开"
},
"jenkins_title": {
"message": "查找并打开"
},
"jenkins_subtitle": {
"message": "查找并打开jenkins jobs"
},
"jenkins_jk_title": {
"message": "查找并打开"
},
Expand Down Expand Up @@ -71,6 +77,12 @@
"jenkins_jkset_subtitle": {
"message": "设置jenkins url"
},
"note_title": {
"message": "添加笔记"
},
"note_subtitle": {
"message": "标签以'#'开始, 标签文本只支持英文及中文字符, 其它字符自动作为标签结尾标志"
},
"note_note_title": {
"message": "添加笔记"
},
Expand Down Expand Up @@ -131,6 +143,18 @@
"urlblock_subtitle": {
"message": "屏蔽指定网址"
},
"urlblock_bk_title": {
"message": "屏蔽网址"
},
"urlblock_bk_subtitle": {
"message": "屏蔽指定网址"
},
"urlblock_bk8_title": {
"message": "屏蔽网址8小时"
},
"urlblock_bk8_subtitle": {
"message": "屏蔽指定网址8小时"
},
"youdao_title": {
"message": "有道翻译"
},
Expand Down
2 changes: 2 additions & 0 deletions css/options.css
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,9 @@ a {
}

.changelog {
padding: 5px 12px;
height: 400px;
border: 1px solid #ededed;
overflow: scroll;
}

Expand Down
1 change: 1 addition & 0 deletions js/common/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ define(function (require, exports, module) {

return {
key: item.key,
orkey: item.key,
title: chrome.i18n.getMessage(name + '_' + (keyname || key) + '_title'),
subtitle: chrome.i18n.getMessage(name + '_' + (keyname || key) + '_subtitle'),
icon,
Expand Down
12 changes: 8 additions & 4 deletions js/main/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ define(function (require, exports, module) {
this.lastcmd = this.cmd;
}

return commands[this.cmd].plugin.onInput.call(this, key);
return commands[this.cmd].plugin.onInput.call(this, key, commands[this.cmd]);
},

createItem: function (index, item) {
Expand Down Expand Up @@ -140,7 +140,7 @@ define(function (require, exports, module) {

let plugin = commands[this.cmd].plugin;

plugin.onEnter.call(this, $(elem).data('id'), elem);
plugin.onEnter.call(this, $(elem).data('id'), elem, commands[this.cmd]);
_gaq.push(['_trackEvent', 'exec', 'enter', plugin.name]);
});

Expand Down Expand Up @@ -185,10 +185,14 @@ define(function (require, exports, module) {

plugins.forEach((plugin) => {
if (plugin.commands instanceof Array) {
let pname = plugin.name;
let pcmds;

try {
pcmds = pluginsData[plugin.name].commands;
pcmds = pluginsData[pname].commands;
if (plugin.version > (pluginsData[pname].version || 1)) {
pcmds = $.extend(true, plugin.commands, pcmds);
}
} catch (e) {
pcmds = plugin.commands;
}
Expand All @@ -197,7 +201,7 @@ define(function (require, exports, module) {
if (pcmds) {
pcmds.forEach((command) => commands[command.key] = {
...command,
name: plugin.name,
name: pname,
plugin
});
}
Expand Down
45 changes: 36 additions & 9 deletions js/options/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,26 @@ define(function(require, exports, module) {
var pluginList = require('/js/plugins/plugins').plugins;

let plugins = pluginList.map(plugin => {
let {name, icon, commands, title} = plugin;
let {name, icon, commands, title, version} = plugin;

return {
name,
version,
commands,
title,
icon
}
});
let config;

/*
pluginsData: {
[pname]: {
version,
commands
}
}
*/
chrome.storage.sync.get('config', function(res) {
if (res.config) {
config = res.config;
Expand All @@ -28,23 +37,41 @@ define(function(require, exports, module) {

// 总是确保数据是最新的
plugins.forEach(plugin => {
if (!pluginsData[plugin.name]) {
pluginsData[plugin.name] = {
commands: plugin.commands
};
}
mergePluginData(plugin, pluginsData);
});

render(pluginsData);
});

function mergePluginData(plugin, pluginsData) {
let pname = plugin.name;
let cachePlugin = pluginsData[pname];
let version = plugin.version;

if (!cachePlugin) {
pluginsData[pname] = {
version,
commands: plugin.commands
};
} else {
if (!cachePlugin.version) {
cachePlugin.version = 1;
}

if (version > cachePlugin.version) {
// rough merge
cachePlugin.commands = $.extend(true, plugin.commands, cachePlugin.commands);
cachePlugin.version = version;
}
}
}

function render(pluginsData) {
console.log(pluginsData);
new Vue({
el: '#app',
data: function() {
return {
version: '2.5.4',
version: '2.5.5',
activeName: 'plugins',
pluginSearchText: '',
currentPlugin: null,
Expand Down Expand Up @@ -81,7 +108,7 @@ define(function(require, exports, module) {
}, function() {
self.$message('保存成功!');
});
_gaq.push(['_trackEvent', 'options_plugins', 'save']);
_gaq.push(['_trackEvent', 'options_plugins', 'save', this.currentPlugin.name]);
}
}
});
Expand Down
2 changes: 2 additions & 0 deletions js/plugins/bookmark.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

define(function (require, exports, module) {
var chrome = window.chrome;
var version = 1;
var name = 'bookmark';
var key = 'bm';
var icon = chrome.extension.getURL('img/bookmark.png');
Expand Down Expand Up @@ -69,6 +70,7 @@ define(function (require, exports, module) {
}

module.exports = {
version,
name: 'Bookmarks',
icon,
title,
Expand Down
2 changes: 2 additions & 0 deletions js/plugins/calculate.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

define(function (require, exports, module) {
var name = 'calculate';
var version = 1;
var key = 'calc';
var icon = chrome.extension.getURL('img/calc.png');
var title = chrome.i18n.getMessage(name + '_title');
Expand Down Expand Up @@ -42,6 +43,7 @@ define(function (require, exports, module) {
}

module.exports = {
version,
name: 'Calculator',
icon,
title,
Expand Down
2 changes: 2 additions & 0 deletions js/plugins/del.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
define(function (require, exports, module) {
var util = require('../common/util');

var version = 1;
var name = 'deleteExtension';
var key = 'del';
var icon = chrome.extension.getURL('img/del.png');
Expand Down Expand Up @@ -106,6 +107,7 @@ define(function (require, exports, module) {
}

module.exports = {
version,
name: 'Delete Extension',
icon,
title,
Expand Down
2 changes: 2 additions & 0 deletions js/plugins/download.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

define(function (require, exports, module) {
var chrome = window.chrome;
var version = 1;
var name = 'download';
var key = 'dl';
var icon = chrome.extension.getURL('img/download.png');
Expand Down Expand Up @@ -70,6 +71,7 @@ define(function (require, exports, module) {
}

module.exports = {
version,
name: 'Downloads',
icon,
title,
Expand Down
2 changes: 2 additions & 0 deletions js/plugins/help.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

define(function (require, exports, module) {
var _ = require('../lib/underscore')
var version = 1;
var name = 'help'
var key = 'help'
var icon = chrome.extension.getURL('img/help.ico');
Expand Down Expand Up @@ -46,6 +47,7 @@ define(function (require, exports, module) {
}

module.exports = {
version,
name: 'Help',
icon,
title,
Expand Down
2 changes: 2 additions & 0 deletions js/plugins/his.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/

define(function (require, exports, module) {
var version = 1;
var name = 'history';
var key = 'his';
var icon = chrome.extension.getURL('img/history.png');
Expand Down Expand Up @@ -59,6 +60,7 @@ define(function (require, exports, module) {
}

module.exports = {
version,
name: 'History',
icon,
title,
Expand Down
2 changes: 2 additions & 0 deletions js/plugins/jenkins.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
define(function (require, exports, module) {
var util = require('../common/util')

var version = 1;
var name = 'jenkins'
//'jk', 'jkb', 'jkc', 'jkw', 'jkset'
var keys = [
Expand Down Expand Up @@ -165,6 +166,7 @@ define(function (require, exports, module) {
}

module.exports = {
version,
name: 'Jenkins',
icon,
title,
Expand Down
Loading

0 comments on commit 4275b95

Please sign in to comment.