updated server scripts
This commit is contained in:
parent
002f6aa7fb
commit
23414b6d8b
|
@ -1,32 +1,35 @@
|
|||
function plugin_load(config, div, entry) {
|
||||
function plugin_start(div, entry, editable) {
|
||||
if(typeof plugin_init !== 'undefined') plugin_init(div, entry, editable);
|
||||
if(typeof plugin_render !== 'undefined') plugin_render(div, entry);
|
||||
}
|
||||
|
||||
function plugin_load(config, div, entry, editable) {
|
||||
$("#load-pre-status").text("Loading...");
|
||||
var status_span = $('#load-status');
|
||||
|
||||
var len1 = config.javascript && config.javascript.length || 0;
|
||||
var len2 = config.globals && config.javascript.length || 0;
|
||||
var num_progress = len1 + len2;
|
||||
var len_deps = config.dependencies && config.dependencies.length || 0;
|
||||
var len_globals = config.globals && Object.keys(config.globals).length || 0;
|
||||
|
||||
var progress = 0;
|
||||
var num_progress = len_deps + len_globals;
|
||||
|
||||
status_span.after(" / " + num_progress);
|
||||
status_span.text("0");
|
||||
|
||||
var progress = 0;
|
||||
var check = function() {
|
||||
if (++progress == num_progress) {
|
||||
status_span.text(progress + 1 + "");
|
||||
if (++progress >= num_progress) { // has to be >= for num_progress = 0
|
||||
status_span.parent().empty();
|
||||
if(typeof plugin_init !== 'undefined') plugin_init(div, entry);
|
||||
if(typeof plugin_render !== 'undefined') plugin_render(div, entry);
|
||||
$.ajax({dataType: "script", cache: true, url: config.javascript, success: function() { plugin_start(div, entry, editable); }});
|
||||
}
|
||||
}
|
||||
|
||||
config.javascript.forEach(function(script) {
|
||||
config.dependencies.forEach(function(script) {
|
||||
$.ajax({
|
||||
dataType: "script",
|
||||
cache: true,
|
||||
url: script,
|
||||
success: function () {
|
||||
status_span.text(progress + 1 + "");
|
||||
check();
|
||||
}
|
||||
success: check
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -45,4 +48,9 @@ function plugin_load(config, div, entry) {
|
|||
link.media = 'all';
|
||||
$('head').append(link);
|
||||
});
|
||||
|
||||
// always adding a style element for to use for convenience
|
||||
$('head').append($('<style id="dynamic_styler"></style>'));
|
||||
|
||||
if(num_progress == 0) check();
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ $LOCATION$ -> location of plugin
|
|||
every plugin is its own folder and if folder is
|
||||
"myplugin" and this website's url is "http://example.com",
|
||||
then $LOCATION$ gets the value of http://example.com/myplugin
|
||||
requirements: flask, redis
|
||||
"""
|
||||
|
||||
import sys
|
||||
|
@ -18,14 +19,11 @@ import random
|
|||
|
||||
import redis
|
||||
from flask import Flask, Response, request
|
||||
from flask_cors import CORS
|
||||
|
||||
|
||||
app = Flask(__name__)
|
||||
CORS(app, resources={r"/*": {"origins": "*"}})
|
||||
redis = redis.Redis(host='localhost', port=6379, db=0)
|
||||
|
||||
URL = "http://plugins.lexonomy.cjvt.si"
|
||||
URL = "https://plugins.lexonomy.cjvt.si"
|
||||
REPLACE_STRING = "$LOCATION$"
|
||||
|
||||
|
||||
|
@ -50,7 +48,7 @@ def generate_etag(N=12):
|
|||
|
||||
|
||||
def return_file(path, plugin=None):
|
||||
full_path = path if plugin is None else "plugins/{}/{}".format(plugin, path)
|
||||
full_path = path if plugin is None else"{}/{}".format(plugin, path)
|
||||
|
||||
if not os.path.isfile(full_path):
|
||||
return "File not found", 404
|
||||
|
@ -102,6 +100,7 @@ def return_file(path, plugin=None):
|
|||
elif request.headers['If-None-Match'] != etag:
|
||||
status_code = 200
|
||||
|
||||
status_code = 200
|
||||
return Response(result, mimetype=mt, headers=headers, status=status_code)
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user