From 92f2a28ba30395f646cfb88b043ae565015dcb3d Mon Sep 17 00:00:00 2001 From: Humerus Date: Sat, 20 Dec 2014 22:29:57 -0500 Subject: [PATCH 1/5] Added initial code for plugins --- resources/PluginIndex.html | 96 +++++++++++++++++++++++++++- src/PocketDockConsole/RunCommand.php | 29 ++++++++- 2 files changed, 122 insertions(+), 3 deletions(-) diff --git a/resources/PluginIndex.html b/resources/PluginIndex.html index 3aa12c3..af0d855 100644 --- a/resources/PluginIndex.html +++ b/resources/PluginIndex.html @@ -11,6 +11,8 @@ + + + + @@ -138,6 +140,14 @@ width: 100%; height: auto; } + + ul.ui-autocomplete { + z-index: 1100; + } + + #plugin-description { + font-size: 0.9em + } @@ -174,8 +184,44 @@ "sScrollXInner": "100%", "bScrollCollapse": true, "bPaginate": false, - "bFilter": false }); + + $('input[aria-controls="pluginsTable"]').autocomplete({ + minLength: 0, + source: function(request, response) { + $.ajax({ + url: "http://sleepy-wave-2826.herokuapp.com/autocomplete?q=" + request.term, + type: "GET", + dataType: "JSON", + success: function(data) { + var plugins = data['plugin-suggest'][0]['options']; + response($.map(plugins, function(item) { + //console.log(item) + return { + label: item.payload.title, + id: item.payload.resource_id, + desc: item.payload.tag_line, + author: item.payload.username + } + })); + }, + }); + }, + focus: function(event, ui) { + $('input[aria-controls="pluginsTable"]').val(ui.item.label); + return false; + }, + select: function(event, ui) { + $('input[aria-controls="pluginsTable"]').val(ui.item.label); + $('#pluginsTable').dataTable().api().search(ui.item.label).draw() + return false; + } + }) + .autocomplete("instance")._renderItem = function(ul, item) { + return $("
  • ") + .append("" + item.label + "
    " + item.desc + " by " + item.author + "
    ") + .appendTo(ul); + }; }, 2000); } From 5c0401c3c25e281b87350747f889bd99c3e58348 Mon Sep 17 00:00:00 2001 From: Humerus Date: Sun, 21 Dec 2014 17:37:14 -0500 Subject: [PATCH 4/5] Fix some other issues --- resources/PluginIndex.html | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/resources/PluginIndex.html b/resources/PluginIndex.html index bc783b8..9cdcce2 100644 --- a/resources/PluginIndex.html +++ b/resources/PluginIndex.html @@ -159,24 +159,22 @@ } function getPlugins() { - $(document).ready(function() { - $.ajax({ - type: "GET", - url: "http://www.corsproxy.com/forums.pocketmine.net/api.php", - contentType: "application/json; charset=utf-8", - dataType: "json", - data: "", - success: function(res, text, xhr) { - res.resources.forEach(function(res) { - addRow(res); - }); - } - }); + $.ajax({ + type: "GET", + url: "http://sleepy-wave-2826.herokuapp.com/plugins", + contentType: "application/json; charset=utf-8", + dataType: "json", + data: "", + success: function(res, text, xhr) { + res.resources.forEach(function(res) { + addRow(res); + }); + renderpluginTable(); + } }); } function renderpluginTable() { - getPlugins(); setTimeout(function() { var oTable = $('#pluginsTable').dataTable({ "sScrollY": "350px", @@ -452,7 +450,7 @@ } $(function() { - renderpluginTable(); + getPlugins(); doStuff(); editor = ace.edit("editor"); editor.setTheme("ace/theme/monokai"); From 971319c089d1db3f867a494cff35b84d7bef91e6 Mon Sep 17 00:00:00 2001 From: Humerus Date: Sun, 21 Dec 2014 17:56:47 -0500 Subject: [PATCH 5/5] Changed plugin install path --- src/PocketDockConsole/RunCommand.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/PocketDockConsole/RunCommand.php b/src/PocketDockConsole/RunCommand.php index 0abf0dd..963878d 100644 --- a/src/PocketDockConsole/RunCommand.php +++ b/src/PocketDockConsole/RunCommand.php @@ -182,14 +182,14 @@ public function updatePlugins($plugins) { //$this->getOwner()->getLogger()->info($pl . " is already installed"); } else { $plugininfo = $this->getUrl($pl); - file_put_contents("plugins/".$pl.".phar", file_get_contents($plugininfo['link'])); + file_put_contents(\pocketmine\PLUGIN_PATH.$pl.".phar", file_get_contents($plugininfo['link'])); $this->getOwner()->getLogger()->info($pl . " is now installed. Please restart or reload the server."); } } foreach($this->getOwner()->getServer()->getPluginManager()->getPlugins() as $plugin) { if(!in_array($plugin->getName(), $plugins)) { - if(file_exists("plugins/".$plugin->getName().".phar")) { - unlink("plugins/".$plugin->getName().".phar"); + if(file_exists(\pocketmine\PLUGIN_PATH.$plugin->getName().".phar")) { + unlink(\pocketmine\PLUGIN_PATH.$plugin->getName().".phar"); $this->getOwner()->getLogger()->info($plugin->getName() . " was removed. Please restart or reload the server."); } else { $this->getOwner()->getLogger()->info("Unable to remove ".$plugin->getName(). " automatically. Please remove it manually and reload the server.");