Rev966, Display user quota in sidebar, Fix non-root content.json publishing in sidebar, Publish to same ammount of passive peers as limit, Fix site address case bug
This commit is contained in:
parent
e891a10e54
commit
48db062b49
8 changed files with 25 additions and 8 deletions
|
@ -4,6 +4,7 @@ import cgi
|
||||||
import sys
|
import sys
|
||||||
import math
|
import math
|
||||||
import time
|
import time
|
||||||
|
import json
|
||||||
try:
|
try:
|
||||||
import cStringIO as StringIO
|
import cStringIO as StringIO
|
||||||
except:
|
except:
|
||||||
|
@ -290,9 +291,18 @@ class UiWebsocketPlugin(object):
|
||||||
|
|
||||||
def sidebarRenderIdentity(self, body, site):
|
def sidebarRenderIdentity(self, body, site):
|
||||||
auth_address = self.user.getAuthAddress(self.site.address)
|
auth_address = self.user.getAuthAddress(self.site.address)
|
||||||
|
rules = self.site.content_manager.getRules("data/users/%s/content.json" % auth_address)
|
||||||
|
if rules and rules.get("max_size"):
|
||||||
|
quota = rules["max_size"] / 1024
|
||||||
|
content = site.content_manager.contents["data/users/%s/content.json" % auth_address]
|
||||||
|
used = len(json.dumps(content)) + sum([file["size"] for file in content["files"].values()])
|
||||||
|
used = used / 1024
|
||||||
|
else:
|
||||||
|
quota = used = 0
|
||||||
|
|
||||||
body.append("""
|
body.append("""
|
||||||
<li>
|
<li>
|
||||||
<label>Identity address</label>
|
<label>Identity address <small>(used: {used:.2f}kB / {quota:.2f}kB)</small></label>
|
||||||
<span class='input text disabled'>{auth_address}</span>
|
<span class='input text disabled'>{auth_address}</span>
|
||||||
<a href='#Change' class='button' id='button-identity'>Change</a>
|
<a href='#Change' class='button' id='button-identity'>Change</a>
|
||||||
</li>
|
</li>
|
||||||
|
|
|
@ -315,7 +315,7 @@ class Sidebar extends Class
|
||||||
|
|
||||||
# Publish content.json
|
# Publish content.json
|
||||||
@tag.find("#button-publish").off("click").on "click", =>
|
@tag.find("#button-publish").off("click").on "click", =>
|
||||||
inner_path = @tag.find("#select-contents").val()
|
inner_path = @tag.find("#input-contents").val()
|
||||||
@tag.find("#button-publish").addClass "loading"
|
@tag.find("#button-publish").addClass "loading"
|
||||||
wrapper.ws.cmd "sitePublish", {"inner_path": inner_path, "sign": false}, =>
|
wrapper.ws.cmd "sitePublish", {"inner_path": inner_path, "sign": false}, =>
|
||||||
@tag.find("#button-publish").removeClass "loading"
|
@tag.find("#button-publish").removeClass "loading"
|
||||||
|
@ -360,6 +360,7 @@ class Sidebar extends Class
|
||||||
@globe.createPoints()
|
@globe.createPoints()
|
||||||
@globe.animate()
|
@globe.animate()
|
||||||
catch e
|
catch e
|
||||||
|
console.log "WebGL error", e
|
||||||
@tag.find(".globe").addClass("error").text("WebGL not supported")
|
@tag.find(".globe").addClass("error").text("WebGL not supported")
|
||||||
|
|
||||||
@tag.find(".globe").removeClass("loading")
|
@tag.find(".globe").removeClass("loading")
|
||||||
|
|
|
@ -551,7 +551,7 @@ window.initScrollable = function () {
|
||||||
this.tag.find("#button-publish").off("click").on("click", (function(_this) {
|
this.tag.find("#button-publish").off("click").on("click", (function(_this) {
|
||||||
return function() {
|
return function() {
|
||||||
var inner_path;
|
var inner_path;
|
||||||
inner_path = _this.tag.find("#select-contents").val();
|
inner_path = _this.tag.find("#input-contents").val();
|
||||||
_this.tag.find("#button-publish").addClass("loading");
|
_this.tag.find("#button-publish").addClass("loading");
|
||||||
return wrapper.ws.cmd("sitePublish", {
|
return wrapper.ws.cmd("sitePublish", {
|
||||||
"inner_path": inner_path,
|
"inner_path": inner_path,
|
||||||
|
@ -620,6 +620,7 @@ window.initScrollable = function () {
|
||||||
_this.globe.animate();
|
_this.globe.animate();
|
||||||
} catch (_error) {
|
} catch (_error) {
|
||||||
e = _error;
|
e = _error;
|
||||||
|
console.log("WebGL error", e);
|
||||||
_this.tag.find(".globe").addClass("error").text("WebGL not supported");
|
_this.tag.find(".globe").addClass("error").text("WebGL not supported");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@ class Config(object):
|
||||||
|
|
||||||
def __init__(self, argv):
|
def __init__(self, argv):
|
||||||
self.version = "0.3.6"
|
self.version = "0.3.6"
|
||||||
self.rev = 957
|
self.rev = 966
|
||||||
self.argv = argv
|
self.argv = argv
|
||||||
self.action = None
|
self.action = None
|
||||||
self.config_file = "zeronet.conf"
|
self.config_file = "zeronet.conf"
|
||||||
|
|
|
@ -404,8 +404,8 @@ class Site(object):
|
||||||
inner_path, len(published), len(passive_peers)
|
inner_path, len(published), len(passive_peers)
|
||||||
))
|
))
|
||||||
|
|
||||||
for peer in passive_peers[0:3]:
|
for peer in passive_peers[0:limit]:
|
||||||
gevent.spawn(self.publisher, inner_path, passive_peers, published, limit=limit+3)
|
gevent.spawn(self.publisher, inner_path, passive_peers, published, limit=limit*2)
|
||||||
|
|
||||||
# Send my hashfield to every connected peer if changed
|
# Send my hashfield to every connected peer if changed
|
||||||
gevent.spawn(self.sendMyHashfield, 100)
|
gevent.spawn(self.sendMyHashfield, 100)
|
||||||
|
|
|
@ -54,6 +54,11 @@ class SiteManager(object):
|
||||||
from Site import Site
|
from Site import Site
|
||||||
site = self.get(address)
|
site = self.get(address)
|
||||||
if not site: # Site not exist yet
|
if not site: # Site not exist yet
|
||||||
|
# Try to find site with differect case
|
||||||
|
for recover_address, recover_site in self.sites.items():
|
||||||
|
if recover_address.lower() == address.lower():
|
||||||
|
return recover_site
|
||||||
|
|
||||||
if not self.isAddress(address):
|
if not self.isAddress(address):
|
||||||
return False # Not address: %s % address
|
return False # Not address: %s % address
|
||||||
logging.debug("Added new site: %s" % address)
|
logging.debug("Added new site: %s" % address)
|
||||||
|
|
Loading…
Reference in a new issue