Permalink
Browse files

[major] Removed all old codebase. Moved static assets into /theme/ fo…

…lder. /public/ folder is only for generated content.
  • Loading branch information...
1 parent 69321c9 commit 4480d23a092eb2ddd38c849296f3b3d84a693b63 @Marak Marak committed Aug 24, 2011
View
2,272 .gitignore

Large diffs are not rendered by default.

Oops, something went wrong.
View
@@ -1,81 +0,0 @@
-var dnode = require('dnode'),
- fs = require('fs'),
- connect = require('connect'),
- markdown = require('markdown'),
- http = require('http');
-
-var tags = require('../lib/tags'),
- articles = require('../lib/articles');
-
-// This gets the article data and parses the markdown
-var getGuide = function (name, callback) {
- var obj = articles[name].metadata;
- obj.content = markdown.parse(articles[name].article);
-
- callback(null, obj);
-}
-
-// This gets the list of articles with a specific tag
-var getGuides = function (tagId, callback) {
- if (tags.tagid[tagId] == undefined) {
- return callback("Undefined tag");
- }
- else {
- return callback(null, tags.tagid[tagId]);
- }
-}
-
-// This gets the list of tags
-var getTags = function (callback) {
- return callback(null, tags.names);
-}
-
-var getArticleList = function (callback) {
- var list = [];
- var paths = [];
- for (article in articles) {
- list.push(article);
- paths.push(articles[article].path);
- }
- callback(null, list, paths);
-}
-
-var server = connect.createServer();
-
-server.use(function(req, res, next) {
- if (req.url==="/") {
- req.url = "/index.html";
- }
- next();
-});
-
-server.use(connect.static(__dirname+"/../public"));
-server.listen(8080);
-console.log("Main server is running on: http://localhost:8080/");
-
-dnode({
- getGuide: getGuide,
- getGuides: getGuides,
- getTags: getTags,
- getArticleList: getArticleList
-}).listen(server);
-
-
-console.log("POST echo server is running on: http://localhost:1337");
-http.createServer(function (req, res) {
- var str = '';
- req.on('data', function (chunk) {
- str += chunk;
- });
- req.on('end', function () {
- res.writeHead(200, {'Content-Type': 'text/plain'});
- res.end(str);
- });
-}).listen(1337);
-
-
-console.log("HEADER echo server is running on: http://localhost:1338");
-http.createServer(function (req, res) {
- res.writeHead(200, {'Content-Type': 'text/plain'});
- res.end(req.headers.custom);
-}).listen(1338);
View
@@ -1,99 +0,0 @@
-var async = require('async'),
- fs = require('fs'),
- findit = require('findit'),
- path = require('path'),
- tags = require('./tags');
-
-// Holds all the articles in this manner:
-// <article name:> {
-// article: <article data>,
-// metadata: <metadata obj>
-var articles = {};
-
-// This sets up the article object
-// NOTE: if this is ever taking too much memory, the solution is to create a set of `getter`s,
-// that grab from a cache and the hard directory on cache misses. Unlikely to become an issue though.
-var generate_article_list = function (callback) {
- var finder = findit.find(__dirname+'/../articles'),
- done = false, current_requests = 0,
- errors = [];
-
- //When there are no pending requests and the `end` event has been emitted,
- // call the callback
- var finish = function () {
- if (current_requests === 0 && done) {
- if (errors.length === 0) {
- errors = null;
- }
- callback(errors);
- }
- }
-
- // Tranverse the `articles` directory and for each file:
- finder.on('file', function (file) {
-
- // if its an article,
- // get the article name which is the directory the file is in
- // read the file and set `articles[name].article = file`
- if (path.basename(file) === 'article.md') {
- var article_name = path.basename(path.dirname(file));
- ++current_requests;
- fs.readFile(file, 'utf8', function (err, data) {
- --current_requests;
- if (err) {
- errors.push(err);
- return finish();
- }
- articles[article_name] = articles[article_name] || {};
- articles[article_name].article = data;
- articles[article_name].path = path.dirname(path.normalize(file).replace(path.normalize(__dirname+"/../articles"), ""));
- finish()
- });
- }
-
- // if its metadata,
- // get the article name which is the directory the file is in
- // read+parse the file and set `articles[name].metadata = file`
- if (path.basename(file) === 'metadata.json') {
- var article_name = path.basename(path.dirname(file));
- ++current_requests;
- fs.readFile(file, 'utf8', function (err, data) {
- --current_requests;
- if (err) {
- errors.push(err);
- return finish();
- }
- articles[article_name] = articles[article_name] || {};
-
- try {
- var json = JSON.parse(data);
- } catch (e) {
- errors.push(new Error("Invalid json file: " + file));
- return finish();
- }
-
- articles[article_name].metadata = json;
- finish();
- });
- }
- });
-
- finder.on('end', function () {
- done = true;
- finish();
- });
-}
-
-//Regenerate article data once a minute
-var article_generator = function () {
- generate_article_list(function (err) {
- if (err) {
- console.log(err);
- }
- tags.regenerate_tag_data();
- setTimeout(article_generator, 60000);
- });
-}
-article_generator();
-
-module.exports = articles;
View
@@ -15,6 +15,13 @@ var docs = {},
docs = exports;
+
+docs.generators = {
+ article: require('./generators/article'),
+ home: require('./generators/home'),
+ toc: require('./generators/toc')
+};
+
docs.generateTOC = function () {
var articles = docs.getArticles();
View
@@ -0,0 +1,15 @@
+var article = exports;
+
+article.weld = function(data, dom) {
+
+ // perform weld
+
+ return dom;
+
+};
+
+article.generate = function(data, dom) {
+
+ // write all articles
+
+};
View
@@ -0,0 +1,15 @@
+var home = exports;
+
+home.weld = function(data, dom) {
+
+ // perform weld
+
+ return dom;
+
+};
+
+home.generate = function(data, dom) {
+
+ // write toc to file system
+
+};
View
@@ -0,0 +1,15 @@
+var toc = exports;
+
+toc.weld = function(data, dom) {
+
+ // perform weld
+
+ return dom;
+
+};
+
+toc.generate = function(data, dom) {
+
+ // write toc to file system
+
+};
View
@@ -1,48 +0,0 @@
-var async = require('async'),
- fs = require('fs');
- articles = require('./articles');
-
-exports.tagid = {};
-exports.names = [];
-
-// this generated the tags structure
-exports.regenerate_tag_data = function () {
- // reset the old data without setting the variable (so we reference the same object)
- exports.names.length = 0
- for (name in exports.tagid) {
- delete exports.tagid[name];
- }
-
- for (article in articles) {
- if ( articles[article].metadata === undefined) {
- console.log(article, 'has no `metadata.json` file');
- continue;
- }
-
- if ( articles[article].article === undefined) {
- console.log(article, 'has no `article` file');
- continue;
- }
-
- // for each tag, add the article to the list of articles that reference it
- var tags = articles[article].metadata.tags;
- for(var i = 0; i < tags.length; ++i) {
- if (exports.tagid[tags[i]] === undefined) {
- exports.tagid[tags[i]] = [];
- }
- exports.tagid[tags[i]].push(article);
- }
- }
-
- // generate a list of tags
- for (tag in exports.tagid) {
- exports.names.push(tag);
- }
- exports.names.sort(function (a,b) {
- if (a.toLowerCase() < b.toLowerCase()) {
- return -1;
- }
-
- return 1;
- });
-};
@@ -1,18 +0,0 @@
-# How do I use Regular Expressions in Node.js/Javascript?
-
-Node implements the same built-in Regular Expression methods as standard JavaScript, which can be quite useful for string matching.
-
-- Describe the `RegExp()` Object and its constructor, implicit and explicit instatiation, both static and dynamic.
-- Describe the evils of the need to double-escape regular strings passed into the `RegExp()` constructor.
-- Mention Evil Regexes briefly when mentioning dynamic regexes.
-- Some Regular Expression functions are String methods; others are RegExp methods.
- - String.match(RegExp) - Tests `RegExp` against the provided string, and returns an array of results.
- - Describe the RegExp.test(string) method - returns a matched/not matched boolean.
- - RegExp.exec(string) - pretty much the same as String.match(RegExp)
- - String.replace()
- - Basic syntax - myString.replace(/re/, 'replacement')
- - Replacement with backreferences ($1, $2, $`, $', etc.)
- - Replacement by callback
-- Describe what JS Regex doesn't do - no lookbehind, no atomic grouping, no named capture groups, no conditionals
-- Maybe mention a situation where using regex would be a bad idea
-
View
@@ -1,64 +0,0 @@
-<html>
-<head>
-<title>NodeDocs</title>
-<script src="/dnode.js"></script>
-</head>
-<body>
- <h1>List of all tags:</h1>
- <div id="list-of-tags"></div><br />
- <h1>List of articles with tag `<span id="current-tag"></span>`:</h1>
- <div id="list-of-articles"></div><br />
- <h1>Contents of Article `<span id="current-article"></span>`:</h1>
- <div id="article"></div>
-</body>
-<script>
- window.onload = function () {
- var remote = null;
- loadTag = function (tag) {
- document.getElementById("current-tag").innerHTML = tag;
- remote.getGuides(tag, function (err, list) {
- if (err) {
- document.getElementById("list-of-articles").innerHTML = err;
- return;
- }
- document.getElementById("list-of-articles").innerHTML = "";
- for (var i = 0; i < list.length; ++i) {
- document.getElementById("list-of-articles").innerHTML +=
- "<a href='#' onclick='loadArticle(\""+list[i]+"\")'>"+list[i]+"</a> ";
- }
- });
- }
-
- loadArticle = function (article) {
- remote.getGuide(article, function (err, guide) {
- document.getElementById("current-article").innerHTML = article;
- if (err) {
- document.getElementById("article").innerHTML = err;
- return;
- }
- var article_ = guide.content;
- delete guide.content;
- document.getElementById("article").innerHTML = JSON.stringify(guide) +
- "<br /><br />" +article_.replace("\\n","<br />");
- });
- }
-
-
-
- DNode.connect(function (remote_) {
- remote = remote_;
- remote.getTags(function (err, tags) {
- if (err) {
- document.getElementById("list-of-tags").innerHTML = err;
- return;
- }
-
- for (var i = 0; i < tags.length; ++i) {
- document.getElementById("list-of-tags").innerHTML +=
- "<a href='#' onclick='loadTag(\""+tags[i]+"\")'>"+tags[i]+"</a> ";
- }
- });
- });
- }
-</script>
-</html>
Oops, something went wrong.

0 comments on commit 4480d23

Please sign in to comment.