Permalink
Browse files

Merge branch 'master' into theme

  • Loading branch information...
2 parents b4f6c90 + 3266e2b commit 98ff08eea023472c436c9d740b020f9119655fb1 @bennage committed Mar 26, 2012
Showing with 78 additions and 67 deletions.
  1. +0 −50 lib/data.js
  2. +4 −4 lib/routes.js
  3. +9 −9 lib/table.js
  4. +1 −1 public/javascripts/client.js
  5. +1 −1 public/stylesheets/style.styl
  6. +61 −0 test/config.specs.js
  7. +2 −2 test/viewhelpers.specs.js
View
@@ -1,50 +0,0 @@
-var fs = require('fs'),
- path = require('path');
-
-// yes, sync is evil!
-
-var data_file = './data/data',
- hash_table = loadSync();
-
-console.log('reading data from file');
-console.dir(hash_table);
-
-function getCommentsFor(documentId, callback) {
-
- if (!hash_table[documentId]) {
- hash_table[documentId] = {};
- }
-
- callback(null, hash_table[documentId]);
-}
-
-function saveCommentFor(documentId, comment) {
- if (!hash_table[documentId]) {
- hash_table[documentId] = {};
- }
-
- if (!comment.id) throw new Error('cannot save a comment without an id');
-
- hash_table[documentId][comment.id] = comment;
-
- persist();
-}
-
-function persist() {
- var data = JSON.stringify(hash_table);
- fs.writeFile(data_file, data, 'utf8');
-}
-
-function loadSync() {
- if (path.existsSync(data_file)) {
- var data = fs.readFileSync(data_file, 'utf8');
- return JSON.parse(data);
- } else {
- return {};
- }
-}
-
-module.exports = {
- saveCommentFor: saveCommentFor,
- getCommentsFor: getCommentsFor
-};
View
@@ -29,28 +29,28 @@ module.exports = {
handleComment: function(req, res) {
var documentId = req.params.file,
- commentId = req.params.commentId;
+ hash = req.params.commentId;
// only an admin can set this flag
if (req.context.user.__pundit_role__ !== 'admin') {
res.send(403);
}
- store.handleComment(documentId, commentId);
+ store.handleComment(documentId, req.context.user.__pundit_id__ + hash);
res.send(200);
},
deleteComment: function(req, res) {
var documentId = req.params.file,
- commentId = req.params.commentId;
+ hash = req.params.commentId;
// only an admin can set this flag
if (req.context.user.__pundit_role__ !== 'admin') {
res.send(403);
}
- store.deleteComment(documentId, commentId);
+ store.deleteComment(documentId, req.context.user.__pundit_id__ + hash);
res.send(200);
},
View
@@ -1,5 +1,4 @@
-var uuid = require('node-uuid'),
- azure = require('azure');
+var azure = require('azure');
var config = require('./config');
@@ -13,9 +12,9 @@ var settings = {},
var service = azure.ServiceClient,
TableQuery = azure.TableQuery;
-var partition = 'part1';
-var tableName = 'config';
-var rowKey = 'default';
+var partition = 'part1',
+ tableName = 'config',
+ rowKey = 'default';
var client = azure.createTableService();
@@ -95,12 +94,13 @@ function saveCommentFor(file, comment) {
comment.RowKey = comment.author_login + comment.hash;
//todo: replace with insertOrReplaceEntity
-client.queryEntity(table, partition, comment.RowKey, function(err, result) {
+ client.queryEntity(table, partition, comment.RowKey, function(err, result) {
if (err && err.code === 'ResourceNotFound') {
client.insertEntity(table, comment, function(err) {
- if (err) console.dir(err);console.log('comment saved');
+ if (err) console.dir(err);
+ console.log('comment saved');
});
} else {
@@ -109,7 +109,7 @@ client.queryEntity(table, partition, comment.RowKey, function(err, result) {
console.log('comment updated');
});
}
- });
+ });
}
function handleComment(file, commentId) {
@@ -175,4 +175,4 @@ module.exports = {
getCommentsFor: getCommentsFor,
handleComment: handleComment,
deleteComment: deleteComment
-};
+};
@@ -1,6 +1,6 @@
(function() {
- var elems = 'h1,h2,h3,h4,h5,h6,p,img',
+ var elems = 'h1,h2,h3,h4,h5,h6,p,img,li',
root = '#for-review',
focus = null,
context = '',
@@ -102,7 +102,7 @@ body
position absolute
width 16px
height 16px
- margin-left -24px
+ left 6px
#for-review
background-color paper
View
@@ -0,0 +1,61 @@
+var assert = require('assert');
+
+var config = require('../lib/config');
+
+// specifications indicating what the application
+// expects to find in the configuration file
+module.exports = {
+
+ 'AZURE_STORAGE_ACCOUNT': function() {
+ // the name of the Azure storage account
+ assert.equal(typeof config.AZURE_STORAGE_ACCOUNT, 'string');
+ },
+
+ 'AZURE_STORAGE_ACCESS_KEY': function() {
+ // the primary access key of the Azure storage account
+ assert.equal(typeof config.AZURE_STORAGE_ACCESS_KEY, 'string');
+ },
+
+ 'administrators': function() {
+ // an array containing the ids of the administrators
+ // there should be at least one administrator
+ // ids are in the form [provider]__[username]
+ // e.g., github__bennage
+ assert.ok(config.administrators.length > 0);
+ },
+
+ 'source.repo': function() {
+ // the name of the github repository
+ // in the form of [username]/[reponame]
+ // or similarly [organization]/[reponame]
+ assert.ok(config.source);
+ assert.equal(typeof config.source.repo, 'string');
+ },
+
+ 'source.ignore': function() {
+ // an array of files to be ignore in the repo
+ // e.g., ['.gitignore','readme.md']
+ // if no files are ignored, provide empty array []
+ assert.ok(config.source);
+ assert.ok(config.source.ignore);
+ assert.ok(config.source.ignore.length);
+ },
+
+ 'github auth': function() {
+ // required for github authenticaton
+ assert.equal(typeof config.github.appId, 'string');
+ assert.equal(typeof config.github.appSecret, 'string');
+ },
+
+ 'facebook auth': function() {
+ // required for facebook authenticaton
+ assert.equal(typeof config.facebook.appId, 'string');
+ assert.equal(typeof config.facebook.appSecret, 'string');
+ },
+
+ 'twitter auth': function() {
+ // required for twitter authenticaton
+ assert.equal(typeof config.twitter.consumerKey, 'string');
+ assert.equal(typeof config.twitter.consumerSecret, 'string');
+ }
+};
@@ -64,13 +64,13 @@ module.exports = {
});
},
- 'helper exposes login when user is present': function() {
+ 'helper exposes the pundit-specific login when user is present': function() {
testHelper(function(helper) {
var request = {
context: {
user: {
- login: 'some_user'
+ __pundit_id__: 'some_user'
}
}
};

0 comments on commit 98ff08e

Please sign in to comment.