Skip to content
Browse files

finished with the profile view, starting the sharing of code

  • Loading branch information...
1 parent 676ad42 commit dc1ab078be2b61baef986a6281bfd297b5468fe8 @matthewfl committed Dec 11, 2010
Showing with 98 additions and 10 deletions.
  1. +19 −4 Bespin/control.js
  2. +2 −1 db.notes
  3. +5 −3 front-end.js
  4. +63 −0 sandbox/build.js
  5. +9 −2 static/profile.html
View
23 Bespin/control.js
@@ -118,6 +118,13 @@
"description": "Change user, profile and sharing settings",
"pointer": "#profileCommand",
"params": []
+ },
+ {
+ "ep": "command",
+ "name": "reload_check",
+ "pointer":"#reloadCheck",
+ "params":[],
+ "key": "ctrl_r"
}
]
});
@@ -134,6 +141,7 @@ var loadFile="";
var loadValue = env.editor.value;
var fileList=[];
var hostList=[];
+var publicList=[];
var userName=null;
var userPass=null;
@@ -376,6 +384,7 @@ exports.loginCommand = function (args,request) {
Ajax.Call('list', function(data) {
fileList = data[0];
hostList = data[1];
+ publicList = data[2];
hostList.pop();
});
Ajax.send();
@@ -401,7 +410,7 @@ exports.profileCommand = function (args, request) {
if(!userToken) { alert("you need to login for this command"); return request.done("Not logedin"); }
$.facebox('<div id="profile" class="bespin">Loading...</div>');
Ajax.Call("profile-data", function (data) {
- $("#profile").html('Name: <input id="Pname" type="input" style="width: 90%; color:#000;"><hr>Email:<input id="Pemail" type="input" style="width: 90%; color: #000;"><hr>Profile: (<a href="http://jsapp.us/p/'+userName+'" target="_blank">view profile</a>)<br><textarea id="Pprofile" rows="12" style="color: #000; width: 98%;"></textarea><div style="width: 30%;"> </div><input type="button" value="save" id="profileSave" style="width: 95%; display: inline;">');
+ $("#profile").html('Display name: <input id="Pname" type="input" style="width: 90%; color:#000;"><hr>Email:<input id="Pemail" type="input" style="width: 90%; color: #000;"><hr>Profile: (<a href="http://jsapp.us/p/'+userName+'" target="_blank">view profile</a>)<br><textarea id="Pprofile" rows="12" style="color: #000; width: 98%;"></textarea><div style="width: 30%;"> </div><input type="button" value="save" id="profileSave" style="width: 95%; display: inline;">');
$("#Pname").val(data.name || userName);
$("#Pemail").val(data.email);
@@ -412,8 +421,9 @@ exports.profileCommand = function (args, request) {
"name": $("#Pname").val(),
"email": $("#Pemail").val(),
"markdown": $("#Pprofile").val()
- }, function () {
- alert("profile saved");
+ }, function (d) {
+ if(d)
+ alert("profile saved");
});
Ajax.send();
});
@@ -445,7 +455,7 @@ exports.shareCommand = function (args, request) {
"file": loadFile
}, function (b) {
if(b.ok) {
- request.done('Code shared at: <a href="http://jsapp.us/s/'+b.num+'">http://jsapp.us/s/'+b.num+'</a>');
+ request.done('Code shared at: <a href="http://jsapp.us/s/'+b.num+'" target="_blank">http://jsapp.us/s/'+b.num+'</a>');
location.hash="s"+b.num;
}else{
request.done("Failed to share code");
@@ -466,6 +476,11 @@ exports.sidebarCommand = function () {
window.sideBar(null);
};
+exports.reloadCheck = function () {
+ if(confirm("Are you sure that you want to reload the page\nDoing so will log you out"))
+ location.reload();
+};
+
var Ajax = {
View
3 db.notes
@@ -13,4 +13,5 @@ prefixes:
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
+ setting_name_[user] display name of user
+ lsPublic_[user] List of files that the user has shared
View
8 front-end.js
@@ -8,7 +8,7 @@ var server = router.getServer();
var db = require('./db');
var config = require('./config');
var async = require('./lib/async').async;
-var Makrdown = (new (require('./lib/showdown').Showdown.converter)).makeHtml;
+var Markdown = (new (require('./lib/showdown').Showdown.converter)).makeHtml;
var sandbox = require('./sandbox');
@@ -37,9 +37,10 @@ var ajaxActions = {
async([
[
function () { db.get("lsFs_"+user, this); },
- function () { db.get("lsOwn_"+user, this); }
+ function () { db.get("lsOwn_"+user, this); },
+ function () { db.get("lsPublic_"+user, this); }
],
- function () { back([(this[0] || "").split("*"), (this[1] || "").split("*")]); }
+ function () { back([(this[0] || "").split("*"), (this[1] || "").split("*"), (this[2] || "").split("*")]); }
]);
},
save: function (data, user, back) {
@@ -155,6 +156,7 @@ var ajaxActions = {
db.set("setting_name_"+user, data.name);
db.set("email_"+user, data.email);
db.set("profile_"+user, data.markdown);
+ back(true);
}
};
View
63 sandbox/build.js
@@ -2,6 +2,69 @@ var db = require('../db');
var jsmin = require('../lib/jsmin').jsmin;
var modules = require('./modules');
+function builder (user, code, back) {
+ this.back = back;
+ this.user = user;
+ this.need = {};
+ this.pub = {};
+ this.code = {};
+ this.counter=1;
+ this.require(code);
+ this.code._ = jsmin("",code,1);
+ this.count();
+}
+
+builder.prototype.require = function (code) {
+ code.replace(/require\s*?\((.*?)\)/g, function (r, v) {
+ try {
+ console.log(v);
+ var name = v.replace(/\"(.*)\"|\'(.*)\'/, function (r) { return r.substring(1,r.length-1); });
+ if(typeof this.need[name] != "undefined") {
+ this.need[name] = false;
+ this.searcher(name);
+ }
+ }catch(e) {
+ throw "Require needs to be static";
+ }
+ return r;
+ });
+};
+
+builder.prototype.searcher = function (name) {
+ if(name.indexOf("./") == 0) {
+ this.counter++;
+ (function (name,self) {
+ db.get("fs_"+user+"_"+name.substring(2), function (code) {
+ self.code[name] = code ? jsmin("",code,1) : "throw '"+name+" not found';";
+ self.count();
+ });
+ })(name, this);
+ }else if(typeof modules[name] != "undefined") {}
+ else if(name.indexOf('/') != -1) {
+ var user = a.substring(0,a.indexOf('/'));
+ var file = a.substring(a.indexOf('/')+1);
+ if(typeof this.pub[user] != "undefined") {
+ if(this.pub[user].indexOf(file) != -1) {
+
+ }else{
+ this.error
+ }
+ }else{
+ (function (user, self) {
+ db.get("lsPublic_"+user, function (data) {
+ self.pub[user] = data;
+ });
+ })(user, this);
+ }
+ }else
+ this.code[name] = 'throw "Module '+name+' not found";';
+};
+
+builder.prototype.count = function () {
+ if(!--this.counter)
+ this.back(this.code);
+};
+
exports.build = function (code, user, back) {
var ret={};
var need={};
View
11 static/profile.html
@@ -22,23 +22,30 @@
<h3>{USER}</h3>
</center>
<hr>
- <div id="domains">
+ <h4><center>Applications</center></h4>
+ <div id="domains" class="push_1">
{SUBDOMAIN}
+ <div class="break"> </div>
</div>
</div>
<div class="grid_9">
<div class="alpha"> </div>
<div class="grid_6">
<center><h2>{NAME}</h2></center>
</div>
+ <div class="clear"> </div>
<hr>
<div class="grid_9">
{MARKDOWN}
</div>
<div class="omega"> </div>
</div>
+ <div class="clear"> </div>
+ <div class="grid_12">
+ <hr>
+ <center><small><small>This profile is powered by <a href="http://jsapp.us">JSApp.US</a> | Think that you can make a better profile view, <a href="https://github.com/matthewfl/node-host" target="_blank">JSApp.US is open source</a></small></small></center>
+ </div>
</div>
- <div class="break"> </div>
<script type="text/javascript">
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;

0 comments on commit dc1ab07

Please sign in to comment.
Something went wrong with that request. Please try again.