support browsing directories outside save dir

This commit is contained in:
Kartik K. Agaram 2023-10-20 00:00:38 -07:00
parent 189c0c9e75
commit 459b1df08a
4 changed files with 14 additions and 11 deletions

View File

@ -1,13 +1,16 @@
on.initialize = function(arg)
if #arg > 0 then
Data_dir = arg[1]
if is_absolute_path(arg[1]) then
Data_dir = arg[1]
else
Data_dir = App.current_dir..arg[1]
end
end
local repo_path = love.filesystem.getSaveDirectory()..'/'..Data_dir
print('reading articles from '..repo_path)
if not file_exists(repo_path) then
error('no directory '..repo_path..' found. Please store articles to browse there before opening this app.')
print('reading articles from '..Data_dir)
if not file_exists(Data_dir) then
error('no directory '..Data_dir..' found. Please store articles to browse there before opening this app.')
end
local comment_path = repo_path..'/comments'
local comment_path = Data_dir..'/comments'
if not file_exists(comment_path) then
error('Sorry, I am not permitted to create directories (folders). Please create directory '..comment_path..' for storing comments in.')
end
@ -19,4 +22,4 @@ on.initialize = function(arg)
A()
Viewport.x, Viewport.y = Viewport_bounds.xmin, Viewport_bounds.ymin
B()
end
end

View File

@ -1,3 +1,3 @@
full_path = function(id)
return App.save_dir..Data_dir..'/'..id
return Data_dir..'/'..id
end

View File

@ -1,5 +1,5 @@
initialize_file_picker = function()
Files = love.filesystem.getDirectoryItems(Data_dir)
Files = App.files(Data_dir)
for i=#Files,1,-1 do
if not Files[i]:match('%.md$') then
table.remove(Files, i)
@ -16,4 +16,4 @@ initialize_file_picker = function()
border={r=0.4, g=0.4, b=0.7}
})
end
end
end

View File

@ -1 +1 @@
Data_dir = 'data'
Data_dir = App.save_dir .. 'data'