Utf8 js merge error fix, no peer found error fix, Large site confirmation dialog display fix
This commit is contained in:
parent
9c5176a8cb
commit
2d588a5006
5 changed files with 62 additions and 36 deletions
|
@ -34,7 +34,7 @@ def merge(merged_path):
|
||||||
if not changed: return # Assets not changed, nothing to do
|
if not changed: return # Assets not changed, nothing to do
|
||||||
|
|
||||||
if os.path.isfile(merged_path): # Find old parts to avoid unncessary recompile
|
if os.path.isfile(merged_path): # Find old parts to avoid unncessary recompile
|
||||||
merged_old = open(merged_path, "rb").read()
|
merged_old = open(merged_path, "rb").read().decode("utf8")
|
||||||
old_parts = {}
|
old_parts = {}
|
||||||
for match in re.findall("(/\* ---- (.*?) ---- \*/(.*?)(?=/\* ----|$))", merged_old, re.DOTALL):
|
for match in re.findall("(/\* ---- (.*?) ---- \*/(.*?)(?=/\* ----|$))", merged_old, re.DOTALL):
|
||||||
old_parts[match[1]] = match[2].strip("\n\r")
|
old_parts[match[1]] = match[2].strip("\n\r")
|
||||||
|
@ -52,7 +52,7 @@ def merge(merged_path):
|
||||||
command = config.coffeescript_compiler % os.path.join(*file_path.split("/")) # Fix os path separator
|
command = config.coffeescript_compiler % os.path.join(*file_path.split("/")) # Fix os path separator
|
||||||
s = time.time()
|
s = time.time()
|
||||||
compiler = subprocess.Popen(command, shell=True, stderr=subprocess.STDOUT, stdout=subprocess.PIPE)
|
compiler = subprocess.Popen(command, shell=True, stderr=subprocess.STDOUT, stdout=subprocess.PIPE)
|
||||||
out = compiler.stdout.read()
|
out = compiler.stdout.read().decode("utf8")
|
||||||
logging.debug("Running: %s (Done in %.2fs)" % (command, time.time()-s))
|
logging.debug("Running: %s (Done in %.2fs)" % (command, time.time()-s))
|
||||||
if out and out.startswith("("):
|
if out and out.startswith("("):
|
||||||
parts.append(out)
|
parts.append(out)
|
||||||
|
@ -63,14 +63,14 @@ def merge(merged_path):
|
||||||
else: # Not changed use the old_part
|
else: # Not changed use the old_part
|
||||||
parts.append(old_parts[file_path])
|
parts.append(old_parts[file_path])
|
||||||
else: # Add to parts
|
else: # Add to parts
|
||||||
parts.append(open(file_path).read())
|
parts.append(open(file_path).read().decode("utf8"))
|
||||||
|
|
||||||
merged = "\n".join(parts)
|
merged = u"\n".join(parts)
|
||||||
if ext == "css": # Vendor prefix css
|
if ext == "css": # Vendor prefix css
|
||||||
from lib.cssvendor import cssvendor
|
from lib.cssvendor import cssvendor
|
||||||
merged = cssvendor.prefix(merged)
|
merged = cssvendor.prefix(merged)
|
||||||
merged = merged.replace("\r", "")
|
merged = merged.replace("\r", "")
|
||||||
open(merged_path, "wb").write(merged)
|
open(merged_path, "wb").write(merged.encode("utf8"))
|
||||||
logging.debug("Merged %s (%.2fs)" % (merged_path, time.time()-s_total))
|
logging.debug("Merged %s (%.2fs)" % (merged_path, time.time()-s_total))
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -225,7 +225,7 @@ class Site:
|
||||||
|
|
||||||
event_done.get() # Wait for done
|
event_done.get() # Wait for done
|
||||||
if len(published) < min(len(self.peers), limit): time.sleep(0.2) # If less than we need sleep a bit
|
if len(published) < min(len(self.peers), limit): time.sleep(0.2) # If less than we need sleep a bit
|
||||||
if len(published) == 0: gevent.join(publishers) # No successful publish, wait for all publisher
|
if len(published) == 0: gevent.joinall(publishers) # No successful publish, wait for all publisher
|
||||||
|
|
||||||
self.log.info("Successfuly published to %s peers" % len(published))
|
self.log.info("Successfuly published to %s peers" % len(published))
|
||||||
return len(published)
|
return len(published)
|
||||||
|
|
|
@ -17,6 +17,17 @@ class Loading
|
||||||
@printLine " Connecting..."
|
@printLine " Connecting..."
|
||||||
|
|
||||||
|
|
||||||
|
showTooLarge: (site_info) ->
|
||||||
|
if $(".console .button-setlimit").length == 0 # Not displaying it yet
|
||||||
|
line = @printLine("Site size: <b>#{parseInt(site_info.settings.size/1024/1024)}MB</b> is larger than default allowed #{parseInt(site_info.size_limit)}MB", "warning")
|
||||||
|
button = $("<a href='#Set+limit' class='button button-setlimit'>Open site and set size limit to #{site_info.next_size_limit}MB</a>")
|
||||||
|
button.on "click", (=> return window.wrapper.setSizeLimit(site_info.next_size_limit) )
|
||||||
|
line.after(button)
|
||||||
|
setTimeout (=>
|
||||||
|
@printLine('Ready.')
|
||||||
|
), 100
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# We dont need loadingscreen anymore
|
# We dont need loadingscreen anymore
|
||||||
hideScreen: ->
|
hideScreen: ->
|
||||||
|
|
|
@ -227,6 +227,10 @@ class Wrapper
|
||||||
@address = site_info.address
|
@address = site_info.address
|
||||||
@setSiteInfo site_info
|
@setSiteInfo site_info
|
||||||
|
|
||||||
|
if site_info.settings.size > site_info.size_limit*1024*1024 # Site size too large and not displaying it yet
|
||||||
|
@loading.showTooLarge(site_info)
|
||||||
|
|
||||||
|
if site_info.content
|
||||||
window.document.title = site_info.content.title+" - ZeroNet"
|
window.document.title = site_info.content.title+" - ZeroNet"
|
||||||
@log "Setting title to", window.document.title
|
@log "Setting title to", window.document.title
|
||||||
|
|
||||||
|
@ -243,20 +247,16 @@ class Wrapper
|
||||||
if site_info.event[1] == window.inner_path # File downloaded we currently on
|
if site_info.event[1] == window.inner_path # File downloaded we currently on
|
||||||
@loading.hideScreen()
|
@loading.hideScreen()
|
||||||
if not @site_info then @reloadSiteInfo()
|
if not @site_info then @reloadSiteInfo()
|
||||||
|
if site_info.content
|
||||||
|
window.document.title = site_info.content.title+" - ZeroNet"
|
||||||
|
@log "Setting title to", window.document.title
|
||||||
if not $(".loadingscreen").length # Loading screen already removed (loaded +2sec)
|
if not $(".loadingscreen").length # Loading screen already removed (loaded +2sec)
|
||||||
@notifications.add("modified", "info", "New version of this page has just released.<br>Reload to see the modified content.")
|
@notifications.add("modified", "info", "New version of this page has just released.<br>Reload to see the modified content.")
|
||||||
# File failed downloading
|
# File failed downloading
|
||||||
else if site_info.event[0] == "file_failed"
|
else if site_info.event[0] == "file_failed"
|
||||||
@site_error = site_info.event[1]
|
@site_error = site_info.event[1]
|
||||||
if site_info.settings.size > site_info.size_limit*1024*1024 # Site size too large and not displaying it yet
|
if site_info.settings.size > site_info.size_limit*1024*1024 # Site size too large and not displaying it yet
|
||||||
if $(".console .button-setlimit").length == 0 # Not displaying it yet
|
@loading.showTooLarge(site_info)
|
||||||
line = @loading.printLine("Site size: <b>#{parseInt(site_info.settings.size/1024/1024)}MB</b> is larger than default allowed #{parseInt(site_info.size_limit)}MB", "warning")
|
|
||||||
button = $("<a href='#Set+limit' class='button button-setlimit'>Open site and set size limit to #{site_info.next_size_limit}MB</a>")
|
|
||||||
button.on "click", (=> return @setSizeLimit(site_info.next_size_limit) )
|
|
||||||
line.after(button)
|
|
||||||
setTimeout (=>
|
|
||||||
@loading.printLine('Ready.')
|
|
||||||
), 100
|
|
||||||
|
|
||||||
else
|
else
|
||||||
@loading.printLine("#{site_info.event[1]} download failed", "error")
|
@loading.printLine("#{site_info.event[1]} download failed", "error")
|
||||||
|
@ -302,8 +302,9 @@ class Wrapper
|
||||||
setSizeLimit: (size_limit, reload=true) =>
|
setSizeLimit: (size_limit, reload=true) =>
|
||||||
@ws.cmd "siteSetLimit", [size_limit], (res) =>
|
@ws.cmd "siteSetLimit", [size_limit], (res) =>
|
||||||
@loading.printLine res
|
@loading.printLine res
|
||||||
|
@inner_loaded = false # Inner frame not loaded, just a 404 page displayed
|
||||||
if reload
|
if reload
|
||||||
$("iframe").attr "src", $("iframe").attr("src") # Reload iframe
|
$("iframe").attr "src", $("iframe").attr("src")+"?"+(+new Date) # Reload iframe
|
||||||
return false
|
return false
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -486,6 +486,25 @@ jQuery.extend( jQuery.easing,
|
||||||
return this.printLine(" Connecting...");
|
return this.printLine(" Connecting...");
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading.prototype.showTooLarge = function(site_info) {
|
||||||
|
var button, line;
|
||||||
|
if ($(".console .button-setlimit").length === 0) {
|
||||||
|
line = this.printLine("Site size: <b>" + (parseInt(site_info.settings.size / 1024 / 1024)) + "MB</b> is larger than default allowed " + (parseInt(site_info.size_limit)) + "MB", "warning");
|
||||||
|
button = $("<a href='#Set+limit' class='button button-setlimit'>Open site and set size limit to " + site_info.next_size_limit + "MB</a>");
|
||||||
|
button.on("click", ((function(_this) {
|
||||||
|
return function() {
|
||||||
|
return window.wrapper.setSizeLimit(site_info.next_size_limit);
|
||||||
|
};
|
||||||
|
})(this)));
|
||||||
|
line.after(button);
|
||||||
|
return setTimeout(((function(_this) {
|
||||||
|
return function() {
|
||||||
|
return _this.printLine('Ready.');
|
||||||
|
};
|
||||||
|
})(this)), 100);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
Loading.prototype.hideScreen = function() {
|
Loading.prototype.hideScreen = function() {
|
||||||
if (!$(".loadingscreen").hasClass("done")) {
|
if (!$(".loadingscreen").hasClass("done")) {
|
||||||
if (this.screen_visible) {
|
if (this.screen_visible) {
|
||||||
|
@ -1042,14 +1061,18 @@ jQuery.extend( jQuery.easing,
|
||||||
return function(site_info) {
|
return function(site_info) {
|
||||||
_this.address = site_info.address;
|
_this.address = site_info.address;
|
||||||
_this.setSiteInfo(site_info);
|
_this.setSiteInfo(site_info);
|
||||||
|
if (site_info.settings.size > site_info.size_limit * 1024 * 1024) {
|
||||||
|
_this.loading.showTooLarge(site_info);
|
||||||
|
}
|
||||||
|
if (site_info.content) {
|
||||||
window.document.title = site_info.content.title + " - ZeroNet";
|
window.document.title = site_info.content.title + " - ZeroNet";
|
||||||
return _this.log("Setting title to", window.document.title);
|
return _this.log("Setting title to", window.document.title);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
})(this));
|
})(this));
|
||||||
};
|
};
|
||||||
|
|
||||||
Wrapper.prototype.setSiteInfo = function(site_info) {
|
Wrapper.prototype.setSiteInfo = function(site_info) {
|
||||||
var button, line;
|
|
||||||
if (site_info.event != null) {
|
if (site_info.event != null) {
|
||||||
if (site_info.event[0] === "file_added" && site_info.bad_files) {
|
if (site_info.event[0] === "file_added" && site_info.bad_files) {
|
||||||
this.loading.printLine(site_info.bad_files + " files needs to be downloaded");
|
this.loading.printLine(site_info.bad_files + " files needs to be downloaded");
|
||||||
|
@ -1060,6 +1083,10 @@ jQuery.extend( jQuery.easing,
|
||||||
if (!this.site_info) {
|
if (!this.site_info) {
|
||||||
this.reloadSiteInfo();
|
this.reloadSiteInfo();
|
||||||
}
|
}
|
||||||
|
if (site_info.content) {
|
||||||
|
window.document.title = site_info.content.title + " - ZeroNet";
|
||||||
|
this.log("Setting title to", window.document.title);
|
||||||
|
}
|
||||||
if (!$(".loadingscreen").length) {
|
if (!$(".loadingscreen").length) {
|
||||||
this.notifications.add("modified", "info", "New version of this page has just released.<br>Reload to see the modified content.");
|
this.notifications.add("modified", "info", "New version of this page has just released.<br>Reload to see the modified content.");
|
||||||
}
|
}
|
||||||
|
@ -1067,21 +1094,7 @@ jQuery.extend( jQuery.easing,
|
||||||
} else if (site_info.event[0] === "file_failed") {
|
} else if (site_info.event[0] === "file_failed") {
|
||||||
this.site_error = site_info.event[1];
|
this.site_error = site_info.event[1];
|
||||||
if (site_info.settings.size > site_info.size_limit * 1024 * 1024) {
|
if (site_info.settings.size > site_info.size_limit * 1024 * 1024) {
|
||||||
if ($(".console .button-setlimit").length === 0) {
|
this.loading.showTooLarge(site_info);
|
||||||
line = this.loading.printLine("Site size: <b>" + (parseInt(site_info.settings.size / 1024 / 1024)) + "MB</b> is larger than default allowed " + (parseInt(site_info.size_limit)) + "MB", "warning");
|
|
||||||
button = $("<a href='#Set+limit' class='button button-setlimit'>Open site and set size limit to " + site_info.next_size_limit + "MB</a>");
|
|
||||||
button.on("click", ((function(_this) {
|
|
||||||
return function() {
|
|
||||||
return _this.setSizeLimit(site_info.next_size_limit);
|
|
||||||
};
|
|
||||||
})(this)));
|
|
||||||
line.after(button);
|
|
||||||
setTimeout(((function(_this) {
|
|
||||||
return function() {
|
|
||||||
return _this.loading.printLine('Ready.');
|
|
||||||
};
|
|
||||||
})(this)), 100);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
this.loading.printLine(site_info.event[1] + " download failed", "error");
|
this.loading.printLine(site_info.event[1] + " download failed", "error");
|
||||||
}
|
}
|
||||||
|
@ -1142,8 +1155,9 @@ jQuery.extend( jQuery.easing,
|
||||||
this.ws.cmd("siteSetLimit", [size_limit], (function(_this) {
|
this.ws.cmd("siteSetLimit", [size_limit], (function(_this) {
|
||||||
return function(res) {
|
return function(res) {
|
||||||
_this.loading.printLine(res);
|
_this.loading.printLine(res);
|
||||||
|
_this.inner_loaded = false;
|
||||||
if (reload) {
|
if (reload) {
|
||||||
return $("iframe").attr("src", $("iframe").attr("src"));
|
return $("iframe").attr("src", $("iframe").attr("src") + "?" + (+(new Date)));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
})(this));
|
})(this));
|
||||||
|
|
Loading…
Reference in a new issue