rafmacalaba commited on
Commit
83bfa80
·
verified ·
1 Parent(s): d22f5a2

shared push token support

Browse files
Files changed (1) hide show
  1. review.html +16 -7
review.html CHANGED
@@ -76,9 +76,17 @@ footer .sp { flex: 1; }
76
  <button id="hubBtn" onclick="exp()">export</button>
77
  </footer>
78
  <script>
79
- let SINK = null, HFFUSER = null;
80
  fetch('./sink.json').then(r => r.ok ? r.json() : null).then(async j => {
81
- if (!j || !j.url) return;
 
 
 
 
 
 
 
 
82
  SINK = j.url.replace(/\/$/, '');
83
  paintLogin();
84
  try {
@@ -300,9 +308,10 @@ async function sinkCommit(entry) {
300
  return hubCommit(entry);
301
  }
302
  async function hubCommit(entry) {
303
- // static hosting has no ruling sink: commit straight to the public
304
- // dataset with the annotator's own write token (stored locally only).
305
- const tok = ($('hubtok').value || '').trim();
 
306
  if (!tok) return 'this browser only (add HF token to sync)';
307
  try {
308
  const repo = 'rafmacalaba/data-use-annotations';
@@ -328,8 +337,8 @@ async function pushAll() {
328
  // one read, merge every local ruling, one commit to your own file.
329
  // use after pasting your token, or to retry anything saved locally only.
330
  if (needName()) return;
331
- const tok = ($('hubtok').value || '').trim();
332
- if (!tok) { $('mine').textContent = 'paste your HF write token first (footer field)'; $('hubtok').focus(); return; }
333
  const btn = $('pushBtn');
334
  btn.disabled = true;
335
  try {
 
76
  <button id="hubBtn" onclick="exp()">export</button>
77
  </footer>
78
  <script>
79
+ let SINK = null, HFFUSER = null, SHAREDTOK = null;
80
  fetch('./sink.json').then(r => r.ok ? r.json() : null).then(async j => {
81
+ if (!j) return;
82
+ // Optional shared push token (see README: public repo = public token,
83
+ // scope it to data-use-annotations writes only, rotate after the round).
84
+ if (j.pushToken) {
85
+ SHAREDTOK = j.pushToken;
86
+ const h = $('hubtok');
87
+ if (h) h.style.display = 'none';
88
+ }
89
+ if (!j.url) return;
90
  SINK = j.url.replace(/\/$/, '');
91
  paintLogin();
92
  try {
 
308
  return hubCommit(entry);
309
  }
310
  async function hubCommit(entry) {
311
+ // commit straight to the public dataset: personal token first,
312
+ // else the shared push token from sink.json (public repo = public
313
+ // token: scope it to data-use-annotations writes only).
314
+ const tok = ($('hubtok').value || '').trim() || SHAREDTOK || '';
315
  if (!tok) return 'this browser only (add HF token to sync)';
316
  try {
317
  const repo = 'rafmacalaba/data-use-annotations';
 
337
  // one read, merge every local ruling, one commit to your own file.
338
  // use after pasting your token, or to retry anything saved locally only.
339
  if (needName()) return;
340
+ const tok = ($('hubtok').value || '').trim() || SHAREDTOK || '';
341
+ if (!tok) { $('mine').textContent = 'push unavailable — no shared token configured'; return; }
342
  const btn = $('pushBtn');
343
  btn.disabled = true;
344
  try {