Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
renderjs
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
renderjs
Commits
0b8d2257
Commit
0b8d2257
authored
Jun 04, 2013
by
Romain Courteaud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Display the list of keys in localstorage
parent
1c69f917
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
6 deletions
+33
-6
gadget/filebrowser.js
gadget/filebrowser.js
+13
-2
renderjs.js
renderjs.js
+20
-4
No files found.
gadget/filebrowser.js
View file @
0b8d2257
...
@@ -6,13 +6,24 @@
...
@@ -6,13 +6,24 @@
$
.
ajax
({
$
.
ajax
({
method
:
'
GET
'
,
method
:
'
GET
'
,
// XXX Hardcoded
// XXX Hardcoded
url
:
"
browser://browse
r
/ls/
"
,
url
:
"
browser://browse/ls/
"
,
context
:
$
(
'
body
'
),
context
:
$
(
'
body
'
),
error
:
function
(
jqXHR
,
textStatus
,
errorThrown
)
{
error
:
function
(
jqXHR
,
textStatus
,
errorThrown
)
{
$
(
this
).
text
(
errorThrown
);
$
(
this
).
text
(
errorThrown
);
},
},
success
:
function
(
value
,
textStatus
,
jqXHR
)
{
success
:
function
(
value
,
textStatus
,
jqXHR
)
{
$
(
this
).
text
(
value
);
var
content_type
=
jqXHR
.
getResponseHeader
(
"
Content-Type
"
)
||
""
;
// XXX Hardcoded mime type
if
(
content_type
.
split
(
'
;
'
)[
0
]
===
"
application/hal+json
"
)
{
// XXX Will fail if response does not send expected links...
$
(
this
).
html
(
"
<ul>
"
);
for
(
var
i
in
value
.
_links
.
contents
){
$
(
this
).
append
(
"
<li>
"
+
value
.
_links
.
contents
[
i
].
href
+
"
</li>
"
);
}
$
(
this
).
append
(
"
</ul>
"
);
}
else
{
$
(
this
).
text
(
"
Unsupported content type
"
+
content_type
);
};
},
},
});
});
});
});
...
...
renderjs.js
View file @
0b8d2257
...
@@ -1053,7 +1053,8 @@
...
@@ -1053,7 +1053,8 @@
dispatch
=
function
()
{
dispatch
=
function
()
{
// XXX Local hack
// XXX Local hack
var
ls_regexp
=
/browser:
\/\/
localstorage
\/([\w\W]
+
)
/
,
var
ls_regexp
=
/browser:
\/\/
localstorage
\/([\w\W]
+
)
/
,
browse_regexp
=
/browser:
\/\/
browse
\/
ls
\/([\w\W]
+
)
/
,
browse_file_regexp
=
/browser:
\/\/
browse
\/
ls
\/([\w\W]
+
)
/
,
browse_directory_regexp
=
/browser:
\/\/
browse
\/
ls
\/
/
,
key
;
key
;
if
(
ls_regexp
.
test
(
this
.
url
))
{
if
(
ls_regexp
.
test
(
this
.
url
))
{
key
=
ls_regexp
.
exec
(
this
.
url
)[
1
];
key
=
ls_regexp
.
exec
(
this
.
url
)[
1
];
...
@@ -1070,16 +1071,31 @@
...
@@ -1070,16 +1071,31 @@
}
else
{
}
else
{
this
.
respond
(
405
,
{},
""
);
this
.
respond
(
405
,
{},
""
);
}
}
}
else
if
(
browse_regexp
.
test
(
this
.
url
))
{
}
else
if
(
browse_
file_
regexp
.
test
(
this
.
url
))
{
key
=
browse_regexp
.
exec
(
this
.
url
)[
1
];
key
=
browse_
file_
regexp
.
exec
(
this
.
url
)[
1
];
this
.
respond
(
200
,
{
this
.
respond
(
200
,
{
'
Content-Type
'
:
'
application/hal+json
'
'
Content-Type
'
:
'
application/hal+json
'
},
JSON
.
stringify
({
},
JSON
.
stringify
({
_links
:
{
_links
:
{
self
:
{
href
:
'
browser://browse/ls/
'
+
key
},
self
:
{
href
:
this
.
url
},
enclosure
:
{
href
:
'
browser://localstorage/
'
+
key
},
enclosure
:
{
href
:
'
browser://localstorage/
'
+
key
},
}
}
}));
}));
}
else
if
(
browse_directory_regexp
.
test
(
this
.
url
))
{
var
response
=
{
_links
:
{
self
:
{
href
:
this
.
url
},
contents
:
[],
}
};
for
(
var
key
in
localStorage
){
response
.
_links
.
contents
.
push
({
href
:
'
browser://browse/ls/
'
+
key
});
}
this
.
respond
(
200
,
{
'
Content-Type
'
:
'
application/hal+json
'
},
JSON
.
stringify
(
response
));
}
else
{
}
else
{
this
.
respond
(
404
,
{},
""
);
this
.
respond
(
404
,
{},
""
);
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment