mirror of
https://github.com/urbit/shrub.git
synced 2024-12-14 01:08:54 +03:00
fix hidden nodes being navigable, trailing slashes
This commit is contained in:
parent
b1ee492125
commit
fa84cec8d3
@ -33,7 +33,6 @@ Links = React.createFactory query {
|
||||
div {id:"sibs",style}, keys.map (key) =>
|
||||
href = window.tree.basepath @props.path+"/"+key
|
||||
data = @props.kids[key]
|
||||
return null if data.meta.hide
|
||||
head = data.meta.title if data.meta
|
||||
head ?= @toText data.head
|
||||
head ||= key
|
||||
@ -107,7 +106,7 @@ module.exports = query {
|
||||
e.preventDefault()
|
||||
e.stopPropagation()
|
||||
if href?[0] isnt "/"
|
||||
href = (document.location.pathname.replace /[^\/]*$/, '') + href
|
||||
href = (document.location.pathname.replace /\/?[^\/]*$/, '') + href
|
||||
_this.goTo window.tree.fragpath href
|
||||
if id
|
||||
window.location.hash = id
|
||||
|
@ -19,7 +19,9 @@ $ ->
|
||||
_path = prefix + path
|
||||
if _path.slice(-1) is "/" then _path = _path.slice(0,-1)
|
||||
_path
|
||||
window.tree.fragpath = (path) -> path.replace window.tree._basepath,""
|
||||
window.tree.fragpath = (path) ->
|
||||
path.replace(/\/$/,'')
|
||||
.replace(window.tree._basepath,"")
|
||||
|
||||
TreeActions = require './actions/TreeActions.coffee'
|
||||
TreePersistence = require './persistence/TreePersistence.coffee'
|
||||
@ -37,6 +39,7 @@ $ ->
|
||||
sorted = true
|
||||
keys = []
|
||||
for k,v of kids
|
||||
continue if v.meta?.hide
|
||||
if not v.meta?.sort? then sorted = false
|
||||
keys[Number(v.meta?.sort)] = k
|
||||
if sorted isnt true
|
||||
|
@ -93,9 +93,6 @@ Links = React.createFactory(query({
|
||||
var className, data, head, href;
|
||||
href = window.tree.basepath(_this.props.path + "/" + key);
|
||||
data = _this.props.kids[key];
|
||||
if (data.meta.hide) {
|
||||
return null;
|
||||
}
|
||||
if (data.meta) {
|
||||
head = data.meta.title;
|
||||
}
|
||||
@ -236,7 +233,7 @@ module.exports = query({
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
if ((href != null ? href[0] : void 0) !== "/") {
|
||||
href = (document.location.pathname.replace(/[^\/]*$/, '')) + href;
|
||||
href = (document.location.pathname.replace(/\/?[^\/]*$/, '')) + href;
|
||||
}
|
||||
_this.goTo(window.tree.fragpath(href));
|
||||
}
|
||||
@ -1290,7 +1287,7 @@ $(function() {
|
||||
return _path;
|
||||
};
|
||||
window.tree.fragpath = function(path) {
|
||||
return path.replace(window.tree._basepath, "");
|
||||
return path.replace(/\/$/, '').replace(window.tree._basepath, "");
|
||||
};
|
||||
TreeActions = require('./actions/TreeActions.coffee');
|
||||
TreePersistence = require('./persistence/TreePersistence.coffee');
|
||||
@ -1301,15 +1298,18 @@ $(function() {
|
||||
rend(body({}, ""), $('#cont')[0]);
|
||||
window.tree.util = {
|
||||
getKeys: function(kids) {
|
||||
var k, keys, ref, ref1, sorted, v;
|
||||
var k, keys, ref, ref1, ref2, sorted, v;
|
||||
sorted = true;
|
||||
keys = [];
|
||||
for (k in kids) {
|
||||
v = kids[k];
|
||||
if (((ref = v.meta) != null ? ref.sort : void 0) == null) {
|
||||
if ((ref = v.meta) != null ? ref.hide : void 0) {
|
||||
continue;
|
||||
}
|
||||
if (((ref1 = v.meta) != null ? ref1.sort : void 0) == null) {
|
||||
sorted = false;
|
||||
}
|
||||
keys[Number((ref1 = v.meta) != null ? ref1.sort : void 0)] = k;
|
||||
keys[Number((ref2 = v.meta) != null ? ref2.sort : void 0)] = k;
|
||||
}
|
||||
if (sorted !== true) {
|
||||
return keys = _.keys(kids).sort();
|
||||
|
Loading…
Reference in New Issue
Block a user