further ui improvements
This commit is contained in:
parent
ee3bd40ef7
commit
2a4fdeeb96
@ -15,15 +15,30 @@ $fa-font-path: "/bower_components/font-awesome/fonts";
|
||||
padding: 0.2em 0;
|
||||
}
|
||||
|
||||
.indent {
|
||||
margin-left: 2em;
|
||||
}
|
||||
table.revisions th, table.revisions td{
|
||||
padding-left: 1em;
|
||||
padding-right: 1em;
|
||||
}
|
||||
|
||||
table.revisions td.content {
|
||||
max-height: 30em;
|
||||
}
|
||||
table.revisions .state {
|
||||
width: 7em;
|
||||
}
|
||||
|
||||
form.controls {
|
||||
margin-top: 1em;
|
||||
}
|
||||
|
||||
form.form-inline.controls > * {
|
||||
margin-right: 1em;
|
||||
}
|
||||
form.form-inline.controls > .form-group > label, {
|
||||
margin-right: 0.5em;
|
||||
}
|
||||
|
||||
// Component styles are injected through grunt
|
||||
// injector
|
||||
@import 'account/login/login.scss';
|
||||
|
@ -28,4 +28,68 @@ angular.module('markdownFormatWdiffApp')
|
||||
controller: 'DocumentWdiffCtrl'
|
||||
});
|
||||
|
||||
})
|
||||
.factory('App', function ($window, Auth) {
|
||||
var root = {};
|
||||
|
||||
root.json = function (object) {
|
||||
return JSON.stringify(object, null, " ");
|
||||
};
|
||||
|
||||
//returns true if this revision is the current revision in its document
|
||||
root.isCurrent = function (revision) {
|
||||
if (!revision)
|
||||
return false;
|
||||
|
||||
return revision._id == revision.document.currentRevision;
|
||||
};
|
||||
|
||||
//returns true if this revision is the first revision in its document
|
||||
// Note: documents have an initial empty sentinel revision - that is the zeroth revision
|
||||
root.isFirst = function (revision) {
|
||||
if (!revision)
|
||||
return false;
|
||||
|
||||
if (revision.document.revisions.length <= 1)
|
||||
return true;
|
||||
|
||||
return revision._id == revision.document.revisions[1];
|
||||
};
|
||||
|
||||
//returns true if the current user is logged in and is the owner of this document / revision
|
||||
root.isOwner = function (document) {
|
||||
var currentUser = Auth.getCurrentUser();
|
||||
if (!currentUser || !document || !document.owner)
|
||||
return false;
|
||||
|
||||
return document.owner._id == currentUser._id;
|
||||
}
|
||||
|
||||
//looks up this revision in the document revisions list
|
||||
//and returns the previous revision
|
||||
//if this is the oldest revision, then just return itself
|
||||
root.previousRevision = function (document, revision) {
|
||||
//find the index of the revision in documents
|
||||
var index = _.findIndex(document.revisions, '_id');
|
||||
var prevIndex = index-1;
|
||||
if (prevIndex < 0)
|
||||
prevIndex = 0;
|
||||
|
||||
return document.revisions[prevIndex];
|
||||
}
|
||||
//looks up this revision in the document revisions list
|
||||
//and returns the previous revision
|
||||
//if this is the oldest revision, then just return itself
|
||||
root.nextRevision = function (document, revision) {
|
||||
//find the index of the revision in documents
|
||||
var index = _.findIndex(document.revisions, '_id');
|
||||
var prevIndex = index+1;
|
||||
if (prevIndex >= document.revisions.size())
|
||||
prevIndex = document.revisions.size()-1;
|
||||
|
||||
return document.revisions[prevIndex];
|
||||
}
|
||||
|
||||
|
||||
return root;
|
||||
});
|
@ -1,3 +0,0 @@
|
||||
table.revisions {
|
||||
column-gap: 2em;
|
||||
}
|
@ -1,7 +1,8 @@
|
||||
'use strict';
|
||||
|
||||
angular.module('markdownFormatWdiffApp')
|
||||
.controller('DocumentIndexCtrl', function ($scope, $routeParams, $http, Auth, $location) {
|
||||
.controller('DocumentIndexCtrl', function ($scope, $routeParams, $http, Auth, $location, App) {
|
||||
$scope.App = App;
|
||||
$scope.title = 'Documents';
|
||||
|
||||
$scope.documents = [];
|
||||
@ -25,11 +26,10 @@ angular.module('markdownFormatWdiffApp')
|
||||
$http.post('/api/documents', {title: $scope.newDocumentTitle})
|
||||
.success(function(newDocument) {
|
||||
$scope.documents.push(newDocument);
|
||||
//and document view page
|
||||
$location.path('/'+newDocument._id);
|
||||
//skip redirecting to document view page
|
||||
//$location.path('/'+newDocument._id);
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
$scope.json = function (object) { return JSON.stringify(object, null, " "); };
|
||||
})
|
||||
|
@ -4,8 +4,8 @@ nav(ng-include='"components/elements/header.html"')
|
||||
|
||||
.container
|
||||
.row(ng-show='isLoggedIn()')
|
||||
.col-lg-9.col-md-12
|
||||
form.form-inline
|
||||
.col-lg-0.col-md-12
|
||||
form.form-inline.controls.well
|
||||
.form-group
|
||||
label(for='title-input')
|
||||
| New Document
|
||||
@ -14,29 +14,39 @@ nav(ng-include='"components/elements/header.html"')
|
||||
| Create
|
||||
|
||||
.row
|
||||
.col-lg-6.col-md-12(ng-repeat='document in documents | orderBy:"currentRevision.created":true' )
|
||||
.col-md-6.col-sm-12(ng-repeat='document in documents | orderBy:"currentRevision.created":true' )
|
||||
.center-block
|
||||
h1
|
||||
a(href='/{{document._id}}')
|
||||
{{document.title}}
|
||||
| {{document.title}}
|
||||
a.btn.btn-default.pull-right(href='/{{document._id}}/revision/new')
|
||||
| New rev
|
||||
a.btn.btn-default.pull-right(ng-hide='document.revisions.length<=1', href='/wdiff/{{document.revisions[1]._id}}/{{document.currentRevision._id}}')
|
||||
| Wdiff all
|
||||
div.indent
|
||||
p(ng-hide='App.isOwner(document)')
|
||||
span
|
||||
| Owner:
|
||||
span
|
||||
| {{document.owner.name}}
|
||||
table.revisions
|
||||
tr
|
||||
th.state State
|
||||
th.created revision
|
||||
tr(ng-repeat='revision in document.revisions | orderBy:"created":true | limitTo:5' )
|
||||
th.created Revision
|
||||
//th.wdiff(colspan='2') Wdiff With
|
||||
tr(ng-repeat='revision in document.revisions | orderBy:"created":true | limitTo:5' ng-hide='$last')
|
||||
td.state {{revision.state}}
|
||||
td.created
|
||||
h4
|
||||
a(href='/{{document._id}}/revision/{{revision._id}}')
|
||||
{{revision.created}}
|
||||
//div
|
||||
p
|
||||
| State:
|
||||
{{document.currentRevision.state}}
|
||||
p
|
||||
| Updated:
|
||||
{{document.currentRevision.created}}
|
||||
//these aren't working great
|
||||
//td.wdiff.prev
|
||||
a.btn.btn-default(ng-hide='$last', href='/wdiff/{{App.previousRevision(document, revision)._id}}/{{revision._id}}') Prev
|
||||
//td.wdiff.curr
|
||||
a.btn.btn-default(ng-hide='$first', href='/wdiff/{{revision._id}}/{{document.currentRevision._id}}') Current
|
||||
//pre
|
||||
{{json(document)}}
|
||||
{{App.json(document)}}
|
||||
|
||||
|
||||
footer(ng-include='"components/elements/footer.html"')
|
@ -1,7 +1,8 @@
|
||||
'use strict';
|
||||
|
||||
angular.module('markdownFormatWdiffApp')
|
||||
.controller('DocumentRevisionNewCtrl', function ($scope, $routeParams, $http, Auth, $location) {
|
||||
.controller('DocumentRevisionNewCtrl', function ($scope, $routeParams, $http, Auth, $location, App) {
|
||||
$scope.App = App;
|
||||
$scope.title = '';
|
||||
$scope.subtitle = '';
|
||||
|
||||
@ -12,14 +13,6 @@ angular.module('markdownFormatWdiffApp')
|
||||
$scope.getCurrentUser = Auth.getCurrentUser;
|
||||
$scope.isLoggedIn = Auth.isLoggedIn;
|
||||
|
||||
$scope.isOwner = function () {
|
||||
var currentUser = Auth.getCurrentUser();
|
||||
if (!currentUser || !$scope.revision || !$scope.revision.owner)
|
||||
return false;
|
||||
|
||||
return $scope.revision.owner._id == currentUser._id;
|
||||
};
|
||||
|
||||
var path = '/api/documents/' + $routeParams.id;
|
||||
$http.get(path).success(function(document) {
|
||||
$scope.document = document;
|
||||
@ -30,7 +23,6 @@ angular.module('markdownFormatWdiffApp')
|
||||
|
||||
|
||||
$scope.saveRevision = function() {
|
||||
alert(JSON.stringify($scope.revision))
|
||||
//save the revision to the document
|
||||
$http.post('/api/documents/'+$routeParams.id+'/revisions', $scope.revision)
|
||||
.success(function(newRevision) {
|
||||
@ -39,5 +31,4 @@ angular.module('markdownFormatWdiffApp')
|
||||
});
|
||||
};
|
||||
|
||||
$scope.json = function (object) { return JSON.stringify(object, null, " "); };
|
||||
})
|
||||
|
@ -5,7 +5,7 @@ nav(ng-include='"components/elements/header.html"')
|
||||
.container
|
||||
.row
|
||||
.col-lg-6.col-md-12
|
||||
form
|
||||
form.controls
|
||||
h4
|
||||
{{document.title}} - {{revision.created}}
|
||||
.form-group
|
||||
|
@ -1,7 +1,8 @@
|
||||
'use strict';
|
||||
|
||||
angular.module('markdownFormatWdiffApp')
|
||||
.controller('DocumentRevisionCtrl', function ($scope, $routeParams, $http, Auth) {
|
||||
.controller('DocumentRevisionCtrl', function ($scope, $routeParams, $http, Auth, App) {
|
||||
$scope.App = App;
|
||||
$scope.revision = {};
|
||||
|
||||
$scope.title = '';
|
||||
@ -20,11 +21,11 @@ angular.module('markdownFormatWdiffApp')
|
||||
}
|
||||
|
||||
//returns true if this revision is the current revision in its document
|
||||
$scope.isCurrent = function () {
|
||||
if (!$scope.revision)
|
||||
$scope.isCurrent = function (revision) {
|
||||
if (!revision)
|
||||
return false;
|
||||
|
||||
return $scope.revision._id == $scope.revision.document.currentRevision;
|
||||
return revision._id == revision.document.currentRevision;
|
||||
}
|
||||
|
||||
var path = '/api/documents/'+$routeParams.id+'/revisions/' + $routeParams.revisionid;
|
||||
@ -34,6 +35,5 @@ angular.module('markdownFormatWdiffApp')
|
||||
$scope.subtitle = $scope.isCurrent() ? " (current)":(" ("+$scope.revision.created+")");
|
||||
});
|
||||
|
||||
$scope.json = function (object) { return JSON.stringify(object, null, " "); };
|
||||
|
||||
})
|
||||
|
@ -6,8 +6,18 @@ nav(ng-include='"components/elements/header.html"')
|
||||
.row
|
||||
//span(ng-show='isCurrent()')
|
||||
| Current revision
|
||||
a.btn.btn-primary(ng-hide='isCurrent()' href='/wdiff/{{revision._id}}/{{revision.document.currentRevision}}')
|
||||
| wdiff current
|
||||
form.form-inline.controls.well
|
||||
|
||||
a.btn.btn-primary(ng-hide='App.isFirst(revision)' href='/{{revision.document._id}}/revision/{{App.previousRevision(revision.document, revision)._id}}')
|
||||
| View Previous
|
||||
//a.btn.btn-primary(ng-hide='App.isFirst()' href='/wdiff/{{App.previousRevision(revision.document, revision)._id}}/{{revision._id}}')
|
||||
| Wdiff from Previous
|
||||
//a.btn.btn-primary(ng-hide='App.isCurrent()' href='/wdiff/{{revision._id}}/{{App.nextRevision(revision.document, revision)._id}}')
|
||||
| Wdiff to Next
|
||||
a.btn.btn-primary(ng-hide='App.isCurrent(revision)' href='/{{revision.document._id}}/revision/{{App.nextRevision(revision.document, revision)._id}}')
|
||||
| View Next
|
||||
a.btn.btn-primary.pull-right(ng-hide='App.isCurrent(revision)' href='/wdiff/{{revision._id}}/{{revision.document.currentRevision}}')
|
||||
| Wdiff to Current
|
||||
|
||||
.row
|
||||
.col-lg-6.col-md-9
|
||||
|
@ -1,7 +1,8 @@
|
||||
'use strict';
|
||||
|
||||
angular.module('markdownFormatWdiffApp')
|
||||
.controller('DocumentShowCtrl', function ($scope, $routeParams, $http, Auth) {
|
||||
.controller('DocumentShowCtrl', function ($scope, $routeParams, $http, Auth, App) {
|
||||
$scope.App = App;
|
||||
$scope.document = {};
|
||||
$scope.title = '';
|
||||
|
||||
@ -23,6 +24,17 @@ angular.module('markdownFormatWdiffApp')
|
||||
$scope.title = document.title;
|
||||
});
|
||||
|
||||
$scope.json = function (object) { return JSON.stringify(object, null, " "); };
|
||||
//looks up this revision in the document revisions list
|
||||
//and returns the previous revision
|
||||
//if this is the oldest revision, then just return itself
|
||||
$scope.previousRevision = function (revision) {
|
||||
//find the index of the revision in documents
|
||||
var index = _.findIndex($scope.document.revisions, '_id');
|
||||
var prevIndex = index-1;
|
||||
if (prevIndex < 0)
|
||||
prevIndex = 0;
|
||||
|
||||
return $scope.document.revisions[prevIndex];
|
||||
}
|
||||
|
||||
})
|
||||
|
@ -3,27 +3,37 @@ nav(ng-include='"components/navbar/navbar.html"')
|
||||
nav(ng-include='"components/elements/header.html"')
|
||||
|
||||
.container
|
||||
.row(ng-show='isOwner()')
|
||||
.row
|
||||
.col-lg-12
|
||||
form
|
||||
a.btn.btn-primary(href='/{{document._id}}/revision/new')
|
||||
| New Revision
|
||||
|
||||
|
||||
.row
|
||||
.col-lg-6.col-md-9.center-block
|
||||
.col-lg-6.col-sm-12
|
||||
form.form-inline.controls.well(ng-show='App.isOwner(document)')
|
||||
a.btn.btn-primary(href='/{{document._id}}/revision/new')
|
||||
| New Revision
|
||||
|
||||
table.revisions
|
||||
tr
|
||||
th.state State
|
||||
th.created revision
|
||||
tr(ng-repeat='revision in document.revisions | orderBy:"created":true | limitTo:5' )
|
||||
th.created Revision
|
||||
tr(ng-repeat='revision in document.revisions | orderBy:"created":true' ng-hide='$last' )
|
||||
td.state {{revision.state}}
|
||||
td.created
|
||||
h4
|
||||
a(href='/{{document._id}}/revision/{{revision._id}}')
|
||||
{{revision.created}}
|
||||
//pre
|
||||
| {{json(revision)}}
|
||||
//these aren't working great
|
||||
//td.wdiff.prev
|
||||
a.btn.btn-default(ng-hide='$last', href='/wdiff/{{App.previousRevision(document, revision)._id}}/{{revision._id}}') Prev
|
||||
//td.wdiff.curr
|
||||
a.btn.btn-default(ng-hide='$first', href='/wdiff/{{revision._id}}/{{document.currentRevision._id}}') Current
|
||||
|
||||
.col-lg-6.col-sm-12
|
||||
div(btf-markdown='document.currentRevision.content')
|
||||
|
||||
//pre.col-lg-6
|
||||
| {{json(document)}}
|
||||
|
||||
|
||||
footer(ng-include='"components/elements/footer.html"')
|
@ -1,7 +1,8 @@
|
||||
'use strict';
|
||||
|
||||
angular.module('markdownFormatWdiffApp')
|
||||
.controller('DocumentWdiffCtrl', function ($scope, $routeParams, $http, Auth) {
|
||||
.controller('DocumentWdiffCtrl', function ($scope, $routeParams, $http, Auth, App) {
|
||||
$scope.App = App;
|
||||
$scope.wdiff = '';
|
||||
$scope.title = '';
|
||||
$scope.same = false;
|
||||
@ -10,24 +11,8 @@ angular.module('markdownFormatWdiffApp')
|
||||
|
||||
$scope.getCurrentUser = Auth.getCurrentUser;
|
||||
$scope.isLoggedIn = Auth.isLoggedIn;
|
||||
/*
|
||||
//returns true if the current user is logged in and is the owner of this document / revision
|
||||
$scope.isOwner = function () {
|
||||
var currentUser = Auth.getCurrentUser();
|
||||
if (!currentUser || !$scope.revision || !$scope.revision.owner)
|
||||
return false;
|
||||
|
||||
return $scope.revision.owner._id == currentUser._id;
|
||||
}
|
||||
|
||||
//returns true if this revision is the current revision in its document
|
||||
$scope.isCurrent = function () {
|
||||
if (!$scope.revision)
|
||||
return false;
|
||||
|
||||
return $scope.revision._id == $scope.revision.document.currentRevision._id;
|
||||
}
|
||||
*/
|
||||
var path = '/api/documents/wdiff/'+$routeParams.revisionida+'/'+$routeParams.revisionidb;
|
||||
$http.get(path).success(function(result) {
|
||||
$scope.result = result;
|
||||
@ -39,6 +24,5 @@ angular.module('markdownFormatWdiffApp')
|
||||
$scope.subtitle = "wdiff: "+result.a.created + " / " + result.b.created;
|
||||
});
|
||||
|
||||
$scope.json = function (object) { return JSON.stringify(object, null, " "); };
|
||||
|
||||
})
|
||||
|
@ -161,6 +161,7 @@ exports.showRevision = function(req, res) {
|
||||
.findById(req.params.revisionid)
|
||||
.populate('owner', '_id name')
|
||||
.populate('document', '_id title currentRevision')
|
||||
.populate('document.revisions', '_id')
|
||||
.exec(function (err, revision) {
|
||||
if(err) { return handleError(res, err); }
|
||||
if(!revision) { return res.send(404); }
|
||||
|
@ -205,7 +205,7 @@ function rewriteWdiffMarkdown(source) {
|
||||
// |([ \t]+[0-9]+\.) - numeric lists
|
||||
// )?
|
||||
// [ \t]+ - trailing whitespace
|
||||
var PREFIX = /^([ \t]*\>)*(([ \t]*#*)|([ \t]+[\*\+-])|([ \t]+[0-9]+\.))?[ \t]+/
|
||||
var PREFIX = /^([ \t]*\>)*(([ \t]*#*)|([ \t]*[\*\+-])|([ \t]*[\d]+\.))?[ \t]+/
|
||||
//var PREFIX = /^#*/
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user