79 points · by mckoss · 15y ago · 41 comments
#!/usr/bin/ruby -rcgi
H,B=%w'HomePage w7.cgi?n=%s';c=CGI.new'html4';n,d=c['n']!=''?c['n']:H,c['d'];t=`xx
cat #{n}`;d!=''&&`echo #{t=CGI.escapeHTML(d)} >#{n}`;c.instance_eval{out{h1{n}+
a(B%H){H}+pre{t.gsub(/([A-Z]\w+){2}/){a(B%$&){$&}}}+form("get"){textarea('d'){t
}+hidden('n',n)+submit}}}
http://www.joe-bowers.com/static/mirror/thisHackWasNotProper...Then you probably wouldn't title your article, "in XXX lines of code". But the author of this particular author did, so it's assumed that he considers this to be a big achievement. technomancy merely points out that this is not really an amazing achievement.
My point was with 80 lines of "purpose built" code - you can create a functioning wiki. But we do stand on the shoulders of giants - I hope I gave proper attribution.
The point is that you can create similar feats with a similarly small amount of code.
And let's not forget the millions of lines for the browser and the underlying operating system!
There's no point to mention how many lines of code it is, unless it's actually true.
Pageforest is still a work in progress, but I'd love to get more feedback on it if you'd like to try building your own apps on the platform.
Pageforest has a focus on building a multi-tenant application hub. I think of it as kind of distributed Google Docs infrastructure:
- Users' data is stored in a unified document store that is owned by the user. They can view and manage all their "documents" created from applications from one place. - They can use their Pageforest account to grant permissions to each application they want to use to write into their document store.
BTW - Pageforest is currently hosted as a Google AppEngine app - so it picks up the scalability benefits of BigTable with a datacenter managed by Google.
(1) Users sign in on the www.pageforest.com domain only. Applications are not given access to a users's credentials.
(2) Users must specifically grant access to each application for an app to write data on their behalf.
(3) We create an app-specific authentication token in the app sub-domain you are signed in to.
(4) To protect against cross-side request forgery (CSRF), we require the REFERER to be from the application domain (and NOT from the /docs sub-directory) for authenticated requests.
(5) Our authentication cookies are HTTP-Only. This makes is impossible for injected javascript to access the authentication cookie.
(6) Our app-based authentication cookies expire in 24 hours. Users can get a new cookie by re-authorizing the app from www.pageforest.com.
(7) We don't require ssl use for sign-in. This is probably our biggest security hole. But apps can be used on an SSL domain at https://appid.pageforest.appspot.com.
(8) We never transmit a user's password over the web - we use a challenge/response protocol that hashes the username/password on the client, and only sends the SHA1 of the user's response to a challenge.
Here's my take. WYSIWYG, AJAX, and no libraries in two lines:
<iframe src="javascript:unescape('%3Cbody%20contentEditable%3E')" style="width: 500px; height: 500px"></iframe>
<button onclick="var x=new XMLHttpRequest;x.open('POST','/update',1);x.setRequestHeader('Content-type','application/x-www-form-urlencoded');x.send(frames[0].innerHTML)">Save</button>
On JSBin: http://jsbin.com/ebiju3 (don't try saving, there's no server part here!)It's hairball.
http://www.aviary.com/viewfull?fguid=b6286c3c-228d-11e0-81ea...
I'm planning to extend this app (no longer just 80 lines), so it supports multiple pages PER WIKI. This will use the "Blob" storage feature of Pageforest. Each document has a top level JSON object intrinsic to it - but can have any number of child Blobs stored beneath it.
I'll also have to extend Showdown to enable auto-linking via CamelCase references.
In this case, the "edit" link looks exactly like a link (inline element with underlining and a different color when you hover over it), but it's a span instead. Why invent your own tags when they already exist? All you do is break things for people that aren't you. Follow the standards and everything will work for everyone. Make up your own, and you can only ensure that what you test works.
#include <stdio.h>-mel