package SReview::Files::Collection::HTTP::nginx::JSON;
use Moose;
use Mojo::UserAgent;
use DateTime::Format::Strptime;
extends 'SReview::Files::Collection::HTTP';
sub _probe_children {
my $self =
s->is_success) {
foreach my $obj(@{$res->json}) {
if($obj->{type} eq "directory") {
foreach my $child(@{SReview::Files::Collection::HTTP::nginx::JSON->new(baseurl => join("/", $self->baseurl,
ta::Dumper;
sub add {
my $c = shift->openapi->valid_input or return;
return add_with_json($c, $c->req->json, "events", $c->openapi->spec('/components/schemas/Event/properties'));
}
sub update {
r return;
my $eventId = $c->param("eventId");
my $event = $c->req->json;
$event->{id} = $eventId;
return update_with_json($c, $event, "events", $c->openapi->spec('/components/schemas/Event/pr
rict;
use warnings;
package SReview::Config;
use Data::Dumper;
use Carp;
use Mojo::JSON qw/decode_json encode_json/;
use Text::Format;
=head1 NAME
SReview::Config - Self-reproducing and self-docum
efault;
my $NAME = uc $name;
if(exists($ENV{"SREVIEW_${NAME}"})) {
$self->set($name => decode_json($ENV{"SREVIEW_${NAME}"}));
}
};
=head2 $config->define_deprecated(oldname, newname, conversion_
}
my $NAME = uc $oldname;
if(exists($ENV{"SREVIEW_${NAME}"})) {
$self->set($newname => decode_json($ENV{"SREVIEW_${NAME}"}));
}
}
=head2 $config->define_computed('name')
Defines a default value
package SReview::Web;
use Mojo::Base 'Mojolicious';
use Mojo::Collection 'c';
use Mojo::JSON qw(encode_json);
use Mojo::Pg;
use Mojo::URL;
use Crypt::PRNG qw/random_string/;
use SReview;
use SReview:
t('/released' => sub {
my $c = shift;
my $st;
my $conference = {};
my $videos = [];
my %json;
my %formats;
my $have_default = 0;
$st = $c->dbh->prepare("SELECT MIN(starttime::date), MA
WHERE talks.event = ? LIMIT 1");
$st->execute($c->eventid);
if($st->rows < 1) {
$c->render(json => {});
return;
}
$row = $st->fetchrow_hashref;
my $collection = SReview::Files::Factory
e Media::Convert::Asset::ProfileFactory;
use Mojo::Pg;
use Mojo::Template;
use Mojo::JSON qw/encode_json decode_json/;
use SReview::Config::Common;
use SReview::Talk::State;
use SReview::Talk::Progres
cute($self->talkid);
my $row = $st->fetchrow_arrayref;
if(defined($row->[0])) {
return decode_json($row->[0]);
}
return {};
}
has 'active_stream' => (
is => 'rw',
builder => '_probe_stream',
if($self->_has_flags) {
$db->prepare("UPDATE talks SET flags=? WHERE id = ?")->execute(encode_json($self->flags), $self->talkid);
}
if($self->has_stream) {
$db->prepare("UPDATE talks SET activ
g::Common;
use SReview::Config;
use strict;
use warnings;
use feature 'state';
use Mojo::JSON qw/decode_json/;
sub get_default_cfile {
my $dir = $ENV{SREVIEW_WDIR};
my $write = shift;
$dir = ".
{SREVIEW_S3_DEFAULT_HOST};
}
if(exists($ENV{SREVIEW_S3_EXTRA_CONFIGS})) {
my $extras = decode_json($ENV{SREVIEW_S3_EXTRA_CONFIGS});
foreach my $extra(keys %$extras) {
$rv->{$extra} = $extras-
YPE talkstate;
ALTER TYPE talkstate_new RENAME TO talkstate;
-- 21 up
ALTER TABLE talks ADD flags json;
-- 21 down
ALTER TABLE talks DROP flags;
-- 22 up
CREATE TYPE talkstate_new AS ENUM (
'waiti
lename);
ALTER TABLE talks ALTER flags TYPE jsonb;
-- 23 down
ALTER TABLE raw_files DROP CONSTRAINT unique_filename;
ALTER TABLE talks ALTER flags TYPE json;
-- 24 up
CREATE TYPE talkstate_new AS ENUM
w/db_query update_with_json add_with_json delete_with_query/;
our @EXPORT_OK = qw/db_query_log is_authed/;
use SReview::Config::Common;
use Mojo::JSON qw/decode_json encode_json/;
use DateTime::Forma
;
$c->render(openapi => $row->[0]);
}
sub update_with_json {
my ($c, $json, $tablename, $fields, $fixup) = @_;
my @args;
if(!exists($json->{id})) {
$c->render(openapi => {errors => [{message
return;
}
$c->app->log->debug("updating $tablename with " . encode_json($json));
my @updates;
while(my @tuple = each %$json) {
if($tuple[0] eq "id") {
$c->app->log->debug("skipping id");
(json => $rv);
}
sub index { }
1;
__DATA__
@@ schedule/index.html.ep
% layout 'admin'
<h1>Schedule management</h1>
<p>Possitble actions:</p>
<dl><dt>GET /admin/schedule/list</dt>
<dd>Creates a JSON
he talk with the given ID</dd>
<dt>PUT /admin/schedule/talk/</dt>
<dd>Create a new talk (requires JSON object)</dd>
<dt>PUT /admin/schedule/talk/:id</dt>
<dd>Update the data of the talk with the given
use SReview::API::Helpers qw/db_query update_with_json add_with_json is_authed/;
use Mojo::Util 'slugify';
use Mojo::JSON qw/encode_json decode_json/;
use DateTime::Format::Pg;
use SReview::Talk;
s
g->parse_datetime($talk->{endtime})->iso8601();
if($talk->{flags}) {
$talk->{flags} = decode_json($talk->{flags});
}
if(!is_authed($c)) {
delete($talk->{
return $talks;
}
sub fixup {
my $talk = shift;
if($talk->{flags}) {
$talk->{flags} = decode_json($talk->{flags});
}
return $talk;
}
sub listByEvent {
my $c = shift->openapi->valid_input or r
ers;
sub add {
my $c = shift->openapi->valid_input or return;
my $user = $c->req->json;
return add_with_json($c, $user, "users", $c->openapi->spec('/components/schemas/User/properties'));
}
sub
put or return;
my $userId = $c->param("userId");
my $user = $c->req->json;
$user->{id} = $userId;
return update_with_json($c, $user, "users", $c->openapi->spec('/components/schemas/User/propert
ession->{room} = $row->[4];
my $json = {};
if(!$c->session->{volunteer}) {
my $apikey = random_string();
$json->{apiKey} = $apikey;
$c
talk->video_fragments);
$data->{filename} = $talk->relative_name . "/main" . $c->srconfig->get("preview_exten");
$data->{room} = $talk->room;
$c->render(json => $data);
}
1;
my $c = shift->openapi->valid_input or return;
my $track = $c->req->json;
return add_with_json($c, $track, "tracks", $c->openapi->spec('/components/schemas/Track/properties'));
or return;
my $track = $c->req->json;
my $trackId = $c->param('trackId');
$track->{id} = $trackId;
return update_with_json($c, $track, "tracks", $c->openapi->spec('
my $c = shift->openapi->valid_input or return;
my $room = $c->req->json;
return add_with_json($c, $room, "rooms", $c->openapi->spec('/components/schemas/Room/properties'));
}
my $roomId = $c->param('roomId');
my $room = $c->req->json;
$room->{id} = $roomId;
return update_with_json($c, $room, "rooms", $c->openapi->spec('/components/schemas/Room/
i->valid_input or return;
my $speaker = $c->req->json;
$c->app->log->debug(join(',', keys %$speaker));
return add_with_json($c, $speaker, "speakers", $c->openapi->spec('/components/
rId = $c->param("speakerId");
my $speaker = $c->req->json;
$speaker->{id} = $speakerId;
return update_with_json($c, $speaker, "speakers", $c->openapi->spec('/components/sche
responses:
200:
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/ConfigData'
/config/legend:
responses:
200:
description: OK
content:
application/json:
schema:
type: array
items:
type:
responses:
200:
description: OK
content:
application/json:
schema:
type: array
items:
$ref: