Toggle navigation
Toggle navigation
This project
Loading...
Sign in
arcs
/
arcs.js
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
3
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
didier
2016-03-06 02:05:13 +0000
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
de222720b1ccd4bf25376c9adfcea9808d098bb6
de222720
1 parent
de721eb2
started development of webservice and interface
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
212 additions
and
15 deletions
utils/forge/app/arcsforge.js
utils/forge/app/forge.html
utils/forge/service/arcsforgeservice.js
utils/forge/service/document.js
utils/forge/service/package.json
utils/forge/app/arcsforge.js
View file @
de22272
var
ARCSForge
=
{};
var
ARCSForge
=
{
sessionId
:
""
,
projectList
:
[],
files
:
{}
};
console
.
log
(
document
.
getElementById
(
"codewindow"
));
var
cm
=
CodeMirror
(
document
.
body
);
var
cm
=
CodeMirror
.
fromTextArea
(
document
.
getElementById
(
"codewindow"
),
{
lineNumbers
:
true
,
mode
:
"javascript"
});
var
doc
=
new
Document
();
cm
.
on
(
"change"
,
doc
.
change
);
cm
.
refresh
();
function
login
()
{
// to be implemented
$
.
post
(
"/login"
,{
login
:
$
(
'#login'
).
val
(),
password
:
md5
(
$
(
'#pass'
).
val
())
},
function
(
data
)
{
ARCSForge
.
sessionId
=
data
;
$
.
mobile
.
changePage
(
'#pageEdit'
);
});
}
function
logout
()
{
console
.
log
(
'logout'
,
ARCSForge
.
sessionId
);
$
.
get
(
"/logout/"
+
ARCSForge
.
sessionId
);
$
.
mobile
.
changePage
(
'#pageLogin'
);
}
\ No newline at end of file
...
...
utils/forge/app/forge.html
View file @
de22272
<html>
<head>
<title>
ARCS.js online forge
</title>
<link
rel=
"stylesheet"
text=
"text/css"
href=
"arcsforge.css"
>
<script
src=
"../../../deps/CodeMirror/codemirror.js"
></script>
<meta
name=
"viewport"
content=
"width=device-width, initial-scale=1"
>
<link
rel=
"stylesheet"
href=
"../../../deps/CodeMirror/codemirror.css"
>
<link
rel=
"stylesheet"
href=
"../../../deps/jquery-mobile-bower/jquery.mobile-1.4.5.css"
>
<!--link rel="stylesheet" href="arcsforge.css"-->
<script
src=
"../../../deps/jquery/jquery.js"
></script>
<script
src=
"../../../deps/jquery-mobile-bower/jquery.mobile-1.4.5.js"
></script>
<script
src=
"../../../deps/CodeMirror/codemirror.js"
></script>
<script
src=
"../../../deps/CodeMirror-javascript/index.js"
></script>
<script
src=
"../../../deps/md5/md5.min.js"
></script>
</head>
<body>
<body
onbeforeunload=
"logout()"
>
<!-- Login -->
<div
data-role=
"page"
id=
"pageLogin"
>
<div
data-role=
"header"
data-theme=
"b"
>
<h1>
ARCS Forge
</h1>
</div>
<div
data-role=
"main"
class=
"ui-content"
>
<p>
Please provide your identifiers in order to connect to the forge.
</p>
<label
for=
"loginField"
>
Login:
</label>
<input
name=
"loginField"
id=
"login"
value=
""
type=
"text"
>
<label
for=
"passField"
>
Password:
</label>
<input
name=
"passField"
id=
"pass"
value=
""
type=
"text"
>
<a
href=
"#"
onclick=
"login()"
class=
"ui-btn ui-corner-all ui-btn-inline"
>
Login
</a>
<!-- actions should be to check credentials and then propose workspaces -->
</div>
</div>
<!-- Project -->
<div
data-role=
"page"
id=
"pageProjects"
>
<div
data-role=
"header"
data-theme=
"b"
>
<h1>
ARCS Forge
</h1>
<button
onclick=
"logout()"
class=
"ui-btn ui-icon-power ui-btn-right ui-corner-all ui-btn-icon-notext "
></button>
</div>
<div
data-role=
"main"
class=
"ui-content"
>
</div>
</div>
<!-- Edition -->
<div
data-role=
"page"
id=
"pageEdit"
>
<div
data-role=
"header"
data-theme=
"b"
>
<button
onclick=
"logout()"
class=
"ui-btn ui-icon-power ui-btn-right ui-corner-all ui-btn-icon-notext "
></button>
<h1>
ARCS Forge
</h1>
<button
onclick=
"logout()"
class=
"ui-btn ui-icon-power ui-btn-right ui-corner-all ui-btn-icon-notext "
></button>
</div>
<div
data-role=
"main"
class=
"ui-content"
>
<p>
You can write down your code here :
</p>
<textarea
name=
"codewindow"
data-role=
"none"
id=
"codewindow"
></textarea>
<a
href=
"#panel"
class=
"ui-btn"
>
Panel
</a>
</div>
<div
data-role=
"panel"
id=
"panel"
>
<a
href=
"#"
class=
"ui-btn"
>
Hello?
</a>
</div>
</div>
<script
src=
"arcsforge.js"
></script>
<h1>
Forge ARCS.js
</h1>
</body>
</html>
\ No newline at end of file
...
...
utils/forge/service/arcsforgeservice.js
View file @
de22272
...
...
@@ -6,25 +6,101 @@ var https = require('https');
var
express
=
require
(
'express'
);
var
app
=
express
();
var
expressWs
=
require
(
'express-ws'
)(
app
);
var
bodyParser
=
require
(
'body-parser'
);
var
multer
=
require
(
'multer'
);
var
upload
=
multer
();
/*var ldap = require('ldapjs');
var client = ldap.createClient({});*/
var
Document
=
require
(
'./document.js'
);
var
Forge
=
require
(
'./document.js'
);
console
.
log
(
Forge
);
var
usersConfig
=
new
Forge
.
Settings
(
'./etc/users.json'
);
var
sessions
=
[];
app
.
use
(
bodyParser
.
json
());
app
.
use
(
bodyParser
.
urlencoded
({
extended
:
true
}));
app
.
get
(
'/app/:name'
,
function
(
req
,
res
)
{
var
options
=
{
root
:
__dirname
+
'/../app/'
,
dotfiles
:
'deny'
,
headers
:
{
'x-timestamp'
:
Date
.
now
(),
'x-sent'
:
true
}
};
var
fileName
=
req
.
params
.
name
;
res
.
sendFile
(
fileName
,
options
,
function
(
err
)
{
if
(
err
)
{
console
.
log
(
err
);
res
.
status
(
err
.
status
).
end
();
}
else
{
console
.
log
(
'Sent: '
,
fileName
);
}
});
});
app
.
get
(
'/deps/*'
,
function
(
req
,
res
)
{
var
options
=
{
root
:
__dirname
+
'/../../..'
,
dotfiles
:
'deny'
,
headers
:
{
'x-timestamp'
:
Date
.
now
(),
'x-sent'
:
true
}
};
console
.
log
(
req
.
url
);
var
fileName
=
req
.
originalUrl
;
res
.
sendFile
(
fileName
,
options
,
function
(
err
)
{
if
(
err
)
{
console
.
log
(
err
);
res
.
status
(
err
.
status
).
end
();
}
else
{
console
.
log
(
'Sent: '
,
fileName
);
}
});
});
app
.
post
(
'/login'
,
upload
.
array
(),
function
(
req
,
res
)
{
console
.
log
(
'attempted to login with id '
,
req
.
body
);
usersConfig
.
set
(
req
.
body
.
login
,{});
// let's say the user is connected.
var
sessionId
=
Date
.
now
().
toString
(
16
);
sessions
[
sessionId
]
=
{
user
:
req
.
body
.
login
};
res
.
send
(
sessionId
);
});
app
.
get
(
'/logout/:sessionId'
,
function
(
req
,
res
)
{
// here we will have to purge the session
delete
sessions
[
req
.
params
.
sessionId
];
res
.
send
(
req
.
params
.
sessionId
);
});
var
httpServer
=
http
.
createServer
(
app
);
httpServer
.
listen
(
3000
);
process
.
on
(
'SIGINT'
,
function
(
code
)
{
console
.
log
(
"Ctrl-C"
);
process
.
exit
();
process
.
exit
();
});
process
.
on
(
'exit'
,
function
(
code
)
{
console
.
log
(
"Par ici la sortie"
);
usersConfig
.
save
();
});
\ No newline at end of file
...
...
utils/forge/service/document.js
View file @
de22272
var
fs
=
require
(
'fs'
);
exports
.
Document
=
function
()
{
var
Document
=
function
()
{
var
contents
=
""
;
var
fileName
=
""
;
var
lines
=
[
""
];
...
...
@@ -12,11 +11,14 @@ exports.Document = function() {
this
.
load
=
function
()
{
if
(
fileName
!==
""
)
{
contents
=
fs
.
readFileSync
(
fileName
);
updateLines
();
}
};
this
.
save
=
function
()
{
fs
.
writeFileSync
(
fileName
,
contents
);
};
this
.
setFile
=
function
(
fn
)
{
...
...
@@ -56,3 +58,42 @@ exports.Document = function() {
};
};
/* Settings class to load and save config files */
var
Settings
=
function
(
registry
)
{
var
fileName
=
registry
;
try
{
var
contents
=
require
(
registry
);
}
catch
(
e
)
{
contents
=
{};}
this
.
set
=
function
(
key
,
value
)
{
contents
[
key
]
=
value
;
};
this
.
get
=
function
(
key
)
{
return
contents
[
key
];
};
this
.
save
=
function
()
{
var
fileContents
=
JSON
.
stringify
(
contents
);
fs
.
writeFileSync
(
fileName
,
fileContents
);
};
};
var
Project
=
function
(
name
)
{
var
components
=
[];
var
description
=
""
;
var
html
=
""
;
var
files
=
[];
};
module
.
exports
=
{
Document
:
Document
,
Settings
:
Settings
,
Project
:
Project
};
\ No newline at end of file
...
...
utils/forge/service/package.json
View file @
de22272
...
...
@@ -15,6 +15,8 @@
"devDependencies"
:
{
"express"
:
">=4.13.4"
,
"express-ws"
:
">=1.0.0"
,
"body-parser"
:
">=1.15.0"
,
"multer"
:
">=1.1.0"
,
"ldapjs"
:
">=1.0.0"
}
}
...
...
Please
register
or
login
to post a comment