Compare commits
3
Commits
3ebeacf2e0
...
f4efb0f48a
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f4efb0f48a | ||
|
|
e5b08b0873 | ||
|
|
30c28f1c45 |
@@ -16,22 +16,37 @@ I think the opening UI should be to display the top 10 books in-progress (sort o
|
|||||||
allows the user to immediately enter an updated progress. Additional alphabetic keys are an option to access other features. This way
|
allows the user to immediately enter an updated progress. Additional alphabetic keys are an option to access other features. This way
|
||||||
tracker use is near frictionless. (0 maps to 10)
|
tracker use is near frictionless. (0 maps to 10)
|
||||||
|
|
||||||
## data structure of an item
|
## Contributions
|
||||||
|
|
||||||
|
This repo is hosted at https://gitea.tangentfox.com/tangent/Asymtome and
|
||||||
|
force-pushed to https://github.com/TangentFoxy/Asymtome when commits are made.
|
||||||
|
I accept pull requests and issues, but management of the code is handled there.
|
||||||
|
|
||||||
|
Licensing? I don't care. Do whatever you want. IP rights are stupid.
|
||||||
|
|
||||||
|
## Book Data Structure
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
title = "Title",
|
"title": "Title",
|
||||||
author = "Author",
|
"author": "Author",
|
||||||
series = "Series",
|
"series": "Series",
|
||||||
pages = 100,
|
"pages": 100,
|
||||||
priority = 0,
|
"priority": 0,
|
||||||
progress = 0.5,
|
"progress": 0.5,
|
||||||
|
"hidden": true
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
- `title`, `author`, `series`, and `pages` are optional.
|
- `title`, `author`, `series`, `pages`, and `hidden` are optional.
|
||||||
- At least one of `title`, `author`, or `series` must be defined.
|
- At least one of `title`, `author`, or `series` must be defined.
|
||||||
- `priority` is the ELO ranking, initializing to `0`.
|
- `priority` is the ELO ranking, initializing to `0`.
|
||||||
- `progress` represents read/unread/in-progress status. `0` is unread, `1` is read, and anything in-between in a percentage of progress.
|
- `progress` represents read/unread/in-progress status. `0` is unread, `1` is
|
||||||
|
read, and anything in-between in a percentage of progress.
|
||||||
|
- `hidden` is undefined or `true` to hide a book from ALL of the interface
|
||||||
|
without deleting its data.
|
||||||
|
|
||||||
## the name
|
## Why "Asymptome" ?
|
||||||
A combination of asymptote - because you will die before you finish your reading list, always getting closer but never arriving - and tome.
|
A combination of asymptote - because you will die before you finish your reading
|
||||||
|
list, always getting closer but never arriving - and tome.
|
||||||
|
|
||||||
|
It's also a-symptom of my neuroses. :D
|
||||||
+89
-1
@@ -2,6 +2,17 @@
|
|||||||
local json = require "lib.dkjson"
|
local json = require "lib.dkjson"
|
||||||
math.randomseed(os.time())
|
math.randomseed(os.time())
|
||||||
|
|
||||||
|
local default_file = "books.json"
|
||||||
|
|
||||||
|
local path_exists = function(path_name)
|
||||||
|
local file = io.open(path_name, "r")
|
||||||
|
if file then
|
||||||
|
file:close()
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
local load_json = function(file_name)
|
local load_json = function(file_name)
|
||||||
local file, error_message = io.open(file_name, "r")
|
local file, error_message = io.open(file_name, "r")
|
||||||
assert(file, error_message)
|
assert(file, error_message)
|
||||||
@@ -18,7 +29,7 @@ local save_json = function(file_name, data)
|
|||||||
file:close()
|
file:close()
|
||||||
end
|
end
|
||||||
|
|
||||||
local random_order = function(array)
|
local get_random_order = function(array)
|
||||||
local temporary, order = {}, {}
|
local temporary, order = {}, {}
|
||||||
for i = 1, #array do
|
for i = 1, #array do
|
||||||
temporary[i] = i
|
temporary[i] = i
|
||||||
@@ -28,3 +39,80 @@ local random_order = function(array)
|
|||||||
end
|
end
|
||||||
return order
|
return order
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local filters = {
|
||||||
|
all_books = function(book)
|
||||||
|
if book.hidden then return false end
|
||||||
|
return true
|
||||||
|
end,
|
||||||
|
unread = function(book)
|
||||||
|
if book.hidden then return false end
|
||||||
|
if book.progress == 0 then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
return false
|
||||||
|
end,
|
||||||
|
read = function(book)
|
||||||
|
if book.hidden then return false end
|
||||||
|
if book.progress == 1 then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
return false
|
||||||
|
end,
|
||||||
|
in_progress = function(book)
|
||||||
|
if book.hidden then return false end
|
||||||
|
if book.progress > 0 and book.progress < 1 then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
return false
|
||||||
|
end,
|
||||||
|
}
|
||||||
|
|
||||||
|
local sort_orders
|
||||||
|
sort_orders = {
|
||||||
|
most_progress = function(A, B)
|
||||||
|
return A.progress > B.progress
|
||||||
|
end,
|
||||||
|
least_progress = function(A, B)
|
||||||
|
return A.progress < B.progress
|
||||||
|
end,
|
||||||
|
highest_priority = function(A, B)
|
||||||
|
return A.priority > B.priority
|
||||||
|
end,
|
||||||
|
lowest_priority = function(A, B)
|
||||||
|
return A.priority < B.priority
|
||||||
|
end,
|
||||||
|
most_pages_remaining = function(A, B)
|
||||||
|
if not (A.pages and B.pages) then -- if pages is unknown for both, fallback to percentage
|
||||||
|
return A.progress > B.progress
|
||||||
|
end
|
||||||
|
local average_page_count = data.total_pages / #data.books
|
||||||
|
local a = (A.pages or average_page_count) - (A.pages or average_page_count) * A.progress
|
||||||
|
local b = (B.pages or average_page_count) - (B.pages or average_page_count) * B.progress
|
||||||
|
return a > b
|
||||||
|
end,
|
||||||
|
fewest_pages_remaining = function(A, B)
|
||||||
|
return not sort_orders.most_pages_remaining(A, B)
|
||||||
|
end,
|
||||||
|
}
|
||||||
|
|
||||||
|
local data
|
||||||
|
if path_exists(default_file) then
|
||||||
|
data = load_json(default_file)
|
||||||
|
-- TODO verify data structure
|
||||||
|
else
|
||||||
|
data = {
|
||||||
|
books = {},
|
||||||
|
elo = {
|
||||||
|
distance_constant = 5,
|
||||||
|
maximum_change = 2.5,
|
||||||
|
},
|
||||||
|
total_pages = 0,
|
||||||
|
defaults = {
|
||||||
|
launch = {
|
||||||
|
filter = "in_progress",
|
||||||
|
sort = "fewest_pages_remaining",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
end
|
||||||
Reference in New Issue
Block a user