Skip to content

Commit 190b13e

Browse files
committed
Site clone menu item, Display update message on listModifications, Minor UI tweak
1 parent eb2edd3 commit 190b13e

File tree

6 files changed

+59
-12
lines changed

6 files changed

+59
-12
lines changed

css/ZeroHello.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ ul, li { margin: 0px; padding: 0px; list-style-type: none }
153153
.menu-item { display: block; text-decoration: none; color: black; padding: 6px 24px; transition: all 0.2s }
154154
.menu-item-separator { margin-top: 5px; border-top: 1px solid #eee }
155155

156-
.menu-item:hover { background-color: #EEE }
156+
.menu-item:hover { background-color: #F6F6F6; transition: none }
157157
.menu-item:active, .menu-item:focus { background-color: #AF3BFF; color: white; transition: none }
158158

159159

css/all.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
<div class="user">Current user: <a class='identicon' href='#Show+Private+key' title='Show private key'></a><a href="#Logout" class="button button-logout">Logout</a></div>
1717
<div class="version current">Version: <a href="https://github.com/HelloZeroNet/ZeroNet" target="_top">Unknown</a></div>
18-
<div class="version latest new" title="New update available">Latest: <a href="https://github.com/HelloZeroNet/ZeroNet" target="_top">0.2.9</a></div>
18+
<div class="version latest new" title="New update available">Latest: <a href="https://github.com/HelloZeroNet/ZeroNet" target="_top">0.3.0</a></div>
1919
<br><a href="#Update" class="button button-update button-submit">Update to new version</a>
2020
<br><span class='broken-autoupdate'>Err, we broke the autoupdate for this version.<br> Please overwrite your current <b>update.py</b> file<br> with the <a href="https://raw.githubusercontent.com/HelloZeroNet/ZeroNet/master/update.py" target="_top">latest one from github</a>, run it and restart ZeroNet.<br>Sorry for the troubles!</span>
2121
</div>

js/SiteMenu.coffee

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,12 @@ class SiteMenu extends Menu
4848
@addItem "Pause", (-> window.zero_hello.sitePause site.address )
4949
else
5050
@addItem "Resume", (-> window.zero_hello.siteResume site.address )
51+
if site.content?.cloneable
52+
if zero_hello.server_info.rev < 200
53+
@addItem "Clone", (-> window.zero_hello.cmd "wrapperNotification", ["info", "Please update to version 0.3.1 to use the site clone feature!"] )
54+
else
55+
@addItem "Clone", (-> window.zero_hello.siteClone site.address )
56+
5157
@addItem("Delete", (-> window.zero_hello.siteDelete site.address ) ).addClass("menu-item-separator")
5258

5359

js/ZeroHello.coffee

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ class ZeroHello extends ZeroFrame
1010

1111
$(".button-update").on "click", =>
1212
$(".button-update").addClass("loading")
13+
$(".broken-autoupdate").css("display", "block").html "Please run update.py manually<br>if ZeroNet doesn't comes back within 1 minute."
1314
@cmd "serverUpdate", {}
1415

1516

@@ -120,17 +121,19 @@ class ZeroHello extends ZeroFrame
120121

121122

122123
# Show/hide loading
123-
if site.tasks > 0 # Site tasks running
124+
if site.tasks > 0 or site.event?[0] == "updating" # Site tasks running
124125
$(".anim-updating", elem).addClass("visible")
125126
else
126127
$(".anim-updating", elem).removeClass("visible")
127128

128129
# Show success
129-
if site.event?[0] == "file_done" or site.event?[0] == "file_started"
130+
if site.event?[0] in ["file_done", "file_started", "updating", "updated"]
130131
if site.bad_files > 0
131132
success = "Updating: #{site.bad_files} left"
132-
else if site.event[0] == "file_done" and site.bad_files == 0
133+
else if site.event[0] in ["file_done", "updated"] and site.bad_files == 0
133134
success = "Site updated"
135+
else
136+
success = "Site updating..."
134137
if success
135138
$(".notify", elem).text(success).addClass("success").addClassLater("visible")
136139

@@ -201,6 +204,7 @@ class ZeroHello extends ZeroFrame
201204
{"content": {"title": "ZeroBoard", "description": "Messaging board demo", "domain": "Board.ZeroNetwork.bit"}, "address": "1Gfey7wVXXg1rxk751TBTxLJwhddDNfcdp", "settings": {"serving": false}}
202205
{"content": {"title": "ZeroBlog", "description": "Blogging platform Demo", "domain": "Blog.ZeroNetwork.bit"}, "address": "1BLogC9LN4oPDcruNz3qo1ysa133E9AGg8", "settings": {"serving": false}}
203206
{"content": {"title": "ZeroTalk", "description": "Decentralized forum demo", "domain": "Talk.ZeroNetwork.bit"}, "address": "1TaLk3zM7ZRskJvrh3ZNCDVGXvkJusPKQ", "settings": {"serving": false}}
207+
{"content": {"title": "ZeroID", "description": "Sample trusted authorization provider", "domain": "ZeroID.bit"}, "address": "1iD5ZQJMNXu43w1qLB8sfdHVKppVMduGz", "settings": {"serving": false}}
204208
{"content": {"title": "ZeroMarket", "description": "Simple market demo (coming soon)"}, "address": "ZeroMarket", "disabled": true, "settings": {"serving": false}}
205209
]
206210

@@ -279,6 +283,11 @@ class ZeroHello extends ZeroFrame
279283
@cmd "siteResume", {"address": address}
280284

281285

286+
# Create new site from this
287+
siteClone: (address) ->
288+
@cmd "siteClone", {"address": address}
289+
290+
282291
# Delete site
283292
siteDelete: (address) ->
284293
site = @sites[address]

js/all.js

Lines changed: 38 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -841,6 +841,7 @@ jQuery.extend( jQuery.easing,
841841
__extends(SiteMenu, _super);
842842

843843
function SiteMenu(elem, site) {
844+
var _ref;
844845
SiteMenu.__super__.constructor.call(this, $(".hamburger", elem));
845846
this.elem.addClass("menu-site");
846847
this.addItem("Update", (function() {
@@ -855,6 +856,17 @@ jQuery.extend( jQuery.easing,
855856
return window.zero_hello.siteResume(site.address);
856857
}));
857858
}
859+
if ((_ref = site.content) != null ? _ref.cloneable : void 0) {
860+
if (zero_hello.server_info.rev < 200) {
861+
this.addItem("Clone", (function() {
862+
return window.zero_hello.cmd("wrapperNotification", ["info", "Please update to version 0.3.1 to use the site clone feature!"]);
863+
}));
864+
} else {
865+
this.addItem("Clone", (function() {
866+
return window.zero_hello.siteClone(site.address);
867+
}));
868+
}
869+
}
858870
this.addItem("Delete", (function() {
859871
return window.zero_hello.siteDelete(site.address);
860872
})).addClass("menu-item-separator");
@@ -879,6 +891,7 @@ jQuery.extend( jQuery.easing,
879891
}).call(this);
880892

881893

894+
882895
/* ---- data/1EU1tbG9oC1A8jz2ouVwGZyQ5asrNsE4Vr/js/ZeroHello.coffee ---- */
883896

884897

@@ -913,6 +926,7 @@ jQuery.extend( jQuery.easing,
913926
return $(".button-update").on("click", (function(_this) {
914927
return function() {
915928
$(".button-update").addClass("loading");
929+
$(".broken-autoupdate").css("display", "block").html("Please run update.py manually<br>if ZeroNet doesn't comes back within 1 minute.");
916930
return _this.cmd("serverUpdate", {});
917931
};
918932
})(this));
@@ -991,7 +1005,7 @@ jQuery.extend( jQuery.easing,
9911005
};
9921006

9931007
ZeroHello.prototype.applySitedata = function(elem, site) {
994-
var error, href, modified, success, _ref, _ref1, _ref2, _ref3;
1008+
var error, href, modified, success, _ref, _ref1, _ref2, _ref3, _ref4, _ref5;
9951009
if (typeof site.bad_files === "object") {
9961010
site.bad_files = site.bad_files.length;
9971011
}
@@ -1034,16 +1048,18 @@ jQuery.extend( jQuery.easing,
10341048
$(elem).addClass("site-paused");
10351049
$(".status", elem).text("Paused");
10361050
}
1037-
if (site.tasks > 0) {
1051+
if (site.tasks > 0 || ((_ref1 = site.event) != null ? _ref1[0] : void 0) === "updating") {
10381052
$(".anim-updating", elem).addClass("visible");
10391053
} else {
10401054
$(".anim-updating", elem).removeClass("visible");
10411055
}
1042-
if (((_ref1 = site.event) != null ? _ref1[0] : void 0) === "file_done" || ((_ref2 = site.event) != null ? _ref2[0] : void 0) === "file_started") {
1056+
if ((_ref2 = (_ref3 = site.event) != null ? _ref3[0] : void 0) === "file_done" || _ref2 === "file_started" || _ref2 === "updating" || _ref2 === "updated") {
10431057
if (site.bad_files > 0) {
10441058
success = "Updating: " + site.bad_files + " left";
1045-
} else if (site.event[0] === "file_done" && site.bad_files === 0) {
1059+
} else if (((_ref4 = site.event[0]) === "file_done" || _ref4 === "updated") && site.bad_files === 0) {
10461060
success = "Site updated";
1061+
} else {
1062+
success = "Site updating...";
10471063
}
10481064
}
10491065
if (success) {
@@ -1055,7 +1071,7 @@ jQuery.extend( jQuery.easing,
10551071
} else {
10561072
error = "Update failed";
10571073
}
1058-
} else if (site.tasks === 0 && site.bad_files > 0 && ((_ref3 = site.event) != null ? _ref3[0] : void 0) !== "file_done") {
1074+
} else if (site.tasks === 0 && site.bad_files > 0 && ((_ref5 = site.event) != null ? _ref5[0] : void 0) !== "file_done") {
10591075
error = site.bad_files + " file update failed";
10601076
}
10611077
if (error) {
@@ -1136,6 +1152,16 @@ jQuery.extend( jQuery.easing,
11361152
"settings": {
11371153
"serving": false
11381154
}
1155+
}, {
1156+
"content": {
1157+
"title": "ZeroID",
1158+
"description": "Sample trusted authorization provider",
1159+
"domain": "ZeroID.bit"
1160+
},
1161+
"address": "1iD5ZQJMNXu43w1qLB8sfdHVKppVMduGz",
1162+
"settings": {
1163+
"serving": false
1164+
}
11391165
}, {
11401166
"content": {
11411167
"title": "ZeroMarket",
@@ -1233,6 +1259,12 @@ jQuery.extend( jQuery.easing,
12331259
});
12341260
};
12351261

1262+
ZeroHello.prototype.siteClone = function(address) {
1263+
return this.cmd("siteClone", {
1264+
"address": address
1265+
});
1266+
};
1267+
12361268
ZeroHello.prototype.siteDelete = function(address) {
12371269
var site, title;
12381270
site = this.sites[address];
@@ -1263,4 +1295,4 @@ jQuery.extend( jQuery.easing,
12631295

12641296
window.zero_hello = new ZeroHello();
12651297

1266-
}).call(this);
1298+
}).call(this);

0 commit comments

Comments
 (0)