Skip to content

Commit

Permalink
added a lot of basic files for the profile view, added some code to f…
Browse files Browse the repository at this point in the history
…ront-end, still working on it
  • Loading branch information
matthewfl committed Dec 11, 2010
1 parent fbeba07 commit 9677f79
Show file tree
Hide file tree
Showing 10 changed files with 1,498 additions and 3 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
@@ -0,0 +1,3 @@
[submodule "static/less"]
path = static/less
url = https://github.com/cloudhead/less.js.git
1 change: 1 addition & 0 deletions README
Expand Up @@ -4,6 +4,7 @@ This is the code base from http://jsapp.us
To get started developing To get started developing
Install nginx ( http://nginx.org/ ) and load in the config file from devel/nginx.conf Install nginx ( http://nginx.org/ ) and load in the config file from devel/nginx.conf
run: run:
git submodule update --init --recursive
ln -s dn.nstore.js db.js ln -s dn.nstore.js db.js
ln -s config.sample.js config.js ln -s config.sample.js config.js
python devel/HostRedirProxy.py python devel/HostRedirProxy.py
Expand Down
7 changes: 6 additions & 1 deletion db.notes
Expand Up @@ -8,4 +8,9 @@ prefixes:
lsOwn_[user]=[subHostName] List of subdomains that are owned by the user lsOwn_[user]=[subHostName] List of subdomains that are owned by the user
lsHost_[user]=[hostName] List of domains that are owned by user lsHost_[user]=[hostName] List of domains that are owned by user
share_# The code for shared code share_# The code for shared code
share_index The value of the last shared code, just use db.addInt to access share_index The value of the last shared code, just use db.addInt to access
login_[user] The hash of a user's password
email_[user] The user's password
profile_[user] The markdown from a user profile
setting_[type]_[user] General setting from the user
setting_name_[user] display name of user
47 changes: 45 additions & 2 deletions front-end.js
Expand Up @@ -8,6 +8,7 @@ var server = router.getServer();
var db = require('./db'); var db = require('./db');
var config = require('./config'); var config = require('./config');
var async = require('./lib/async').async; var async = require('./lib/async').async;
var Makrdown = (new (require('./lib/showdown').Showdown.converter)).makeHtml;


var sandbox = require('./sandbox'); var sandbox = require('./sandbox');


Expand Down Expand Up @@ -222,7 +223,8 @@ var indexFiles = {
shareBasePre: "", shareBasePre: "",
shareBasePost: "", shareBasePost: "",
shareNotFound: "/////////////////////////////////\n// The file could not be found //\n/////////////////////////////////", shareNotFound: "/////////////////////////////////\n// The file could not be found //\n/////////////////////////////////",
index: "" index: "",
profile: fs.readFileSync('./static/profile.html').toString()
}; };
indexFiles.index = indexFiles.raw.replace("{CODE}", indexFiles.head + indexFiles.indexExample); indexFiles.index = indexFiles.raw.replace("{CODE}", indexFiles.head + indexFiles.indexExample);
var shareBaseSplit = indexFiles.raw.replace("{CODE}", "\/*\n * This code was shared using JSApp.US\n *\/\n\n{CODE}").split("{CODE}"); var shareBaseSplit = indexFiles.raw.replace("{CODE}", "\/*\n * This code was shared using JSApp.US\n *\/\n\n{CODE}").split("{CODE}");
Expand All @@ -239,14 +241,55 @@ server.get(/\/s\/(.*)$/, function (req, res, match) {
res.writeHead(code ? 200:404, {"Content-type":"text/html"}); res.writeHead(code ? 200:404, {"Content-type":"text/html"});
res.write(indexFiles.shareBasePre); res.write(indexFiles.shareBasePre);
if(code) if(code)
res.write(code.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;")) res.write(code.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;"));
else else
res.write(indexFiles.shareNotFound); res.write(indexFiles.shareNotFound);
res.write(indexFiles.shareBasePost); res.write(indexFiles.shareBasePost);
res.end(); res.end();
}); });
}); });


server.get(/\/p\/(.*)$/, function (req, res, match) {
if(match.length < 2) return "User was not found";
var user = match;
async([
[
function () { db.get("lsOwn_"+user, this); },
function () { db.get("email_"+user, this); },
function () { db.get("setting_name_"+user, this); },
function () { db.get("profile_"+user, this); }
],
[
function () {
var i,ret="",l = this[0].split("*");
for(i=0;i<l.length-1;++i) {
ret += '<div class="site"><a href="http://'+l[i]+'.jsapp.us" target="_blank">'+l[i]+'</a></div>';
}
this(ret);
},
function () {
this(crypto.createHash('md5').update(this[1] || "").digest('hex'));
},
function () {
if(this[2])
this(this[2].replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;"));
else
this(user.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;"));
},
function () {
if(this[3])
this(Markdown(this[3].replace(/</g, "&lt;").replace(/>/g, "&gt;")));
else
this("You can create your profile using the profile command from the editor");
}
],
function () {
res.writeHead(200, {"Content-type": "text/html"});
res.write(indexFiles.profile.replace(/\{SUBDOMAIN\}/g, this[0]).replace(/\{EHASH\}/g, this[1])
}
]);
});



server.get(/\/error/, function (req, res) { server.get(/\/error/, function (req, res) {
res.writeHead(503, {"Content-Type": "text/html"}); res.writeHead(503, {"Content-Type": "text/html"});
Expand Down

0 comments on commit 9677f79

Please sign in to comment.