mirror of
https://github.com/iv-org/invidious.git
synced 2024-09-11 01:18:06 +02:00
Add mapping macro and move templated into helpers.cr
This commit is contained in:
parent
b388181cd4
commit
4ae88cd286
@ -1,3 +1,18 @@
|
|||||||
|
macro add_mapping(mapping)
|
||||||
|
def initialize({{*mapping.keys.map { |id| "@#{id}".id }}})
|
||||||
|
end
|
||||||
|
|
||||||
|
def to_a
|
||||||
|
return [{{*mapping.keys.map { |id| "@#{id}".id }}}]
|
||||||
|
end
|
||||||
|
|
||||||
|
DB.mapping({{mapping}})
|
||||||
|
end
|
||||||
|
|
||||||
|
macro templated(filename)
|
||||||
|
render "src/views/#{{{filename}}}.ecr", "src/views/layout.ecr"
|
||||||
|
end
|
||||||
|
|
||||||
class Video
|
class Video
|
||||||
module HTTPParamConverter
|
module HTTPParamConverter
|
||||||
def self.from_rs(rs)
|
def self.from_rs(rs)
|
||||||
@ -5,24 +20,7 @@ class Video
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def initialize(id, info, updated, title, views, likes, dislikes, wilson_score, published, description)
|
add_mapping({
|
||||||
@id = id
|
|
||||||
@info = info
|
|
||||||
@updated = updated
|
|
||||||
@title = title
|
|
||||||
@views = views
|
|
||||||
@likes = likes
|
|
||||||
@dislikes = dislikes
|
|
||||||
@wilson_score = wilson_score
|
|
||||||
@published = published
|
|
||||||
@description = description
|
|
||||||
end
|
|
||||||
|
|
||||||
def to_a
|
|
||||||
return [@id, @info, @updated, @title, @views, @likes, @dislikes, @wilson_score, @published, @description]
|
|
||||||
end
|
|
||||||
|
|
||||||
DB.mapping({
|
|
||||||
id: String,
|
id: String,
|
||||||
info: {
|
info: {
|
||||||
type: HTTP::Params,
|
type: HTTP::Params,
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
# "Invidious" (which indexes popular video sites)
|
# "Invidious" (which is what YouTube should be)
|
||||||
# Copyright (C) 2018 Omar Roth
|
# Copyright (C) 2018 Omar Roth
|
||||||
#
|
#
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# This program is free software: you can redistribute it and/or modify
|
||||||
|
Loading…
Reference in New Issue
Block a user