]> gitweb.fluxo.info Git - semanticscuttle.git/commitdiff
Initial code for showing cached bookmarks feature/cache
authorSilvio Rhatto <rhatto@riseup.net>
Wed, 12 Aug 2015 13:49:40 +0000 (10:49 -0300)
committerSilvio Rhatto <rhatto@riseup.net>
Wed, 12 Aug 2015 13:49:47 +0000 (10:49 -0300)
data/config.default.php
data/templates/default/bookmarks.tpl.php

index 5e560a7de5b7339ab0a5da231cbf6ab53aae9e36..dd220ac2943b07594861f831486b624123071790 100644 (file)
@@ -778,4 +778,27 @@ $unittestUrl = null;
  */
 $allowUnittestMode = false;
 
+/***************************************************
+ * Caching support
+ *
+ * Use the following configuration if you want to provide a link
+ * to a cached copy of your bookmarks.
+ *
+ * Please note that these feature just provide the link if a cached
+ * copy exists.
+ *
+ * You should download SemanticScuttle bookmarks using a tool like
+ * https://git.sarava.org/?p=httruta.git
+ */
+
+/**
+ * Set to the filesystem folder where your bookmark cache resides.
+ */
+$cacheFolder = null;
+
+/**
+ * Set to the base public URL of you cache folder.
+ */
+$cacheUrl = null;
+
 ?>
index 2a3d1690424854887129db9e43a1f38cd6142f69..35bbcdbfdebc3fd95eac5110e0a7d6be229cd34f 100644 (file)
@@ -337,6 +337,20 @@ if ($currenttag!= '') {
                        }
                }
 
+    // Local cache
+    $cacheLink = null;
+    if ($GLOBALS['cacheFolder'] != null && $GLOBALS['cacheUrl'] != null) {
+      // Hashing discussion at http://linuxprocess.free.fr/MHonArc/Oct-2005/msg00016.html
+      $assetHash = sha1($row['bAddress'] . "\n");
+      $assetHash = substr($assetHash, 0, 2) . '/' . substr($assetHash, 2, 2) . '/' . $assetHash;
+      $assetFile = $GLOBALS['cacheFolder'] . '/' . $assetHash;
+
+      if (file_exists($assetFile)) {
+        $assetLink = $GLOBALS['cacheUrl'] . '/' . $assetHash;
+        $cacheLink = "| <a href=\"$assetLink\">Cache</a>";
+      }
+    }
+
                // Copy link
                if ($userservice->isLoggedOn()
             && ($currentUser->getId() != $row['uId'])
@@ -425,6 +439,7 @@ if ($currenttag!= '') {
             . $copy . "\n"
             . $edit . "\n"
             . $update . "\n"
+            . $cacheLink ."\n"
             . "  </div>\n";
                echo $privateNoteField != ''
             ? '    <div class="privateNote" title="'. T_('Private Note on this bookmark') .'">'.$privateNoteField."</div>\n"