Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
baas-ide
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
guxukai
baas-ide
Commits
7359d273
Commit
7359d273
authored
Jan 06, 2017
by
Alex Beregszaszi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Support downloading Swarm objects via RPC
parent
ca2301de
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
3 deletions
+14
-3
app.js
src/app.js
+14
-3
No files found.
src/app.js
View file @
7359d273
...
@@ -516,12 +516,23 @@ var run = function () {
...
@@ -516,12 +516,23 @@ var run = function () {
})
})
}
}
function
handleSwarmImport
(
url
,
cb
)
{
swarmgw
.
get
(
url
,
function
(
err
,
content
)
{
// retry if this failed and we're connected via RPC
if
(
err
&&
!
executionContext
.
isVM
())
{
var
web3
=
executionContext
.
web3
()
web3
.
swarm
.
download
(
url
,
cb
)
}
else
{
cb
(
err
,
content
)
}
})
}
function
handleImportCall
(
url
,
cb
)
{
function
handleImportCall
(
url
,
cb
)
{
var
match
var
match
if
(
files
.
exists
(
url
))
{
if
(
files
.
exists
(
url
))
{
cb
(
null
,
files
.
get
(
url
))
cb
(
null
,
files
.
get
(
url
))
}
else
if
((
githubM
atch
=
/^
(
https
?
:
\/\/)?(
www.
)?
github.com
\/([^/]
*
\/[^/]
*
)\/(
.*
)
/
.
exec
(
url
)))
{
}
else
if
((
m
atch
=
/^
(
https
?
:
\/\/)?(
www.
)?
github.com
\/([^/]
*
\/[^/]
*
)\/(
.*
)
/
.
exec
(
url
)))
{
handleGithubCall
(
githubMatch
[
3
],
githubM
atch
[
4
],
function
(
err
,
content
)
{
handleGithubCall
(
match
[
3
],
m
atch
[
4
],
function
(
err
,
content
)
{
if
(
err
)
{
if
(
err
)
{
cb
(
'Unable to import "'
+
url
+
'": '
+
err
)
cb
(
'Unable to import "'
+
url
+
'": '
+
err
)
return
return
...
@@ -533,7 +544,7 @@ var run = function () {
...
@@ -533,7 +544,7 @@ var run = function () {
})
})
}
else
if
((
match
=
/^
(
bzzr
?
:
\/\/?
.*
)
$/
.
exec
(
url
)))
{
}
else
if
((
match
=
/^
(
bzzr
?
:
\/\/?
.*
)
$/
.
exec
(
url
)))
{
$
(
'#output'
).
append
(
$
(
'<div/>'
).
append
(
$
(
'<pre/>'
).
text
(
'Loading '
+
url
+
' ...'
)))
$
(
'#output'
).
append
(
$
(
'<div/>'
).
append
(
$
(
'<pre/>'
).
text
(
'Loading '
+
url
+
' ...'
)))
swarmgw
.
ge
t
(
match
[
1
],
function
(
err
,
content
)
{
handleSwarmImpor
t
(
match
[
1
],
function
(
err
,
content
)
{
if
(
err
)
{
if
(
err
)
{
cb
(
'Unable to import "'
+
url
+
'": '
+
err
)
cb
(
'Unable to import "'
+
url
+
'": '
+
err
)
return
return
...
...
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