Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
caedc4b
Get the first draft up there
teamcons Oct 8, 2025
d05b665
forgor meson dependency
teamcons Oct 8, 2025
77012e6
Add CI
teamcons Oct 8, 2025
64b6e96
Make the json optional
teamcons Oct 8, 2025
c7833f2
Comprehensive readme
teamcons Oct 8, 2025
ca35a8d
I think this has to be an unowned, right?
teamcons Oct 8, 2025
1ec86db
Add a demo for upcoming tostring
teamcons Oct 8, 2025
fbd5cbf
add the dynamical internal unique storage thingy
teamcons Oct 8, 2025
61059c2
create string counterpart
teamcons Oct 8, 2025
05bf41a
add in the demo to be able to test without installing
teamcons Oct 8, 2025
b4979a8
more info
teamcons Oct 8, 2025
591cccc
Allow building for windows
teamcons Oct 8, 2025
5ded2da
Update README.md
teamcons Oct 14, 2025
2be275f
Update README.md
teamcons Oct 15, 2025
678681c
add is_empty()
teamcons Oct 15, 2025
5ea9698
add in method to add later
teamcons Oct 17, 2025
ea06dd4
add contains() and do better is_empty()
teamcons Oct 19, 2025
f92ea99
Explicit getter setter default
teamcons Oct 19, 2025
0b9f87f
code style, debug
teamcons Oct 19, 2025
e0323e9
Add read-only
teamcons Oct 30, 2025
5d17210
Keep a Glib.File ref and add delete, but theres simplification doable…
teamcons Oct 30, 2025
a429e4c
make datadir check static, make linter happy, follow camelcase conven…
teamcons Oct 30, 2025
80ffdee
Explicit GLib to silence warnings, and disable valadoc making stuff fail
teamcons Oct 30, 2025
871cf8e
Some renaming
teamcons Oct 31, 2025
b468bd0
Add an init() and a couple static values
teamcons Oct 31, 2025
29ccbea
Niceify README
teamcons Oct 31, 2025
047390b
Add demo executable
teamcons Oct 31, 2025
5dee412
meson for demo
teamcons Oct 31, 2025
b56f57d
fix minimistake
teamcons Oct 31, 2025
556026e
fix minimistake - dependency should be a string
teamcons Oct 31, 2025
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
42 changes: 42 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: CI

on:
pull_request:
types:
- opened
- reopened
- synchronize

jobs:
build:
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
version: [stable, unstable, development-target]
container:
image: ghcr.io/elementary/docker:${{ matrix.version }}

steps:
- uses: actions/checkout@v5
- name: Install Dependencies
run: |
apt update
apt install -y meson valac libjson-glib-dev
- name: Build
run: |
meson setup build --prefix=/usr
ninja -C build
ninja -C build install

lint:
runs-on: ubuntu-latest

container:
image: valalang/lint

steps:
- uses: actions/checkout@v5
- name: Lint
run: io.elementary.vala-lint -d .
89 changes: 88 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,58 @@
# libfridge

Simple Vala App Storage Library
A simple, hassle-free storage library to keep your data fresh.
Ready out of the box, comprehensive for vala newcomers, and built to be reliable and out of your way.

This library primarily contains:

- StringStorage: Store a string, any size.
- JsonStorage: Store an array of Json.Node or Json.Objects
- Static variables to keep track of your data files

## Features:
- [x] Smart instancing: Each instance is its own distinct file, and you can let Fridge deal with that.
- [x] Cache: By default a cache lets you access content faster
- [x] Optional error handling: You can connect to the error() signal. If you want to.
- [x] Optional Json: You can rely on pretty pure vala here if you want to keep it light
- [x] Add a contains() method, so people can do if (var in storageinstance)
- [x] Handy: Static values to help you manage your datadir

Wishlist of features:
- [ ] Integrated debounce saving?
- [ ] More agressive trying to load/save in case of errors
- [ ] Optional SQL storage i think? Something stupid: One key one value. Optional like the json one
- [ ] Save to binary?
- [ ] Make shit async for cases with heavy objects?
- [ ] encrypted storage ? using some combined magic of libsecret and some traditional encrypt library? maybe a salt and a randomly generated password? so user only need unlock their keyring, and the random gen gets pulled out invisibly.



## How to use: Crash course

All instances are meant to represent a file on disk. Simply declare:

```
var mystorage = new Fridge.json_storage();
```

Or any variant depending what you want to store... And you are good to go!
Save by doing:

```
mystorage.content = thing_to_save;
```

Access it by doing:

```
var thing_to_load = mystorage.content;
```

## Apps using Fridge:

- [ ] Jorts (https://github.com/ellie-commons/Jorts)
- [ ] You can expand this list!


## Build Instructions

Expand All @@ -24,6 +76,41 @@ To install libfridge:
ninja install
```


## Add to your meson

With Fridge installed on your puter, simply add to your dependencies:

```
dependency('libfridge-0.1'),
```


## Add to your flatpak project

Simply copy the in your manifest before your app sources:

```
- name: libfridge
buildsystem: meson
sources:
- type: git
url: https://github.com/vala-community/libfridge.git
tag: 0.0.1
commit: [NOT DONE YET]
x-checker-data:
type: git
tag-pattern: '^([\d.]+)$'
```

By default JsonStorage is included. If you do not use it, and wish to skip having a json dependency, you can add immediately after the buildsystem line:

```
config-opts:
- -Denable_json=false
```


## Documentation

By default, documentation is built by default using [`valadoc`](https://docs.vala.dev/developer-guides/documentation/valadoc-guide.html)
Expand Down
16 changes: 16 additions & 0 deletions demo/demo.vala

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For testing purposes, Taking advantage of meson’s test features would be convenient. These could run in CI actions too! For example: https://github.com/vala-lang/vala-lint/tree/master/test

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably. I was thinking of doing a local fork of the Slate app (text editor that saves in data unsaved files), so there is a everyday testing we can do

Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Testing and demo purposes
// valac --pkg libfridge demo.vala

public static int main (string[] args) {

var sto = new Fridge.StringStorage ();
print ("\n" + "Location: " + sto.storage_path + "\n");

switch (args[1]) {
case "load": print (sto.content);break;
case "save": sto.content = args[2];break;
default: ;break;
}

return 0;
}
11 changes: 11 additions & 0 deletions demo/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@

executable(
'libfridge-demo',
'demo.vala',

dependencies: [
dependency ('libfridge-0.1')
],

install: true,
)
Loading