Rev908, Sidebar shorten long bad filenames, Only show opener error if site is using the API

This commit is contained in:
HelloZeroNet 2016-02-23 01:36:47 +01:00
parent b2fb1fcd3c
commit 58fa5f6e16
6 changed files with 47 additions and 48 deletions

View file

@ -149,7 +149,7 @@ class UiWebsocketPlugin(object):
else:
percent = 100 * (float(size) / size_total)
percent = math.floor(percent*100)/100 # Floor to 2 digits
body.append(u"<li style='width: %.2f%%' class='%s back-%s' title='%s'></li>" % (percent, extension, color, extension))
body.append(u"""<li style='width: %.2f%%' class='%s back-%s' title="%s"></li>""" % (percent, extension, color, extension))
# Legend
body.append("</ul><ul class='graph-legend'>")
@ -202,7 +202,7 @@ class UiWebsocketPlugin(object):
body.append("""
<li>
<label>Size limit <small>(limit used: {percent_used:.0%}, free space: {free_space:,d}MB)</small></label>
<input type='text' class='text text-num' value='{size_limit}' id='input-sitelimit'/><span class='text-post'>MB</span>
<input type='text' class='text text-num' value="{size_limit}" id='input-sitelimit'/><span class='text-post'>MB</span>
<a href='#Set' class='button' id='button-sitelimit'>Set</a>
</li>
""".format(**locals()))
@ -262,7 +262,7 @@ class UiWebsocketPlugin(object):
""")
for bad_file in site.bad_files.keys():
body.append("<li class='color-red'>%s</li>" % cgi.escape(bad_file, True))
body.append("""<li class='color-red' title="%s">%s</li>""" % (cgi.escape(bad_file, True), cgi.escape(bad_file, True)))
body.append("""
</ul>
@ -278,7 +278,7 @@ class UiWebsocketPlugin(object):
body.append(u"""
<li>
<label>Database <small>({size:.2f}kB)</small></label>
<input type='text' class='text disabled' value='{inner_path}' disabled='disabled'/>
<input type='text' class='text disabled' value="{inner_path}" disabled='disabled'/>
<a href='#Reindex' class='button' style='display: none'>Reindex</a>
</li>
""".format(**locals()))

View file

