Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

gonna break something. I know it.

  • Loading branch information...
commit cdaf1b83aca24b802743c2f046cc1ccaff0b99a4 1 parent 3919bb8
Default Username authored root committed
View
141 app.js
@@ -57,7 +57,8 @@ nowjs.on('connect', function () {
this.now.c_confirmProject(this.user.teamID);
});
nowjs.on('disconnect', function () {
- console.log("DISCONNECT > "+this.user.clientId+" >> "+this.user.about.name+" <"+this.user.about.email+">");
+ //console.log("DISCONNECT > "+this.user.clientId+" >> "+this.user.about.name+" <"+this.user.about.email+">");
+ console.log("DISCONNECT > "+this.user.clientId+" >> "+this.now.name);
var teamgroup = nowjs.getGroup(this.user.teamID);
// remove user from all file groups.
if(this.user.grouplist !== undefined){
@@ -236,50 +237,25 @@ everyone.now.s_commitProject = function(txt, committerCallback){
var team = this.user.teamID;
console.log("committing project... >> " + team);
var teamProjGitPath = '/NETFS/'+team;
-
// this only needs done when a new repo is created...
//localRepoInitBare(teamProjGitPath, function(err){});
-
localRepoCommit(this.user, teamProjGitPath, txt, function(err){
if(err) {
console.log(err);
}
committerCallback(err);
});
-
- /*
- try{
- fs.realpathSync(teamProjGitPath);
- // if we get here, we've already initialized our .git repo.
- var repo = git.Repo(teamProjGitPath, {is_bare:true}, function(err, repo){
- if( err ) { throw new Error( err ); }
- console.log("no errors getting repo (but .git dir may be blank...)");
- repo.git.commit({}, '-a', '-m' + safeMsg, function(err, commit){
- if( err ) { throw new Error( err ); }
- console.log("made it through commit.");
- });
- });
- }catch(ex){
- console.log("No repository found yet for team: " + team + " >> initializing a new one...");
- fs.mkdir(teamProjGitPath, 0755, function(err){
- if( err ) { throw new Error( err ); }
- console.log("created .git directory.");
- var repo = git.Repo(teamProjGitPath, {is_bare:true}, function(err, repo){
- if( err ) { throw new Error( err ); }
- console.log("opened repo, now need to initialize it.");
- console.log(git);
- git.init(teamProjGitPath, function(err, git) {
- if( err ) { throw new Error( err ); }
- console.log("Initialized new repo!");
- repo.git.commit({}, '-a', '-m' + safeMsg, function(err, commit){
- if( err ) { throw new Error( err ); }
- console.log("made it through commit (2nd path).");
- });
- });
- });
- });
- }
- */
+};
+everyone.now.s_fetchProjectCommits = function(fetcherCallback){
+ var team = this.user.teamID;
+ console.log("fetching project commits... >> " + team);
+ var teamProjGitPath = '/NETFS/'+team;
+ localRepoFetchGitLog(this.user, teamProjGitPath, "", function(err){
+ if(err) {
+ console.log(err);
+ }
+ fetcherCallback(err);
+ });
};
everyone.now.s_deployProject = function(txt, deployerCallback){
var team = this.user.teamID;
@@ -329,6 +305,88 @@ function localRepoCommit(userObj, gitRepoPath, message, callback){
callback(error);
});
}
+function localRepoFetchGitLog(userObj, gitRepoPath, fname, fetcherCallback) {
+ // TODO: Make the filtering part of the git command, not an after thought with a ton of results.
+ // Seeing all checkpoints since the beginning of a project could lead to looking at many thousand results...
+ var authString = userObj.about.name+" <"+userObj.about.email+">";
+ var safeAuthString = Utf8.encode(authString).replace(/\"/g, "\\\"");
+ var maxInitialFetch = 10; // hardcoded max value so things don't get crazy until it's explicitly part of the git command...
+ var maxResults = 5;
+ var saveThisEntry = false;
+ var filter = null;
+ console.log("GIT: Commit to >> "+gitRepoPath+" by: "+safeAuthString);
+ var cmd = "git log -n"+maxInitialFetch+" --numstat --pretty=format:\"commit %H%naname %an%namail %ae%nrdate %ar%nutime %at%ncnote %s\" -- "+fname;
+ console.log(cmd);
+ var child = exec(cmd, {
+ encoding: 'utf8',
+ timeout: 30000,
+ maxBuffer: 200*1024,
+ killSignal: 'SIGTERM',
+ cwd: gitRepoPath,
+ env: null
+ },
+ function (error, stdout, stderr) {
+ if (error !== null) {
+ console.log('exec error: ' + error);
+ callback(error, null);
+ }else{
+ // success! notify team members.
+ var teamgroup = nowjs.getGroup(userObj.teamID);
+ var fromUserId = userObj.clientId;
+ //teamgroup.now.c_processUserFileEvent("", "commitProject", fromUserId, 0, "", safeMsg);
+ console.log("***** STD OUT *****");
+ var logLines = stdout.split("\n");
+ //console.log(logLines);
+ var out = [];
+ for(var i=0; i<logLines.length; i++){
+ var line = logLines[i];
+ if(line.indexOf("commit") == 0){
+ // new entry.. first check if we've hit max entries
+ if(out.length >= maxResults){
+ break;
+ }
+ out.push({}); // start a new array
+ out[out.length-1]['commit'] = line.substring(8);
+ saveThisEntry = true;
+ }
+ if(saveThisEntry){
+ if(line.indexOf("aname") == 0){
+ out[out.length-1]['auth_name'] = line.substring(8);
+ }
+ if(line.indexOf("amail") == 0){
+ out[out.length-1]['auth_email'] = line.substring(8);
+ }
+ if(line.indexOf("rdate") == 0){
+ out[out.length-1]['time_relative'] = line.substring(8);
+ }
+ if(line.indexOf("utime") == 0){
+ out[out.length-1]['time_epoch'] = line.substring(8);
+ }
+ if(line.indexOf("cnote") == 0){
+ var comment = line.substring(8);
+ out[out.length-1]['comment'] = comment;
+ if(filter != null){
+ if(comment.indexOf(filter) < 0){
+ out.pop();
+ saveThisEntry = false;
+ }
+ }
+ }
+ if(line.length > 0 && !isNaN(line.charAt(0)) ){
+ //echo "numeric line.. counting changes!\n";
+ var numArray = line.split("\t");
+ if(numArray.length >= 2 && !isNaN(numArray[0]) && !isNaN(numArray[1]) && numArray[0] != "-" && numArray[1] != "-"){
+ out[out.length-1]['linesAdded'] = numArray[0];
+ out[out.length-1]['linesDeleted'] = numArray[1];
+ }
+ }
+ }
+ }
+ console.log(out);
+ fetcherCallback(out);
+ }
+ });
+}
//
// group management stuff.
//
@@ -548,7 +606,8 @@ function localFileDuplicate(userObj, fname, newFName, fileDuplicatorCallback){
// DEPLOY / LAUNCH! :D
//
function localProjectDeploy(userObj, deployerCallback){
- var team = userObj.teamID;
+ var team = userObj.teamID;
+ var fromUserId = userObj.clientId;
var projPath = '/NETFS/'+team;
var projectName = team;
@@ -581,6 +640,10 @@ function localProjectDeploy(userObj, deployerCallback){
console.log("START: " + stdout);
console.log("DEPLOY SUCCESSFUL: " + launchURL);
setTimeout(function(){
+ var teamgroup = nowjs.getGroup(team);
+ teamgroup.now.c_processUserFileEvent("", "launchProject", fromUserId, 0);
+ }, 50);
+ setTimeout(function(){
deployerCallback(null, launchURL);
}, 1500);
}
@@ -675,6 +738,8 @@ var Utf8 = {
return string;
}
}
+
+
//
//
//
View
30 public/index.css
@@ -53,7 +53,7 @@ body {
top: 45px;
width: 200px;
overflow: visible;
- z-index: 100;
+ z-index: 9;
}
.notificationItem {
background: rgba(0,0,0,0.85);
@@ -157,28 +157,28 @@ body {
#topProjName {
position: absolute;
z-index: 0;
- left: 2px;
- top: 2px;
- font-size: 26px;
- font-weight: 600;
+ left: 190px;
+ top: 12px;
+ font-size: 10px;
+ font-weight: 400;
color: rgba(0,0,0,0.40);
- text-align: center;
- right: 2px;
+ text-align: left;
}
#topSpaceLink {
position: absolute;
+ padding: 2px;
font-size: 10px;
z-index: 1000;
cursor: pointer;
color: #000;
- text-shadow: 0px 0px 7px #fff;
text-decoration: none;
- left: 20px;
- top: 5px;
+ left: 10px;
+ top: 10px;
letter-spacing: 1px;
}
-#topSpaceLink span {
- letter-spacing: 4px;
+#topSpaceLink:hover {
+ background: #f10;
+ color: #fff;
}
#editor {
margin: 0px;
@@ -195,11 +195,11 @@ body {
}
#whoIAm {
font-family: Arial, sans-serif;
- font-size: 11px;
+ font-size: 10px;
color: #191919;
position: absolute;
- top: 11px;
- left: 15px;
+ top: 12px;
+ left: 115px;
}
#whoAreThey {
font-family: Arial, sans-serif;
View
5 public/index.html
@@ -53,11 +53,11 @@
<pre id="editor"></pre>
<div id="top">
- <div id='topProjName'></div>
+ <a href='http://space.chaoscollective.org'><div id='topSpaceLink'>BACK TO SPACE</div></a>
<div id="whoIAm"></div>
+ <div id='topProjName'></div>
<div id="whoAreThey" title="No one else is collaborating">0</div>
<div id='notifications'></div>
- <a href='http://space.chaoscollective.org'><div id='topSpaceLink'>&#8592; BACK TO SPACE</div></a>
<div id='topMenu'>
<div class='topMenuItem' id='topMenu_CMD' onclick='toggleShiftShift();'><span>C</span>MD</div>
<div class='topMenuItem' id='topMenu_HUD' onclick='toggleHUD();'><span>H</span>UD</div>
@@ -66,7 +66,6 @@
</div>
</div>
-
<script src="js/ace/ace.js" type="text/javascript" charset="utf-8"></script>
<script src="js/theme-chaos.js" type="text/javascript" charset="utf-8"></script>
<script src="js/ace/mode-javascript.js" type="text/javascript" charset="utf-8"></script>
View
25 public/index.js
@@ -467,6 +467,11 @@ now.c_processUserFileEvent = function(fname, event, fromUserId, usersInFile, se
var userColor = userColorMap[fromUserId%userColorMap.length];
notifyAndAddMessageToLog(userColor, uName, "commited project with note: <div class='itemType_projectAction'>"+msg+"</div>");
}
+ if(event == "launchProject"){
+ console.log("launch!");
+ var userColor = userColorMap[fromUserId%userColorMap.length];
+ notifyAndAddMessageToLog(userColor, uName, "<div class='itemType_projectAction'>Launched the project!</div>");
+ }
updateHUD();
}
now.c_processUserEvent = function(event, fromUserId, fromUserName){
@@ -500,7 +505,7 @@ now.c_processMessage = function(scope, type, message, fromUserId, fromUse
now.c_confirmProject = function(teamID){
now.teamID = teamID;
console.log("PROJECT: " + now.teamID);
- $("#topProjName").html(teamID);
+ $("#topProjName").html("// <b>"+teamID+"</b>");
}
// ---------------------------------------------------------
// Main functions...
@@ -1341,21 +1346,33 @@ now.ready(function(){
updateFileBrowserFromFileList(filesAndInfo);
});
now.core.on('disconnect', function () {
- console.log("DISCONNECT... Setting nowIsOnline to false"); // this.user.clientId
+ console.log("DISCONNECT... Setting nowIsOnline to false"); // this.user.clientId
nowIsOnline = false;
setFileStatusIndicator("offline");
});
now.core.on('connect', function () {
- console.log("CONNECT... Setting nowIsOnline to true"); // this.user.clientId
+ console.log("CONNECT... Setting nowIsOnline to true"); // this.user.clientId
nowIsOnline = true;
setFileStatusIndicator("default");
});
console.log(now);
- $("#whoIAm").html("Hello, <b>"+now.name+"</b>");
+ $("#whoIAm").html("// Hello, <b>"+now.name+"</b>");
setTimeout(function(){
$("#logOutputIFrame").attr("src", "http://logs.chaoscollective.org/live?log="+now.teamID);
document.title = now.teamID;
}, 1000);
+ console.log("fetching git commits...");
+ now.s_fetchProjectCommits(function(commits){
+ console.log(" -- returned from git commit fetch --");
+ console.log(commits);
+ var cHTML = "";
+ for(var i=commits.length-1; i>=0; i--){
+ var c = commits[i];
+ cHTML += "<br/><div style='opacity: 0.8; padding-lefT: 20px; font-style: italic;'>"+c.time_relative+"</div><div style='padding-left: 20px; color: #090; width: 40px; display: inline-block; text-align: right;'>+"+c.linesAdded+"</div> <div style='color: #900; width: 40px; display: inline-block;'>-"+c.linesDeleted+"</div><div class='itemType_projectAction'>"+c.comment+"</div><div style='clear: both;'></div>";
+ }
+ notifyAndAddMessageToLog("#CCCCCC", "CHAOS", "Most recent commits "+cHTML);
+ console.log(" ------------------------------------");
+ });
//toggleHUD();
});
$(window).ready(function() {
View
36 public/index.styl
@@ -56,7 +56,7 @@ body {
top: 45px;
width: 200px;
overflow: visible;
- z-index: 100;
+ z-index: 9;
}
.notificationItem {
background: rgba(0,0,0,0.85);
@@ -95,6 +95,12 @@ body {
background: #1A1A1A;
color: rgba(255, 255, 255, 0.98);
}
+#topStatus {
+ position: absolute;
+ top: 0px;
+ left: 0px;
+ bottom: 35px;
+}
#logWindow {
position: absolute;
right: 15px;
@@ -160,29 +166,29 @@ body {
#topProjName {
position: absolute;
z-index: 0;
- left: 2px;
- top: 2px;
- font-size: 26px;
- font-weight: 600;
+ left: 190px;
+ top: 12px;
+ font-size: 10px;
+ font-weight: 400;
color: rgba(0, 0, 0, 0.4);
- text-align: center;
- right: 2px;
+ text-align: left;
}
#topSpaceLink {
position: absolute;
+ padding: 2px;
font-size: 10px;
z-index: 1000;
cursor: pointer;
color: black;
- text-shadow: 0px 0px 7px white;
text-decoration: none;
- left: 20px;
- top: 12px;
+ left: 10px;
+ top: 10px;
letter-spacing: 1px;
}
-#topSpaceLink span {
- letter-spacing: 4px;
+#topSpaceLink:hover {
+ background: #F10;
+ color: #FFF;
}
#editor {
@@ -200,11 +206,11 @@ body {
}
#whoIAm {
font-family: Arial, sans-serif;
- font-size: 11px;
+ font-size: 10px;
color: #191919;
position: absolute;
- top: 11px;
- left: 15px;
+ top: 12px;
+ left: 115px;
}
#whoAreThey {
font-family: Arial, sans-serif;
Please sign in to comment.
Something went wrong with that request. Please try again.