support browsing directories outside save dir
This commit is contained in:
parent
189c0c9e75
commit
459b1df08a
|
@ -1,13 +1,16 @@
|
||||||
on.initialize = function(arg)
|
on.initialize = function(arg)
|
||||||
if #arg > 0 then
|
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
|
end
|
||||||
local repo_path = love.filesystem.getSaveDirectory()..'/'..Data_dir
|
print('reading articles from '..Data_dir)
|
||||||
print('reading articles from '..repo_path)
|
if not file_exists(Data_dir) then
|
||||||
if not file_exists(repo_path) then
|
error('no directory '..Data_dir..' found. Please store articles to browse there before opening this app.')
|
||||||
error('no directory '..repo_path..' found. Please store articles to browse there before opening this app.')
|
|
||||||
end
|
end
|
||||||
local comment_path = repo_path..'/comments'
|
local comment_path = Data_dir..'/comments'
|
||||||
if not file_exists(comment_path) then
|
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.')
|
error('Sorry, I am not permitted to create directories (folders). Please create directory '..comment_path..' for storing comments in.')
|
||||||
end
|
end
|
||||||
|
@ -19,4 +22,4 @@ on.initialize = function(arg)
|
||||||
A()
|
A()
|
||||||
Viewport.x, Viewport.y = Viewport_bounds.xmin, Viewport_bounds.ymin
|
Viewport.x, Viewport.y = Viewport_bounds.xmin, Viewport_bounds.ymin
|
||||||
B()
|
B()
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
full_path = function(id)
|
full_path = function(id)
|
||||||
return App.save_dir..Data_dir..'/'..id
|
return Data_dir..'/'..id
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
initialize_file_picker = function()
|
initialize_file_picker = function()
|
||||||
Files = love.filesystem.getDirectoryItems(Data_dir)
|
Files = App.files(Data_dir)
|
||||||
for i=#Files,1,-1 do
|
for i=#Files,1,-1 do
|
||||||
if not Files[i]:match('%.md$') then
|
if not Files[i]:match('%.md$') then
|
||||||
table.remove(Files, i)
|
table.remove(Files, i)
|
||||||
|
@ -16,4 +16,4 @@ initialize_file_picker = function()
|
||||||
border={r=0.4, g=0.4, b=0.7}
|
border={r=0.4, g=0.4, b=0.7}
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Data_dir = 'data'
|
Data_dir = App.save_dir .. 'data'
|
Loading…
Reference in New Issue