Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
  • 3 commits
  • 3 files changed
  • 0 comments
  • 1 contributor
Jul 02, 2012
Chris Dent add status.js to edit.html 72626d6
Chris Dent Use /status.js (tiddlyweb.status var)
for determining space, host and permissions
5f2bf77
Chris Dent If /status.js has filled tiddlyweb.status, use that
Avoids a calls to /spaces if not required.
14d62b4
2  edit.html
@@ -56,5 +56,7 @@
56 56
 <script
57 57
 src="http://tiddlyspace.com/bags/edit_extra/tiddlers/edit.js"></script>
58 58
 <!--script src="edit.js"></script--!>
  59
+<!--script src="http://cdent.tiddlyspace.com/status.js"></script--!>
  60
+<script src="/status.js"></script>
59 61
 <script src="/bags/common/tiddlers/backstage.js"></script>
60 62
 </html>
39  edit.js
@@ -10,8 +10,9 @@ var recentTags = new Set()
10 10
     , currentFields = {}
11 11
     , currentBag
12 12
     , startHash = adler32('')
13  
-    , host
14  
-    , space
  13
+    , space = tiddlyweb.status.space.name
  14
+    , host = tiddlyweb.status.server_host.scheme + '://' + space + '.' +
  15
+        tiddlyweb.status.server_host.host + '/'
15 16
     , publicIcon = 'bags/tiddlyspace/tiddlers/publicIcon'
16 17
     , privateIcon = 'bags/tiddlyspace/tiddlers/privateIcon'
17 18
     , extracludeRE = /^.extraclude (.+?)$([\s\S]*?)^.extraclude$/mg;
@@ -478,35 +479,13 @@ function init() {
478 479
                     }
479 480
     });
480 481
 
481  
-    var url = '/status'
482  
-        , genHost = false;
483  
-    if (window.location.href.match(/^file:/)) {
484  
-        // for dev
485  
-        url = 'http://cdent.tiddlyspace.com/status';
486  
-        genHost = true;
487  
-    }
  482
+    var recipe = tiddlyweb.status.space.recipe;
488 483
 
489  
-    $.ajax({
490  
-        dataType: 'json',
491  
-        url: url,
492  
-        success: function(data) {
493  
-            space = data.space.name;
494  
-            host = '/';
495  
-            if (genHost) {
496  
-                host = data.server_host.scheme + '://'
497  
-                    + space + '.' + data.server_host.host + '/';
498  
-            }
499  
-            if (data.username === 'GUEST') {
500  
-                guestPage();
501  
-            } else {
502  
-                $.ajax({
503  
-                    url: host + 'spaces/' + space + '/members',
504  
-                    success: changes,
505  
-                    error: guestPage,
506  
-                });
507  
-            }
508  
-        }
509  
-    });
  484
+    if (recipe.match(/_private$/)) {
  485
+        changes();
  486
+    }else {
  487
+        guestPage();
  488
+    }
510 489
 }
511 490
 
512 491
 init();
26  editedit.js
@@ -10,15 +10,25 @@ $(document).ready(function() {
10 10
 
11 11
     // don't show edit link if tiddler is not in this space
12 12
     if (bagInfo[0] !== space) return;
  13
+
  14
+    function addLink() {
  15
+        $("<a id='editLink' />").attr('href'
  16
+            , '/edit#' + encodeURIComponent(title))
  17
+            .text("edit tiddler").prependTo(place);
  18
+    }
13 19
     
14 20
     // add edit link if user is member
15  
-    $.ajax({ url: "/spaces/" + space + "/members",
16  
-        success: function(r) {
17  
-            if(r) {
18  
-                $("<a id='editLink' />").attr('href'
19  
-                    , '/edit#' + encodeURIComponent(title))
20  
-                    .text("edit tiddler").prependTo(place);
21  
-            }
  21
+    if (tiddlyweb && tiddlyweb.status) {
  22
+        if (tiddlyweb.space.recipe.match(/_private$/)) {
  23
+            addLink();
22 24
         }
23  
-    });
  25
+    } else {
  26
+        $.ajax({ url: "/spaces/" + space + "/members",
  27
+            success: function(r) {
  28
+                if(r) {
  29
+                    addLink();
  30
+                }
  31
+            }
  32
+        });
  33
+    }
24 34
 });

No commit comments for this range

Something went wrong with that request. Please try again.