Skip to content

Commit c3de1a5

Browse files
author
Magnus
committed
Initial commit with Biologie decks
0 parents  commit c3de1a5

7 files changed

Lines changed: 209 additions & 0 deletions

File tree

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
name: Generate Deck Index
2+
3+
on:
4+
push:
5+
branches: [ main, master ]
6+
pull_request:
7+
branches: [ main, master ]
8+
9+
jobs:
10+
generate-index:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout repository
15+
uses: actions/checkout@v4
16+
17+
- name: Install jq
18+
run: sudo apt-get install -y jq
19+
20+
- name: Generate index.json
21+
run: |
22+
# Start the JSON structure
23+
echo '{ "last_updated": "'$(date -u +"%Y-%m-%dT%H:%M:%SZ")'", "semesters": [] }' > index.json
24+
25+
# Loop through all directories (except hidden ones)
26+
for dir in */; do
27+
# Skip hidden folders and .github
28+
if [[ "$dir" == .*/ || "$dir" == ".github/" ]]; then
29+
continue
30+
fi
31+
32+
dirname=$(basename "$dir")
33+
echo "📁 Processing folder: $dirname"
34+
35+
# Check for meta.json for custom display name
36+
display_name="$dirname"
37+
if [ -f "${dir}meta.json" ]; then
38+
custom_name=$(jq -r '.display_name // empty' "${dir}meta.json" 2>/dev/null)
39+
if [ -n "$custom_name" ]; then
40+
display_name="$custom_name"
41+
fi
42+
fi
43+
44+
# Find all .apkg and .json deck files (not meta.json)
45+
files_json="[]"
46+
47+
for file in "$dir"*.apkg "$dir"*.json; do
48+
# Skip if no matches or if it's meta.json
49+
[ -e "$file" ] || continue
50+
[[ "$file" == *"meta.json" ]] && continue
51+
52+
filename=$(basename "$file")
53+
filepath="$file"
54+
55+
# Get file size in MB
56+
size_bytes=$(stat -f%z "$file" 2>/dev/null || stat -c%s "$file" 2>/dev/null)
57+
size_mb=$(echo "scale=2; $size_bytes / 1048576" | bc)
58+
59+
# Extract name without extension
60+
name="${filename%.*}"
61+
# Convert underscores and hyphens to spaces, capitalize
62+
pretty_name=$(echo "$name" | sed 's/[_-]/ /g' | awk '{for(i=1;i<=NF;i++) $i=toupper(substr($i,1,1)) tolower(substr($i,2))}1')
63+
64+
# Add to files array
65+
files_json=$(echo "$files_json" | jq \
66+
--arg path "$filepath" \
67+
--arg name "$pretty_name" \
68+
--arg size "$size_mb" \
69+
'. += [{"path": $path, "name": $name, "size_mb": ($size | tonumber)}]')
70+
71+
echo " 📄 Found: $filename ($size_mb MB)"
72+
done
73+
74+
# Only add semester if it has files
75+
file_count=$(echo "$files_json" | jq '. | length')
76+
if [ "$file_count" -gt 0 ]; then
77+
# Add this semester to the index
78+
tmp=$(mktemp)
79+
jq --arg name "$dirname" \
80+
--arg display "$display_name" \
81+
--argjson files "$files_json" \
82+
'.semesters += [{"name": $name, "display_name": $display, "files": $files}]' \
83+
index.json > "$tmp" && mv "$tmp" index.json
84+
85+
echo " ✅ Added $file_count files from $dirname"
86+
fi
87+
done
88+
89+
echo ""
90+
echo "📋 Generated index.json:"
91+
cat index.json | jq .
92+
93+
- name: Commit and push if changed
94+
run: |
95+
git config --local user.name 'OpenAnki Bot'
96+
git config --local user.email 'bot@openanki.app'
97+
git add index.json
98+
99+
# Only commit if there are changes
100+
if git diff --staged --quiet; then
101+
echo "No changes to index.json"
102+
else
103+
git commit -m "🔄 Auto-update deck index"
104+
git push
105+
fi

README.md

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
# 📚 OpenAnki Community Deck Repository
2+
3+
This is a template repository for sharing Anki flashcard decks with the OpenAnki community.
4+
5+
## 🚀 Quick Setup
6+
7+
1. **Use this template** - Click "Use this template" to create your own deck repository
8+
2. **Upload your decks** - Drag & drop `.apkg` files into semester/topic folders
9+
3. **Commit** - That's it! The index is auto-generated
10+
11+
## 📁 Structure
12+
13+
```
14+
/
15+
├── semester_1/
16+
│ ├── anatomy.apkg
17+
│ └── biochemistry.apkg
18+
├── semester_2/
19+
│ └── pharmacology.apkg
20+
└── index.json ← Auto-generated!
21+
```
22+
23+
## 📋 How It Works
24+
25+
1. **You add decks** to folders (create new folders as needed)
26+
2. **GitHub Actions** automatically scans all folders
27+
3. **index.json** is regenerated with the complete file list
28+
4. **OpenAnki users** add your repo and can browse/download decks
29+
30+
## ✨ Best Practices
31+
32+
- Use descriptive folder names (they become category titles)
33+
- Use underscores or hyphens in folder names: `semester_1` or `clinical-medicine`
34+
- Include deck subject in the filename: `anatomy_basics.apkg`
35+
- Keep individual decks under 50MB for fast downloads
36+
37+
## 🔧 Customization
38+
39+
### Custom Category Names
40+
41+
Create a `meta.json` in any folder to customize display:
42+
43+
```json
44+
{
45+
"display_name": "First Semester - Preclinical",
46+
"description": "Foundation courses"
47+
}
48+
```
49+
50+
### File Metadata
51+
52+
The GitHub Action can optionally read deck metadata:
53+
54+
```json
55+
{
56+
"path": "semester_1/anatomy.apkg",
57+
"name": "Complete Anatomy",
58+
"size_mb": 12.5
59+
}
60+
```
61+
62+
## 🤝 Contributing
63+
64+
1. Fork this repository
65+
2. Add your decks
66+
3. Submit a pull request
67+
68+
## 📄 License
69+
70+
Decks shared here should respect copyright. Only share:
71+
- Your own original content
72+
- Open-licensed materials
73+
- Materials you have permission to redistribute
5.93 MB
Binary file not shown.
5.06 MB
Binary file not shown.

biologie/meta.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"display_name": "🧬 Biologie"
3+
}

index.json

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"last_updated": "2025-12-23T20:15:00Z",
3+
"semesters": [
4+
{
5+
"name": "biologie",
6+
"display_name": "🧬 Biologie",
7+
"files": [
8+
{
9+
"path": "biologie/Mikrobiologie Vorlesung (Janne).apkg",
10+
"name": "Mikrobiologie Vorlesung",
11+
"size_mb": 5.9
12+
},
13+
{
14+
"path": "biologie/Pflanzenphys Harter (Janne).apkg",
15+
"name": "Pflanzenphysiologie Harter",
16+
"size_mb": 5.1
17+
}
18+
]
19+
},
20+
{
21+
"name": "semester_1",
22+
"display_name": "📚 Semester 1",
23+
"files": []
24+
}
25+
]
26+
}

semester_1/.gitkeep

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Placeholder
2+
Add your .apkg decks here

0 commit comments

Comments
 (0)