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
9d552b12
Commit
9d552b12
authored
Sep 10, 2019
by
LianaHus
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
farther refactoring
standard fixes
parent
a936bd94
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
139 additions
and
28 deletions
+139
-28
app.js
src/app.js
+4
-4
basicFileProvider.js
src/app/files/basicFileProvider.js
+119
-0
fileProviderBase.js
src/app/files/fileProviderBase.js
+12
-18
readonlyProvider.js
src/app/files/readonlyProvider.js
+3
-5
remixDProvider.js
src/app/files/remixDProvider.js
+1
-1
No files found.
src/app.js
View file @
9d552b12
...
...
@@ -13,14 +13,14 @@ var QueryParams = require('./lib/query-params')
var
GistHandler
=
require
(
'./lib/gist-handler'
)
var
Storage
=
remixLib
.
Storage
var
LocalStorageProvider
=
require
(
'./app/files/localStorageProvider'
)
var
Remix
dProvider
=
require
(
'./app/files/remixd
Provider'
)
var
Remix
DProvider
=
require
(
'./app/files/remixD
Provider'
)
var
Config
=
require
(
'./config'
)
var
Renderer
=
require
(
'./app/ui/renderer'
)
var
examples
=
require
(
'./app/editor/example-contracts'
)
var
modalDialogCustom
=
require
(
'./app/ui/modal-dialog-custom'
)
var
FileManager
=
require
(
'./app/files/fileManager'
)
var
ReadonlyProvider
=
require
(
'./app/files/readonlyProvider'
)
var
NotPersistedExplorer
=
require
(
'./app/files/NotPersistedExplor
er'
)
var
BasicFileProvider
=
require
(
'./app/files/basicFileProvid
er'
)
var
toolTip
=
require
(
'./app/ui/tooltip'
)
var
CompilerMetadata
=
require
(
'./app/files/compiler-metadata'
)
var
CompilerImport
=
require
(
'./app/compiler/compiler-imports'
)
...
...
@@ -122,10 +122,10 @@ class App {
if
(
message
.
error
)
toolTip
(
message
.
error
)
})
self
.
_components
.
filesProviders
[
'localhost'
]
=
new
Remix
d
Provider
(
remixd
)
self
.
_components
.
filesProviders
[
'localhost'
]
=
new
Remix
D
Provider
(
remixd
)
self
.
_components
.
filesProviders
[
'swarm'
]
=
new
ReadonlyProvider
(
'swarm'
)
self
.
_components
.
filesProviders
[
'github'
]
=
new
ReadonlyProvider
(
'github'
)
self
.
_components
.
filesProviders
[
'gist'
]
=
new
NotPersistedExplor
er
(
'gist'
)
self
.
_components
.
filesProviders
[
'gist'
]
=
new
BasicFileProvid
er
(
'gist'
)
self
.
_components
.
filesProviders
[
'ipfs'
]
=
new
ReadonlyProvider
(
'ipfs'
)
self
.
_components
.
filesProviders
[
'https'
]
=
new
ReadonlyProvider
(
'https'
)
self
.
_components
.
filesProviders
[
'http'
]
=
new
ReadonlyProvider
(
'http'
)
...
...
src/app/files/basicFileProvider.js
0 → 100644
View file @
9d552b12
'use strict'
const
EventManager
=
require
(
'../../lib/events'
)
const
toolTip
=
require
(
'../ui/tooltip'
)
class
BasicFileProvider
{
constructor
(
type
)
{
this
.
event
=
new
EventManager
()
this
.
files
=
{}
this
.
paths
=
{}
this
.
normalizedNames
=
{}
// contains the raw url associated with the displayed path
this
.
paths
[
type
]
=
{}
this
.
type
=
type
this
.
readonly
=
true
}
close
(
cb
)
{
this
.
files
=
{}
cb
()
}
init
(
cb
)
{
this
.
files
=
{}
}
exists
(
path
,
cb
)
{
if
(
!
this
.
files
)
return
cb
(
null
,
false
)
var
unprefixedPath
=
this
.
removePrefix
(
path
)
cb
(
null
,
this
.
files
[
unprefixedPath
]
!==
undefined
)
}
get
(
path
,
cb
)
{
if
(
this
.
normalizedNames
[
path
])
path
=
this
.
normalizedNames
[
path
]
// ensure we actually use the normalized path from here
var
unprefixedPath
=
this
.
removePrefix
(
path
)
var
content
=
this
.
files
[
unprefixedPath
]
if
(
!
content
)
{
content
=
this
.
files
[
this
.
type
+
'/'
+
this
.
normalizedNames
[
path
]]
}
if
(
cb
)
{
cb
(
null
,
content
)
}
return
content
}
set
(
path
,
content
,
cb
)
{
this
.
addReadOnly
(
path
,
content
)
if
(
cb
)
cb
()
return
true
}
addReadOnly
(
path
,
content
,
rawPath
)
{
path
=
this
.
removePrefix
(
path
)
try
{
// lazy try to format JSON
content
=
JSON
.
stringify
(
JSON
.
parse
(
content
),
null
,
'
\
t'
)
}
catch
(
e
)
{}
if
(
!
rawPath
)
rawPath
=
path
// splitting off the path in a tree structure, the json tree is used in `resolveDirectory`
var
split
=
path
var
folder
=
false
while
(
split
.
lastIndexOf
(
'/'
)
!==
-
1
)
{
var
subitem
=
split
.
substring
(
split
.
lastIndexOf
(
'/'
))
split
=
split
.
substring
(
0
,
split
.
lastIndexOf
(
'/'
))
if
(
!
this
.
paths
[
this
.
type
+
'/'
+
split
])
{
this
.
paths
[
this
.
type
+
'/'
+
split
]
=
{}
}
this
.
paths
[
this
.
type
+
'/'
+
split
][
split
+
subitem
]
=
{
isDirectory
:
folder
}
folder
=
true
}
this
.
paths
[
this
.
type
][
split
]
=
{
isDirectory
:
folder
}
this
.
files
[
path
]
=
content
this
.
normalizedNames
[
rawPath
]
=
path
this
.
event
.
trigger
(
'fileAdded'
,
[
this
.
type
+
'/'
+
path
,
true
])
return
true
}
remove
(
path
)
{
var
unprefixedPath
=
this
.
removePrefix
(
path
)
var
folderPath
=
path
.
substring
(
0
,
path
.
lastIndexOf
(
'/'
))
if
(
this
.
paths
[
folderPath
])
{
delete
this
.
paths
[
folderPath
][
unprefixedPath
]
delete
this
.
files
[
path
]
}
this
.
event
.
trigger
(
'fileRemoved'
,
[
this
.
type
+
'/'
+
unprefixedPath
])
return
true
}
rename
(
oldPath
,
newPath
,
isFolder
)
{
if
(
isFolder
)
{
return
toolTip
(
'folder renaming is not handled by this explorer'
)
}
var
unprefixedoldPath
=
this
.
removePrefix
(
oldPath
)
var
unprefixednewPath
=
this
.
removePrefix
(
newPath
)
this
.
get
(
oldPath
,
(
error
,
content
)
=>
{
if
(
error
)
return
console
.
log
(
error
)
this
.
remove
(
oldPath
)
this
.
set
(
newPath
,
content
)
this
.
event
.
trigger
(
'fileRenamed'
,
[
this
.
type
+
'/'
+
unprefixedoldPath
,
this
.
type
+
'/'
+
unprefixednewPath
,
isFolder
])
})
}
isReadOnly
(
path
)
{
return
false
}
list
()
{
return
this
.
files
}
resolveDirectory
(
path
,
callback
)
{
var
self
=
this
if
(
path
[
0
]
===
'/'
)
path
=
path
.
substring
(
1
)
if
(
!
path
)
return
callback
(
null
,
{
[
self
.
type
]:
{
}
})
// we just return the json tree populated by `addReadOnly`
callback
(
null
,
this
.
paths
[
path
])
}
removePrefix
(
path
)
{
return
path
.
indexOf
(
this
.
type
+
'/'
)
===
0
?
path
.
replace
(
this
.
type
+
'/'
,
''
)
:
path
}
}
module
.
exports
=
BasicFileProvider
src/app/files/fileProviderBase.js
View file @
9d552b12
'use strict'
import
*
as
packageJson
from
'../../../package.json'
class
FileProvider
{
constructor
()
{
super
(
profile
)
}
exists
(
path
,
cb
)
{
throw
new
Error
(
this
.
name
+
' function is not implemented for '
+
this
.
constructor
.
name
+
' class'
)
}
exists
(
path
,
cb
)
{
throw
new
Error
(
this
.
name
+
' function is not implemented for '
+
this
.
constructor
.
name
+
' class'
);
}
init
(
cb
)
{
throw
new
Error
(
this
.
name
+
' function is not implemented for '
+
this
.
constructor
.
name
+
' class'
)
}
init
(
cb
)
{
throw
new
Error
(
this
.
name
+
' function is not implemented for '
+
this
.
constructor
.
name
+
' class'
);
}
get
(
path
,
cb
)
{
throw
new
Error
(
this
.
name
+
' function is not implemented for '
+
this
.
constructor
.
name
+
' class'
)
}
get
(
path
,
cb
)
{
throw
new
Error
(
this
.
name
+
' function is not implemented for '
+
this
.
constructor
.
name
+
' class'
);
}
set
(
path
,
content
,
cb
)
{
throw
new
Error
(
this
.
name
+
' function is not implemented for '
+
this
.
constructor
.
name
+
' class'
)
}
set
(
path
,
content
,
cb
)
{
throw
new
Error
(
this
.
name
+
' function is not implemented for '
+
this
.
constructor
.
name
+
' class'
);
}
addReadOnly
(
path
,
content
)
{
throw
new
Error
(
this
.
name
+
' function is not implemented for '
+
this
.
constructor
.
name
+
' class'
)
}
addReadOnly
(
path
,
content
)
{
throw
new
Error
(
this
.
name
+
' function is not implemented for '
+
this
.
constructor
.
name
+
' class'
);
}
isReadOnly
(
path
)
{
throw
new
Error
(
this
.
name
+
' function is not implemented for '
+
this
.
constructor
.
name
+
' class'
)
}
isReadOnly
(
path
)
{
throw
new
Error
(
this
.
name
+
' function is not implemented for '
+
this
.
constructor
.
name
+
' class'
);
}
remove
(
path
)
{
throw
new
Error
(
this
.
name
+
' function is not implemented for '
+
this
.
constructor
.
name
+
' class'
)
}
remove
(
path
)
{
throw
new
Error
(
this
.
name
+
' function is not implemented for '
+
this
.
constructor
.
name
+
' class'
);
}
rename
(
oldPath
,
newPath
,
isFolder
)
{
throw
new
Error
(
this
.
name
+
' function is not implemented for '
+
this
.
constructor
.
name
+
' class'
)
}
rename
(
oldPath
,
newPath
,
isFolder
)
{
throw
new
Error
(
this
.
name
+
' function is not implemented for '
+
this
.
constructor
.
name
+
' class'
);
}
resolveDirectory
(
path
,
callback
)
{
throw
new
Error
(
this
.
name
+
' function is not implemented for '
+
this
.
constructor
.
name
+
' class'
)
}
resolveDirectory
(
path
,
callback
)
{
throw
new
Error
(
this
.
name
+
' function is not implemented for '
+
this
.
constructor
.
name
+
' class'
);
}
removePrefix
(
path
)
{
throw
new
Error
(
this
.
name
+
' function is not implemented for '
+
this
.
constructor
.
name
+
' class'
)
}
removePrefix
(
path
)
{
throw
new
Error
(
this
.
name
+
' function is not implemented for '
+
this
.
constructor
.
name
+
' class'
);
}
updateRefs
(
path
,
type
)
{
throw
new
Error
(
this
.
name
+
' function is not implemented for '
+
this
.
constructor
.
name
+
' class'
);
}
updateRefs
(
path
,
type
)
{
throw
new
Error
(
this
.
name
+
' function is not implemented for '
+
this
.
constructor
.
name
+
' class'
)
}
}
module
.
exports
=
FileProvider
\ No newline at end of file
module
.
exports
=
FileProvider
src/app/files/readonlyProvider.js
View file @
9d552b12
'use strict'
var
Readonly
Provider
=
require
(
'./basicFileProvider'
)
let
BasicFile
Provider
=
require
(
'./basicFileProvider'
)
class
ReadonlyProvider
extends
BasicFileProvider
{
constructor
(
type
)
{
super
(
type
)
}
remove
(
path
)
{
return
false
}
rename
(
oldPath
,
newPath
,
isFolder
)
{
return
false
}
isReadOnly
(
path
)
{
return
true
}
}
module
.
exports
=
ReadonlyProvider
src/app/files/remix
d
Provider.js
→
src/app/files/remix
D
Provider.js
View file @
9d552b12
...
...
@@ -2,7 +2,7 @@
var
EventManager
=
require
(
'../../lib/events'
)
var
pathtool
=
require
(
'path'
)
module
.
exports
=
class
Remix
d
Provider
{
module
.
exports
=
class
Remix
D
Provider
{
constructor
(
remixd
)
{
this
.
event
=
new
EventManager
()
this
.
_remixd
=
remixd
...
...
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