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 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>
|
||||
|
|
|
@ -1343,4 +1343,4 @@ THREE.MorphBlendMesh.prototype.setAnimationDirectionForward=function(a){if(a=thi
|
|||
THREE.MorphBlendMesh.prototype.setAnimationDuration=function(a,b){var c=this.animationsMap[a];c&&(c.duration=b,c.fps=(c.end-c.start)/c.duration)};THREE.MorphBlendMesh.prototype.setAnimationWeight=function(a,b){var c=this.animationsMap[a];c&&(c.weight=b)};THREE.MorphBlendMesh.prototype.setAnimationTime=function(a,b){var c=this.animationsMap[a];c&&(c.time=b)};THREE.MorphBlendMesh.prototype.getAnimationTime=function(a){var b=0;if(a=this.animationsMap[a])b=a.time;return b};
|
||||
THREE.MorphBlendMesh.prototype.getAnimationDuration=function(a){var b=-1;if(a=this.animationsMap[a])b=a.duration;return b};THREE.MorphBlendMesh.prototype.playAnimation=function(a){var b=this.animationsMap[a];b?(b.time=0,b.active=!0):console.warn("animation["+a+"] undefined")};THREE.MorphBlendMesh.prototype.stopAnimation=function(a){if(a=this.animationsMap[a])a.active=!1};
|
||||
THREE.MorphBlendMesh.prototype.update=function(a){for(var b=0,c=this.animationsList.length;b<c;b++){var d=this.animationsList[b];if(d.active){var e=d.duration/d.length;d.time+=d.direction*a;if(d.mirroredLoop){if(d.time>d.duration||0>d.time)d.direction*=-1,d.time>d.duration&&(d.time=d.duration,d.directionBackwards=!0),0>d.time&&(d.time=0,d.directionBackwards=!1)}else d.time%=d.duration,0>d.time&&(d.time+=d.duration);var f=d.startFrame+THREE.Math.clamp(Math.floor(d.time/e),0,d.length-1),g=d.weight;
|
||||
f!==d.currentFrame&&(this.morphTargetInfluences[d.lastFrame]=0,this.morphTargetInfluences[d.currentFrame]=1*g,this.morphTargetInfluences[f]=0,d.lastFrame=d.currentFrame,d.currentFrame=f);e=d.time%e/e;d.directionBackwards&&(e=1-e);this.morphTargetInfluences[d.currentFrame]=e*g;this.morphTargetInfluences[d.lastFrame]=(1-e)*g}}};
|
||||
f!==d.currentFrame&&(this.morphTargetInfluences[d.lastFrame]=0,this.morphTargetInfluences[d.currentFrame]=1*g,this.morphTargetInfluences[f]=0,d.lastFrame=d.currentFrame,d.currentFrame=f);e=d.time%e/e;d.directionBackwards&&(e=1-e);this.morphTargetInfluences[d.currentFrame]=e*g;this.morphTargetInfluences[d.lastFrame]=(1-e)*g}}};
|
|
@ -432,4 +432,4 @@ DAT.Globe = function(container, opts) {
|
|||
|
||||
return this;
|
||||
|
||||
};
|
||||
};
|
||||
|
|
|
@ -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")
|
||||
|
|
|
@ -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");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue