Rewrite docs
[blerg.git] / www / js / blerg.js
index 737d84c..dcb5679 100644 (file)
@@ -104,7 +104,7 @@ LoginStatus.prototype.post = function(msg) {
             if (j && j.status == 'success') {
                 $('post.content').value = '';
                 if (location.hash != '#' + this.username) {
-                    location.hash = this.username;
+                    location.href = '/#' + this.username;
                     hashSwitch();
                 } else {
                     currentPager.itemCount++;
@@ -247,10 +247,14 @@ function mangleRecord(record, template) {
     record.data = record.data.replace('&', '&amp;').replace('<', '&lt;').replace('>', '&gt');
 
     // Turn HTTP URLs into links
-    record.data = record.data.replace(/(\s|^)(https?:\/\/[a-zA-Z0-9.-]*[a-zA-Z0-9](\/(\S*[^.!,;?()\s])?)?)/g, '$1<a href="$2">$2</a>');
+    record.data = record.data.replace(/(\s|^)(https?:\/\/[a-zA-Z0-9.-]*[a-zA-Z0-9](\/([^\s"]*[^.!,;?()\s])?)?)/g, '$1<a href="$2">$2</a>');
 
     // Turn markdown links into links
-    record.data = record.data.replace(/(\s|^)\[([^\]]+)\]\((https?:\/\/[a-zA-Z0-9.-]*[a-zA-Z0-9](\/[^)]*?)?)\)/, '$1<a href="$3">$2</a>');
+    record.data = record.data.replace(/(\s|^)\[([^\]]+)\]\((https?:\/\/[a-zA-Z0-9.-]*[a-zA-Z0-9](\/[^)"]*?)?)\)/, '$1<a href="$3">$2</a>');
+
+    // Turn *foo* into italics and **foo** into bold
+    record.data = record.data.replace(/(\s)\*\*([^*]+)\*\*(\s)/, '$1<b>$2</b>$3');
+    record.data = record.data.replace(/(\s)\*([^*]+)\*(\s)/, '$1<i>$2</i>$3');
 
     // Turn refs and tags into links
     record.data = record.data.replace(/(\s|^)#(\w+)/g, '$1<a href="#tag/$2">#$2</a>');
@@ -353,7 +357,7 @@ function signup() {
         },
         onSuccess: function(r) {
             $('signup').hide();
-            location.hash = username;
+            location.href = '/#' + username;
             hashSwitch();
 
             loginStatus.login(username, password);