Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,21 @@ python src/unidesk/main.py

```
src/unidesk/
main.py entry point
home.py main window and all navigation logic
pages.py text content for each informational page
credits.py list of contributors
links.py external links shown in the Links page
main.py entry point
home.py main window and all navigation logic
pages.py text content for each informational page
credits.py list of contributors
links.py external links shown in the Links page
academic_institutions.py known universities and their departments
academic_config.py reads/writes the shared academic profile
```

To update any page content just open `pages.py` and edit the body text for that page. To add a new contributor open `credits.py`.

## Academic profile

The footer on the home screen has a **Configure UniOS** button. It opens a page where you pick your university and department from dropdowns, which is saved to `~/.unios/academicConfig.json`. Other UniOS apps (such as UniBackpack) read this file, so the available choices live in `academic_institutions.py` and must stay in sync with those apps. If UniBackpack adds new universities or departments, mirror them in `academic_institutions.py`.

## Contributing

Contributions are welcome. If you want to improve the UI, fix a typo, or add a new page, open a pull request on GitHub. If you find a bug, open an issue. There is no contribution too small.
Expand Down
37 changes: 37 additions & 0 deletions src/unidesk/academic_config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import json
import os

# Where the shared UniOS academic profile is persisted. Other UniOS apps read
# this same file, so the location and key names below must not change.
CONFIG_DIR = os.path.join(os.path.expanduser("~"), ".unios")
CONFIG_PATH = os.path.join(CONFIG_DIR, "academicConfig.json")


def load_academic_config():
"""Return the saved academic profile as a dict.

Always returns {"universityName": str, "departmentName": str}. A missing,
corrupt, or partial file yields empty strings instead of raising.
"""
config = {"universityName": "", "departmentName": ""}
try:
with open(CONFIG_PATH, encoding="utf-8") as f:
data = json.load(f)
except (FileNotFoundError, json.JSONDecodeError, OSError):
return config

if isinstance(data, dict):
config["universityName"] = data.get("universityName", "") or ""
config["departmentName"] = data.get("departmentName", "") or ""
return config


def save_academic_config(university, department):
"""Persist the academic profile to ~/.unios/academicConfig.json."""
os.makedirs(CONFIG_DIR, exist_ok=True)
data = {
"universityName": university,
"departmentName": department,
}
with open(CONFIG_PATH, "w", encoding="utf-8") as f:
json.dump(data, f, indent=2)
9 changes: 9 additions & 0 deletions src/unidesk/academic_institutions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Academic institutions known to UniOS.
#
# IMPORTANT: This list must stay in sync with UniBackpack's hardcoded values
# (UniBackpack/src/MainWindow.cpp).
UNIVERSITIES = {
"Aristotle University of Thessaloniki": ["Informatics", "Physics"],
"University of Western Macedonia": ["Informatics", "Mechanical Engineering"],
"University of Macedonia": ["Applied Informatics", "Economics"],
}
Loading
Loading