diff options
| author | Omar Roth <omarroth@hotmail.com> | 2018-03-07 17:58:33 -0600 |
|---|---|---|
| committer | Omar Roth <omarroth@hotmail.com> | 2018-03-07 17:58:33 -0600 |
| commit | 4ae88cd2860cb018b5ff24625a869bf80fbeefbe (patch) | |
| tree | 5650e462e0420c75919f13e38781621bd2373eda /src | |
| parent | b388181cd449817e9a17d4392ced4b83760a0b1e (diff) | |
| download | invidious-4ae88cd2860cb018b5ff24625a869bf80fbeefbe.tar.gz invidious-4ae88cd2860cb018b5ff24625a869bf80fbeefbe.tar.bz2 invidious-4ae88cd2860cb018b5ff24625a869bf80fbeefbe.zip | |
Add mapping macro and move templated into helpers.cr
Diffstat (limited to 'src')
| -rw-r--r-- | src/helpers.cr | 34 | ||||
| -rw-r--r-- | src/invidious.cr | 2 |
2 files changed, 17 insertions, 19 deletions
diff --git a/src/helpers.cr b/src/helpers.cr index 7aefe615..deb46080 100644 --- a/src/helpers.cr +++ b/src/helpers.cr @@ -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 module HTTPParamConverter def self.from_rs(rs) @@ -5,24 +20,7 @@ class Video end end - def initialize(id, info, updated, title, views, likes, dislikes, wilson_score, published, description) - @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({ + add_mapping({ id: String, info: { type: HTTP::Params, diff --git a/src/invidious.cr b/src/invidious.cr index 126820fe..545b3fe7 100644 --- a/src/invidious.cr +++ b/src/invidious.cr @@ -1,4 +1,4 @@ -# "Invidious" (which indexes popular video sites) +# "Invidious" (which is what YouTube should be) # Copyright (C) 2018 Omar Roth # # This program is free software: you can redistribute it and/or modify |
