File size: 3,266 Bytes
97a6ab5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# CS26 — Computer-Science Dataset + Portal

This repo contains:

- **A Hugging Face Dataset**: `CS26/Computer-Science`
- **A Hugging Face Space (portal)**: `CS26/cs26-portal` (Gradio)

The portal is live at:

- Direct app URL: `https://cs26-cs26-portal.hf.space/`
- Space page: `https://huggingface.co/spaces/CS26/cs26-portal`

## Authentication (no tokens in repos)

Do **not** hardcode any `hf_...` tokens in code or commit them to git.

Use the Hugging Face CLI to store your token **locally**:

```powershell
hf auth login --force
hf auth whoami
```

This stores credentials in your user profile cache and lets `huggingface_hub` authenticate automatically.

## Portal (Space) — `cs26-portal/app.py`

Features:

- **RTL + Hebrew UI** (including mixed Hebrew / Latin in search headings)
- Folder navigation with breadcrumbs
- **Stateful refresh and deep links**: current folder is stored in the **`?path=`** query string (URL-encoded), with **`#`** kept in sync for refresh-friendly navigation, plus a **`localStorage`** copy for resilience
- Search within current folder subtree
- File actions on click:
  - **PDF**: downloads immediately
  - **ZIP/archives**: download immediately
  - **Office (doc/docx/ppt/pptx)**: opens OfficeApps viewer in a **new tab**, and shows a preview pane with “הורדה” + “תצוגה (Office)”
  - **Images**: in-page preview + download link
  - **Text/code (txt/c/...)**: in-page preview + download link
- **Prepare Folder ZIP**: builds a ZIP from the dataset via `snapshot_download` / temp zip; status and errors are shown in a **status** markdown area next to the download widget
- **Direct Hugging Face downloads**: filenames with Hebrew (or other non-ASCII) may still appear percent-encoded in some browsers when downloading straight from `huggingface.co` URLs; the app uses best-effort `<a download>` where applicable

### Deploy the Space

From repo root:

```powershell
python .\upload_space.py
```

### Troubleshooting

- **Search shows nothing**: search is scoped to the **current folder subtree**; navigate into a year or topic folder first, or clear the search box and use **רענון** after changing folders.
- **ZIP errors or long waits**: large folders download many files from Hugging Face first; watch the status markdown under the ZIP button for progress or a Python traceback if something fails.
- **Blank preview for images**: raster previews are embedded as data URIs when needed; if something still fails, use the dataset **resolve** link from the preview panel.

## Dataset uploader — `upload_to_hf.py`

Uploads the local folder to the dataset repo **in batches of 10 files** with retry/resume.

It excludes:

- `.git/**`
- `cs26-portal/**`
- `upload_to_hf.py`, `upload_space.py`

Run:

```powershell
python .\upload_to_hf.py
```

Optional environment variables:

- `HF_REPO_ID` (default `CS26/Computer-Science`)
- `HF_LOCAL_FOLDER` (default `c:\GitRepos\Computer-Science`)
- `HF_BATCH_SIZE` (default `10`)
- `HF_RETRY_SLEEP_SECONDS` (default `5`)

## Rollback safety

Local repo has:

- tag: `backup-before-portal-fixes`
- branch: `backup/current-state`

Space repo has:

- tag: `backup-before-portal-fixes`
- branch: `backup/current-state`
- tag: `latest` pointing at current `main` HEAD