@ -67,6 +67,7 @@
.filelist { font-size: 12px; font-family: monospace; margin: 0px; padding: 0px; list-style-type: none; line-height: 1.5em; }
.filelist li:before { content: '\2022'; font-size: 11px; line-height: 0px; vertical-align: 0px; margin-right: 5px; color: #FFBE00; }
.filelist li { overflow: hidden; text-overflow: ellipsis; }
/* COLORS */

View file

@ -121,6 +121,7 @@
.filelist { font-size: 12px; font-family: monospace; margin: 0px; padding: 0px; list-style-type: none; line-height: 1.5em; }
.filelist li:before { content: '\2022'; font-size: 11px; line-height: 0px; vertical-align: 0px; margin-right: 5px; color: #FFBE00; }
.filelist li { overflow: hidden; text-overflow: ellipsis; }
/* COLORS */

View file

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

View file

@ -23,6 +23,7 @@ class Wrapper
@wrapperWsInited = false # Wrapper notified on websocket open
@site_error = null # Latest failed file download
@address = null
@opener = null
window.onload = @onLoad # On iframe loaded
$(window).on "hashchange", => # On hash change
@ -64,9 +65,16 @@ class Wrapper
else
@sendInner message # Pass message to inner frame
# Incoming message from inner frame
onMessageInner: (e) =>
if not window.postmessage_nonce_security and @opener == null # Test opener
if window.opener
@log "Opener present", window.opener
@displayOpenerDialog()
return false
else
@opener = false
message = e.data
if window.postmessage_nonce_security and message.wrapper_nonce != window.wrapper_nonce
@log "Message nonce error:", message.wrapper_nonce, '!=', window.wrapper_nonce
@ -118,6 +126,14 @@ class Wrapper
return back
displayOpenerDialog: ->
elem = $("<div class='opener-overlay'><div class='dialog'>You have opened this page by clicking on a link. Please, confirm if you want to load this site.<a href='?' target='_blank' class='button'>Open site</a></div></div>")
elem.find('a').on "click", ->
window.open("?", "_blank")
window.close()
return false
$("body").prepend(elem)
# - Actions -
actionNotification: (message) ->
@ -383,25 +399,4 @@ else
ws_url = proto.ws + ":" + origin.replace(proto.http+":", "") + "/Websocket?wrapper_key=" + window.wrapper_key
if window.opener and window.postmessage_nonce_security == false
# Window opener security problem workaround: Open a new window, close this one
console.log "Opener present:", window.opener
setTimeout ( -> # Wait 200ms to parent tab closing
console.log "Opener still present:", window.opener
if window.opener
# Opener still present, display message
elem = $("<div class='opener-overlay'><div class='dialog'>You have opened this page by clicking on a link. Please, confirm if you want to load this site.<a href='?' target='_blank' class='button'>Open site</a></div></div>")
elem.find('a').on "click", ->
window.open("?", "_blank")
window.close()
return false
$("body").prepend(elem)
else
window.location.reload()
# Opener gone, continue init
# window.wrapper = new Wrapper(ws_url)
# window.wrapper.reload()
), 200
else
window.wrapper = new Wrapper(ws_url)
window.wrapper = new Wrapper(ws_url)

View file

@ -781,6 +781,7 @@ jQuery.extend( jQuery.easing,
this.wrapperWsInited = false;
this.site_error = null;
this.address = null;
this.opener = null;
window.onload = this.onLoad;
$(window).on("hashchange", (function(_this) {
return function() {
@ -835,6 +836,15 @@ jQuery.extend( jQuery.easing,
Wrapper.prototype.onMessageInner = function(e) {
var cmd, message, query;
if (!window.postmessage_nonce_security && this.opener === null) {
if (window.opener) {
this.log("Opener present", window.opener);
this.displayOpenerDialog();
return false;
} else {
this.opener = false;
}
}
message = e.data;
if (window.postmessage_nonce_security && message.wrapper_nonce !== window.wrapper_nonce) {
this.log("Message nonce error:", message.wrapper_nonce, '!=', window.wrapper_nonce);
@ -899,6 +909,17 @@ jQuery.extend( jQuery.easing,
return back;
};
Wrapper.prototype.displayOpenerDialog = function() {
var elem;
elem = $("<div class='opener-overlay'><div class='dialog'>You have opened this page by clicking on a link. Please, confirm if you want to load this site.<a href='?' target='_blank' class='button'>Open site</a></div></div>");
elem.find('a').on("click", function() {
window.open("?", "_blank");
window.close();
return false;
});
return $("body").prepend(elem);
};
Wrapper.prototype.actionNotification = function(message) {
var body;
message.params = this.toHtmlSafe(message.params);
@ -1266,25 +1287,6 @@ jQuery.extend( jQuery.easing,
ws_url = proto.ws + ":" + origin.replace(proto.http + ":", "") + "/Websocket?wrapper_key=" + window.wrapper_key;
if (window.opener && window.postmessage_nonce_security === false) {
console.log("Opener present:", window.opener);
setTimeout((function() {
var elem;
console.log("Opener still present:", window.opener);
if (window.opener) {
elem = $("<div class='opener-overlay'><div class='dialog'>You have opened this page by clicking on a link. Please, confirm if you want to load this site.<a href='?' target='_blank' class='button'>Open site</a></div></div>");
elem.find('a').on("click", function() {
window.open("?", "_blank");
window.close();
return false;
});
return $("body").prepend(elem);
} else {
return window.location.reload();
}
}), 200);
} else {
window.wrapper = new Wrapper(ws_url);
}
window.wrapper = new Wrapper(ws_url);
}).call(this);