Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: coreh/nide
base: 993520e215
...
head fork: coreh/nide
compare: feature-git
Checking mergeability… Don't worry, you can still create the pull request.
  • 3 commits
  • 10 files changed
  • 0 commit comments
  • 1 contributor
View
122 client/css/style.css
@@ -135,6 +135,59 @@ body {
padding: 0;
}
+#sidebar .badge {
+ background: rgba(0,0,0,0.8);
+ color: #fff;
+ font-size: 75%;
+ text-shadow: 0 1px black;
+ padding: 2px 8px;
+ border-radius: 20px;
+ font-weight: bold;
+ box-shadow: 0 2px 0 rgba(0,0,0,0.1), 0 0 0 1px rgba(255,255,255,0.1);
+ cursor: pointer;
+}
+
+#sidebar .badge.selected {
+ background: rgba(55,120,194,0.3);
+ box-shadow: 0 1px 2px rgba(0,0,0,0.2) inset, 0 1px 0 rgba(255,255,255,0.5);
+ color: #3d5979;
+ text-shadow: 0 1px 0 rgba(255,255,255,0.5);
+}
+
+#sidebar .badge .short {
+ -webkit-transition: max-width 0.15s ease, opacity 0.15s ease;
+ display: inline-block;
+ max-width: 10px;
+ overflow: hidden;
+ opacity: 1;
+}
+
+#sidebar .badge:hover .short, #sidebar .badge.selected .short {
+ max-width: 0px;
+ opacity: 0;
+}
+
+#sidebar .badge .description {
+ -webkit-transition: max-width 0.5s ease, opacity 0.5s ease;
+ margin-left: 3px;
+ margin-right: -3px;
+ display: inline-block;
+ max-width: 0;
+ overflow: hidden;
+ opacity: 0;
+}
+
+#sidebar .badge:active {
+ background: rgba(0,0,0,0.5);
+}
+
+#sidebar .badge:hover .description, #sidebar .badge.selected .description {
+ max-width: 120px;
+ overflow: hidden;
+ margin-right: 0;
+ opacity: 1;
+}
+
#content {
position: absolute;
left: 250px;
@@ -307,6 +360,12 @@ body {
background: url('../img/noise.png') #fff;
}
+#content .change-viewer {
+ width: 100%;
+ height: 100%;
+ background: url('../img/noise.png') #eee;
+}
+
#content .documentation-viewer iframe {
border: none;
position: absolute;
@@ -338,6 +397,55 @@ body {
width: 100%;
}
+#content .changes {
+ background: #eed;
+ padding: 0 0 10px;
+ margin: 30px 0;
+ box-shadow: 0 1px 0 rgba(0,0,0,0.15) inset, 0 -1px 0 rgba(0,0,0,0.15) inset, 0 2px 20px -15px black, 0 15px 20px -10px white inset;
+ text-shadow: 0 1px rgba(255,255,255,0.8)
+}
+
+#content .change {
+ padding: 4px;
+ margin: 4px 8px;
+ background: #fafaea;
+ border-radius: 4px;
+ box-shadow: 0 0 0 1px rgba(0,0,0,0.1), 0 5px 15px white inset, 0 2px 4px rgba(0,0,0,0.05);
+ font-size: 110%;
+ color: #333311;
+}
+
+#content .change label {
+ display: block;
+}
+
+#content .change-viewer form {
+ padding: 4px;
+ margin: 4px 8px;
+ background: #fafafa;
+ border-radius: 4px;
+ box-shadow: 0 0 0 1px rgba(0,0,0,0.1), 0 5px 15px white inset, 0 2px 4px rgba(0,0,0,0.05);
+}
+
+#content .change-viewer form input[type='text'], #content .change-viewer form textarea {
+ display: block;
+ width: 98%;
+ max-width: 98%;
+ margin: 2px auto;
+ font-family: inherit;
+ font-size: 120%;
+ padding: 8px;
+ -webkit-box-sizing: content-box;
+ border: none;
+ box-shadow: 0 2px 3px rgba(0,0,0,0.2) inset, 0 0 0 1px rgba(0,0,0,0.1) inset;
+ border-radius: 3px;
+}
+
+#content .change-viewer form textarea {
+ height: 100px;
+}
+
+
#lightbox {
position: absolute;
background: rgba(0,0,0,0.25);
@@ -409,6 +517,10 @@ body {
margin-top: 10px;
}
+.actions.right-aligned {
+ text-align: right;
+}
+
.popup-menu {
position: absolute;
margin: 0;
@@ -482,4 +594,14 @@ body {
float: right;
position: relative;
left: 1px;
+}
+
+#changes {
+ display: none;
+}
+
+.clip {
+ position: absolute;
+ margin-top: -45px;
+ right: 0;
}
View
BIN  client/img/clip.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  client/img/git.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
3  client/index.html
@@ -34,12 +34,13 @@
<script src="js/DirectoryEditor.js"></script>
<script src="js/DocumentationViewer.js"></script>
<script src="js/NPMEditor.js"></script>
+ <script src="js/ChangeViewer.js"></script>
</head>
<body>
<div id="sidebar">
<input type="search" id="search-field" placeholder="Filter Files by Name">
<ul>
- <li class="root" id="project"><img src="img/project.png">Project
+ <li class="root" id="project"><img src="img/project.png">Project <span class="badge" id="changes">0<span class="description"> uncomitted changes</span></span>
<div id="files">
<ul>
<li><img src="img/ajax-loader.gif">Loading project...
View
62 client/js/ChangeViewer.js
@@ -0,0 +1,62 @@
+var changes = []
+var updateChanges = function() {
+ if (changes.length > 0) {
+ $('#changes').fadeIn()
+ $('#changes')[0].innerHTML = changes.length + '<span class="description">uncommited changes</span>';
+ } else {
+ $('#changes').fadeOut()
+ }
+}
+
+var ChangeViewer = function(entry) {
+ var editor = document.createElement('div')
+ editor.className = 'change-viewer'
+ var actionsBar = document.createElement('div')
+ actionsBar.className = 'actions'
+ actionsBar.innerHTML = '<button>Reset All Changes</button> <button class="right">Commit and <span style="line-height: 1em;">⬆</span> Push to Origin </button> <button class="right">Commit</button>'
+ editor.appendChild(actionsBar)
+ var messageForm = document.createElement('form')
+ messageForm.innerHTML = '<input type="text" placeholder="Commit Summary" class="commit-summary"><textarea placeholder="Extended Description" class="extended-description"></textarea>'
+ $(".extended-description", messageForm).hide()
+ editor.appendChild(messageForm)
+ var additionalOptions = document.createElement('div')
+ additionalOptions.innerHTML = '<label><input type="checkbox" checked> Clean up auto-save versions on commit</label>'
+ additionalOptions.className = 'actions right-aligned'
+ editor.appendChild(additionalOptions)
+ var changesDiv = document.createElement('div')
+ changesDiv.className = 'changes'
+ var changesDivActionsBar = document.createElement('div')
+ changesDivActionsBar.className = 'actions'
+ changesDivActionsBar.innerHTML = '<img src="img/clip.png" class="clip"><b>Files to be commited</b> <button>Check/Uncheck All</button>'
+ changesDiv.appendChild(changesDivActionsBar);
+ for (var i = 0; i < changes.length; i++) {
+ var changeDiv = document.createElement('div')
+ changeDiv.className = 'change'
+ var labelText = changes[i].sourceFile;
+ var disabled = ""
+ if (changes[i].destinationFile) {
+ labelText += '' + changes[i].destinationFile;
+ disabled = "disabled"
+ }
+ if (changes[i].index == 'D') {
+ disabled = "disabled"
+ labelText += ' <b>(deleted)</b>'
+ }
+ if (changes[i].index == '?') {
+ labelText += ' <b>(new)</b>'
+ }
+ changeDiv.innerHTML = '<label><input type="checkbox" checked ' + disabled +'> ' + labelText + '</label>'
+ changesDiv.appendChild(changeDiv)
+ }
+ editor.appendChild(changesDiv)
+
+ $(".commit-summary", messageForm).focus(function(){
+ $(".extended-description", messageForm).slideDown();
+ })
+ $(".commit-summary", messageForm).blur(function(){
+ if (this.value == '') {
+ $(".extended-description", messageForm).slideUp();
+ }
+ })
+ return editor
+}
View
5 client/js/ServerConnection.js
@@ -13,6 +13,11 @@ var ServerConnection = function() {
packages = reportedPackages
updatePackages()
})
+
+ socket.on('changes', function(reportedChanges) {
+ changes = reportedChanges
+ updateChanges()
+ })
socket.on('welcome', function() {
ui.displayWelcomeScreen();
View
10 client/js/UserInterfaceController.js
@@ -108,6 +108,13 @@ var UserInterfaceController = function() {
}, null, $('#docs')[0])
}
})
+
+ $('#changes').click(function(e) {
+ _this.selectFile({
+ type: 'changes',
+ path: '/'
+ }, null, $('#changes')[0])
+ })
$('#add-file').click(function(e) {
var filename = prompt('Type in a filename for the new file:', 'untitled.js')
@@ -285,6 +292,9 @@ var UserInterfaceController = function() {
case "npm":
editor = new NPMEditor(entry)
break;
+ case "changes":
+ editor = new ChangeViewer(entry)
+ break;
}
setCurrentEditor(editor)
View
9 main.js
@@ -14,7 +14,14 @@ var checkForDependencies = function(callback) {
console.error('Could not find `npm` command. Is npm installed?')
process.exit(-1)
} else {
- callback()
+ exec('which git', function(err, stdout, stderr) {
+ if (err) {
+ console.error('Could not find `git` command. Is git installed?')
+ process.exit(-1)
+ } else {
+ callback()
+ }
+ })
}
})
}
View
104 server/project.js
@@ -57,6 +57,8 @@ exports.start = function() {
exports.shouldDisplayWelcome = false
+exports.shouldUseGit = true
+
exports.init = function() {
try {
fs.mkdirSync('.nide', '755')
@@ -227,15 +229,35 @@ exports.remove = function(path) {
ee.emit('error', 'Invalid Path')
})
} else {
- exec('rm -rf -- ' + process.cwd() + path, function(err) {
- if (!err) {
- // Invalidate file list cache
- listCache = undefined
- ee.emit('success')
- } else {
- ee.emit('err', err)
- }
- })
+ if (exports.shouldUseGit) {
+ exec('git rm -rf -- "' + process.cwd() + path + '"', function(err) {
+ if (!err) {
+ // Invalidate file list cache
+ listCache = undefined
+ ee.emit('success')
+ } else {
+ exec('rm -rf -- "' + process.cwd() + path + '"', function(err) {
+ if (!err) {
+ // Invalidate file list cache
+ listCache = undefined
+ ee.emit('success')
+ } else {
+ ee.emit('err', err)
+ }
+ })
+ }
+ })
+ } else {
+ exec('rm -rf -- "' + process.cwd() + path + '"', function(err) {
+ if (!err) {
+ // Invalidate file list cache
+ listCache = undefined
+ ee.emit('success')
+ } else {
+ ee.emit('err', err)
+ }
+ })
+ }
}
return ee;
}
@@ -249,15 +271,35 @@ exports.rename = function(oldpath, newpath) {
ee.emit('error', 'Invalid Path')
})
} else {
- fs.rename(process.cwd() + oldpath, process.cwd() + newpath, function(err) {
- if (!err) {
- // Invalidate file list cache
- listCache = undefined
- ee.emit('success')
- } else {
- ee.emit('err', err)
- }
- })
+ if (exports.shouldUseGit) {
+ exec('git mv -- "' + process.cwd() + oldpath + '" "' + process.cwd() + newpath + '"', function(err) {
+ if (!err) {
+ // Invalidate file list cache
+ listCache = undefined
+ ee.emit('success')
+ } else {
+ fs.rename(process.cwd() + oldpath, process.cwd() + newpath, function(err) {
+ if (!err) {
+ // Invalidate file list cache
+ listCache = undefined
+ ee.emit('success')
+ } else {
+ ee.emit('err', err)
+ }
+ })
+ }
+ })
+ } else {
+ fs.rename(process.cwd() + oldpath, process.cwd() + newpath, function(err) {
+ if (!err) {
+ // Invalidate file list cache
+ listCache = undefined
+ ee.emit('success')
+ } else {
+ ee.emit('err', err)
+ }
+ })
+ }
}
return ee;
}
@@ -371,3 +413,29 @@ exports.uninstall = function(package, save) {
})
return ee;
}
+
+exports.changes = function() {
+ var ee = new EventEmitter()
+ exec('git status --porcelain', function(err, stdout, stderr) {
+ if (err) {
+ ee.emit('error', stderr);
+ } else {
+ var lines = stdout.split('\n')
+ var changes = []
+
+ for (var i = 0; i < lines.length; i++) {
+ var info = lines[i].match(/(.)(.)\ ("[^"]+"|[^\ "]+)(\ \-\>\ ("[^"]+"|[^\ "]+))?/);
+ if (info) {
+ changes.push({
+ index: info[1],
+ workingTree: info[2],
+ sourceFile: info[3],
+ destinationFile: info[5]
+ })
+ }
+ }
+ ee.emit('success', changes);
+ }
+ })
+ return ee;
+}
View
82 server/server.js
@@ -42,14 +42,29 @@ exports.listen = function(port) {
child_process.spawn(browser, [nideUrl]);
io.sockets.on('connection', function(socket) {
- project.list()
- .on('success', function(data) {
- socket.emit('list', data)
- })
- project.packages()
- .on('success', function(packages) {
- socket.emit('packages', packages)
- })
+ var listFilesAndUpdateClient = function() {
+ project.list()
+ .on('success', function(data) {
+ socket.emit('list', data)
+ })
+ }
+ var listPackagesAndUpdateClient = function() {
+ project.packages()
+ .on('success', function(packages) {
+ socket.emit('packages', packages)
+ })
+ }
+ var listChangesAndUpdateClient = function() {
+ project.changes()
+ .on('success', function(changes) {
+ socket.emit('changes', changes)
+ })
+ }
+
+ listFilesAndUpdateClient()
+ listPackagesAndUpdateClient()
+ listChangesAndUpdateClient()
+
if (project.shouldDisplayWelcome) {
socket.emit('welcome')
}
@@ -71,6 +86,7 @@ exports.listen = function(port) {
project.save(data.path, data.content)
.on('success', function(file) {
socket.emit('save-success', { path: data.path })
+ listChangesAndUpdateClient()
})
.on('error', function(err) {
socket.emit('save-error', { path: data.path, error: err })
@@ -79,10 +95,8 @@ exports.listen = function(port) {
socket.on('add', function(path) {
project.add(path)
.on('success', function(file) {
- project.list()
- .on('success', function(data) {
- socket.emit('list', data)
- })
+ listFilesAndUpdateClient()
+ listChangesAndUpdateClient()
})
.on('error', function(err) {
socket.emit('add-error', { path: path, error: err })
@@ -91,10 +105,7 @@ exports.listen = function(port) {
socket.on('add-folder', function(path) {
project.addFolder(path)
.on('success', function(file) {
- project.list()
- .on('success', function(data) {
- socket.emit('list', data)
- })
+ listFilesAndUpdateClient()
})
.on('error', function(err) {
socket.emit('add-folder-error', { path: path, error: err })
@@ -103,10 +114,8 @@ exports.listen = function(port) {
socket.on('remove', function(path) {
project.remove(path)
.on('success', function(file) {
- project.list()
- .on('success', function(data) {
- socket.emit('list', data)
- })
+ listFilesAndUpdateClient()
+ listChangesAndUpdateClient()
})
.on('error', function(err) {
socket.emit('remove-error', { path: path, error: err })
@@ -115,11 +124,9 @@ exports.listen = function(port) {
socket.on('rename', function(data) {
project.rename(data.oldpath, data.newpath)
.on('success', function(file) {
- project.list()
- .on('success', function(list) {
- socket.emit('list', list)
- socket.emit('rename-success', { path: data.newpath })
- })
+ listFilesAndUpdateClient()
+ listChangesAndUpdateClient()
+ socket.emit('rename-success', { path: data.newpath })
})
.on('error', function(err) {
socket.emit('rename-error', { path: data.oldpath, error: err })
@@ -143,14 +150,8 @@ exports.listen = function(port) {
socket.on('install', function(data) {
project.install(data.package, data.save)
.on('success', function() {
- project.packages()
- .on('success', function(packages) {
- socket.emit('packages', packages)
- })
- project.list()
- .on('success', function(list) {
- socket.emit('list', list)
- })
+ listPackagesAndUpdateClient()
+ listFilesAndUpdateClient()
})
.on('error', function(err) {
socket.emit('install-error', err)
@@ -159,24 +160,15 @@ exports.listen = function(port) {
socket.on('uninstall', function(data) {
project.uninstall(data.package, data.save)
.on('success', function() {
- project.packages()
- .on('success', function(packages) {
- socket.emit('packages', packages)
- })
- project.list()
- .on('success', function(list) {
- socket.emit('list', list)
- })
+ listPackagesAndUpdateClient()
+ listFilesAndUpdateClient()
})
.on('error', function(err) {
socket.emit('uninstall-error', err)
})
})
socket.on('packages-refresh', function(data) {
- project.packages()
- .on('success', function(packages) {
- socket.emit('packages', packages)
- })
+ listPackagesAndUpdateClient()
})
})

No commit comments for this range

Something went wrong with that request. Please try again.