Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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

…lder. /public/ folder is only for generated content.
  • Loading branch information...
commit 4480d23a092eb2ddd38c849296f3b3d84a693b63 1 parent 69321c9
@Marak Marak authored
View
2,272 .gitignore
2,272 additions, 0 deletions not shown
View
81 bin/server
@@ -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
99 lib/articles.js
@@ -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
7 lib/docs.js
@@ -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
15 lib/generators/article.js
@@ -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
15 lib/generators/home.js
@@ -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
15 lib/generators/toc.js
@@ -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
48 lib/tags.js
@@ -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;
- });
-};
View
18 outlines/regular-expressions-in-js-outline
@@ -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
64 public/index.htm
@@ -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>
View
84 public/list.htm
@@ -1,84 +0,0 @@
-<html>
-<head>
-<title>NodeDocs</title>
-<script src="/dnode.js"></script>
-<style>
-li {
- padding-left:5px;
-}
-</style>
-</head>
-<body>
- <h1>List of articles:</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;
- 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 />");
- });
- }
-
- var build_tree = function (articles, paths) {
- var tree = {};
- var temp = null;
- for (var i = 0; i < articles.length; ++i) {
- var keys = paths[i].split('/');
- temp = tree;
- for (var j = 1; j < keys.length; ++j) {
- if (j === keys.length-1) {
- temp[keys[j]] = articles[i];
- }
- if (temp[keys[j]] === undefined) {
- temp[keys[j]] = {};
- }
- temp = temp[keys[j]]
- }
- }
- return tree;
- }
-
- var render_tree = function (tree, depth) {
- if (depth === undefined) {
- depth = 0;
- }
- var str = ""
- for (key in tree){
- switch(typeof tree[key]) {
- case 'string':
- str += "<li><a href='#' onclick='loadArticle(\""+tree[key]+"\")'>"+tree[key]+"</a></li>";
- break;
- case 'object':
- var html = "h" + (depth+1) + ">";
- str += "<ul><"+html + key + "</"+html + render_tree(tree[key], depth+1) + "</ul>";
- }
- }
- return str;
- }
-
- DNode.connect(function (remote_) {
- remote = remote_;
- remote.getArticleList(function (err, articles, paths) {
- if (err) {
- document.getElementById("list-of-articles").innerHTML = err;
- return;
- }
- var tree = build_tree(articles, paths);
- document.getElementById("list-of-articles").innerHTML = render_tree(tree);
- });
- });
- }
-</script>
-</html>
View
92 tags/tags.json
@@ -1,92 +0,0 @@
-{
- "Filesystem": {},
- "JSHINT": {},
- "JSLINT": {},
- "JSON": {},
- "REST": {},
- "SSL": {},
- "XML": {},
- "addons": {},
- "arguments": {},
- "argument parsing": {},
- "browser": {},
- "callbacks": {},
- "child processes": {},
- "code coverage": {},
- "command line tools": {},
- "community": {},
- "config.json": {},
- "control flow": {
- "description": "The order in which functions execute"
- },
- "convention": {
- "description": "A coding convention which is used in the node.js community"
- },
- "core": {
- "description": "A core node.js API method or module."
- },
- "dameon": {},
- "debugging": {},
- "deployment": {},
- "dnode": {},
- "dual-sided": {},
- "error message": {},
- "eval": {},
- "eventemitter": {
- "description": "The event emitter class for node.js"
- },
- "files": {
- "description": "Interacting with files and the filesystem"
- },
- "forms": {},
- "git": {},
- "github": {
- "description": "The Github.com social coding website"
- },
- "globals": {
- "description": "Global variables in node.js"
- },
- "hashing": {},
- "http": {},
- "https": {},
- "irc": {},
- "iterators": {},
- "javascript": {},
- "logging": {},
- "modules": {},
- "multi-part file uploads": {},
- "npm": {},
- "package.json": {
- "description": "The package.json format for node.js applications"
- },
- "pkginfo": {},
- "process": {
- "description": "The event emitter class for node.js"
- },
- "processes": {},
- "proxying": {},
- "repl": {
- "description": "An interactive read-eval-print-loop for writing node.js code"
- },
- "require": {
- "description": "The require module for node.js"
- },
- "reverse proxy": {},
- "runInNewContext": {},
- "self": {},
- "signals": {},
- "socket.io": {},
- "sockets": {},
- "streams": {
- "description": "A stream as defined in node.js"
- },
- "tcp": {},
- "testing": {},
- "that": {},
- "this": {},
- "timers": {},
- "twitter": {},
- "udp": {},
- "uploads": {},
- "v8": {}
-}
View
1  theme/article.html
@@ -0,0 +1 @@
+<div id ="article"></div>
View
0  public/fonts/AllerLt.ttf → theme/fonts/AllerLt.ttf
File renamed without changes
View
0  public/fonts/typewriter.ttf → theme/fonts/typewriter.ttf
File renamed without changes
View
0  public/img/logo.png → theme/img/logo.png
File renamed without changes
View
0  public/img/right.png → theme/img/right.png
File renamed without changes
View
3  theme/index.html
@@ -0,0 +1,3 @@
+<div id = "home">
+
+</div>
View
0  public/nodedocs.css → theme/nodedocs.css
File renamed without changes
View
2  public/toc.html → theme/toc.html
@@ -4,7 +4,7 @@
<link rel="stylesheet" href="nodedocs.css" type="text/css" media="screen" title="no title" charset="utf-8">
<header>
- <div class="title">nodedocs.org</div>
+ <div class="title">docs.nodejitsu.com </div>
</header>
<script type="text/javascript" charset="utf-8" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
Please sign in to comment.
Something went wrong with that request. Please try again.