Permalink
Browse files

improved readme style in the sample app.

  • Loading branch information...
miccolis committed Sep 16, 2011
1 parent 2b0c212 commit 2548674315f1434d3153556717938a29fcb25d4c
Showing with 29 additions and 3 deletions.
  1. +10 −2 examples/simple/assets/stylesheets/style.css
  2. +19 −1 examples/simple/models/Project.server.bones
@@ -4,7 +4,7 @@
}
#header ul {
- width: 640px;
+ width: 800px;
margin: 0px auto;
}
#header ul li {
@@ -19,6 +19,14 @@
}
#page {
- width: 640px;
+ width: 800px;
margin: 0px auto;
}
+
+pre {
+ border: 1px solid #666;
+ background: #ffb;
+ color: #666;
+ padding: 5px;
+ overflow: auto;
+}
@@ -36,9 +36,13 @@ models.Project.prototype.sync = function(method, model, options) {
for (var i = 0; i < files.length; i++) {
var match = re.exec(files[i]);
if (match) {
- // Found a README! Send it out!
fs.readFile(projectDir +'/'+ match.input, 'utf8', function(err, data) {
if (err) return callback('Could not retrieve project information.');
+ // It's safe to assume old school REAMEs are manually
+ // wrapped at ~80 chars, but these kids...
+ if (match[1] && match[1] !== '.txt') {
+ data = wrap(data);
+ }
resp.readme = data;
callback();
});
@@ -56,3 +60,17 @@ models.Project.prototype.sync = function(method, model, options) {
});
});
};
+
+var wrap = function(str) {
+ var lines = [];
+ _(str.split(/\n/)).each(function(v) {
+ if (v.length > 80) {
+ var parts = v.match(/.{80}|.+$/g);
+ lines.push(parts.join('\n'));
+ } else {
+ lines.push(v);
+ }
+ });
+
+ return lines.join('\n');
+};

0 comments on commit 2548674

Please sign in to comment.