2023-03-02 13:24:24 -05:00
|
|
|
require 'logger'
|
|
|
|
require 'sequel'
|
|
|
|
require 'sqlite3'
|
|
|
|
require 'sinatra'
|
|
|
|
require 'sinatra/namespace'
|
|
|
|
|
|
|
|
require_relative 'lib/config.rb'
|
|
|
|
|
|
|
|
set :public_folder, __dir__ + '/public'
|
|
|
|
|
|
|
|
set :views, settings.root + '/views'
|
|
|
|
|
|
|
|
# Load configuration file
|
2023-03-03 23:22:17 -05:00
|
|
|
$conf = Config.new(File.join(__dir__, 'data/defaults.yaml'))
|
2023-03-02 13:24:24 -05:00
|
|
|
|
|
|
|
# Initialize logging
|
|
|
|
logger = Logger.new(STDOUT)
|
|
|
|
logger.level = Logger::INFO
|
|
|
|
|
|
|
|
# Load the Sequel timestamps plugin
|
|
|
|
Sequel::Model.plugin :timestamps
|
|
|
|
# Initialize Sequel gem for database actions
|
2023-03-03 23:22:17 -05:00
|
|
|
DB = Sequel.connect(adapter: $conf.get('database.adapter'), database: $conf.get('database.database'))
|
2023-03-02 13:24:24 -05:00
|
|
|
# Load models
|
2023-03-03 13:05:01 -05:00
|
|
|
require_relative 'lib/models/channel.rb'
|
|
|
|
require_relative 'lib/models/video.rb'
|
2023-03-02 13:24:24 -05:00
|
|
|
|
|
|
|
# Load helper functions
|
|
|
|
require_relative 'lib/helpers.rb'
|
|
|
|
|
|
|
|
# Register route handlers
|
|
|
|
require_relative 'lib/routes.rb'
|