Linkding + SingleFile Test

Version 11.1 by XWikiGuest on 2026/03/11 20:49
Warning
For security reasons, the document is displayed in restricted mode as it is not the current version. There may be differences and errors due to this.

Linkding + SingleFile Test

Bookmarks met archief-viewer. Klik op het archief-icoon om de opgeslagen versie te bekijken.

#ldsf-wrapper {
  display: flex;
  flex-direction: column;
  gap: 0;
}
#ldsf-bookmarks {
  color: #ebebeb;
}
#ldsf-bookmarks ul {
  list-style: none;
  padding: 0;
}
#ldsf-bookmarks li {
  padding: 6px 12px;
  background: #2b3e50;
  border-left: 3px solid #df691a;
  border-radius: 0 4px 4px 0;
  margin: 4px 0;
  display: flex;
  align-items: center;
  gap: 8px;
}
#ldsf-bookmarks li:hover { background: #3b4e60; }
#ldsf-bookmarks a { color: #5bc0de; text-decoration: none; }
#ldsf-bookmarks a:hover { color: #df691a; }
#ldsf-bookmarks .sf-btn {
  cursor: pointer;
  background: #4e5d6c;
  border: none;
  color: #5bc0de;
  padding: 2px 8px;
  border-radius: 3px;
  font-size: 14px;
  flex-shrink: 0;
}
#ldsf-bookmarks .sf-btn:hover { background: #df691a; color: #fff; }
#ldsf-bookmarks .sf-btn.active { background: #df691a; color: #fff; }

#ldsf-viewer-container {
  display: none;
  margin-top: 10px;
  border: 1px solid #4e5d6c;
  border-radius: 4px;
  overflow: hidden;
  background: #1a2a3a;
}
#ldsf-viewer-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 12px;
  background: #2b3e50;
  color: #6b7c8d;
  font-size: 13px;
}
#ldsf-viewer-bar .close-btn {
  cursor: pointer;
  background: none;
  border: none;
  color: #d9534f;
  font-size: 18px;
  padding: 0 4px;
}
#ldsf-viewer-bar .close-btn:hover { color: #ff6b6b; }
#ldsf-viewer-frame {
  width: 100%;
  height: 70vh;
  border: none;
  background: #fff;
}
#ldsf-status { color: #6b7c8d; font-size: 13px; margin-bottom: 8px; }
Laden...
...
var LDSF_LINKDING_URL = 'https://bookmarks.rhebergen.org/api/bookmarks/';
var LDSF_TOKEN = '3b7443e0f84e2b2b269adebb96d7475e4a5e653e';
var LDSF_TAG = 'Nuclear-&-Energy';
var LDSF_COUNT = 20;
var LDSF_SHARE = 'eT2X9ttBHK5GoEY';
var LDSF_WEBDAV = 'https://cloud.rhebergen.org/public.php/webdav/';
var LDSF_AUTH = 'Basic ' + btoa(LDSF_SHARE + ':');
var ldsf_urlToFile = {};
var ldsf_archiveMap = {};

function ldsfFindArchive(url) {
  var v = [url, url.replace(/\/$/, ''), url + '/', url.replace(/\?.*$/, '')];
  for (var i = 0; i < v.length; i++) { if (ldsf_urlToFile[v[i]]) return ldsf_urlToFile[v[i]]; }
  return null;
}

function ldsfOpen(idx) {
  var f = ldsf_archiveMap[idx];
  if (f) ldsfShowArchive(f);
}

function ldsfShowArchive(filename) {
  document.getElementById('ldsf-viewer-title').textContent = filename.replace(/\.html?$/i, '');
  document.getElementById('ldsf-viewer-container').style.display = 'block';
  var frame = document.getElementById('ldsf-viewer-frame');
  frame.srcdoc = '

Laden...

'; fetch(LDSF_WEBDAV + encodeURIComponent(filename), { headers: { 'Authorization': LDSF_AUTH } }) .then(function(r) { return r.text(); }) .then(function(html) { frame.srcdoc = html; }) .catch(function(err) { frame.srcdoc = '

Fout: ' + err.message + '

'; }); } function ldsfCloseViewer() { document.getElementById('ldsf-viewer-container').style.display = 'none'; } function ldsfLoadBookmarks() { var apiUrl = LDSF_LINKDING_URL + '?limit=' + LDSF_COUNT + '&q=%23' + encodeURIComponent(LDSF_TAG); fetch(apiUrl, { headers: { 'Authorization': 'Token ' + LDSF_TOKEN } }) .then(function(r) { return r.json(); }) .then(function(data) { var total = data.count || 0; var archiveCount = 0; var container = document.getElementById('ldsf-bookmarks'); var html = '
  • '; (data.results || []).forEach(function(bm, idx) { var title = bm.title || bm.website_title || bm.url; var fname = ldsfFindArchive(bm.url); if (idx < 3) console.log('BM[' + idx + ']:', bm.url, '-> match:', fname); if (fname) { archiveCount++; ldsf_archiveMap[String(idx)] = fname; } html += '
  • '; if (fname) html += '📄'; html += '' + title + ''; }); html += '
'; container.innerHTML = html; document.getElementById('ldsf-status').textContent = total + ' bookmarks, ' + archiveCount + ' met archief'; }) .catch(function(err) { document.getElementById('ldsf-status').textContent = 'Fout: ' + err.message; }); } // Global click handler for archive buttons document.addEventListener('click', function(e) { var el = e.target; if (el && el.getAttribute && el.getAttribute('data-sfidx') !== null) { var idx = el.getAttribute('data-sfidx'); console.log('Archive button clicked, idx:', idx, 'file:', ldsf_archiveMap[idx]); if (ldsf_archiveMap[idx]) ldsfShowArchive(ldsf_archiveMap[idx]); } }, true); // Debug test button document.getElementById('ldsf-test-btn').addEventListener('click', function() { alert('archiveMap: ' + JSON.stringify(ldsf_archiveMap) + '\nurlToFile: ' + JSON.stringify(ldsf_urlToFile)); }); // Load index then bookmarks fetch(LDSF_WEBDAV + 'index.json', { headers: { 'Authorization': LDSF_AUTH } }) .then(function(r) { return r.ok ? r.json() : {}; }) .then(function(idx) { console.log('SingleFile index loaded:', idx); Object.keys(idx).forEach(function(f) { ldsf_urlToFile[idx[f]] = f; }); ldsfLoadBookmarks(); }) .catch(function(err) { console.log('SingleFile index FAILED:', err); ldsfLoadBookmarks(); });