summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAki <please@ignore.pl>2024-02-09 21:38:17 +0100
committerAki <please@ignore.pl>2024-02-09 21:53:31 +0100
commitd41c7d0e1d864bec20cd917354fe82330d0781d5 (patch)
tree972b4d0d7a318c9ba6a4eb58d4830e93fb747105
parentf203f127a8e7b35bd8351b813cd3448e6bf9fd6e (diff)
downloadactivity-d41c7d0e1d864bec20cd917354fe82330d0781d5.zip
activity-d41c7d0e1d864bec20cd917354fe82330d0781d5.tar.gz
activity-d41c7d0e1d864bec20cd917354fe82330d0781d5.tar.bz2
Removed duplication in svg itself
Design is still quite questionable. Main point would be to make them stateful in a non-awkward/hacky way like currently.
-rw-r--r--activity.lua3
-rw-r--r--activity/formats/svg.lua4
2 files changed, 4 insertions, 3 deletions
diff --git a/activity.lua b/activity.lua
index 398d2e8..55cb061 100644
--- a/activity.lua
+++ b/activity.lua
@@ -33,6 +33,7 @@ function generate_rolling (lookup, format, date)
return at.year, dates.day_of_year(at)
end
+ local head = format.start_document"Activity" .. format.start_table()
for index, weekday in pairs(weekdays) do
rows = rows .. format.start_row() .. format.label(weekday)
for week=0,51 do
@@ -45,7 +46,7 @@ function generate_rolling (lookup, format, date)
end
rows = rows .. format.end_row()
end
- return format.start_document"Activity" .. format.start_table() .. rows .. format.end_table() .. format.end_document()
+ return head .. rows .. format.end_table() .. format.end_document()
end
diff --git a/activity/formats/svg.lua b/activity/formats/svg.lua
index ab3ab69..f7e2700 100644
--- a/activity/formats/svg.lua
+++ b/activity/formats/svg.lua
@@ -44,7 +44,7 @@ function svg.end_table ()
end
-local cell_offset = 28
+local cell_offset
function svg.start_row ()
@@ -73,7 +73,7 @@ end
function svg.cell (level)
local cell = ([[<rect class="cell level%d" x="%d"/>]]):format(level, cell_offset)
- cell_offset = cell_offset + 12
+ svg.spot() -- Increment cell_offset in one place in code.
return cell
end