mirror of
https://github.com/iv-org/invidious.git
synced 2025-07-14 09:28:32 +00:00
Add ability to load extension shards for Invidious
This commit is contained in:
parent
b173d4acf2
commit
5bf4e20c5a
2
.gitignore
vendored
2
.gitignore
vendored
@ -7,3 +7,5 @@
|
||||
/invidious
|
||||
/sentry
|
||||
/config/config.yml
|
||||
|
||||
/src/addons/enabled.txt
|
19
src/addons/extract-addons.cr
Normal file
19
src/addons/extract-addons.cr
Normal file
@ -0,0 +1,19 @@
|
||||
require "yaml"
|
||||
|
||||
shardyml = File.open("shard.yml") do |file|
|
||||
YAML.parse(file).as_h
|
||||
end
|
||||
|
||||
# Finds all dependencies prefixed with extendious
|
||||
raw_addons = shardyml["dependencies"].as_h.keys.select(&.as_s.starts_with?("extendious"))
|
||||
addons = [] of String
|
||||
|
||||
raw_addons.map do |addon_name|
|
||||
addon_name = addon_name.as_s
|
||||
addon_module = addon_name.lchop("extendious-")
|
||||
addon_module = addon_module.split("-").map!(&.capitalize).join
|
||||
|
||||
addons << "#{addon_name},#{addon_module}"
|
||||
end
|
||||
|
||||
File.write("src/addons/enabled.txt", addons.join("\n"))
|
@ -243,6 +243,17 @@ Kemal.config.host_binding = Kemal.config.host_binding != "0.0.0.0" ? Kemal.confi
|
||||
Kemal.config.port = Kemal.config.port != 3000 ? Kemal.config.port : CONFIG.port
|
||||
Kemal.config.app_name = "Invidious"
|
||||
|
||||
# Loads optional extensions for Invidious
|
||||
# Essentially just glorified shards with a set naming scheme
|
||||
# and load method
|
||||
|
||||
{{run("./addons/extract-addons.cr", "--minified")}}
|
||||
{% for addon in read_file("src/addons/enabled.txt").lines %}
|
||||
{% shard_name, module_name = addon.split(",") %}
|
||||
require {{shard_name.id.stringify}}
|
||||
{{module_name.id}}Ext.invidious_load
|
||||
{% end %}
|
||||
|
||||
# Use in kemal's production mode.
|
||||
# Users can also set the KEMAL_ENV environmental variable for this to be set automatically.
|
||||
{% if flag?(:release) || flag?(:production) %}
|
||||
|
Loading…
Reference in New Issue
Block a user