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
bbcd0902
Commit
bbcd0902
authored
Dec 04, 2017
by
yann300
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
make compiler import reurn type and clean path
parent
783488a1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
11 deletions
+11
-11
app.js
src/app.js
+2
-2
compiler-imports.js
src/app/compiler/compiler-imports.js
+9
-9
No files found.
src/app.js
View file @
bbcd0902
...
...
@@ -200,10 +200,10 @@ function run () {
if
(
provider
&&
provider
.
exists
(
url
))
{
return
provider
.
get
(
url
,
cb
)
}
handleImports
.
import
(
url
,
(
error
,
content
)
=>
{
handleImports
.
import
(
url
,
(
error
,
content
,
cleanUrl
,
type
)
=>
{
if
(
!
error
)
{
// FIXME: at some point we should invalidate the browser cache
filesProviders
[
'browser'
].
addReadOnly
(
u
rl
,
content
)
filesProviders
[
type
].
addReadOnly
(
cleanU
rl
,
content
)
cb
(
null
,
content
)
}
else
{
cb
(
error
)
...
...
src/app/compiler/compiler-imports.js
View file @
bbcd0902
...
...
@@ -8,7 +8,7 @@ module.exports = {
return
$
.
getJSON
(
'https://api.github.com/repos/'
+
root
+
'/contents/'
+
path
)
.
done
(
function
(
data
)
{
if
(
'content'
in
data
)
{
cb
(
null
,
base64
.
decode
(
data
.
content
))
cb
(
null
,
base64
.
decode
(
data
.
content
)
,
root
+
'/'
+
path
)
}
else
{
cb
(
'Content not received'
)
}
...
...
@@ -21,7 +21,7 @@ module.exports = {
handleSwarmImport
:
function
(
url
,
cb
)
{
swarmgw
.
get
(
url
,
function
(
err
,
content
)
{
cb
(
err
,
content
)
cb
(
err
,
content
,
url
)
})
},
...
...
@@ -31,7 +31,7 @@ module.exports = {
return
$
.
ajax
({
type
:
'GET'
,
url
:
'https://gateway.ipfs.io/'
+
url
})
.
done
(
function
(
data
)
{
cb
(
null
,
data
)
cb
(
null
,
data
,
url
)
})
.
fail
(
function
(
xhr
,
text
,
err
)
{
// NOTE: on some browsers, err equals to '' for certain errors (such as offline browser)
...
...
@@ -41,9 +41,9 @@ module.exports = {
import
:
function
(
url
,
cb
)
{
var
handlers
=
[
{
match
:
/^
(
https
?
:
\/\/)?(
www.
)?
github.com
\/([^/]
*
\/[^/]
*
)\/(
.*
)
/
,
handler
:
(
match
,
cb
)
=>
{
this
.
handleGithubCall
(
match
[
3
],
match
[
4
],
cb
)
}
},
{
match
:
/^
(
bzz
[
ri
]?
:
\/\/?
.*
)
$/
,
handler
:
(
match
,
cb
)
=>
{
this
.
handleSwarmImport
(
match
[
1
],
cb
)
}
},
{
match
:
/^
(
ipfs:
\/\/?
.+
)
/
,
handler
:
(
match
,
cb
)
=>
{
this
.
handleIPFS
(
match
[
1
],
cb
)
}
}
{
type
:
'github'
,
match
:
/^
(
https
?
:
\/\/)?(
www.
)?
github.com
\/([^/]
*
\/[^/]
*
)\/(
.*
)
/
,
handler
:
(
match
,
cb
)
=>
{
this
.
handleGithubCall
(
match
[
3
],
match
[
4
],
cb
)
}
},
{
type
:
'swarm'
,
match
:
/^
(
bzz
[
ri
]?
:
\/\/?
.*
)
$/
,
handler
:
(
match
,
cb
)
=>
{
this
.
handleSwarmImport
(
match
[
1
],
cb
)
}
},
{
type
:
'ipfs'
,
match
:
/^
(
ipfs:
\/\/?
.+
)
/
,
handler
:
(
match
,
cb
)
=>
{
this
.
handleIPFS
(
match
[
1
],
cb
)
}
}
]
var
found
=
false
...
...
@@ -57,13 +57,13 @@ module.exports = {
found
=
true
$
(
'#output'
).
append
(
$
(
'<div/>'
).
append
(
$
(
'<pre/>'
).
text
(
'Loading '
+
url
+
' ...'
)))
handler
.
handler
(
match
,
function
(
err
,
content
)
{
handler
.
handler
(
match
,
function
(
err
,
content
,
cleanUrl
)
{
if
(
err
)
{
cb
(
'Unable to import "'
+
u
rl
+
'": '
+
err
)
cb
(
'Unable to import "'
+
cleanU
rl
+
'": '
+
err
)
return
}
cb
(
null
,
content
)
cb
(
null
,
content
,
cleanUrl
,
handler
.
type
)
})
}
})
...
...
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