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:
HelloZeroNet 2016-03-09 15:30:04 +01:00
parent e891a10e54
commit 48db062b49
8 changed files with 25 additions and 8 deletions

View file

@ -4,6 +4,7 @@ import cgi
import sys
import math
import time
import json
try:
import cStringIO as StringIO
except:
@ -290,9 +291,18 @@ class UiWebsocketPlugin(object):
def sidebarRenderIdentity(self, body, site):
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("""
<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>
<a href='#Change' class='button' id='button-identity'>Change</a>
</li>

View file

@ -315,7 +315,7 @@ class Sidebar extends Class
# Publish content.json
@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"
wrapper.ws.cmd "sitePublish", {"inner_path": inner_path, "sign": false}, =>
@tag.find("#button-publish").removeClass "loading"
@ -360,6 +360,7 @@ class Sidebar extends Class
@globe.createPoints()
@globe.animate()
catch e
console.log "WebGL error", e
@tag.find(".globe").addClass("error").text("WebGL not supported")
@tag.find(".globe").removeClass("loading")

View file

@ -551,7 +551,7 @@ window.initScrollable = function () {
this.tag.find("#button-publish").off("click").on("click", (function(_this) {
return function() {
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");
return wrapper.ws.cmd("sitePublish", {
"inner_path": inner_path,
@ -620,6 +620,7 @@ window.initScrollable = function () {
_this.globe.animate();
} catch (_error) {
e = _error;
console.log("WebGL error", e);
_this.tag.find(".globe").addClass("error").text("WebGL not supported");
}
}

View file

@ -8,7 +8,7 @@ class Config(object):
def __init__(self, argv):
self.version = "0.3.6"
self.rev = 957
self.rev = 966
self.argv = argv
self.action = None
self.config_file = "zeronet.conf"

View file

@ -404,8 +404,8 @@ class Site(object):
inner_path, len(published), len(passive_peers)
))
for peer in passive_peers[0:3]:
gevent.spawn(self.publisher, inner_path, passive_peers, published, limit=limit+3)
for peer in passive_peers[0:limit]:
gevent.spawn(self.publisher, inner_path, passive_peers, published, limit=limit*2)
# Send my hashfield to every connected peer if changed
gevent.spawn(self.sendMyHashfield, 100)

View file

@ -54,6 +54,11 @@ class SiteManager(object):
from Site import Site
site = self.get(address)
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):
return False # Not address: %s % address
logging.debug("Added new site: %s" % address)