diff options
author | elioat <elioat@tilde.institute> | 2022-12-10 14:28:47 -0500 |
---|---|---|
committer | elioat <elioat@tilde.institute> | 2022-12-10 14:28:47 -0500 |
commit | 0ec27e5e710f043a881495ba5c9c8233d484b4ae (patch) | |
tree | 349b9fb32d6946401dabcf278a3bb88473d2362b /src | |
parent | ad53189f13036f268ebbb03e261848a018fd3897 (diff) | |
download | december-2022-0ec27e5e710f043a881495ba5c9c8233d484b4ae.tar.gz |
got the core pieces in place
Diffstat (limited to 'src')
-rw-r--r-- | src/catalogue.lil | 71 | ||||
-rw-r--r-- | src/test.csv | 7 | ||||
-rw-r--r-- | src/tmp.lil | 49 |
3 files changed, 69 insertions, 58 deletions
diff --git a/src/catalogue.lil b/src/catalogue.lil index 0129360..e305f57 100644 --- a/src/catalogue.lil +++ b/src/catalogue.lil @@ -1,66 +1,27 @@ -# spent a good bit of time playing with lil and reviewing the docs. I am now -# totally smitten and excited to use lil. - -# a basic sketch of the data table at the center of the action - -# catalogue.entry_type -# catalogue.parent # not 100% certain how to reference another entry by id -# catalogue.title -# catalogue.body -# catalogue.reference -# catalogue.created_date -# catalogue.updated_date # does this matter? (sorta leaning towards "no") - -# entry_type's -# - link -# - note -# - folder - -# every item can have 1 parent -# a parent is usually a folder - -# data table wrapped in an interactive cli for adding, querying, and viewing -# input data. Input data stored as CSV between sessions - -# NOTE: if input data is stored as CSV is becomes trivial to pipe in and out -# of SQLite in the future...if that'd be desirable - -# NOTE: I'm using just 1 table so that this can be easily exported as CSV... -# if it weren't for that requirement, I'd have multiple tables - -# catalogue:table catalogue - -# alternate syntax to make a table, -# t: insert food:("Eggs","Pancakes","Grapefruit") quantity:(3,4,1) tasty:(1,1,0) into 0 - -# validate that I can write a table to disk and read it back in -# show[catalogue] -# out:writecsv[catalogue] -# show[out] -# write["test.csv" out] - -# data:read["test.csv"] -# newtable:readcsv[data "sis "] # this column spec. syntax looks hilarious -# show[newtable] -# HUGE SUCCESS! +on load_db db do + data:read[db] + out:readcsv[data "sss"] +end -# Not sure how to programmatically access/view the implicit ID column...or if that is wise? -# in lieu of using the implicit IDs when referencing a row, I think maybe I'll come up with -# my own ID and use that instead...a well known ID? +on save_db t db do + out:writecsv[t] + write[db out] +end on entry d t do + # where d is a table representing a new row to be added to t, an existing table date_fmt_string:"date +%Y-%m-%d | tr -d '\n'" wget_fmt_string:"wget -qO- " , d.url , " | grep -o \"<title>[^<]*\" | sed -e 's/<[^>]*>//g' | tr -d '\n'" t:insert title:(shell[wget_fmt_string].out) reference:(d.url) created_date:(shell[date_fmt_string].out) into t end -# where d is a table representing a new row to be added to t, an existing table +# read in a csv, and store in memory as a table +catalogue:load_db["test.csv"] -row.url:"https://smallandnearlysilent.com" +# add a row to the table stored in memory +row.url:"https://tenforward.social" row:table row -test:entry[row catalogue] - -show[test] # NOTE, keep in mind that this generates a totally new table +catalogue:entry[row catalogue] -# HOLD UP! I've over complicated things; I'm going to shift gears, make this projects -# only focused on link logging, not a general purpose DB. \ No newline at end of file +# write the updated data to csv +save_db[catalogue "test.csv"] diff --git a/src/test.csv b/src/test.csv index 8b04c72..35bd89b 100644 --- a/src/test.csv +++ b/src/test.csv @@ -1,3 +1,4 @@ -reference,created_date -https://eli.li,2022-12-07 -https://smallandnearlysilent.com,2022-12-07 \ No newline at end of file +title,reference,created_date +small and nearly silent | pubnix programming playground for friends,https://smallandnearlysilent.com,2022-12-10 +Oatmeal,https://eli.li,2022-12-10 +Ten Forward,https://tenforward.social,2022-12-10 \ No newline at end of file diff --git a/src/tmp.lil b/src/tmp.lil index 06f5a7f..5ad150e 100644 --- a/src/tmp.lil +++ b/src/tmp.lil @@ -56,4 +56,53 @@ print[filter] print[spread_conforming] +# spent a good bit of time playing with lil and reviewing the docs. I am now +# totally smitten and excited to use lil. + +# a basic sketch of the data table at the center of the action + +# catalogue.entry_type +# catalogue.parent # not 100% certain how to reference another entry by id +# catalogue.title +# catalogue.body +# catalogue.reference +# catalogue.created_date +# catalogue.updated_date # does this matter? (sorta leaning towards "no") + +# entry_type's +# - link +# - note +# - folder + +# every item can have 1 parent +# a parent is usually a folder + +# data table wrapped in an interactive cli for adding, querying, and viewing +# input data. Input data stored as CSV between sessions + +# NOTE: if input data is stored as CSV is becomes trivial to pipe in and out +# of SQLite in the future...if that'd be desirable + +# NOTE: I'm using just 1 table so that this can be easily exported as CSV... +# if it weren't for that requirement, I'd have multiple tables + +# catalogue:table catalogue + +# alternate syntax to make a table, +# t: insert food:("Eggs","Pancakes","Grapefruit") quantity:(3,4,1) tasty:(1,1,0) into 0 + + + + +# validate that I can write a table to disk and read it back in +# show[catalogue] +# out:writecsv[catalogue] +# show[out] +# write["test.csv" out] + +# data:read["test.csv"] +# newtable:readcsv[data "sis "] # this column spec. syntax looks hilarious +# show[newtable] +# HUGE SUCCESS! + |