Sort plugins by download count

Allow loading models from custom URLs
This commit is contained in:
JannisX11 2021-08-27 15:48:32 +02:00
parent c613bb32c4
commit 06d0dab517
3 changed files with 36 additions and 1 deletions

View File

@ -633,6 +633,13 @@ function addStartScreenSection(id, data) {
//Update Screen
if (Blockbench.hasFlag('after_update') && data.new_version) {
addStartScreenSection(data.new_version)
jQuery.ajax({
url: 'https://blckbn.ch/api/event/successful_update',
type: 'POST',
data: {
version: Blockbench.version
}
})
}
if (data.psa) {
(function() {

View File

@ -521,6 +521,12 @@ BARS.defineActions(function() {
}).fail(error => {
Blockbench.showQuickMessage('message.invalid_link')
})
} else {
$.getJSON(link, (model) => {
Codecs.project.load(model, {path: ''});
}).fail(error => {
Blockbench.showQuickMessage('message.invalid_link')
})
}
}, 'https://blckbn.ch/1234')
}

View File

@ -3,6 +3,7 @@ const Plugins = {
Vue: [], //Vue Object
installed: [], //Simple List of Names
json: undefined, //Json from website
download_stats: {},
all: [], //Vue Object Data
registered: {},
devReload() {
@ -18,7 +19,12 @@ const Plugins = {
},
sort() {
Plugins.all.sort(function(a,b) {
return sort_collator.compare(a.title, b.title)
let download_difference = (Plugins.download_stats[b.id] || 0) - (Plugins.download_stats[a.id] || 0);
if (download_difference) {
return download_difference
} else {
return sort_collator.compare(a.title, b.title);
}
});
}
}
@ -120,6 +126,15 @@ class Plugin {
await scope.install(first);
resolve()
}, 20)
if (first) {
jQuery.ajax({
url: 'https://blckbn.ch/api/event/install_plugin',
type: 'POST',
data: {
plugin: scope.id
}
})
}
})
});
});
@ -383,6 +398,13 @@ Plugins.loading_promise = new Promise((resolve, reject) => {
})
})
$.getJSON('https://blckbn.ch/api/stats/plugins?weeks=2', data => {
Plugins.download_stats = data;
if (Plugins.json) {
Plugins.sort();
}
})
async function loadInstalledPlugins() {
if (!Plugins.loading_promise.resolved) {
await Plugins.loading_promise;