Permalink
Browse files

Separated out the client-side code, adapted to work better with npm 1.0

  • Loading branch information...
1 parent 2b8e083 commit bbf3bb8b5e682023196111552d54482d6f7f5299 Alex Young committed May 2, 2011
Showing with 68 additions and 69 deletions.
  1. +1 −0 .gitignore
  2. +3 −13 README.textile
  3. +9 −9 app.js
  4. +0 −45 public/javascripts/{application.js → documents.js}
  5. +10 −0 public/javascripts/flash.js
  6. +38 −0 public/javascripts/resize.js
  7. +7 −2 views/layout.jade
View
@@ -2,3 +2,4 @@
.DS_Store
tmp/*
log/*
+node_modules/
View
@@ -22,19 +22,9 @@ These are the libraries that the project requires:
* "Jade":http://jade-lang.com/
* "less":https://github.com/cloudhead/less.js
-This revision of the code has been tested with:
+See the package.json file for the versions of the dependencies I've tested with.
-* Node 0.2.4
-* Mongo 1.4.4 and 1.6.5
-* Mongoose 0.0.4
-* connect-mongodb 0.0.4
-* Express 1.0.0
-* Jade 0.6.0
-* Less 1.0.40
-* Stylus 0.5.1
-* node_mailer 0.4.52
-
-On Mac OS Snow Leopard and Debian Lenny.
+On Mac OS Snow Leopard and Debian Lenny/Squeeze.
h3. Dependency Installation
@@ -43,7 +33,7 @@ Make sure you're running a mongo instance (type <code>mongod</code> if required)
<pre>
git clone git@github.com:alexyoung/nodepad.git nodepad
cd nodepad
-npm install .
+npm install
node app.js
</pre>
View
18 app.js
@@ -1,13 +1,13 @@
-var express = require('express@2.2.2'),
- connect = require('connect@1.3.0'),
- jade = require('jade@0.10.4'),
+var express = require('express'),
+ connect = require('connect'),
+ jade = require('jade'),
app = module.exports = express.createServer(),
- mongoose = require('mongoose@1.2.0'),
- mongoStore = require('connect-mongodb@0.2.2'),
- mailer = require('mailer@0.4.52'),
- stylus = require('stylus@0.11.10'),
- markdown = require('markdown@0.2.1').markdown,
- connectTimeout = require('connect-timeout@0.0.1'),
+ mongoose = require('mongoose'),
+ mongoStore = require('connect-mongodb'),
+ mailer = require('mailer'),
+ stylus = require('stylus'),
+ markdown = require('markdown').markdown,
+ connectTimeout = require('connect-timeout'),
sys = require('sys'),
path = require('path'),
models = require('./models'),
@@ -258,49 +258,4 @@
.submit();
}
});
-
- // Correct widths and heights based on window size
- function resize() {
- var height = $(window).height() - $('#header').height() - 1,
- width = $('.content').width(),
- ov = $('.outline-view'),
- ed = $('#editor'),
- toolbar = $('.toolbar'),
- divider = $('.content-divider'),
- content = $('.content'),
- controls = $('#controls');
-
- $('#DocumentTitles').css({ height: height - toolbar.height() + 'px' });
- ov.css({ height: height + 'px' });
- toolbar.css({ width: ov.width() + 'px' });
-
- content.css({
- height: height - controls.height() + 'px',
- width: $('body').width() - ov.width() - divider.width() - 1 + 'px'
- });
-
- divider.css({ height: height + 'px' });
-
- ed.css({
- width: content.width() + 'px',
- height: content.height() - 22 - $('input.title').height() + 'px'
- }).focus();
-
- $('#controls').css({
- width: content.width() + 'px'
- });
- }
-
- function hideFlashMessages() {
- $(this).fadeOut();
- }
-
- setTimeout(function() {
- $('.flash').each(hideFlashMessages);
- }, 5000);
- $('.flash').click(hideFlashMessages);
-
- $(window).resize(resize);
- $(window).focus(resize);
- resize();
})();
@@ -0,0 +1,10 @@
+(function() {
+ function hideFlashMessages() {
+ $(this).fadeOut();
+ }
+
+ setTimeout(function() {
+ $('.flash').each(hideFlashMessages);
+ }, 5000);
+ $('.flash').click(hideFlashMessages);
+})();
@@ -0,0 +1,38 @@
+(function() {
+ // Correct widths and heights based on window size
+ function resize() {
+ var height = $(window).height() - $('#header').height() - 1,
+ width = $('.content').width(),
+ ov = $('.outline-view'),
+ ed = $('#editor'),
+ toolbar = $('.toolbar'),
+ divider = $('.content-divider'),
+ content = $('.content'),
+ controls = $('#controls');
+
+ $('#DocumentTitles').css({ height: height - toolbar.height() + 'px' });
+ ov.css({ height: height + 'px' });
+ toolbar.css({ width: ov.width() + 'px' });
+
+ content.css({
+ height: height - controls.height() + 'px',
+ width: $('body').width() - ov.width() - divider.width() - 1 + 'px'
+ });
+
+ divider.css({ height: height + 'px' });
+
+ ed.css({
+ width: content.width() + 'px',
+ height: content.height() - 22 - $('input.title').height() + 'px'
+ }).focus();
+
+ $('#controls').css({
+ width: content.width() + 'px'
+ });
+ }
+
+ $(window).resize(resize);
+ $(window).focus(resize);
+ resize();
+})();
+
View
@@ -24,8 +24,13 @@ html
input(name='s', value='Search')
!{flashMessages}
!= body
- script(type='text/javascript', src='/javascripts/application.js')
+ script(type='text/javascript', src='/javascripts/flash.js')
- if (typeof documents !== 'undefined')
+ script(type='text/javascript', src='/javascripts/documents.js')
+ script(type='text/javascript', src='/javascripts/resize.js')
script(type='text/javascript')
- Documents.refresh(!{JSON.stringify(documents)});
+ $(function() {
+ if (typeof Documents !== 'undefined')
+ Documents.refresh(!{JSON.stringify(documents)});
+ });

0 comments on commit bbf3bb8

Please sign in to comment.