fix relative paths
This commit is contained in:
parent
f6cf84e310
commit
3c2de65806
@ -1,19 +1,17 @@
|
|||||||
local to_json = require("lapis.util").to_json
|
local to_json = require("lapis.util").to_json
|
||||||
local autoload = require("lapis.util").autoload
|
local autoload = require("lapis.util").autoload
|
||||||
local config = require("lapis.config")
|
local config = require("lapis.config")
|
||||||
|
|
||||||
-- print(to_json(config.get()))
|
|
||||||
|
|
||||||
local hotmixes = autoload("hotmixes")
|
local hotmixes = autoload("hotmixes")
|
||||||
|
|
||||||
local function Roothandler(self)
|
local function Roothandler(self)
|
||||||
local stuff = hotmixes.utils.these_files( hotmixes.utils.data_path )
|
|
||||||
|
|
||||||
local latest_path, latest_name = hotmixes.utils.these_latest()
|
local path = config.get().mount .. self.titles.url
|
||||||
|
local stuff = hotmixes.utils.these_files( path .. hotmixes.utils.request_path )
|
||||||
|
local latest_path, latest_name = hotmixes.utils.these_latest( path )
|
||||||
|
|
||||||
self.total = hotmixes.utils.total_files_dir( config.get().mount )
|
self.total = hotmixes.utils.total_files_dir( path )
|
||||||
self.uri = hotmixes.utils.request_path
|
self.uri = hotmixes.utils.request_path
|
||||||
self.path = '/data' .. hotmixes.utils.request_path
|
self.path = '/data/' .. self.titles.url .. hotmixes.utils.request_path
|
||||||
self.dirs = stuff.dirs
|
self.dirs = stuff.dirs
|
||||||
self.files = stuff.files
|
self.files = stuff.files
|
||||||
self.images = stuff.images
|
self.images = stuff.images
|
||||||
|
|||||||
@ -41,7 +41,7 @@ utils['match_image'] = function( file )
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
utils['latest_files'] = function(directory)
|
utils['latest_files'] = function( directory )
|
||||||
local i, t, popen = 0, {}, io.popen
|
local i, t, popen = 0, {}, io.popen
|
||||||
local pfile = popen('find "'..directory..'" -type f ! -name \'*.filepart\' -printf \'%C@ %p\n\'| sort -nr | head -7 | cut -f2- -d" "| sed s:"'..directory..'/"::')
|
local pfile = popen('find "'..directory..'" -type f ! -name \'*.filepart\' -printf \'%C@ %p\n\'| sort -nr | head -7 | cut -f2- -d" "| sed s:"'..directory..'/"::')
|
||||||
for filename in pfile:lines() do
|
for filename in pfile:lines() do
|
||||||
@ -80,17 +80,14 @@ utils['these_files'] = function( path )
|
|||||||
return stuff
|
return stuff
|
||||||
end
|
end
|
||||||
|
|
||||||
utils['these_latest'] = function()
|
utils['these_latest'] = function( path )
|
||||||
-- list last 10 modified files in our directory
|
-- list last 10 modified files in our directory
|
||||||
local latest_path, latest_name = {}, {}
|
local latest_path, latest_name = {}, {}
|
||||||
|
|
||||||
for i, file_path in ipairs( utils.latest_files( data_dir ) ) do
|
for i, file_path in ipairs( utils.latest_files( path ) ) do
|
||||||
file_path = file_path:gsub( data_dir, "/" )
|
file_path = file_path:gsub( path, "/" )
|
||||||
table.insert( latest_path, file_path)
|
table.insert( latest_path, file_path)
|
||||||
|
|
||||||
-- local to_json = require("lapis.util").to_json
|
|
||||||
-- print( to_json(latest_path) )
|
|
||||||
|
|
||||||
local temp = ""
|
local temp = ""
|
||||||
local result = ""
|
local result = ""
|
||||||
for i = file_path:len(), 1, -1 do
|
for i = file_path:len(), 1, -1 do
|
||||||
|
|||||||
@ -23,7 +23,7 @@
|
|||||||
<br>
|
<br>
|
||||||
<h1 class="h1">Latest uploads:</h1>
|
<h1 class="h1">Latest uploads:</h1>
|
||||||
<% for i, file in ipairs(latestpath) do %>
|
<% for i, file in ipairs(latestpath) do %>
|
||||||
<a class="amixlink" href="<%= '/data' .. file %>">
|
<a class="amixlink" href="<%= '/data/' .. titles.url .. '/' .. file %>">
|
||||||
<span class="mixlink"><%= latestname[i] %></span>
|
<span class="mixlink"><%= latestname[i] %></span>
|
||||||
</a>
|
</a>
|
||||||
</br>
|
</br>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user