22 Commits

Author SHA1 Message Date
dreamer 4bfba762b4 add hotmixes.net 2026-06-02 15:56:50 +02:00
dreamer 6e33ad712e add latest date and podcast:guid 2026-04-27 11:15:55 +02:00
dreamer 7ed0a1863d rss channel details 2026-04-27 11:02:23 +02:00
dreamer 49a8626708 more 2026-04-25 16:49:04 +02:00
dreamer 223d62f2a3 more tweaks 2026-04-25 16:45:19 +02:00
dreamer c2577ad3dc tweak stuff 2026-04-25 16:39:39 +02:00
dreamer ea3ff90349 try formatting itunes feed 2026-04-25 16:26:40 +02:00
dreamer 49cc36ef31 use custom escape function 2026-04-14 08:24:34 +02:00
dreamer fe70315a63 un-escape more chars 2026-04-13 21:35:46 +02:00
dreamer 3aec58719b don't remove leading slash 2026-04-13 21:27:08 +02:00
dreamer b86f583f42 try un-escaping slash 2026-04-13 21:08:59 +02:00
dreamer ae1eca427f add license 2026-04-07 09:27:43 +02:00
dreamer 64b07ad34d undo retain forward slashes 2026-03-31 11:27:45 +02:00
dreamer 6fbc87a465 retain forward slashes 2026-03-31 11:25:18 +02:00
dreamer c88c43fd8e retain forward slashes 2026-03-31 11:23:53 +02:00
dreamer 807e124570 properly handle escaping of paths 2026-03-31 11:16:28 +02:00
dreamer 0493632932 undo the other too 2026-03-30 12:43:50 +02:00
dreamer ce4f7f54da undo request_path escape 2026-03-30 12:42:59 +02:00
dreamer 9df7ed5be8 escape more paths 2026-03-30 12:36:02 +02:00
dreamer 82035ea239 sort files and dirs 2026-03-30 12:27:30 +02:00
dreamer b47f7c8e75 Merge branch 'main' into bugfix/escape_urls 2026-03-30 12:17:34 +02:00
dreamer dc196fb621 escape url paths 2026-03-30 12:17:07 +02:00
10 changed files with 155 additions and 20 deletions
+21
View File
@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2026 Wasted Audio
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
+16 -4
View File
@@ -16,21 +16,33 @@ if string.find(ngx.var.host, "panamaracing.club") then
name = "Panama Racing Club Archive", name = "Panama Racing Club Archive",
url = "panamaracing.club", url = "panamaracing.club",
css = "panamaracing.css", css = "panamaracing.css",
header = "panamaracing.club_header.png" header = "panamaracing.club_header.png",
feed = "panamaracing.club"
} }
elseif string.find(ngx.var.host, "videohotmix.net") then elseif string.find(ngx.var.host, "videohotmix.net") then
page_titles = { page_titles = {
name = "Hotmix Video Archive", name = "Hotmix Video Archive",
url = "videohotmix.net", url = "videohotmix.net",
css = "videohotmix.css", css = "videohotmix.css",
header = "videohotmix.net-logo.png" header = "videohotmix.net-logo.png",
feed = "videohotmix"
} }
elseif string.find(ngx.var.host, "hotmixxx.com") then elseif string.find(ngx.var.host, "hotmixxx.com") then
page_titles = { page_titles = {
name = "Hotmix Video Archive", name = "Hotmix Video Archive",
url = "videohotmix.net", url = "videohotmix.net",
css = "videohotmix.css", css = "videohotmix.css",
header = "videohotmix.net-logo.png" header = "videohotmix.net-logo.png",
feed = "hotmixxx"
}
elseif string.find(ngx.var.host, "hotmixes.net") then
page_titles = {
name = "Hotmix Video Archive",
url = "videohotmix.net",
css = "videohotmix.css",
header = "videohotmix.net-logo.png",
feed = "hotmixes"
} }
else else
page_titles = { page_titles = {
@@ -49,7 +61,7 @@ app:get("/latest.json", function(self)
return handlers.Latesthandler(self) return handlers.Latesthandler(self)
end) end)
app:get("/latest.xml", function(self) app:get("/latest.rss", function(self)
self.titles = page_titles self.titles = page_titles
return handlers.RSShandler(self) return handlers.RSShandler(self)
end) end)
+4 -1
View File
@@ -7,12 +7,15 @@ local hotmixes = autoload("hotmixes")
local function RSShandler(self) local function RSShandler(self)
local path = config.get().mount .. self.titles.url local path = config.get().mount .. self.titles.url
local latest_path, latest_name = hotmixes.utils.these_latest( path ) local latest_path, latest_name, latest_size, latest_date = hotmixes.utils.rss_latest( path )
local host = self.req.parsed_url.scheme .. '://' .. self.req.parsed_url.host local host = self.req.parsed_url.scheme .. '://' .. self.req.parsed_url.host
self.datapath = host .. '/data/' .. self.titles.url .. '/' self.datapath = host .. '/data/' .. self.titles.url .. '/'
self.latestpath = latest_path self.latestpath = latest_path
self.latestname = latest_name self.latestname = latest_name
self.latestsize = latest_size
self.latestdate = latest_date
self.datenow = hotmixes.utils.rss_date_now()
return { content_type = "application/rss+xml", layout = require "views.rss" } return { content_type = "application/rss+xml", layout = require "views.rss" }
end end
+1 -1
View File
@@ -18,7 +18,7 @@ local function Latesthandler(self)
local file_data = {} local file_data = {}
file_data["name"] = latest_name[i] file_data["name"] = latest_name[i]
file_data["url"] = data_path .. escape(file) file_data["url"] = data_path .. file
table.insert(latest_json["files"], file_data) table.insert(latest_json["files"], file_data)
end end
+1 -1
View File
@@ -1,4 +1,3 @@
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")
local hotmixes = autoload("hotmixes") local hotmixes = autoload("hotmixes")
@@ -17,6 +16,7 @@ local function Roothandler(self)
self.images = stuff.images self.images = stuff.images
self.latestpath = latest_path self.latestpath = latest_path
self.latestname = latest_name self.latestname = latest_name
self.functions = { hotesc = hotmixes.utils.hotesc }
if self.titles['url'] == "panamaracing.club" then if self.titles['url'] == "panamaracing.club" then
return { render = "root", layout = require "views.prc_layout" } return { render = "root", layout = require "views.prc_layout" }
+79 -1
View File
@@ -1,5 +1,6 @@
local lfs = require 'lfs_ffi' local lfs = require 'lfs_ffi'
local config = require("lapis.config").get() local config = require("lapis.config").get()
local escape = require("lapis.util").escape
-- setup -- setup
@@ -25,10 +26,15 @@ local data_path = data_dir .. request_path
local type_image = { jpg=true, jpeg=true, png=true, gif=true } local type_image = { jpg=true, jpeg=true, png=true, gif=true }
local type_media = { mp3=true, flac=true, wav=true, mp4=true } local type_media = { mp3=true, flac=true, wav=true, mp4=true }
local type_audio = { mp3=true, flac=true, wav=true }
local type_allowed = { jpg=true, jpeg=true, png=true, gif=true, mp3=true, flac=true, wav=true, mp4=true } local type_allowed = { jpg=true, jpeg=true, png=true, gif=true, mp3=true, flac=true, wav=true, mp4=true }
local utils = {} local utils = {}
local function hotesc ( str )
return escape(str):gsub("%%2f", "/"):gsub("%%2d", "-"):gsub("%%2e", ".")
end
utils['request_path'] = request_path utils['request_path'] = request_path
utils['data_path'] = data_path utils['data_path'] = data_path
@@ -55,6 +61,19 @@ utils['latest_files'] = function( directory )
return t return t
end end
utils['latest_audio'] = function( directory )
local i, t, popen = 0, {}, io.popen
local pfile = popen('find -L "'..directory..'" -type f ! -name \'*.filepart\' ! -name \'*.mp4\' ! -name \'*.png\' ! -name \'*.jpg\' ! -name \'*.jpeg\' ! -name \'*.gif\' -printf \'%C@ %p\n\'| sort -nr | head -7 | cut -f2- -d" "| sed s:"'..directory..'/"::')
for filename in pfile:lines() do
if utils.match_ext ( filename, type_audio ) then
i = i + 1
t[i] = filename
end
end
pfile:close()
return t
end
utils['these_files'] = function( path ) utils['these_files'] = function( path )
local files, dirs, images = {}, {}, {} local files, dirs, images = {}, {}, {}
for file in lfs.dir( path ) do for file in lfs.dir( path ) do
@@ -83,12 +102,17 @@ utils['these_files'] = function( path )
return stuff return stuff
end end
utils['hotesc'] = function( str )
return hotesc(str)
end
utils['these_latest'] = function( path ) 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( path ) ) do for i, file_path in ipairs( utils.latest_files( path ) ) do
table.insert( latest_path, file_path) local escpath = hotesc(file_path)
table.insert( latest_path, escpath )
local temp = "" local temp = ""
local result = "" local result = ""
@@ -110,6 +134,51 @@ utils['these_latest'] = function( path )
return latest_path, latest_name return latest_path, latest_name
end end
utils['rss_latest'] = function( path )
local latest_path, latest_name, latest_size, latest_date = {}, {}, {}, {}
for i, file_path in ipairs( utils.latest_audio( path ) ) do
local popen = io.popen
-- get the size of the file
local psize = popen('wc -c <'..path..'/'..file_path)
for size in psize:lines() do
ngx.log(ngx.INFO, size)
table.insert( latest_size, size)
end
psize:close()
-- get the date of the file
local pdate = popen('date -d @$(stat -c "%Y" '..path..'/'..file_path..') "+%a, %-d %b %Y %H:%M:%S %Z"')
for date in pdate:lines() do
table.insert( latest_date, date )
end
pdate:close()
local escpath = hotesc(file_path)
table.insert( latest_path, escpath )
local temp = ""
local result = ""
for i = file_path:len(), 1, -1 do
if file_path:sub(i,i) ~= "/" then
temp = temp..file_path:sub(i,i)
else
break
end
end
for j = temp:len(), 1, -1 do
result = result..temp:sub(j,j)
end
table.insert( latest_name, result )
end
return latest_path, latest_name, latest_size, latest_date
end
utils['total_files_dir'] = function( path ) utils['total_files_dir'] = function( path )
local i, t, popen = 0, {}, io.popen local i, t, popen = 0, {}, io.popen
local pfile = popen('find "'..path..'" -type f | wc -l') local pfile = popen('find "'..path..'" -type f | wc -l')
@@ -121,4 +190,13 @@ utils['total_files_dir'] = function( path )
return t return t
end end
utils['rss_date_now'] = function()
local popen = io.popen
local pdate = popen('date "+%a, %-d %b %Y %H:%M:%S %Z"')
for date in pdate:lines() do
return date
end
pdate:close()
end
return utils return utils
+1 -1
View File
@@ -31,7 +31,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/' .. titles.url .. '/' .. file:gsub("#", "%%23") %>"> <a class="amixlink" href="<%= '/data/' .. titles.url .. '/' .. file %>">
<span class="mixlink"><%= latestname[i] %></span> <span class="mixlink"><%= latestname[i] %></span>
</a> </a>
</br> </br>
+2 -2
View File
@@ -10,13 +10,13 @@
<% for i, dir in ipairs(dirs) do %> <% for i, dir in ipairs(dirs) do %>
<br> <br>
<a href="<%= uri .. dir %>" class="djsection"><span><%= dir %></span></a> <a href="<%- functions.hotesc(uri .. dir) %>" class="djsection"><span><%= dir %></span></a>
<br> <br>
<% end %> <% end %>
<br> <br>
<% for i, file in ipairs(files) do %> <% for i, file in ipairs(files) do %>
<a class="amixlink" href="<%= path .. file:gsub("#", "%%23") %>"> <a class="amixlink" href="<%- functions.hotesc(path .. file) %>">
<span class="mixlink"><%= file %></span> <span class="mixlink"><%= file %></span>
</a> </a>
<br> <br>
+27 -6
View File
@@ -1,17 +1,38 @@
<?xml version="1.0" encoding="ISO-8859-1" ?> <?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"> <rss version="2.0"
xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd"
xmlns:podcast="https://podcastindex.org/namespace/1.0"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:content="http://purl.org/rss/1.0/modules/content/">
<channel> <channel>
<atom:link href="https://<%= titles['url'] %>/latest.xml" rel="self" type="application/rss+xml" /> <atom:link href="https://<%= titles['url'] %>/latest.rss"
rel="self" type="application/rss+xml" />
<title><%= titles['name'] %></title> <title><%= titles['name'] %></title>
<link>https://<%= titles['url'] %></link> <link>https://<%= titles['url'] %></link>
<description>Latest uploads</description> <language>en-us</language>
<itunes:author>Intergalactic FM</itunes:author>
<itunes:owner>
<itunes:name>Intergalactic FM</itunes:name>
</itunes:owner>
<description>Latest audio uploads on <%= titles['name'] %></description>
<itunes:summary>Latest audio uploads on <%= titles['name'] %></itunes:summary>
<itunes:explicit>false</itunes:explicit>
<itunes:category text="Music">
<itunes:category text="Electronic"/>
</itunes:category>
<itunes:image href="https://intergalactic.fm/themes/custom/ifm/logo.svg"/>
<lastBuildDate><%= datenow %></lastBuildDate>
<podcast:guid>intergalactic-fm-<%= titles['feed'] %>-feed</podcast:guid>
<% for i, file in ipairs(latestpath) do %> <% for i, file in ipairs(latestpath) do %>
<item> <item>
<title><%= latestname[i] %></title> <title><%= latestname[i] %></title>
<link><%= datapath .. file:gsub("#", "%%23") %></link> <enclosure url="<%= datapath .. file %>" length="<%= latestsize[i] %>" type="audio/mpeg"/>
<guid><%= datapath .. file %></guid>
<pubDate><%= latestdate[i] %></pubDate>
<description><![CDATA[<%= latestname[i] %>]]></description> <description><![CDATA[<%= latestname[i] %>]]></description>
<guid><%= datapath .. file:gsub("#", "%%23") %></guid> <itunes:explicit>false</itunes:explicit>
</item> </item>
<% end %> <% end %>
</channel> </channel>
+2 -2
View File
@@ -8,12 +8,12 @@ services:
- /data:/mnt/data:ro - /data:/mnt/data:ro
labels: labels:
- traefik.enable=true - traefik.enable=true
- traefik.http.routers.hotmixes.rule=Host(`videohotmix.net`) || Host(`www.videohotmix.net`) || Host(`panamaracing.club`) || Host(`hotmixxx.com`) - traefik.http.routers.hotmixes.rule=Host(`videohotmix.net`) || Host(`www.videohotmix.net`) || Host(`panamaracing.club`) || Host(`hotmixxx.com`) || Host(`hotmixes.net`) || Host(`www.hotmixes.net`)
- traefik.http.routers.hotmixes.entrypoints=web - traefik.http.routers.hotmixes.entrypoints=web
- traefik.http.routers.hotmixes.middlewares=redirect-https-hotmixes - traefik.http.routers.hotmixes.middlewares=redirect-https-hotmixes
- traefik.http.middlewares.redirect-https-hotmixes.redirectscheme.scheme=https - traefik.http.middlewares.redirect-https-hotmixes.redirectscheme.scheme=https
- traefik.http.routers.hotmixes_ssl.rule=Host(`videohotmix.net`) || Host(`www.videohotmix.net`) || Host(`panamaracing.club`) || Host(`hotmixxx.com`) - traefik.http.routers.hotmixes_ssl.rule=Host(`videohotmix.net`) || Host(`www.videohotmix.net`) || Host(`panamaracing.club`) || Host(`hotmixxx.com`) || Host(`hotmixes.net`) || Host(`www.hotmixes.net`)
- traefik.http.routers.hotmixes_ssl.entrypoints=websecure - traefik.http.routers.hotmixes_ssl.entrypoints=websecure
- traefik.http.routers.hotmixes_ssl.tls.certresolver=myresolver - traefik.http.routers.hotmixes_ssl.tls.certresolver=myresolver