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
d8bdc059
Commit
d8bdc059
authored
Dec 04, 2017
by
yann300
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add BasicReadOnlyProvider (swarm, github, gist, ipfs)
parent
b7b09951
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
107 additions
and
0 deletions
+107
-0
app.js
src/app.js
+5
-0
basicReadOnlyExplorer.js
src/app/files/basicReadOnlyExplorer.js
+102
-0
No files found.
src/app.js
View file @
d8bdc059
...
@@ -36,6 +36,7 @@ var handleImports = require('./app/compiler/compiler-imports')
...
@@ -36,6 +36,7 @@ var handleImports = require('./app/compiler/compiler-imports')
var
FileManager
=
require
(
'./app/files/fileManager'
)
var
FileManager
=
require
(
'./app/files/fileManager'
)
var
ContextualListener
=
require
(
'./app/editor/contextualListener'
)
var
ContextualListener
=
require
(
'./app/editor/contextualListener'
)
var
ContextView
=
require
(
'./app/editor/contextView'
)
var
ContextView
=
require
(
'./app/editor/contextView'
)
var
BasicReadOnlyExplorer
=
require
(
'./app/files/basicReadOnlyExplorer'
)
var
styleGuide
=
remixLib
.
ui
.
styleGuide
var
styleGuide
=
remixLib
.
ui
.
styleGuide
var
styles
=
styleGuide
()
var
styles
=
styleGuide
()
...
@@ -111,6 +112,10 @@ class App {
...
@@ -111,6 +112,10 @@ class App {
self
.
_api
.
filesProviders
=
{}
self
.
_api
.
filesProviders
=
{}
self
.
_api
.
filesProviders
[
'browser'
]
=
new
Browserfiles
(
fileStorage
)
self
.
_api
.
filesProviders
[
'browser'
]
=
new
Browserfiles
(
fileStorage
)
self
.
_api
.
filesProviders
[
'localhost'
]
=
new
SharedFolder
(
new
Remixd
())
self
.
_api
.
filesProviders
[
'localhost'
]
=
new
SharedFolder
(
new
Remixd
())
self
.
_api
.
filesProviders
[
'swarm'
]
=
new
BasicReadOnlyExplorer
(
'swarm'
)
self
.
_api
.
filesProviders
[
'github'
]
=
new
BasicReadOnlyExplorer
(
'github'
)
self
.
_api
.
filesProviders
[
'gist'
]
=
new
BasicReadOnlyExplorer
(
'gist'
)
self
.
_api
.
filesProviders
[
'ipfs'
]
=
new
BasicReadOnlyExplorer
(
'ipfs'
)
self
.
_view
=
{}
self
.
_view
=
{}
self
.
_components
=
{}
self
.
_components
=
{}
self
.
data
=
{
self
.
data
=
{
...
...
src/app/files/basicReadOnlyExplorer.js
0 → 100644
View file @
d8bdc059
'use strict'
var
EventManager
=
require
(
'remix-lib'
).
EventManager
class
SwarmExplorer
{
constructor
(
type
)
{
this
.
event
=
new
EventManager
()
this
.
files
=
{}
this
.
type
=
type
}
close
(
cb
)
{
this
.
files
=
{}
cb
()
}
init
(
cb
)
{
this
.
files
=
{}
}
exists
(
path
)
{
if
(
!
this
.
files
)
return
false
return
this
.
files
[
path
]
!==
undefined
}
get
(
path
,
cb
)
{
var
content
=
this
.
files
[
path
]
if
(
cb
)
{
cb
(
null
,
content
)
}
return
content
}
set
(
path
,
content
,
cb
)
{
return
true
}
addReadOnly
(
path
,
content
)
{
this
.
files
[
this
.
type
+
'/'
+
path
]
=
content
this
.
event
.
trigger
(
'fileAdded'
,
[
this
.
type
+
'/'
+
path
,
true
])
return
true
}
isReadOnly
(
path
)
{
return
true
}
remove
(
path
)
{
delete
this
.
files
[
path
]
}
rename
(
oldPath
,
newPath
,
isFolder
)
{
return
true
}
list
()
{
return
this
.
files
}
//
// Tree model for files
// {
// 'a': { }, // empty directory 'a'
// 'b': {
// 'c': {}, // empty directory 'b/c'
// 'd': { '/readonly': true, '/content': 'Hello World' } // files 'b/c/d'
// 'e': { '/readonly': false, '/path': 'b/c/d' } // symlink to 'b/c/d'
// 'f': { '/readonly': false, '/content': '<executable>', '/mode': 0755 }
// }
// }
//
listAsTree
()
{
function
hashmapize
(
obj
,
path
,
val
)
{
var
nodes
=
path
.
split
(
'/'
)
var
i
=
0
for
(;
i
<
nodes
.
length
-
1
;
i
++
)
{
var
node
=
nodes
[
i
]
if
(
obj
[
node
]
===
undefined
)
{
obj
[
node
]
=
{}
}
obj
=
obj
[
node
]
}
obj
[
nodes
[
i
]]
=
val
}
var
tree
=
{}
var
self
=
this
// This does not include '.remix.config', because it is filtered
// inside list().
Object
.
keys
(
this
.
list
()).
forEach
(
function
(
path
)
{
hashmapize
(
tree
,
path
,
{
'/readonly'
:
self
.
isReadOnly
(
path
),
'/content'
:
self
.
get
(
path
)
})
})
return
tree
}
}
module
.
exports
=
SwarmExplorer
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