mirror of
https://github.com/algora-io/tv.git
synced 2024-11-16 00:58:59 +02:00
initial commit
This commit is contained in:
commit
e07cf7fd6c
217
.credo.exs
Normal file
217
.credo.exs
Normal file
@ -0,0 +1,217 @@
|
||||
# This file contains the configuration for Credo and you are probably reading
|
||||
# this after creating it with `mix credo.gen.config`.
|
||||
#
|
||||
# If you find anything wrong or unclear in this file, please report an
|
||||
# issue on GitHub: https://github.com/rrrene/credo/issues
|
||||
#
|
||||
%{
|
||||
#
|
||||
# You can have as many configs as you like in the `configs:` field.
|
||||
configs: [
|
||||
%{
|
||||
#
|
||||
# Run any config using `mix credo -C <name>`. If no config name is given
|
||||
# "default" is used.
|
||||
#
|
||||
name: "default",
|
||||
#
|
||||
# These are the files included in the analysis:
|
||||
files: %{
|
||||
#
|
||||
# You can give explicit globs or simply directories.
|
||||
# In the latter case `**/*.{ex,exs}` will be used.
|
||||
#
|
||||
included: [
|
||||
"lib/",
|
||||
"src/",
|
||||
"test/",
|
||||
"web/",
|
||||
"apps/*/lib/",
|
||||
"apps/*/src/",
|
||||
"apps/*/test/",
|
||||
"apps/*/web/"
|
||||
],
|
||||
excluded: [~r"/_build/", ~r"/deps/", ~r"/node_modules/"]
|
||||
},
|
||||
#
|
||||
# Load and configure plugins here:
|
||||
#
|
||||
plugins: [],
|
||||
#
|
||||
# If you create your own checks, you must specify the source files for
|
||||
# them here, so they can be loaded by Credo before running the analysis.
|
||||
#
|
||||
requires: [],
|
||||
#
|
||||
# If you want to enforce a style guide and need a more traditional linting
|
||||
# experience, you can change `strict` to `true` below:
|
||||
#
|
||||
strict: false,
|
||||
#
|
||||
# To modify the timeout for parsing files, change this value:
|
||||
#
|
||||
parse_timeout: 5000,
|
||||
#
|
||||
# If you want to use uncolored output by default, you can change `color`
|
||||
# to `false` below:
|
||||
#
|
||||
color: true,
|
||||
#
|
||||
# You can customize the parameters of any check by adding a second element
|
||||
# to the tuple.
|
||||
#
|
||||
# To disable a check put `false` as second element:
|
||||
#
|
||||
# {Credo.Check.Design.DuplicatedCode, false}
|
||||
#
|
||||
checks: %{
|
||||
enabled: [
|
||||
#
|
||||
## Consistency Checks
|
||||
#
|
||||
{Credo.Check.Consistency.ExceptionNames, []},
|
||||
{Credo.Check.Consistency.LineEndings, []},
|
||||
{Credo.Check.Consistency.ParameterPatternMatching, []},
|
||||
{Credo.Check.Consistency.SpaceAroundOperators, []},
|
||||
{Credo.Check.Consistency.SpaceInParentheses, []},
|
||||
{Credo.Check.Consistency.TabsOrSpaces, []},
|
||||
|
||||
#
|
||||
## Design Checks
|
||||
#
|
||||
# You can customize the priority of any check
|
||||
# Priority values are: `low, normal, high, higher`
|
||||
#
|
||||
{Credo.Check.Design.AliasUsage,
|
||||
[priority: :low, if_nested_deeper_than: 2, if_called_more_often_than: 0]},
|
||||
{Credo.Check.Design.TagFIXME, []},
|
||||
# You can also customize the exit_status of each check.
|
||||
# If you don't want TODO comments to cause `mix credo` to fail, just
|
||||
# set this value to 0 (zero).
|
||||
#
|
||||
{Credo.Check.Design.TagTODO, [exit_status: 2]},
|
||||
|
||||
#
|
||||
## Readability Checks
|
||||
#
|
||||
{Credo.Check.Readability.AliasOrder, []},
|
||||
{Credo.Check.Readability.FunctionNames, []},
|
||||
{Credo.Check.Readability.LargeNumbers, []},
|
||||
{Credo.Check.Readability.MaxLineLength, [priority: :low, max_length: 120]},
|
||||
{Credo.Check.Readability.ModuleAttributeNames, []},
|
||||
# {Credo.Check.Readability.ModuleDoc, []},
|
||||
{Credo.Check.Readability.ModuleNames, []},
|
||||
{Credo.Check.Readability.ParenthesesInCondition, []},
|
||||
{Credo.Check.Readability.ParenthesesOnZeroArityDefs, []},
|
||||
{Credo.Check.Readability.PipeIntoAnonymousFunctions, []},
|
||||
{Credo.Check.Readability.PredicateFunctionNames, []},
|
||||
{Credo.Check.Readability.PreferImplicitTry, []},
|
||||
{Credo.Check.Readability.RedundantBlankLines, []},
|
||||
{Credo.Check.Readability.Semicolons, []},
|
||||
{Credo.Check.Readability.SpaceAfterCommas, []},
|
||||
{Credo.Check.Readability.StringSigils, []},
|
||||
{Credo.Check.Readability.TrailingBlankLine, []},
|
||||
{Credo.Check.Readability.TrailingWhiteSpace, []},
|
||||
{Credo.Check.Readability.UnnecessaryAliasExpansion, []},
|
||||
{Credo.Check.Readability.VariableNames, []},
|
||||
{Credo.Check.Readability.WithSingleClause, []},
|
||||
|
||||
#
|
||||
## Refactoring Opportunities
|
||||
#
|
||||
{Credo.Check.Refactor.Apply, []},
|
||||
{Credo.Check.Refactor.CondStatements, []},
|
||||
{Credo.Check.Refactor.CyclomaticComplexity, []},
|
||||
{Credo.Check.Refactor.FilterCount, []},
|
||||
{Credo.Check.Refactor.FilterFilter, []},
|
||||
{Credo.Check.Refactor.FunctionArity, []},
|
||||
{Credo.Check.Refactor.LongQuoteBlocks, []},
|
||||
{Credo.Check.Refactor.MapJoin, []},
|
||||
{Credo.Check.Refactor.MatchInCondition, []},
|
||||
{Credo.Check.Refactor.NegatedConditionsInUnless, []},
|
||||
{Credo.Check.Refactor.NegatedConditionsWithElse, []},
|
||||
{Credo.Check.Refactor.Nesting, []},
|
||||
{Credo.Check.Refactor.RedundantWithClauseResult, []},
|
||||
{Credo.Check.Refactor.RejectReject, []},
|
||||
{Credo.Check.Refactor.UnlessWithElse, []},
|
||||
{Credo.Check.Refactor.WithClauses, []},
|
||||
|
||||
#
|
||||
## Warnings
|
||||
#
|
||||
{Credo.Check.Warning.ApplicationConfigInModuleAttribute, []},
|
||||
{Credo.Check.Warning.BoolOperationOnSameValues, []},
|
||||
{Credo.Check.Warning.Dbg, []},
|
||||
{Credo.Check.Warning.ExpensiveEmptyEnumCheck, []},
|
||||
{Credo.Check.Warning.IExPry, []},
|
||||
{Credo.Check.Warning.IoInspect, []},
|
||||
{Credo.Check.Warning.MissedMetadataKeyInLoggerConfig, []},
|
||||
{Credo.Check.Warning.OperationOnSameValues, []},
|
||||
{Credo.Check.Warning.OperationWithConstantResult, []},
|
||||
{Credo.Check.Warning.RaiseInsideRescue, []},
|
||||
{Credo.Check.Warning.SpecWithStruct, []},
|
||||
{Credo.Check.Warning.UnsafeExec, []},
|
||||
{Credo.Check.Warning.UnusedEnumOperation, []},
|
||||
{Credo.Check.Warning.UnusedFileOperation, []},
|
||||
{Credo.Check.Warning.UnusedKeywordOperation, []},
|
||||
{Credo.Check.Warning.UnusedListOperation, []},
|
||||
{Credo.Check.Warning.UnusedPathOperation, []},
|
||||
{Credo.Check.Warning.UnusedRegexOperation, []},
|
||||
{Credo.Check.Warning.UnusedStringOperation, []},
|
||||
{Credo.Check.Warning.UnusedTupleOperation, []}
|
||||
# {Credo.Check.Warning.WrongTestFileExtension, []}
|
||||
],
|
||||
disabled: [
|
||||
#
|
||||
# Checks scheduled for next check update (opt-in for now)
|
||||
{Credo.Check.Refactor.UtcNowTruncate, []},
|
||||
|
||||
#
|
||||
# Controversial and experimental checks (opt-in, just move the check to `:enabled`
|
||||
# and be sure to use `mix credo --strict` to see low priority checks)
|
||||
#
|
||||
{Credo.Check.Consistency.MultiAliasImportRequireUse, []},
|
||||
{Credo.Check.Consistency.UnusedVariableNames, []},
|
||||
{Credo.Check.Design.DuplicatedCode, []},
|
||||
{Credo.Check.Design.SkipTestWithoutComment, []},
|
||||
{Credo.Check.Readability.AliasAs, []},
|
||||
{Credo.Check.Readability.BlockPipe, []},
|
||||
{Credo.Check.Readability.ImplTrue, []},
|
||||
{Credo.Check.Readability.MultiAlias, []},
|
||||
{Credo.Check.Readability.NestedFunctionCalls, []},
|
||||
{Credo.Check.Readability.OneArityFunctionInPipe, []},
|
||||
{Credo.Check.Readability.OnePipePerLine, []},
|
||||
{Credo.Check.Readability.SeparateAliasRequire, []},
|
||||
{Credo.Check.Readability.SingleFunctionToBlockPipe, []},
|
||||
{Credo.Check.Readability.SinglePipe, []},
|
||||
{Credo.Check.Readability.Specs, []},
|
||||
{Credo.Check.Readability.StrictModuleLayout, []},
|
||||
{Credo.Check.Readability.WithCustomTaggedTuple, []},
|
||||
{Credo.Check.Refactor.ABCSize, []},
|
||||
{Credo.Check.Refactor.AppendSingleItem, []},
|
||||
{Credo.Check.Refactor.DoubleBooleanNegation, []},
|
||||
{Credo.Check.Refactor.FilterReject, []},
|
||||
{Credo.Check.Refactor.IoPuts, []},
|
||||
{Credo.Check.Refactor.MapMap, []},
|
||||
{Credo.Check.Refactor.ModuleDependencies, []},
|
||||
{Credo.Check.Refactor.NegatedIsNil, []},
|
||||
{Credo.Check.Refactor.PassAsyncInTestCases, []},
|
||||
{Credo.Check.Refactor.PipeChainStart, []},
|
||||
{Credo.Check.Refactor.RejectFilter, []},
|
||||
{Credo.Check.Refactor.VariableRebinding, []},
|
||||
{Credo.Check.Warning.LazyLogging, []},
|
||||
{Credo.Check.Warning.LeakyEnvironment, []},
|
||||
{Credo.Check.Warning.MapGetUnsafePass, []},
|
||||
{Credo.Check.Warning.MixEnv, []},
|
||||
{Credo.Check.Warning.UnsafeToAtom, []}
|
||||
|
||||
# {Credo.Check.Refactor.MapInto, []},
|
||||
|
||||
#
|
||||
# Custom checks can be created using `mix credo.gen.check`.
|
||||
#
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
28
.dockerignore
Normal file
28
.dockerignore
Normal file
@ -0,0 +1,28 @@
|
||||
.dockerignore
|
||||
# there are valid reasons to keep the .git, namely so that you can get the
|
||||
# current commit hash
|
||||
#.git
|
||||
.log
|
||||
tmp
|
||||
|
||||
# Mix artifacts
|
||||
_build
|
||||
deps
|
||||
*.ez
|
||||
releases
|
||||
|
||||
# Generate on crash by the VM
|
||||
erl_crash.dump
|
||||
|
||||
# Static artifacts
|
||||
node_modules
|
||||
|
||||
# Env files
|
||||
.env
|
||||
.env*.local
|
||||
.env.dev
|
||||
.env.prod
|
||||
|
||||
# Local files
|
||||
/tmp
|
||||
/.local
|
12
.env.example
Normal file
12
.env.example
Normal file
@ -0,0 +1,12 @@
|
||||
DATABASE_URL="postgresql://user:pass@localhost:5432/db"
|
||||
|
||||
GITHUB_CLIENT_ID=""
|
||||
GITHUB_CLIENT_SECRET=""
|
||||
|
||||
AWS_ENDPOINT_URL_S3="https://fly.storage.tigris.dev"
|
||||
AWS_REGION="auto"
|
||||
AWS_ACCESS_KEY_ID=""
|
||||
AWS_SECRET_ACCESS_KEY=""
|
||||
BUCKET_NAME=""
|
||||
|
||||
EVENT_SINK_URL=""
|
6
.formatter.exs
Normal file
6
.formatter.exs
Normal file
@ -0,0 +1,6 @@
|
||||
[
|
||||
import_deps: [:ecto, :phoenix],
|
||||
inputs: ["*.{heex,ex,exs}", "priv/*/seeds.exs", "{config,lib,test}/**/*.{heex,ex,exs}"],
|
||||
subdirectories: ["priv/*/migrations"],
|
||||
plugins: [Phoenix.LiveView.HTMLFormatter]
|
||||
]
|
43
.gitignore
vendored
Normal file
43
.gitignore
vendored
Normal file
@ -0,0 +1,43 @@
|
||||
# The directory Mix will write compiled artifacts to.
|
||||
/_build/
|
||||
|
||||
# If you run "mix test --cover", coverage assets end up here.
|
||||
/cover/
|
||||
|
||||
# The directory Mix downloads your dependencies sources to.
|
||||
/deps/
|
||||
|
||||
# Where 3rd-party dependencies like ExDoc output generated docs.
|
||||
/doc/
|
||||
|
||||
# Ignore .fetch files in case you like to edit your project deps locally.
|
||||
/.fetch
|
||||
|
||||
# If the VM crashes, it generates a dump, let's ignore it too.
|
||||
erl_crash.dump
|
||||
|
||||
# Also ignore archive artifacts (built via "mix archive.build").
|
||||
*.ez
|
||||
|
||||
# Ignore package tarball (built via "mix hex.build").
|
||||
algora-*.tar
|
||||
|
||||
# Ignore assets that are produced by build tools.
|
||||
/priv/static/assets/
|
||||
|
||||
# In case you use Node.js/npm, you want to ignore these.
|
||||
npm-debug.log
|
||||
/assets/node_modules/
|
||||
|
||||
# Ignore env files
|
||||
.env
|
||||
.env*.local
|
||||
.env.dev
|
||||
.env.prod
|
||||
|
||||
# Ignore local files
|
||||
/tmp
|
||||
/.local
|
||||
|
||||
# TODO: remove this once we start serving og images dynamically
|
||||
/priv/static/images/og
|
12
.iex.exs
Normal file
12
.iex.exs
Normal file
@ -0,0 +1,12 @@
|
||||
import Ecto.Query
|
||||
import Ecto.Changeset
|
||||
|
||||
alias Algora.Accounts
|
||||
alias Algora.Library
|
||||
alias Algora.Repo
|
||||
|
||||
IEx.configure(inspect: [charlists: :as_lists])
|
||||
|
||||
if Code.ensure_loaded?(ExSync) && function_exported?(ExSync, :register_group_leader, 0) do
|
||||
ExSync.register_group_leader()
|
||||
end
|
91
Dockerfile
Normal file
91
Dockerfile
Normal file
@ -0,0 +1,91 @@
|
||||
# Find eligible builder and runner images on Docker Hub. We use Ubuntu/Debian instead of
|
||||
# Alpine to avoid DNS resolution issues in production.
|
||||
#
|
||||
# https://hub.docker.com/r/hexpm/elixir/tags?page=1&name=ubuntu
|
||||
# https://hub.docker.com/_/ubuntu?tab=tags
|
||||
#
|
||||
#
|
||||
# This file is based on these images:
|
||||
#
|
||||
# - https://hub.docker.com/r/hexpm/elixir/tags - for the build image
|
||||
# - https://hub.docker.com/_/debian?tab=tags&page=1&name=bullseye-20210902-slim - for the release image
|
||||
# - https://pkgs.org/ - resource for finding needed packages
|
||||
# - Ex: hexpm/elixir:1.12.0-erlang-24.0.1-debian-bullseye-20210902-slim
|
||||
#
|
||||
ARG BUILDER_IMAGE="hexpm/elixir:1.15.7-erlang-26.2-debian-bookworm-20231009-slim"
|
||||
ARG RUNNER_IMAGE="debian:bookworm-20231009-slim"
|
||||
|
||||
FROM ${BUILDER_IMAGE} as builder
|
||||
|
||||
# install build dependencies
|
||||
RUN apt-get update -y && apt-get install -y build-essential git && apt-get clean && rm -f /var/lib/apt/lists/*_*
|
||||
|
||||
# prepare build dir
|
||||
WORKDIR /app
|
||||
|
||||
# install hex + rebar
|
||||
RUN mix local.hex --force && \
|
||||
mix local.rebar --force
|
||||
|
||||
# set build ENV
|
||||
ENV MIX_ENV="prod"
|
||||
|
||||
# install mix dependencies
|
||||
COPY mix.exs mix.lock ./
|
||||
RUN mix deps.get --only $MIX_ENV
|
||||
RUN mkdir config
|
||||
|
||||
# copy compile-time config files before we compile dependencies
|
||||
# to ensure any relevant config change will trigger the dependencies
|
||||
# to be re-compiled.
|
||||
COPY config/config.exs config/${MIX_ENV}.exs config/
|
||||
RUN mix deps.compile
|
||||
|
||||
COPY priv priv
|
||||
|
||||
# Compile the release
|
||||
COPY lib lib
|
||||
|
||||
# note: if your project uses a tool like https://purgecss.com/,
|
||||
# which customizes asset compilation based on what it finds in
|
||||
# your Elixir templates, you will need to move the asset compilation
|
||||
# step down so that `lib` is available.
|
||||
COPY assets assets
|
||||
|
||||
# compile assets
|
||||
RUN mix assets.deploy
|
||||
|
||||
RUN mix compile
|
||||
|
||||
# Changes to config/runtime.exs don't require recompiling the code
|
||||
COPY config/runtime.exs config/
|
||||
|
||||
COPY rel rel
|
||||
RUN mix release
|
||||
|
||||
# start a new build stage so that the final image will only contain
|
||||
# the compiled release and other runtime necessities
|
||||
FROM ${RUNNER_IMAGE}
|
||||
|
||||
RUN apt-get update -y && apt-get install -y libstdc++6 openssl libncurses5 locales ffmpeg imagemagick && apt-get clean && rm -f /var/lib/apt/lists/*_*
|
||||
|
||||
# Set the locale
|
||||
RUN sed -i '/en_US.UTF-8/s/^# //g' /etc/locale.gen && locale-gen
|
||||
|
||||
ENV LANG en_US.UTF-8
|
||||
ENV LANGUAGE en_US:en
|
||||
ENV LC_ALL en_US.UTF-8
|
||||
|
||||
WORKDIR "/app"
|
||||
RUN chown nobody /app
|
||||
|
||||
# Only copy the final release from the build stage
|
||||
COPY --from=builder --chown=nobody:root /app/_build/prod/rel/algora ./
|
||||
|
||||
USER nobody
|
||||
|
||||
# Set the runtime ENV
|
||||
ENV ECTO_IPV6="true"
|
||||
ENV ERL_AFLAGS="-proto_dist inet6_tcp"
|
||||
|
||||
CMD /app/bin/server
|
661
LICENSE
Normal file
661
LICENSE
Normal file
@ -0,0 +1,661 @@
|
||||
GNU AFFERO GENERAL PUBLIC LICENSE
|
||||
Version 3, 19 November 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU Affero General Public License is a free, copyleft license for
|
||||
software and other kinds of works, specifically designed to ensure
|
||||
cooperation with the community in the case of network server software.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
our General Public Licenses are intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
Developers that use our General Public Licenses protect your rights
|
||||
with two steps: (1) assert copyright on the software, and (2) offer
|
||||
you this License which gives you legal permission to copy, distribute
|
||||
and/or modify the software.
|
||||
|
||||
A secondary benefit of defending all users' freedom is that
|
||||
improvements made in alternate versions of the program, if they
|
||||
receive widespread use, become available for other developers to
|
||||
incorporate. Many developers of free software are heartened and
|
||||
encouraged by the resulting cooperation. However, in the case of
|
||||
software used on network servers, this result may fail to come about.
|
||||
The GNU General Public License permits making a modified version and
|
||||
letting the public access it on a server without ever releasing its
|
||||
source code to the public.
|
||||
|
||||
The GNU Affero General Public License is designed specifically to
|
||||
ensure that, in such cases, the modified source code becomes available
|
||||
to the community. It requires the operator of a network server to
|
||||
provide the source code of the modified version running there to the
|
||||
users of that server. Therefore, public use of a modified version, on
|
||||
a publicly accessible server, gives the public access to the source
|
||||
code of the modified version.
|
||||
|
||||
An older license, called the Affero General Public License and
|
||||
published by Affero, was designed to accomplish similar goals. This is
|
||||
a different license, not a version of the Affero GPL, but Affero has
|
||||
released a new version of the Affero GPL which permits relicensing under
|
||||
this license.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU Affero General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Remote Network Interaction; Use with the GNU General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, if you modify the
|
||||
Program, your modified version must prominently offer all users
|
||||
interacting with it remotely through a computer network (if your version
|
||||
supports such interaction) an opportunity to receive the Corresponding
|
||||
Source of your version by providing access to the Corresponding Source
|
||||
from a network server at no charge, through some standard or customary
|
||||
means of facilitating copying of software. This Corresponding Source
|
||||
shall include the Corresponding Source for any work covered by version 3
|
||||
of the GNU General Public License that is incorporated pursuant to the
|
||||
following paragraph.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the work with which it is combined will remain governed by version
|
||||
3 of the GNU General Public License.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU Affero General Public License from time to time. Such new versions
|
||||
will be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU Affero General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU Affero General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU Affero General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published
|
||||
by the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If your software can interact with users remotely through a computer
|
||||
network, you should also make sure that it provides a way for users to
|
||||
get its source. For example, if your program is a web application, its
|
||||
interface could display a "Source" link that leads users to an archive
|
||||
of the code. There are many ways you could offer source, and different
|
||||
solutions will be better for different programs; see section 13 for the
|
||||
specific requirements.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU AGPL, see
|
||||
<https://www.gnu.org/licenses/>.
|
108
README.md
Normal file
108
README.md
Normal file
@ -0,0 +1,108 @@
|
||||
<!-- PROJECT LOGO -->
|
||||
<p align="center">
|
||||
<a href="https://github.com/algora-io/tv">
|
||||
<img src="https://user-images.githubusercontent.com/17045339/231901505-2936b331-3716-4418-9386-4a5d9cb694ba.svg" alt="Logo">
|
||||
</a>
|
||||
|
||||
<h3 align="center">Algora TV</h3>
|
||||
|
||||
<p align="center">
|
||||
The interactive livestreaming & video sharing service for developers.
|
||||
<br />
|
||||
<a href="https://tv.algora.io">Website</a>
|
||||
·
|
||||
<a href="https://algora.io/discord">Discord</a>
|
||||
·
|
||||
<a href="https://twitter.com/algoraio">Twitter</a>
|
||||
·
|
||||
<a href="https://www.youtube.com/@algora-io">YouTube</a>
|
||||
·
|
||||
<a href="https://github.com/algora-io/tv/issues">Issues</a>
|
||||
</p>
|
||||
</p>
|
||||
|
||||
## Architecture
|
||||
|
||||
```mermaid
|
||||
graph
|
||||
Streamer{Streamer} --> Fly
|
||||
Fly[Elixir App - Fly] --> RTMP
|
||||
Fly --> Web[Web Server - Phoenix]
|
||||
Fly --> Db[Postgres - Fly]
|
||||
RTMP[RTMP Server - Membrane] -->|First mile delivery| Tigris[Object Storage - Tigris]
|
||||
Viewers{Viewers} -->|Last mile delivery| Tigris
|
||||
Viewers --> Fly
|
||||
```
|
||||
|
||||
<!-- GETTING STARTED -->
|
||||
|
||||
## Getting Started
|
||||
|
||||
To get a local copy up and running, please follow these steps.
|
||||
|
||||
### Prerequisites
|
||||
|
||||
Here is what you need to be able to run Algora TV.
|
||||
|
||||
- Elixir (Version: >=1.12)
|
||||
- OTP
|
||||
- PostgreSQL
|
||||
|
||||
## Development
|
||||
|
||||
### Setup
|
||||
|
||||
1. Clone the repo into a public GitHub repository (or fork https://github.com/algora-io/tv/fork).
|
||||
|
||||
```sh
|
||||
git clone https://github.com/algora-io/tv.git
|
||||
```
|
||||
|
||||
2. Go to the project folder
|
||||
|
||||
```sh
|
||||
cd tv
|
||||
```
|
||||
|
||||
3. Install dependencies with mix
|
||||
|
||||
```sh
|
||||
mix deps.get
|
||||
```
|
||||
|
||||
4. Set up your `.env` file
|
||||
|
||||
- Duplicate `.env.example` to `.env`
|
||||
- Add your environment variables in the `.env` file
|
||||
|
||||
5. Create and migrate your database with mix
|
||||
|
||||
```sh
|
||||
mix ecto.setup
|
||||
```
|
||||
|
||||
6. Start your development server
|
||||
|
||||
```sh
|
||||
env $(cat .env | xargs -L 1) iex -S mix phx.server
|
||||
```
|
||||
|
||||
<!-- LICENSE -->
|
||||
|
||||
## License
|
||||
|
||||
Distributed under the [AGPLv3 License](https://github.com/algora-io/tv/blob/main/LICENSE). See `LICENSE` for more information.
|
||||
|
||||
<!-- ACKNOWLEDGEMENTS -->
|
||||
|
||||
## Acknowledgements
|
||||
|
||||
Special thanks to these amazing projects which help power Algora TV:
|
||||
|
||||
- [Tigris](https://www.tigrisdata.com/)
|
||||
- [Fly.io](https://fly.io/)
|
||||
- [Phoenix Framework](https://www.phoenixframework.org/)
|
||||
- [Ecto](https://github.com/elixir-ecto/ecto)
|
||||
- [Membrane](https://membrane.stream/)
|
||||
- [FFmpeg](https://ffmpeg.org/)
|
||||
- [Tailwind CSS](https://tailwindcss.com/)
|
160
assets/css/app.css
Normal file
160
assets/css/app.css
Normal file
@ -0,0 +1,160 @@
|
||||
/* This file is for your main application CSS */
|
||||
@import "tailwindcss/base";
|
||||
@import "tailwindcss/components";
|
||||
@import "tailwindcss/utilities";
|
||||
|
||||
@layer base {
|
||||
:root {
|
||||
--radius: 0.5rem;
|
||||
}
|
||||
* {
|
||||
@apply border-gray-800;
|
||||
}
|
||||
body {
|
||||
@apply bg-gray-950 text-white;
|
||||
}
|
||||
}
|
||||
|
||||
/* animations */
|
||||
.fade-in-scale {
|
||||
animation: 0.2s ease-in 0s normal forwards 1 fade-in-scale-keys;
|
||||
}
|
||||
|
||||
.fade-out-scale {
|
||||
animation: 0.2s ease-out 0s normal forwards 1 fade-out-scale-keys;
|
||||
}
|
||||
|
||||
.fade-in {
|
||||
animation: 0.2s ease-out 0s normal forwards 1 fade-in-keys;
|
||||
}
|
||||
.fade-out {
|
||||
animation: 0.2s ease-out 0s normal forwards 1 fade-out-keys;
|
||||
}
|
||||
|
||||
@keyframes fade-in-scale-keys {
|
||||
0% {
|
||||
scale: 0.95;
|
||||
opacity: 0;
|
||||
}
|
||||
100% {
|
||||
scale: 1;
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes fade-out-scale-keys {
|
||||
0% {
|
||||
scale: 1;
|
||||
opacity: 1;
|
||||
}
|
||||
100% {
|
||||
scale: 0.95;
|
||||
opacity: 0;
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes fade-in-keys {
|
||||
0% {
|
||||
opacity: 0;
|
||||
}
|
||||
100% {
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes fade-out-keys {
|
||||
0% {
|
||||
opacity: 1;
|
||||
}
|
||||
100% {
|
||||
opacity: 0;
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes slide-in-right-keys {
|
||||
100% {
|
||||
transform: translateX(0%);
|
||||
}
|
||||
}
|
||||
|
||||
/* Alerts and form errors used by phx.new */
|
||||
.alert {
|
||||
padding: 15px;
|
||||
margin-bottom: 20px;
|
||||
border: 1px solid transparent;
|
||||
border-radius: 4px;
|
||||
}
|
||||
.alert-info {
|
||||
color: #31708f;
|
||||
background-color: #d9edf7;
|
||||
border-color: #bce8f1;
|
||||
}
|
||||
.alert-warning {
|
||||
color: #8a6d3b;
|
||||
background-color: #fcf8e3;
|
||||
border-color: #faebcc;
|
||||
}
|
||||
.alert-danger {
|
||||
color: #a94442;
|
||||
background-color: #f2dede;
|
||||
border-color: #ebccd1;
|
||||
}
|
||||
.alert p {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
.alert:empty {
|
||||
display: none;
|
||||
}
|
||||
.invalid-feedback {
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
/* LiveView specific classes for your customization */
|
||||
.phx-no-feedback.invalid-feedback,
|
||||
.phx-no-feedback .invalid-feedback {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.phx-click-loading {
|
||||
opacity: 0.5;
|
||||
transition: opacity 1s ease-out;
|
||||
}
|
||||
|
||||
.phx-loading {
|
||||
cursor: wait;
|
||||
}
|
||||
|
||||
.phx-modal {
|
||||
opacity: 1 !important;
|
||||
position: fixed;
|
||||
z-index: 1;
|
||||
left: 0;
|
||||
top: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
overflow: auto;
|
||||
background-color: rgb(255, 255, 255);
|
||||
background-color: rgba(255, 255, 255, 0.4);
|
||||
}
|
||||
|
||||
.phx-modal-content {
|
||||
background-color: #000;
|
||||
margin: 15vh auto;
|
||||
padding: 20px;
|
||||
border: 1px solid #94a3b8;
|
||||
width: 80%;
|
||||
}
|
||||
|
||||
.phx-modal-close {
|
||||
color: #64748b;
|
||||
float: right;
|
||||
font-size: 28px;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.phx-modal-close:hover,
|
||||
.phx-modal-close:focus {
|
||||
color: black;
|
||||
text-decoration: none;
|
||||
cursor: pointer;
|
||||
}
|
101
assets/css/phoenix.css
Normal file
101
assets/css/phoenix.css
Normal file
File diff suppressed because one or more lines are too long
291
assets/js/app.js
Normal file
291
assets/js/app.js
Normal file
@ -0,0 +1,291 @@
|
||||
import "phoenix_html";
|
||||
import { Socket } from "phoenix";
|
||||
import { LiveSocket } from "phoenix_live_view";
|
||||
import Chat from "./user_socket";
|
||||
import topbar from "../vendor/topbar";
|
||||
import videojs from "../vendor/video";
|
||||
import "../vendor/videojs-youtube";
|
||||
|
||||
let isVisible = (el) =>
|
||||
!!(el.offsetWidth || el.offsetHeight || el.getClientRects().length > 0);
|
||||
|
||||
let execJS = (selector, attr) => {
|
||||
document
|
||||
.querySelectorAll(selector)
|
||||
.forEach((el) => liveSocket.execJS(el, el.getAttribute(attr)));
|
||||
};
|
||||
|
||||
let Hooks = {};
|
||||
|
||||
Hooks.Flash = {
|
||||
mounted() {
|
||||
let hide = () =>
|
||||
liveSocket.execJS(this.el, this.el.getAttribute("phx-click"));
|
||||
this.timer = setTimeout(() => hide(), 8000);
|
||||
this.el.addEventListener("phx:hide-start", () => clearTimeout(this.timer));
|
||||
this.el.addEventListener("mouseover", () => {
|
||||
clearTimeout(this.timer);
|
||||
this.timer = setTimeout(() => hide(), 8000);
|
||||
});
|
||||
},
|
||||
destroyed() {
|
||||
clearTimeout(this.timer);
|
||||
},
|
||||
};
|
||||
|
||||
Hooks.Menu = {
|
||||
getAttr(name) {
|
||||
let val = this.el.getAttribute(name);
|
||||
if (val === null) {
|
||||
throw new Error(`no ${name} attribute configured for menu`);
|
||||
}
|
||||
return val;
|
||||
},
|
||||
reset() {
|
||||
this.enabled = false;
|
||||
this.activeClass = this.getAttr("data-active-class");
|
||||
this.deactivate(this.menuItems());
|
||||
this.activeItem = null;
|
||||
window.removeEventListener("keydown", this.handleKeyDown);
|
||||
},
|
||||
destroyed() {
|
||||
this.reset();
|
||||
},
|
||||
mounted() {
|
||||
this.menuItemsContainer = document.querySelector(
|
||||
`[aria-labelledby="${this.el.id}"]`
|
||||
);
|
||||
this.reset();
|
||||
this.handleKeyDown = (e) => this.onKeyDown(e);
|
||||
this.el.addEventListener("keydown", (e) => {
|
||||
if (
|
||||
(e.key === "Enter" || e.key === " ") &&
|
||||
e.currentTarget.isSameNode(this.el)
|
||||
) {
|
||||
this.enabled = true;
|
||||
}
|
||||
});
|
||||
this.el.addEventListener("click", (e) => {
|
||||
if (!e.currentTarget.isSameNode(this.el)) {
|
||||
return;
|
||||
}
|
||||
|
||||
window.addEventListener("keydown", this.handleKeyDown);
|
||||
// disable if button clicked and click was not a keyboard event
|
||||
if (this.enabled) {
|
||||
window.requestAnimationFrame(() => this.activate(0));
|
||||
}
|
||||
});
|
||||
this.menuItemsContainer.addEventListener("phx:hide-start", () =>
|
||||
this.reset()
|
||||
);
|
||||
},
|
||||
activate(index, fallbackIndex) {
|
||||
let menuItems = this.menuItems();
|
||||
this.activeItem = menuItems[index] || menuItems[fallbackIndex];
|
||||
this.activeItem.classList.add(this.activeClass);
|
||||
this.activeItem.focus();
|
||||
},
|
||||
deactivate(items) {
|
||||
items.forEach((item) => item.classList.remove(this.activeClass));
|
||||
},
|
||||
menuItems() {
|
||||
return Array.from(
|
||||
this.menuItemsContainer.querySelectorAll("[role=menuitem]")
|
||||
);
|
||||
},
|
||||
onKeyDown(e) {
|
||||
if (e.key === "Escape") {
|
||||
document.body.click();
|
||||
this.el.focus();
|
||||
this.reset();
|
||||
} else if (e.key === "Enter" && !this.activeItem) {
|
||||
this.activate(0);
|
||||
} else if (e.key === "Enter") {
|
||||
this.activeItem.click();
|
||||
}
|
||||
if (e.key === "ArrowDown") {
|
||||
e.preventDefault();
|
||||
let menuItems = this.menuItems();
|
||||
this.deactivate(menuItems);
|
||||
this.activate(menuItems.indexOf(this.activeItem) + 1, 0);
|
||||
} else if (e.key === "ArrowUp") {
|
||||
e.preventDefault();
|
||||
let menuItems = this.menuItems();
|
||||
this.deactivate(menuItems);
|
||||
this.activate(
|
||||
menuItems.indexOf(this.activeItem) - 1,
|
||||
menuItems.length - 1
|
||||
);
|
||||
} else if (e.key === "Tab") {
|
||||
e.preventDefault();
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
Hooks.VideoPlayer = {
|
||||
mounted() {
|
||||
this.player = videojs("video-player", { autoplay: true });
|
||||
|
||||
window.addEventListener("js:play_video", ({ detail }) => {
|
||||
const { player } = detail;
|
||||
this.player.options({
|
||||
techOrder: [player.type === "video/youtube" ? "youtube" : "html5"],
|
||||
});
|
||||
this.player.src({ src: player.src, type: player.type });
|
||||
this.player.play();
|
||||
this.player.el().parentElement.classList.remove("hidden");
|
||||
this.player.el().parentElement.classList.add("flex");
|
||||
this.player.el().scrollIntoView();
|
||||
});
|
||||
|
||||
this.handleEvent("join_chat", Chat.join);
|
||||
},
|
||||
};
|
||||
|
||||
// Accessible focus handling
|
||||
let Focus = {
|
||||
focusMain() {
|
||||
let target =
|
||||
document.querySelector("main h1") || document.querySelector("main");
|
||||
if (target) {
|
||||
let origTabIndex = target.tabIndex;
|
||||
target.tabIndex = -1;
|
||||
target.focus();
|
||||
target.tabIndex = origTabIndex;
|
||||
}
|
||||
},
|
||||
// Subject to the W3C Software License at https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
|
||||
isFocusable(el) {
|
||||
if (
|
||||
el.tabIndex > 0 ||
|
||||
(el.tabIndex === 0 && el.getAttribute("tabIndex") !== null)
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
if (el.disabled) {
|
||||
return false;
|
||||
}
|
||||
|
||||
switch (el.nodeName) {
|
||||
case "A":
|
||||
return !!el.href && el.rel !== "ignore";
|
||||
case "INPUT":
|
||||
return el.type != "hidden" && el.type !== "file";
|
||||
case "BUTTON":
|
||||
case "SELECT":
|
||||
case "TEXTAREA":
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
},
|
||||
// Subject to the W3C Software License at https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
|
||||
attemptFocus(el) {
|
||||
if (!el) {
|
||||
return;
|
||||
}
|
||||
if (!this.isFocusable(el)) {
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
el.focus();
|
||||
} catch (e) {}
|
||||
|
||||
return document.activeElement === el;
|
||||
},
|
||||
// Subject to the W3C Software License at https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
|
||||
focusFirstDescendant(el) {
|
||||
for (let i = 0; i < el.childNodes.length; i++) {
|
||||
let child = el.childNodes[i];
|
||||
if (this.attemptFocus(child) || this.focusFirstDescendant(child)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
},
|
||||
// Subject to the W3C Software License at https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
|
||||
focusLastDescendant(element) {
|
||||
for (let i = element.childNodes.length - 1; i >= 0; i--) {
|
||||
let child = element.childNodes[i];
|
||||
if (this.attemptFocus(child) || this.focusLastDescendant(child)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
},
|
||||
};
|
||||
|
||||
let csrfToken = document
|
||||
.querySelector("meta[name='csrf-token']")
|
||||
.getAttribute("content");
|
||||
let liveSocket = new LiveSocket("/live", Socket, {
|
||||
hooks: Hooks,
|
||||
params: { _csrf_token: csrfToken },
|
||||
dom: {
|
||||
onNodeAdded(node) {
|
||||
if (node instanceof HTMLElement && node.autofocus) {
|
||||
node.focus();
|
||||
}
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
let routeUpdated = () => {
|
||||
Focus.focusMain();
|
||||
};
|
||||
|
||||
// Show progress bar on live navigation and form submits
|
||||
topbar.config({
|
||||
barColors: { 0: "rgba(147, 51, 234, 1)" },
|
||||
shadowColor: "rgba(0, 0, 0, .3)",
|
||||
});
|
||||
window.addEventListener("phx:page-loading-start", (info) =>
|
||||
topbar.delayedShow(200)
|
||||
);
|
||||
window.addEventListener("phx:page-loading-stop", (info) => topbar.hide());
|
||||
|
||||
// Accessible routing
|
||||
window.addEventListener("phx:page-loading-stop", routeUpdated);
|
||||
|
||||
window.addEventListener("js:exec", (e) =>
|
||||
e.target[e.detail.call](...e.detail.args)
|
||||
);
|
||||
window.addEventListener("js:focus", (e) => {
|
||||
let parent = document.querySelector(e.detail.parent);
|
||||
if (parent && isVisible(parent)) {
|
||||
e.target.focus();
|
||||
}
|
||||
});
|
||||
window.addEventListener("js:focus-closest", (e) => {
|
||||
let el = e.target;
|
||||
let sibling = el.nextElementSibling;
|
||||
while (sibling) {
|
||||
if (isVisible(sibling) && Focus.attemptFocus(sibling)) {
|
||||
return;
|
||||
}
|
||||
sibling = sibling.nextElementSibling;
|
||||
}
|
||||
sibling = el.previousElementSibling;
|
||||
while (sibling) {
|
||||
if (isVisible(sibling) && Focus.attemptFocus(sibling)) {
|
||||
return;
|
||||
}
|
||||
sibling = sibling.previousElementSibling;
|
||||
}
|
||||
Focus.attemptFocus(el.parent) || Focus.focusMain();
|
||||
});
|
||||
window.addEventListener("phx:remove-el", (e) =>
|
||||
document.getElementById(e.detail.id).remove()
|
||||
);
|
||||
|
||||
// connect if there are any LiveViews on the page
|
||||
liveSocket.getSocket().onOpen(() => execJS("#connection-status", "js-hide"));
|
||||
liveSocket.getSocket().onError(() => execJS("#connection-status", "js-show"));
|
||||
liveSocket.connect();
|
||||
|
||||
// expose liveSocket on window for web console debug logs and latency simulation:
|
||||
// >> liveSocket.enableDebug()
|
||||
// >> liveSocket.enableLatencySim(1000) // enabled for duration of browser session
|
||||
// >> liveSocket.disableLatencySim()
|
||||
window.liveSocket = liveSocket;
|
93
assets/js/user_socket.js
Normal file
93
assets/js/user_socket.js
Normal file
@ -0,0 +1,93 @@
|
||||
import { Socket } from "phoenix";
|
||||
|
||||
const system_user = (sender) => sender === "algora";
|
||||
|
||||
const init = () => {
|
||||
let socket = new Socket("/socket", { params: { token: window.userToken } });
|
||||
|
||||
socket.connect();
|
||||
|
||||
let channel;
|
||||
let chatBox;
|
||||
let chatInput;
|
||||
let chatMessages;
|
||||
let handleSend;
|
||||
|
||||
const leave = (channel) => {
|
||||
channel.leave();
|
||||
if (chatInput) {
|
||||
chatInput.value = "";
|
||||
chatInput.removeEventListener("keypress", handleSend);
|
||||
}
|
||||
chatBox.classList.add("lg:w-0");
|
||||
chatBox.classList.remove("lg:w-[20rem]");
|
||||
};
|
||||
|
||||
const join = ({ id, type }) => {
|
||||
if (channel) {
|
||||
leave(channel);
|
||||
}
|
||||
|
||||
if (type !== "livestream") {
|
||||
return;
|
||||
}
|
||||
|
||||
player = player;
|
||||
channel = socket.channel(`room:${id}`, {});
|
||||
chatBox = document.querySelector("#chat-box");
|
||||
chatInput = document.querySelector("#chat-input");
|
||||
chatMessages = document.querySelector("#chat-messages");
|
||||
chatMessages.scrollTop = chatMessages.scrollHeight;
|
||||
chatBox.classList.add("lg:w-[20rem]");
|
||||
chatBox.classList.remove("lg:w-0");
|
||||
|
||||
handleSend = (event) => {
|
||||
if (event.key === "Enter" && chatInput.value.trim()) {
|
||||
channel.push("new_msg", { body: chatInput.value });
|
||||
chatInput.value = "";
|
||||
}
|
||||
};
|
||||
|
||||
if (chatInput) {
|
||||
chatInput.addEventListener("keypress", handleSend);
|
||||
}
|
||||
|
||||
channel.on("new_msg", (payload) => {
|
||||
const messageItem = document.createElement("div");
|
||||
|
||||
const senderItem = document.createElement("span");
|
||||
senderItem.innerText = `${payload.user.handle}: `;
|
||||
senderItem.className = `font-semibold ${
|
||||
system_user(payload.user.handle)
|
||||
? "text-emerald-400"
|
||||
: "text-indigo-400"
|
||||
}`;
|
||||
|
||||
const bodyItem = document.createElement("span");
|
||||
bodyItem.innerText = `${payload.body}`;
|
||||
bodyItem.className = "font-medium text-gray-100";
|
||||
|
||||
messageItem.appendChild(senderItem);
|
||||
messageItem.appendChild(bodyItem);
|
||||
|
||||
chatMessages.appendChild(messageItem);
|
||||
chatMessages.scrollTop = chatMessages.scrollHeight;
|
||||
});
|
||||
|
||||
channel
|
||||
.join()
|
||||
.receive("ok", (resp) => {
|
||||
console.log("Joined successfully", resp);
|
||||
window.channel = channel;
|
||||
})
|
||||
.receive("error", (resp) => {
|
||||
console.log("Unable to join", resp);
|
||||
});
|
||||
};
|
||||
|
||||
return { join };
|
||||
};
|
||||
|
||||
const Chat = init();
|
||||
|
||||
export default Chat;
|
32
assets/tailwind.config.js
Normal file
32
assets/tailwind.config.js
Normal file
@ -0,0 +1,32 @@
|
||||
// See the Tailwind configuration guide for advanced usage
|
||||
// https://tailwindcss.com/docs/configuration
|
||||
|
||||
const colors = require("tailwindcss/colors");
|
||||
|
||||
module.exports = {
|
||||
content: ["./js/**/*.js", "../lib/*_web.ex", "../lib/*_web/**/*.*ex"],
|
||||
theme: {
|
||||
extend: {
|
||||
colors: {
|
||||
white: colors.white,
|
||||
green: colors.emerald,
|
||||
purple: colors.indigo,
|
||||
yellow: colors.amber,
|
||||
gray: {
|
||||
50: "#f8f9fc",
|
||||
100: "#f1f2f9",
|
||||
200: "#e1e2ef",
|
||||
300: "#cbcee1",
|
||||
400: "#9497b8",
|
||||
500: "#65688b",
|
||||
600: "#484b6a",
|
||||
700: "#343756",
|
||||
800: "#1d1e3a",
|
||||
900: "#100f29",
|
||||
950: "#050217",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
plugins: [require("@tailwindcss/forms")],
|
||||
};
|
165
assets/vendor/topbar.js
vendored
Normal file
165
assets/vendor/topbar.js
vendored
Normal file
@ -0,0 +1,165 @@
|
||||
/**
|
||||
* @license MIT
|
||||
* topbar 1.0.0, 2021-01-06
|
||||
* http://buunguyen.github.io/topbar
|
||||
* Copyright (c) 2021 Buu Nguyen
|
||||
*/
|
||||
(function (window, document) {
|
||||
"use strict";
|
||||
|
||||
// https://gist.github.com/paulirish/1579671
|
||||
(function () {
|
||||
var lastTime = 0;
|
||||
var vendors = ["ms", "moz", "webkit", "o"];
|
||||
for (var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) {
|
||||
window.requestAnimationFrame =
|
||||
window[vendors[x] + "RequestAnimationFrame"];
|
||||
window.cancelAnimationFrame =
|
||||
window[vendors[x] + "CancelAnimationFrame"] ||
|
||||
window[vendors[x] + "CancelRequestAnimationFrame"];
|
||||
}
|
||||
if (!window.requestAnimationFrame)
|
||||
window.requestAnimationFrame = function (callback, element) {
|
||||
var currTime = new Date().getTime();
|
||||
var timeToCall = Math.max(0, 16 - (currTime - lastTime));
|
||||
var id = window.setTimeout(function () {
|
||||
callback(currTime + timeToCall);
|
||||
}, timeToCall);
|
||||
lastTime = currTime + timeToCall;
|
||||
return id;
|
||||
};
|
||||
if (!window.cancelAnimationFrame)
|
||||
window.cancelAnimationFrame = function (id) {
|
||||
clearTimeout(id);
|
||||
};
|
||||
})();
|
||||
|
||||
var canvas,
|
||||
currentProgress,
|
||||
showing,
|
||||
progressTimerId = null,
|
||||
fadeTimerId = null,
|
||||
delayTimerId = null,
|
||||
addEvent = function (elem, type, handler) {
|
||||
if (elem.addEventListener) elem.addEventListener(type, handler, false);
|
||||
else if (elem.attachEvent) elem.attachEvent("on" + type, handler);
|
||||
else elem["on" + type] = handler;
|
||||
},
|
||||
options = {
|
||||
autoRun: true,
|
||||
barThickness: 3,
|
||||
barColors: {
|
||||
0: "rgba(26, 188, 156, .9)",
|
||||
".25": "rgba(52, 152, 219, .9)",
|
||||
".50": "rgba(241, 196, 15, .9)",
|
||||
".75": "rgba(230, 126, 34, .9)",
|
||||
"1.0": "rgba(211, 84, 0, .9)",
|
||||
},
|
||||
shadowBlur: 10,
|
||||
shadowColor: "rgba(0, 0, 0, .6)",
|
||||
className: null,
|
||||
},
|
||||
repaint = function () {
|
||||
canvas.width = window.innerWidth;
|
||||
canvas.height = options.barThickness * 5; // need space for shadow
|
||||
|
||||
var ctx = canvas.getContext("2d");
|
||||
ctx.shadowBlur = options.shadowBlur;
|
||||
ctx.shadowColor = options.shadowColor;
|
||||
|
||||
var lineGradient = ctx.createLinearGradient(0, 0, canvas.width, 0);
|
||||
for (var stop in options.barColors)
|
||||
lineGradient.addColorStop(stop, options.barColors[stop]);
|
||||
ctx.lineWidth = options.barThickness;
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(0, options.barThickness / 2);
|
||||
ctx.lineTo(
|
||||
Math.ceil(currentProgress * canvas.width),
|
||||
options.barThickness / 2
|
||||
);
|
||||
ctx.strokeStyle = lineGradient;
|
||||
ctx.stroke();
|
||||
},
|
||||
createCanvas = function () {
|
||||
canvas = document.createElement("canvas");
|
||||
var style = canvas.style;
|
||||
style.position = "fixed";
|
||||
style.top = style.left = style.right = style.margin = style.padding = 0;
|
||||
style.zIndex = 100001;
|
||||
style.display = "none";
|
||||
if (options.className) canvas.classList.add(options.className);
|
||||
document.body.appendChild(canvas);
|
||||
addEvent(window, "resize", repaint);
|
||||
},
|
||||
topbar = {
|
||||
config: function (opts) {
|
||||
for (var key in opts)
|
||||
if (options.hasOwnProperty(key)) options[key] = opts[key];
|
||||
},
|
||||
delayedShow: function(time) {
|
||||
if (showing) return;
|
||||
if (delayTimerId) return;
|
||||
delayTimerId = setTimeout(() => topbar.show(), time);
|
||||
},
|
||||
show: function () {
|
||||
if (showing) return;
|
||||
showing = true;
|
||||
if (fadeTimerId !== null) window.cancelAnimationFrame(fadeTimerId);
|
||||
if (!canvas) createCanvas();
|
||||
canvas.style.opacity = 1;
|
||||
canvas.style.display = "block";
|
||||
topbar.progress(0);
|
||||
if (options.autoRun) {
|
||||
(function loop() {
|
||||
progressTimerId = window.requestAnimationFrame(loop);
|
||||
topbar.progress(
|
||||
"+" + 0.05 * Math.pow(1 - Math.sqrt(currentProgress), 2)
|
||||
);
|
||||
})();
|
||||
}
|
||||
},
|
||||
progress: function (to) {
|
||||
if (typeof to === "undefined") return currentProgress;
|
||||
if (typeof to === "string") {
|
||||
to =
|
||||
(to.indexOf("+") >= 0 || to.indexOf("-") >= 0
|
||||
? currentProgress
|
||||
: 0) + parseFloat(to);
|
||||
}
|
||||
currentProgress = to > 1 ? 1 : to;
|
||||
repaint();
|
||||
return currentProgress;
|
||||
},
|
||||
hide: function () {
|
||||
clearTimeout(delayTimerId);
|
||||
delayTimerId = null;
|
||||
if (!showing) return;
|
||||
showing = false;
|
||||
if (progressTimerId != null) {
|
||||
window.cancelAnimationFrame(progressTimerId);
|
||||
progressTimerId = null;
|
||||
}
|
||||
(function loop() {
|
||||
if (topbar.progress("+.1") >= 1) {
|
||||
canvas.style.opacity -= 0.05;
|
||||
if (canvas.style.opacity <= 0.05) {
|
||||
canvas.style.display = "none";
|
||||
fadeTimerId = null;
|
||||
return;
|
||||
}
|
||||
}
|
||||
fadeTimerId = window.requestAnimationFrame(loop);
|
||||
})();
|
||||
},
|
||||
};
|
||||
|
||||
if (typeof module === "object" && typeof module.exports === "object") {
|
||||
module.exports = topbar;
|
||||
} else if (typeof define === "function" && define.amd) {
|
||||
define(function () {
|
||||
return topbar;
|
||||
});
|
||||
} else {
|
||||
this.topbar = topbar;
|
||||
}
|
||||
}.call(this, window, document));
|
46
assets/vendor/video.js
vendored
Normal file
46
assets/vendor/video.js
vendored
Normal file
File diff suppressed because one or more lines are too long
637
assets/vendor/videojs-youtube.js
vendored
Normal file
637
assets/vendor/videojs-youtube.js
vendored
Normal file
@ -0,0 +1,637 @@
|
||||
(function (root, factory) {
|
||||
if (typeof exports === "object" && typeof module !== "undefined") {
|
||||
var videojs = require("./video");
|
||||
module.exports = factory(videojs.default || videojs);
|
||||
} else if (typeof define === "function" && define.amd) {
|
||||
define(["videojs"], function (videojs) {
|
||||
return (root.Youtube = factory(videojs));
|
||||
});
|
||||
} else {
|
||||
root.Youtube = factory(root.videojs);
|
||||
}
|
||||
})(this, function (videojs) {
|
||||
"use strict";
|
||||
var _isOnMobile = videojs.browser.IS_IOS || videojs.browser.IS_NATIVE_ANDROID;
|
||||
var Tech = videojs.getTech("Tech");
|
||||
class Youtube extends Tech {
|
||||
constructor(options, ready) {
|
||||
super(options, ready);
|
||||
this.setPoster(options.poster);
|
||||
this.setSrc(this.options_.source, true);
|
||||
this.setTimeout(
|
||||
function () {
|
||||
if (this.el_) {
|
||||
this.el_.parentNode.className += " vjs-youtube";
|
||||
if (_isOnMobile) {
|
||||
this.el_.parentNode.className += " vjs-youtube-mobile";
|
||||
}
|
||||
if (Youtube.isApiReady) {
|
||||
this.initYTPlayer();
|
||||
} else {
|
||||
Youtube.apiReadyQueue.push(this);
|
||||
}
|
||||
}
|
||||
}.bind(this)
|
||||
);
|
||||
}
|
||||
dispose() {
|
||||
if (this.ytPlayer) {
|
||||
if (this.ytPlayer.stopVideo) {
|
||||
this.ytPlayer.stopVideo();
|
||||
}
|
||||
if (this.ytPlayer.destroy) {
|
||||
this.ytPlayer.destroy();
|
||||
}
|
||||
} else {
|
||||
var index = Youtube.apiReadyQueue.indexOf(this);
|
||||
if (index !== -1) {
|
||||
Youtube.apiReadyQueue.splice(index, 1);
|
||||
}
|
||||
}
|
||||
this.ytPlayer = null;
|
||||
this.el_.parentNode.className = this.el_.parentNode.className
|
||||
.replace(" vjs-youtube", "")
|
||||
.replace(" vjs-youtube-mobile", "");
|
||||
this.el_.parentNode.removeChild(this.el_);
|
||||
Tech.prototype.dispose.call(this);
|
||||
}
|
||||
createEl() {
|
||||
var div = document.createElement("div");
|
||||
div.setAttribute("id", this.options_.techId);
|
||||
div.setAttribute(
|
||||
"style",
|
||||
"width:100%;height:100%;top:0;left:0;position:absolute"
|
||||
);
|
||||
div.setAttribute("class", "vjs-tech");
|
||||
var divWrapper = document.createElement("div");
|
||||
divWrapper.appendChild(div);
|
||||
if (!_isOnMobile && !this.options_.ytControls) {
|
||||
var divBlocker = document.createElement("div");
|
||||
divBlocker.setAttribute("class", "vjs-iframe-blocker");
|
||||
divBlocker.setAttribute(
|
||||
"style",
|
||||
"position:absolute;top:0;left:0;width:100%;height:100%"
|
||||
);
|
||||
divBlocker.onclick = function () {
|
||||
this.pause();
|
||||
}.bind(this);
|
||||
divWrapper.appendChild(divBlocker);
|
||||
}
|
||||
return divWrapper;
|
||||
}
|
||||
initYTPlayer() {
|
||||
var playerVars = {
|
||||
controls: 0,
|
||||
modestbranding: 1,
|
||||
rel: 0,
|
||||
showinfo: 0,
|
||||
loop: this.options_.loop ? 1 : 0,
|
||||
};
|
||||
if (typeof this.options_.autohide !== "undefined") {
|
||||
playerVars.autohide = this.options_.autohide;
|
||||
}
|
||||
if (typeof this.options_["cc_load_policy"] !== "undefined") {
|
||||
playerVars["cc_load_policy"] = this.options_["cc_load_policy"];
|
||||
}
|
||||
if (typeof this.options_.ytControls !== "undefined") {
|
||||
playerVars.controls = this.options_.ytControls;
|
||||
}
|
||||
if (typeof this.options_.disablekb !== "undefined") {
|
||||
playerVars.disablekb = this.options_.disablekb;
|
||||
}
|
||||
if (typeof this.options_.color !== "undefined") {
|
||||
playerVars.color = this.options_.color;
|
||||
}
|
||||
if (!playerVars.controls) {
|
||||
playerVars.fs = 0;
|
||||
} else if (typeof this.options_.fs !== "undefined") {
|
||||
playerVars.fs = this.options_.fs;
|
||||
}
|
||||
if (this.options_.source.src.indexOf("end=") !== -1) {
|
||||
var srcEndTime = this.options_.source.src.match(/end=([0-9]*)/);
|
||||
this.options_.end = parseInt(srcEndTime[1]);
|
||||
}
|
||||
if (typeof this.options_.end !== "undefined") {
|
||||
playerVars.end = this.options_.end;
|
||||
}
|
||||
if (typeof this.options_.hl !== "undefined") {
|
||||
playerVars.hl = this.options_.hl;
|
||||
} else if (typeof this.options_.language !== "undefined") {
|
||||
playerVars.hl = this.options_.language.substr(0, 2);
|
||||
}
|
||||
if (typeof this.options_["iv_load_policy"] !== "undefined") {
|
||||
playerVars["iv_load_policy"] = this.options_["iv_load_policy"];
|
||||
}
|
||||
if (typeof this.options_.list !== "undefined") {
|
||||
playerVars.list = this.options_.list;
|
||||
} else if (this.url && typeof this.url.listId !== "undefined") {
|
||||
playerVars.list = this.url.listId;
|
||||
}
|
||||
if (typeof this.options_.listType !== "undefined") {
|
||||
playerVars.listType = this.options_.listType;
|
||||
}
|
||||
if (typeof this.options_.modestbranding !== "undefined") {
|
||||
playerVars.modestbranding = this.options_.modestbranding;
|
||||
}
|
||||
if (typeof this.options_.playlist !== "undefined") {
|
||||
playerVars.playlist = this.options_.playlist;
|
||||
}
|
||||
if (typeof this.options_.playsinline !== "undefined") {
|
||||
playerVars.playsinline = this.options_.playsinline;
|
||||
}
|
||||
if (typeof this.options_.rel !== "undefined") {
|
||||
playerVars.rel = this.options_.rel;
|
||||
}
|
||||
if (typeof this.options_.showinfo !== "undefined") {
|
||||
playerVars.showinfo = this.options_.showinfo;
|
||||
}
|
||||
if (this.options_.source.src.indexOf("start=") !== -1) {
|
||||
var srcStartTime = this.options_.source.src.match(/start=([0-9]*)/);
|
||||
this.options_.start = parseInt(srcStartTime[1]);
|
||||
}
|
||||
if (typeof this.options_.start !== "undefined") {
|
||||
playerVars.start = this.options_.start;
|
||||
}
|
||||
if (typeof this.options_.theme !== "undefined") {
|
||||
playerVars.theme = this.options_.theme;
|
||||
}
|
||||
if (typeof this.options_.customVars !== "undefined") {
|
||||
var customVars = this.options_.customVars;
|
||||
Object.keys(customVars).forEach(function (key) {
|
||||
playerVars[key] = customVars[key];
|
||||
});
|
||||
}
|
||||
this.activeVideoId = this.url ? this.url.videoId : null;
|
||||
this.activeList = playerVars.list;
|
||||
var playerConfig = {
|
||||
videoId: this.activeVideoId,
|
||||
playerVars: playerVars,
|
||||
events: {
|
||||
onReady: this.onPlayerReady.bind(this),
|
||||
onPlaybackQualityChange:
|
||||
this.onPlayerPlaybackQualityChange.bind(this),
|
||||
onPlaybackRateChange: this.onPlayerPlaybackRateChange.bind(this),
|
||||
onStateChange: this.onPlayerStateChange.bind(this),
|
||||
onVolumeChange: this.onPlayerVolumeChange.bind(this),
|
||||
onError: this.onPlayerError.bind(this),
|
||||
},
|
||||
};
|
||||
if (
|
||||
typeof this.options_.enablePrivacyEnhancedMode !== "undefined" &&
|
||||
this.options_.enablePrivacyEnhancedMode
|
||||
) {
|
||||
playerConfig.host = "https://www.youtube-nocookie.com";
|
||||
}
|
||||
this.ytPlayer = new YT.Player(this.options_.techId, playerConfig);
|
||||
}
|
||||
onPlayerReady() {
|
||||
if (this.options_.muted) {
|
||||
this.ytPlayer.mute();
|
||||
}
|
||||
var playbackRates = this.ytPlayer.getAvailablePlaybackRates();
|
||||
if (playbackRates.length > 1) {
|
||||
this.featuresPlaybackRate = true;
|
||||
}
|
||||
this.playerReady_ = true;
|
||||
this.triggerReady();
|
||||
if (this.playOnReady) {
|
||||
this.play();
|
||||
} else if (this.cueOnReady) {
|
||||
this.cueVideoById_(this.url.videoId);
|
||||
this.activeVideoId = this.url.videoId;
|
||||
}
|
||||
}
|
||||
onPlayerPlaybackQualityChange() {}
|
||||
onPlayerPlaybackRateChange() {
|
||||
this.trigger("ratechange");
|
||||
}
|
||||
onPlayerStateChange(e) {
|
||||
var state = e.data;
|
||||
if (state === this.lastState || this.errorNumber) {
|
||||
return;
|
||||
}
|
||||
this.lastState = state;
|
||||
switch (state) {
|
||||
case -1:
|
||||
this.trigger("loadstart");
|
||||
this.trigger("loadedmetadata");
|
||||
this.trigger("durationchange");
|
||||
this.trigger("ratechange");
|
||||
break;
|
||||
case YT.PlayerState.ENDED:
|
||||
this.trigger("ended");
|
||||
break;
|
||||
case YT.PlayerState.PLAYING:
|
||||
this.trigger("timeupdate");
|
||||
this.trigger("durationchange");
|
||||
this.trigger("playing");
|
||||
this.trigger("play");
|
||||
if (this.isSeeking) {
|
||||
this.onSeeked();
|
||||
}
|
||||
break;
|
||||
case YT.PlayerState.PAUSED:
|
||||
this.trigger("canplay");
|
||||
if (this.isSeeking) {
|
||||
this.onSeeked();
|
||||
} else {
|
||||
this.trigger("pause");
|
||||
}
|
||||
break;
|
||||
case YT.PlayerState.BUFFERING:
|
||||
this.player_.trigger("timeupdate");
|
||||
this.player_.trigger("waiting");
|
||||
break;
|
||||
}
|
||||
}
|
||||
onPlayerVolumeChange() {
|
||||
this.trigger("volumechange");
|
||||
}
|
||||
onPlayerError(e) {
|
||||
this.errorNumber = e.data;
|
||||
this.trigger("pause");
|
||||
this.trigger("error");
|
||||
}
|
||||
error() {
|
||||
var code = 1e3 + this.errorNumber;
|
||||
switch (this.errorNumber) {
|
||||
case 5:
|
||||
return {
|
||||
code: code,
|
||||
message: "Error while trying to play the video",
|
||||
};
|
||||
case 2:
|
||||
case 100:
|
||||
return { code: code, message: "Unable to find the video" };
|
||||
case 101:
|
||||
case 150:
|
||||
return {
|
||||
code: code,
|
||||
message:
|
||||
"Playback on other Websites has been disabled by the video owner.",
|
||||
};
|
||||
}
|
||||
return {
|
||||
code: code,
|
||||
message: "YouTube unknown error (" + this.errorNumber + ")",
|
||||
};
|
||||
}
|
||||
loadVideoById_(id) {
|
||||
var options = { videoId: id };
|
||||
if (this.options_.start) {
|
||||
options.startSeconds = this.options_.start;
|
||||
}
|
||||
if (this.options_.end) {
|
||||
options.endSeconds = this.options_.end;
|
||||
}
|
||||
this.ytPlayer.loadVideoById(options);
|
||||
}
|
||||
cueVideoById_(id) {
|
||||
var options = { videoId: id };
|
||||
if (this.options_.start) {
|
||||
options.startSeconds = this.options_.start;
|
||||
}
|
||||
if (this.options_.end) {
|
||||
options.endSeconds = this.options_.end;
|
||||
}
|
||||
this.ytPlayer.cueVideoById(options);
|
||||
}
|
||||
src(src) {
|
||||
if (src) {
|
||||
this.setSrc({ src: src });
|
||||
}
|
||||
return this.source;
|
||||
}
|
||||
poster() {
|
||||
if (_isOnMobile) {
|
||||
return null;
|
||||
}
|
||||
return this.poster_;
|
||||
}
|
||||
setPoster(poster) {
|
||||
this.poster_ = poster;
|
||||
}
|
||||
setSrc(source) {
|
||||
if (!source || !source.src) {
|
||||
return;
|
||||
}
|
||||
delete this.errorNumber;
|
||||
this.source = source;
|
||||
this.url = Youtube.parseUrl(source.src);
|
||||
if (!this.options_.poster) {
|
||||
if (this.url.videoId) {
|
||||
this.poster_ =
|
||||
"https://img.youtube.com/vi/" + this.url.videoId + "/0.jpg";
|
||||
this.trigger("posterchange");
|
||||
this.checkHighResPoster();
|
||||
}
|
||||
}
|
||||
if (this.options_.autoplay && !_isOnMobile) {
|
||||
if (this.isReady_) {
|
||||
this.play();
|
||||
} else {
|
||||
this.playOnReady = true;
|
||||
}
|
||||
} else if (this.activeVideoId !== this.url.videoId) {
|
||||
if (this.isReady_) {
|
||||
this.cueVideoById_(this.url.videoId);
|
||||
this.activeVideoId = this.url.videoId;
|
||||
} else {
|
||||
this.cueOnReady = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
autoplay() {
|
||||
return this.options_.autoplay;
|
||||
}
|
||||
setAutoplay(val) {
|
||||
this.options_.autoplay = val;
|
||||
}
|
||||
loop() {
|
||||
return this.options_.loop;
|
||||
}
|
||||
setLoop(val) {
|
||||
this.options_.loop = val;
|
||||
}
|
||||
play() {
|
||||
if (!this.url || !this.url.videoId) {
|
||||
return;
|
||||
}
|
||||
this.wasPausedBeforeSeek = false;
|
||||
if (this.isReady_) {
|
||||
if (this.url.listId) {
|
||||
if (this.activeList === this.url.listId) {
|
||||
this.ytPlayer.playVideo();
|
||||
} else {
|
||||
this.ytPlayer.loadPlaylist(this.url.listId);
|
||||
this.activeList = this.url.listId;
|
||||
}
|
||||
}
|
||||
if (this.activeVideoId === this.url.videoId) {
|
||||
this.ytPlayer.playVideo();
|
||||
} else {
|
||||
this.loadVideoById_(this.url.videoId);
|
||||
this.activeVideoId = this.url.videoId;
|
||||
}
|
||||
} else {
|
||||
this.trigger("waiting");
|
||||
this.playOnReady = true;
|
||||
}
|
||||
}
|
||||
pause() {
|
||||
if (this.ytPlayer) {
|
||||
this.ytPlayer.pauseVideo();
|
||||
}
|
||||
}
|
||||
paused() {
|
||||
return this.ytPlayer
|
||||
? this.lastState !== YT.PlayerState.PLAYING &&
|
||||
this.lastState !== YT.PlayerState.BUFFERING
|
||||
: true;
|
||||
}
|
||||
currentTime() {
|
||||
return this.ytPlayer ? this.ytPlayer.getCurrentTime() : 0;
|
||||
}
|
||||
setCurrentTime(seconds) {
|
||||
if (this.lastState === YT.PlayerState.PAUSED) {
|
||||
this.timeBeforeSeek = this.currentTime();
|
||||
}
|
||||
if (!this.isSeeking) {
|
||||
this.wasPausedBeforeSeek = this.paused();
|
||||
}
|
||||
this.ytPlayer.seekTo(seconds, true);
|
||||
this.trigger("timeupdate");
|
||||
this.trigger("seeking");
|
||||
this.isSeeking = true;
|
||||
if (
|
||||
this.lastState === YT.PlayerState.PAUSED &&
|
||||
this.timeBeforeSeek !== seconds
|
||||
) {
|
||||
clearInterval(this.checkSeekedInPauseInterval);
|
||||
this.checkSeekedInPauseInterval = setInterval(
|
||||
function () {
|
||||
if (this.lastState !== YT.PlayerState.PAUSED || !this.isSeeking) {
|
||||
clearInterval(this.checkSeekedInPauseInterval);
|
||||
} else if (this.currentTime() !== this.timeBeforeSeek) {
|
||||
this.trigger("timeupdate");
|
||||
this.onSeeked();
|
||||
}
|
||||
}.bind(this),
|
||||
250
|
||||
);
|
||||
}
|
||||
}
|
||||
seeking() {
|
||||
return this.isSeeking;
|
||||
}
|
||||
seekable() {
|
||||
if (!this.ytPlayer) {
|
||||
return videojs.createTimeRange();
|
||||
}
|
||||
return videojs.createTimeRange(0, this.ytPlayer.getDuration());
|
||||
}
|
||||
onSeeked() {
|
||||
clearInterval(this.checkSeekedInPauseInterval);
|
||||
this.isSeeking = false;
|
||||
if (this.wasPausedBeforeSeek) {
|
||||
this.pause();
|
||||
}
|
||||
this.trigger("seeked");
|
||||
}
|
||||
playbackRate() {
|
||||
return this.ytPlayer ? this.ytPlayer.getPlaybackRate() : 1;
|
||||
}
|
||||
setPlaybackRate(suggestedRate) {
|
||||
if (!this.ytPlayer) {
|
||||
return;
|
||||
}
|
||||
this.ytPlayer.setPlaybackRate(suggestedRate);
|
||||
}
|
||||
duration() {
|
||||
return this.ytPlayer ? this.ytPlayer.getDuration() : 0;
|
||||
}
|
||||
currentSrc() {
|
||||
return this.source && this.source.src;
|
||||
}
|
||||
ended() {
|
||||
return this.ytPlayer ? this.lastState === YT.PlayerState.ENDED : false;
|
||||
}
|
||||
volume() {
|
||||
return this.ytPlayer ? this.ytPlayer.getVolume() / 100 : 1;
|
||||
}
|
||||
setVolume(percentAsDecimal) {
|
||||
if (!this.ytPlayer) {
|
||||
return;
|
||||
}
|
||||
this.ytPlayer.setVolume(percentAsDecimal * 100);
|
||||
}
|
||||
muted() {
|
||||
return this.ytPlayer ? this.ytPlayer.isMuted() : false;
|
||||
}
|
||||
setMuted(mute) {
|
||||
if (!this.ytPlayer) {
|
||||
return;
|
||||
} else {
|
||||
this.muted(true);
|
||||
}
|
||||
if (mute) {
|
||||
this.ytPlayer.mute();
|
||||
} else {
|
||||
this.ytPlayer.unMute();
|
||||
}
|
||||
this.setTimeout(function () {
|
||||
this.trigger("volumechange");
|
||||
}, 50);
|
||||
}
|
||||
buffered() {
|
||||
if (!this.ytPlayer || !this.ytPlayer.getVideoLoadedFraction) {
|
||||
return videojs.createTimeRange();
|
||||
}
|
||||
var bufferedEnd =
|
||||
this.ytPlayer.getVideoLoadedFraction() * this.ytPlayer.getDuration();
|
||||
return videojs.createTimeRange(0, bufferedEnd);
|
||||
}
|
||||
preload() {}
|
||||
load() {}
|
||||
reset() {}
|
||||
networkState() {
|
||||
if (!this.ytPlayer) {
|
||||
return 0;
|
||||
}
|
||||
switch (this.ytPlayer.getPlayerState()) {
|
||||
case -1:
|
||||
return 0;
|
||||
case 3:
|
||||
return 2;
|
||||
default:
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
readyState() {
|
||||
if (!this.ytPlayer) {
|
||||
return 0;
|
||||
}
|
||||
switch (this.ytPlayer.getPlayerState()) {
|
||||
case -1:
|
||||
return 0;
|
||||
case 5:
|
||||
return 1;
|
||||
case 3:
|
||||
return 2;
|
||||
default:
|
||||
return 4;
|
||||
}
|
||||
}
|
||||
supportsFullScreen() {
|
||||
return (
|
||||
document.fullscreenEnabled ||
|
||||
document.webkitFullscreenEnabled ||
|
||||
document.mozFullScreenEnabled ||
|
||||
document.msFullscreenEnabled
|
||||
);
|
||||
}
|
||||
checkHighResPoster() {
|
||||
var uri =
|
||||
"https://img.youtube.com/vi/" + this.url.videoId + "/maxresdefault.jpg";
|
||||
try {
|
||||
var image = new Image();
|
||||
image.onload = function () {
|
||||
if ("naturalHeight" in image) {
|
||||
if (image.naturalHeight <= 90 || image.naturalWidth <= 120) {
|
||||
return;
|
||||
}
|
||||
} else if (image.height <= 90 || image.width <= 120) {
|
||||
return;
|
||||
}
|
||||
this.poster_ = uri;
|
||||
this.trigger("posterchange");
|
||||
}.bind(this);
|
||||
image.onerror = function () {};
|
||||
image.src = uri;
|
||||
} catch (e) {}
|
||||
}
|
||||
}
|
||||
Youtube.isSupported = function () {
|
||||
return true;
|
||||
};
|
||||
Youtube.canPlaySource = function (e) {
|
||||
return Youtube.canPlayType(e.type);
|
||||
};
|
||||
Youtube.canPlayType = function (e) {
|
||||
return e === "video/youtube";
|
||||
};
|
||||
Youtube.parseUrl = function (url) {
|
||||
var result = { videoId: null };
|
||||
var regex =
|
||||
/^.*(youtu.be\/|v\/|u\/\w\/|embed\/|watch\?v=|\&v=)([^#\&\?]*).*/;
|
||||
var match = url.match(regex);
|
||||
if (match && match[2].length === 11) {
|
||||
result.videoId = match[2];
|
||||
}
|
||||
var regPlaylist = /[?&]list=([^#\&\?]+)/;
|
||||
match = url.match(regPlaylist);
|
||||
if (match && match[1]) {
|
||||
result.listId = match[1];
|
||||
}
|
||||
return result;
|
||||
};
|
||||
function apiLoaded() {
|
||||
YT.ready(function () {
|
||||
Youtube.isApiReady = true;
|
||||
for (var i = 0; i < Youtube.apiReadyQueue.length; ++i) {
|
||||
Youtube.apiReadyQueue[i].initYTPlayer();
|
||||
}
|
||||
});
|
||||
}
|
||||
function loadScript(src, callback) {
|
||||
var loaded = false;
|
||||
var tag = document.createElement("script");
|
||||
var firstScriptTag = document.getElementsByTagName("script")[0];
|
||||
if (!firstScriptTag) {
|
||||
return;
|
||||
}
|
||||
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
|
||||
tag.onload = function () {
|
||||
if (!loaded) {
|
||||
loaded = true;
|
||||
callback();
|
||||
}
|
||||
};
|
||||
tag.onreadystatechange = function () {
|
||||
if (
|
||||
!loaded &&
|
||||
(this.readyState === "complete" || this.readyState === "loaded")
|
||||
) {
|
||||
loaded = true;
|
||||
callback();
|
||||
}
|
||||
};
|
||||
tag.src = src;
|
||||
}
|
||||
function injectCss() {
|
||||
var css =
|
||||
".vjs-youtube .vjs-iframe-blocker { display: none; }" +
|
||||
".vjs-youtube.vjs-user-inactive .vjs-iframe-blocker { display: block; }" +
|
||||
".vjs-youtube .vjs-poster { background-size: cover; }" +
|
||||
".vjs-youtube-mobile .vjs-big-play-button { display: none; }";
|
||||
var head = document.head || document.getElementsByTagName("head")[0];
|
||||
var style = document.createElement("style");
|
||||
style.type = "text/css";
|
||||
if (style.styleSheet) {
|
||||
style.styleSheet.cssText = css;
|
||||
} else {
|
||||
style.appendChild(document.createTextNode(css));
|
||||
}
|
||||
head.appendChild(style);
|
||||
}
|
||||
Youtube.apiReadyQueue = [];
|
||||
if (typeof document !== "undefined") {
|
||||
loadScript("https://www.youtube.com/iframe_api", apiLoaded);
|
||||
injectCss();
|
||||
}
|
||||
if (typeof videojs.registerTech !== "undefined") {
|
||||
videojs.registerTech("Youtube", Youtube);
|
||||
} else {
|
||||
videojs.registerComponent("Youtube", Youtube);
|
||||
}
|
||||
});
|
61
config/config.exs
Normal file
61
config/config.exs
Normal file
@ -0,0 +1,61 @@
|
||||
# This file is responsible for configuring your application
|
||||
# and its dependencies with the aid of the Config module.
|
||||
#
|
||||
# This configuration file is loaded before any dependency and
|
||||
# is restricted to this project.
|
||||
|
||||
# General application configuration
|
||||
import Config
|
||||
|
||||
config :algora,
|
||||
replica: Algora.ReplicaRepo,
|
||||
ecto_repos: [Algora.Repo],
|
||||
rtmp_port: 9006
|
||||
|
||||
config :algora, Oban,
|
||||
repo: Algora.Repo,
|
||||
plugins: [Oban.Plugins.Pruner],
|
||||
queues: [default: 10]
|
||||
|
||||
# Configures the endpoint
|
||||
config :algora, AlgoraWeb.Endpoint,
|
||||
url: [host: "localhost"],
|
||||
secret_key_base: "H04mI/fsBvjCX3HO+P2bxFEM7PG3SaGTV+DE1f/BbTVG9oiOXSXsq+3tjDXxRXSe",
|
||||
pubsub_server: Algora.PubSub,
|
||||
live_view: [signing_salt: "fMm4VTD0Mkn/AB41KV+GwgofkocpAGOf"],
|
||||
render_errors: [
|
||||
formats: [html: AlgoraWeb.ErrorHTML, json: AlgoraWeb.ErrorJSON],
|
||||
layout: false
|
||||
]
|
||||
|
||||
config :esbuild,
|
||||
version: "0.12.18",
|
||||
default: [
|
||||
args: ~w(js/app.js --bundle --target=es2016 --outdir=../priv/static/assets),
|
||||
cd: Path.expand("../assets", __DIR__),
|
||||
env: %{"NODE_PATH" => Path.expand("../deps", __DIR__)}
|
||||
]
|
||||
|
||||
# Configure tailwind (the version is required)
|
||||
config :tailwind,
|
||||
version: "3.1.8",
|
||||
default: [
|
||||
args: ~w(
|
||||
--config=tailwind.config.js
|
||||
--input=css/app.css
|
||||
--output=../priv/static/assets/app.css
|
||||
),
|
||||
cd: Path.expand("../assets", __DIR__)
|
||||
]
|
||||
|
||||
# Configures Elixir's Logger
|
||||
config :logger, :console,
|
||||
format: "$time $metadata[$level] $message\n",
|
||||
metadata: [:request_id]
|
||||
|
||||
# Use Jason for JSON parsing in Phoenix
|
||||
config :phoenix, :json_library, Jason
|
||||
|
||||
# Import environment specific config. This must remain at the bottom
|
||||
# of this file so it overrides the configuration defined above.
|
||||
import_config "#{config_env()}.exs"
|
115
config/dev.exs
Normal file
115
config/dev.exs
Normal file
@ -0,0 +1,115 @@
|
||||
import Config
|
||||
|
||||
config :algora, :files, bucket: System.get_env("BUCKET_NAME")
|
||||
|
||||
config :algora, :github,
|
||||
client_id: System.get_env("GITHUB_CLIENT_ID"),
|
||||
client_secret: System.get_env("GITHUB_CLIENT_SECRET")
|
||||
|
||||
config :algora, :event_sink, url: System.get_env("EVENT_SINK_URL")
|
||||
|
||||
config :ex_aws,
|
||||
# debug_requests: true,
|
||||
json_codec: Jason,
|
||||
access_key_id: System.get_env("AWS_ACCESS_KEY_ID"),
|
||||
secret_access_key: System.get_env("AWS_SECRET_ACCESS_KEY")
|
||||
|
||||
config :ex_aws, :s3,
|
||||
scheme: "https://",
|
||||
host:
|
||||
(with url when url != nil <- System.get_env("AWS_ENDPOINT_URL_S3"),
|
||||
host <- URI.parse(url).host do
|
||||
host
|
||||
else
|
||||
_ -> nil
|
||||
end),
|
||||
region: System.get_env("AWS_REGION")
|
||||
|
||||
# Configure your database
|
||||
config :algora, Algora.Repo,
|
||||
url: System.get_env("DATABASE_URL"),
|
||||
show_sensitive_data_on_connection_error: true,
|
||||
pool_size: 10
|
||||
|
||||
# Configure your replica database
|
||||
config :algora, Algora.ReplicaRepo,
|
||||
url: System.get_env("DATABASE_URL"),
|
||||
show_sensitive_data_on_connection_error: true,
|
||||
pool_size: 10,
|
||||
priv: "priv/repo"
|
||||
|
||||
# For development, we disable any cache and enable
|
||||
# debugging and code reloading.
|
||||
#
|
||||
# The watchers configuration can be used to run external
|
||||
# watchers to your application. For example, we use it
|
||||
# with esbuild to bundle .js and .css sources.
|
||||
config :algora, AlgoraWeb.Endpoint,
|
||||
# Binding to loopback ipv4 address prevents access from other machines.
|
||||
# Change to `ip: {0, 0, 0, 0}` to allow access from other machines.
|
||||
http: [ip: {0, 0, 0, 0}, port: 4000],
|
||||
debug_errors: true,
|
||||
code_reloader: true,
|
||||
check_origin: false,
|
||||
watchers: [
|
||||
# Start the esbuild watcher by calling Esbuild.install_and_run(:default, args)
|
||||
esbuild: {Esbuild, :install_and_run, [:default, ~w(--sourcemap=inline --watch)]},
|
||||
tailwind: {Tailwind, :install_and_run, [:default, ~w(--watch)]}
|
||||
|
||||
# npx: [
|
||||
# "tailwindcss",
|
||||
# "--input=css/app.css",
|
||||
# "--output=../priv/static/assets/app.css",
|
||||
# "--postcss",
|
||||
# "--watch",
|
||||
# cd: Path.expand("../assets", __DIR__)
|
||||
# ]
|
||||
]
|
||||
|
||||
# ## SSL Support
|
||||
#
|
||||
# In order to use HTTPS in development, a self-signed
|
||||
# certificate can be generated by running the following
|
||||
# Mix task:
|
||||
#
|
||||
# mix phx.gen.cert
|
||||
#
|
||||
# Note that this task requires Erlang/OTP 20 or later.
|
||||
# Run `mix help phx.gen.cert` for more information.
|
||||
#
|
||||
# The `http:` config above can be replaced with:
|
||||
#
|
||||
# https: [
|
||||
# port: 4001,
|
||||
# cipher_suite: :strong,
|
||||
# keyfile: "priv/cert/selfsigned_key.pem",
|
||||
# certfile: "priv/cert/selfsigned.pem"
|
||||
# ],
|
||||
#
|
||||
# If desired, both `http:` and `https:` keys can be
|
||||
# configured to run both http and https servers on
|
||||
# different ports.
|
||||
|
||||
# Watch static and templates for browser reloading.
|
||||
config :algora, AlgoraWeb.Endpoint,
|
||||
live_reload: [
|
||||
patterns: [
|
||||
~r"priv/static/.*(js|css|png|jpeg|jpg|gif|svg)$",
|
||||
~r"priv/gettext/.*(po)$",
|
||||
~r"lib/algora_web/(live|views)/.*(ex)$",
|
||||
~r"lib/algora_web/templates/.*(eex)$"
|
||||
]
|
||||
]
|
||||
|
||||
# Do not include metadata nor timestamps in development logs
|
||||
config :logger, :console, format: "[$level] $message\n"
|
||||
|
||||
# Set a higher stacktrace during development. Avoid configuring such
|
||||
# in production as building large stacktraces may be expensive.
|
||||
config :phoenix, :stacktrace_depth, 20
|
||||
|
||||
# Initialize plugs at runtime for faster development compilation
|
||||
config :phoenix, :plug_init_mode, :runtime
|
||||
|
||||
# Disable swoosh api client as it is only required for production adapters.
|
||||
config :swoosh, :api_client, false
|
53
config/prod.exs
Normal file
53
config/prod.exs
Normal file
@ -0,0 +1,53 @@
|
||||
import Config
|
||||
|
||||
# For production, don't forget to configure the url host
|
||||
# to something meaningful, Phoenix uses this information
|
||||
# when generating URLs.
|
||||
#
|
||||
# Note we also include the path to a cache manifest
|
||||
# containing the digested version of static files. This
|
||||
# manifest is generated by the `mix phx.digest` task,
|
||||
# which you should run after static files are built and
|
||||
# before starting your production server.
|
||||
config :algora, AlgoraWeb.Endpoint,
|
||||
url: [host: "tv.algora.io", port: 80],
|
||||
cache_static_manifest: "priv/static/cache_manifest.json"
|
||||
|
||||
# Do not print debug messages in production
|
||||
config :logger, level: :info
|
||||
|
||||
config :swoosh, :api_client, Algora.Finch
|
||||
|
||||
# ## SSL Support
|
||||
#
|
||||
# To get SSL working, you will need to add the `https` key
|
||||
# to the previous section and set your `:url` port to 443:
|
||||
#
|
||||
# config :algora, AlgoraWeb.Endpoint,
|
||||
# ...,
|
||||
# url: [host: "example.com", port: 443],
|
||||
# https: [
|
||||
# ...,
|
||||
# port: 443,
|
||||
# cipher_suite: :strong,
|
||||
# keyfile: System.get_env("SOME_APP_SSL_KEY_PATH"),
|
||||
# certfile: System.get_env("SOME_APP_SSL_CERT_PATH")
|
||||
# ]
|
||||
#
|
||||
# The `cipher_suite` is set to `:strong` to support only the
|
||||
# latest and more secure SSL ciphers. This means old browsers
|
||||
# and clients may not be supported. You can set it to
|
||||
# `:compatible` for wider support.
|
||||
#
|
||||
# `:keyfile` and `:certfile` expect an absolute path to the key
|
||||
# and cert in disk or a relative path inside priv, for example
|
||||
# "priv/ssl/server.key". For all supported SSL configuration
|
||||
# options, see https://hexdocs.pm/plug/Plug.SSL.html#configure/1
|
||||
#
|
||||
# We also recommend setting `force_ssl` in your endpoint, ensuring
|
||||
# no data is ever sent via http, always redirecting to https:
|
||||
#
|
||||
# config :algora, AlgoraWeb.Endpoint,
|
||||
# force_ssl: [hsts: true]
|
||||
#
|
||||
# Check `Plug.SSL` for all available options in `force_ssl`.
|
92
config/runtime.exs
Normal file
92
config/runtime.exs
Normal file
@ -0,0 +1,92 @@
|
||||
import Config
|
||||
|
||||
# config/runtime.exs is executed for all environments, including
|
||||
# during releases. It is executed after compilation and before the
|
||||
# system starts, so it is typically used to load production configuration
|
||||
# and secrets from environment variables or elsewhere. Do not define
|
||||
# any compile-time configuration in here, as it won't be applied.
|
||||
# The block below contains prod specific runtime configuration.
|
||||
|
||||
if System.get_env("PHX_SERVER") && System.get_env("RELEASE_NAME") do
|
||||
config :algora, AlgoraWeb.Endpoint, server: true
|
||||
end
|
||||
|
||||
if config_env() == :prod do
|
||||
database_url =
|
||||
System.get_env("DATABASE_URL") ||
|
||||
raise """
|
||||
environment variable DATABASE_URL is missing.
|
||||
For example: ecto://USER:PASS@HOST/DATABASE
|
||||
"""
|
||||
|
||||
replica_database_url = System.get_env("REPLICA_DATABASE_URL") || database_url
|
||||
|
||||
host = System.get_env("PHX_HOST") || "example.com"
|
||||
ecto_ipv6? = System.get_env("ECTO_IPV6") == "true"
|
||||
|
||||
app_name =
|
||||
System.get_env("FLY_APP_NAME") ||
|
||||
raise "FLY_APP_NAME not available"
|
||||
|
||||
config :algora, Algora.Repo,
|
||||
# ssl: true,
|
||||
socket_options: if(ecto_ipv6?, do: [:inet6], else: []),
|
||||
url: database_url,
|
||||
pool_size: String.to_integer(System.get_env("POOL_SIZE") || "10")
|
||||
|
||||
config :algora, Algora.ReplicaRepo,
|
||||
# ssl: true,
|
||||
priv: "priv/repo",
|
||||
socket_options: if(ecto_ipv6?, do: [:inet6], else: []),
|
||||
url: replica_database_url,
|
||||
pool_size: String.to_integer(System.get_env("POOL_SIZE") || "10")
|
||||
|
||||
secret_key_base =
|
||||
System.get_env("SECRET_KEY_BASE") ||
|
||||
raise """
|
||||
environment variable SECRET_KEY_BASE is missing.
|
||||
You can generate one by calling: mix phx.gen.secret
|
||||
"""
|
||||
|
||||
config :algora, AlgoraWeb.Endpoint,
|
||||
url: [host: host, port: 443, scheme: "https"],
|
||||
http: [
|
||||
# Enable IPv6 and bind on all interfaces.
|
||||
# Set it to {0, 0, 0, 0, 0, 0, 0, 1} for local network only access.
|
||||
# See the documentation on https://hexdocs.pm/plug_cowboy/Plug.Cowboy.html
|
||||
# for details about using IPv6 vs IPv4 and loopback vs public addresses.
|
||||
ip: {0, 0, 0, 0, 0, 0, 0, 0},
|
||||
port: String.to_integer(System.get_env("PORT") || "4000")
|
||||
],
|
||||
secret_key_base: secret_key_base
|
||||
|
||||
config :algora, :files, bucket: System.fetch_env!("BUCKET_NAME")
|
||||
|
||||
config :algora, :github,
|
||||
client_id: System.fetch_env!("GITHUB_CLIENT_ID"),
|
||||
client_secret: System.fetch_env!("GITHUB_CLIENT_SECRET")
|
||||
|
||||
config :algora, :event_sink, url: System.get_env("EVENT_SINK_URL")
|
||||
|
||||
config :ex_aws,
|
||||
json_codec: Jason,
|
||||
access_key_id: System.fetch_env!("AWS_ACCESS_KEY_ID"),
|
||||
secret_access_key: System.fetch_env!("AWS_SECRET_ACCESS_KEY")
|
||||
|
||||
config :ex_aws, :s3,
|
||||
scheme: "https://",
|
||||
host: URI.parse(System.fetch_env!("AWS_ENDPOINT_URL_S3")).host,
|
||||
region: System.fetch_env!("AWS_REGION")
|
||||
|
||||
config :libcluster,
|
||||
topologies: [
|
||||
fly6pn: [
|
||||
strategy: Cluster.Strategy.DNSPoll,
|
||||
config: [
|
||||
polling_interval: 5_000,
|
||||
query: "#{app_name}.internal",
|
||||
node_basename: app_name
|
||||
]
|
||||
]
|
||||
]
|
||||
end
|
44
config/test.exs
Normal file
44
config/test.exs
Normal file
@ -0,0 +1,44 @@
|
||||
import Config
|
||||
|
||||
config :algora,
|
||||
replica: Algora.Repo
|
||||
|
||||
# Configure your database
|
||||
#
|
||||
# The MIX_TEST_PARTITION environment variable can be used
|
||||
# to provide built-in test partitioning in CI environment.
|
||||
# Run `mix help test` for more information.
|
||||
config :algora, Algora.Repo,
|
||||
username: "postgres",
|
||||
password: "postgres",
|
||||
database: "algora_test#{System.get_env("MIX_TEST_PARTITION")}",
|
||||
hostname: "localhost",
|
||||
pool: Ecto.Adapters.SQL.Sandbox,
|
||||
pool_size: 10
|
||||
|
||||
config :algora, Algora.ReplicaRepo,
|
||||
username: "postgres",
|
||||
password: "postgres",
|
||||
database: "algora_test#{System.get_env("MIX_TEST_PARTITION")}",
|
||||
hostname: "localhost",
|
||||
show_sensitive_data_on_connection_error: true,
|
||||
pool_size: 10,
|
||||
priv: "priv/repo"
|
||||
|
||||
# To prevent Oban from running jobs and plugins during test runs, enable :testing mode
|
||||
config :algora, Oban, testing: :inline
|
||||
|
||||
# We don't run a server during test. If one is required,
|
||||
# you can enable the server option below.
|
||||
config :algora, AlgoraWeb.Endpoint,
|
||||
http: [ip: {127, 0, 0, 1}, port: 4002],
|
||||
server: false
|
||||
|
||||
# Print only warnings and errors during test
|
||||
config :logger, level: :warn
|
||||
|
||||
# Initialize plugs at runtime for faster test compilation
|
||||
config :phoenix, :plug_init_mode, :runtime
|
||||
|
||||
# Disable swoosh api client as it is only required for production adapters.
|
||||
config :swoosh, :api_client, false
|
63
fly.toml
Normal file
63
fly.toml
Normal file
@ -0,0 +1,63 @@
|
||||
# fly.toml app configuration file generated for algora-media on 2024-02-08T18:25:10+02:00
|
||||
#
|
||||
# See https://fly.io/docs/reference/configuration/ for information about how to use this file.
|
||||
#
|
||||
|
||||
app = 'algora-media'
|
||||
primary_region = 'otp'
|
||||
kill_signal = 'SIGTERM'
|
||||
kill_timeout = '5s'
|
||||
|
||||
[experimental]
|
||||
auto_rollback = true
|
||||
|
||||
[build]
|
||||
|
||||
[deploy]
|
||||
release_command = '/app/bin/migrate'
|
||||
|
||||
[env]
|
||||
PHX_HOST = 'tv.algora.io'
|
||||
PORT = '4000'
|
||||
|
||||
[[services]]
|
||||
protocol = 'tcp'
|
||||
internal_port = 4000
|
||||
processes = ['app']
|
||||
|
||||
[[services.ports]]
|
||||
port = 80
|
||||
handlers = ['http']
|
||||
force_https = true
|
||||
|
||||
[[services.ports]]
|
||||
port = 443
|
||||
handlers = ['tls', 'http']
|
||||
|
||||
[services.concurrency]
|
||||
type = 'connections'
|
||||
hard_limit = 2500
|
||||
soft_limit = 2000
|
||||
|
||||
[[services.tcp_checks]]
|
||||
interval = '15s'
|
||||
timeout = '2s'
|
||||
grace_period = '20s'
|
||||
|
||||
[[services]]
|
||||
protocol = 'tcp'
|
||||
internal_port = 9006
|
||||
processes = ['app']
|
||||
|
||||
[[services.ports]]
|
||||
port = 9006
|
||||
|
||||
[services.concurrency]
|
||||
type = 'connections'
|
||||
hard_limit = 2500
|
||||
soft_limit = 2000
|
||||
|
||||
[[vm]]
|
||||
cpu_kind = 'shared'
|
||||
cpus = 1
|
||||
memory_mb = 512
|
20
lib/algora.ex
Normal file
20
lib/algora.ex
Normal file
@ -0,0 +1,20 @@
|
||||
defmodule Algora do
|
||||
@moduledoc """
|
||||
The main interface for shared functionality.
|
||||
"""
|
||||
require Logger
|
||||
|
||||
@doc """
|
||||
Looks up `Application` config or raises if keyspace is not configured.
|
||||
"""
|
||||
def config([main_key | rest] = keyspace) when is_list(keyspace) do
|
||||
main = Application.fetch_env!(:algora, main_key)
|
||||
|
||||
Enum.reduce(rest, main, fn next_key, current ->
|
||||
case Keyword.fetch(current, next_key) do
|
||||
{:ok, val} -> val
|
||||
:error -> raise ArgumentError, "no config found under #{inspect(keyspace)}"
|
||||
end
|
||||
end)
|
||||
end
|
||||
end
|
122
lib/algora/accounts.ex
Normal file
122
lib/algora/accounts.ex
Normal file
@ -0,0 +1,122 @@
|
||||
defmodule Algora.Accounts do
|
||||
import Ecto.Query
|
||||
import Ecto.Changeset
|
||||
|
||||
alias Algora.Repo
|
||||
alias Algora.Accounts.{User, Identity}
|
||||
|
||||
def list_users(opts) do
|
||||
Repo.replica().all(from u in User, limit: ^Keyword.fetch!(opts, :limit))
|
||||
end
|
||||
|
||||
def get_users_map(user_ids) when is_list(user_ids) do
|
||||
Repo.replica().all(from u in User, where: u.id in ^user_ids, select: {u.id, u})
|
||||
end
|
||||
|
||||
def admin?(%User{} = user) do
|
||||
user.email in Algora.config([:admin_emails])
|
||||
end
|
||||
|
||||
def update_settings(%User{} = user, attrs) do
|
||||
user |> change_settings(attrs) |> Repo.update()
|
||||
end
|
||||
|
||||
## Database getters
|
||||
|
||||
@doc """
|
||||
Gets a user by email.
|
||||
|
||||
## Examples
|
||||
|
||||
iex> get_user_by_email("foo@example.com")
|
||||
%User{}
|
||||
|
||||
iex> get_user_by_email("unknown@example.com")
|
||||
nil
|
||||
|
||||
"""
|
||||
def get_user_by_email(email) when is_binary(email) do
|
||||
Repo.get_by(User, email: email)
|
||||
end
|
||||
|
||||
@doc """
|
||||
Gets a single user.
|
||||
|
||||
Raises `Ecto.NoResultsError` if the User does not exist.
|
||||
|
||||
## Examples
|
||||
|
||||
iex> get_user!(123)
|
||||
%User{}
|
||||
|
||||
iex> get_user!(456)
|
||||
** (Ecto.NoResultsError)
|
||||
|
||||
"""
|
||||
def get_user!(id), do: Repo.replica().get!(User, id)
|
||||
|
||||
def get_user(id), do: Repo.replica().get(User, id)
|
||||
|
||||
def get_user_by!(fields), do: Repo.replica().get_by!(User, fields)
|
||||
|
||||
## User registration
|
||||
|
||||
@doc """
|
||||
Registers a user from their GithHub information.
|
||||
"""
|
||||
def register_github_user(primary_email, info, emails, token) do
|
||||
if user = get_user_by_provider(:github, primary_email) do
|
||||
update_github_token(user, token)
|
||||
else
|
||||
info
|
||||
|> User.github_registration_changeset(primary_email, emails, token)
|
||||
|> Repo.insert()
|
||||
end
|
||||
end
|
||||
|
||||
def get_user_by_provider(provider, email) when provider in [:github] do
|
||||
query =
|
||||
from(u in User,
|
||||
join: i in assoc(u, :identities),
|
||||
where:
|
||||
i.provider == ^to_string(provider) and
|
||||
fragment("lower(?)", u.email) == ^String.downcase(email)
|
||||
)
|
||||
|
||||
Repo.one(query)
|
||||
end
|
||||
|
||||
def change_settings(%User{} = user, attrs) do
|
||||
User.settings_changeset(user, attrs)
|
||||
end
|
||||
|
||||
defp update_github_token(%User{} = user, new_token) do
|
||||
identity =
|
||||
Repo.one!(from(i in Identity, where: i.user_id == ^user.id and i.provider == "github"))
|
||||
|
||||
{:ok, _} =
|
||||
identity
|
||||
|> change()
|
||||
|> put_change(:provider_token, new_token)
|
||||
|> Repo.update()
|
||||
|
||||
{:ok, Repo.preload(user, :identities, force: true)}
|
||||
end
|
||||
|
||||
def gen_stream_key(%User{} = user) do
|
||||
user =
|
||||
Repo.one!(from(u in User, where: u.id == ^user.id))
|
||||
|
||||
token = :crypto.strong_rand_bytes(32)
|
||||
hashed_token = :crypto.hash(:sha256, token)
|
||||
encoded_token = Base.url_encode64(hashed_token, padding: false)
|
||||
|
||||
{:ok, _} =
|
||||
user
|
||||
|> change()
|
||||
|> put_change(:stream_key, encoded_token)
|
||||
|> Repo.update()
|
||||
|
||||
{:ok, user}
|
||||
end
|
||||
end
|
48
lib/algora/accounts/identity.ex
Normal file
48
lib/algora/accounts/identity.ex
Normal file
@ -0,0 +1,48 @@
|
||||
defmodule Algora.Accounts.Identity do
|
||||
use Ecto.Schema
|
||||
import Ecto.Changeset
|
||||
|
||||
alias Algora.Accounts.{Identity, User}
|
||||
|
||||
# providers
|
||||
@github "github"
|
||||
|
||||
@derive {Inspect, except: [:provider_token, :provider_meta]}
|
||||
schema "identities" do
|
||||
field :provider, :string
|
||||
field :provider_token, :string
|
||||
field :provider_email, :string
|
||||
field :provider_login, :string
|
||||
field :provider_name, :string, virtual: true
|
||||
field :provider_id, :string
|
||||
field :provider_meta, :map
|
||||
|
||||
belongs_to :user, User
|
||||
|
||||
timestamps()
|
||||
end
|
||||
|
||||
@doc """
|
||||
A user changeset for github registration.
|
||||
"""
|
||||
def github_registration_changeset(info, primary_email, emails, token) do
|
||||
params = %{
|
||||
"provider_token" => token,
|
||||
"provider_id" => to_string(info["id"]),
|
||||
"provider_login" => info["login"],
|
||||
"provider_name" => info["name"] || info["login"],
|
||||
"provider_email" => primary_email
|
||||
}
|
||||
|
||||
%Identity{provider: @github, provider_meta: %{"user" => info, "emails" => emails}}
|
||||
|> cast(params, [
|
||||
:provider_token,
|
||||
:provider_email,
|
||||
:provider_login,
|
||||
:provider_name,
|
||||
:provider_id
|
||||
])
|
||||
|> validate_required([:provider_token, :provider_email, :provider_name, :provider_id])
|
||||
|> validate_length(:provider_meta, max: 10_000)
|
||||
end
|
||||
end
|
113
lib/algora/accounts/user.ex
Normal file
113
lib/algora/accounts/user.ex
Normal file
@ -0,0 +1,113 @@
|
||||
defmodule Algora.Accounts.User do
|
||||
use Ecto.Schema
|
||||
import Ecto.Changeset
|
||||
|
||||
alias Algora.Accounts.{User, Identity}
|
||||
|
||||
schema "users" do
|
||||
field :email, :string
|
||||
field :name, :string
|
||||
field :handle, :string
|
||||
field :channel_tagline, :string
|
||||
field :avatar_url, :string
|
||||
field :external_homepage_url, :string
|
||||
field :videos_count, :integer
|
||||
field :is_live, :boolean, default: false
|
||||
field :stream_key, :string
|
||||
field :visibility, Ecto.Enum, values: [public: 1, unlisted: 2]
|
||||
field :bounties_count, :integer
|
||||
|
||||
embeds_many :tech, Tech do
|
||||
field :name, :string
|
||||
field :pct, :float
|
||||
field :color, :string
|
||||
end
|
||||
|
||||
embeds_many :orgs_contributed, Org do
|
||||
field :handle, :string
|
||||
field :avatar_url, :string
|
||||
end
|
||||
|
||||
has_many :identities, Identity
|
||||
|
||||
timestamps()
|
||||
end
|
||||
|
||||
def get_visibility(info) do
|
||||
# HACK: temporary heuristic to prevent abuse
|
||||
with %{"followers" => followers, "created_at" => created_at} <- info,
|
||||
{:ok, registered_at, _} <- DateTime.from_iso8601(created_at),
|
||||
true <- DateTime.diff(DateTime.utc_now(), registered_at, :second) > 30 * 24 * 60 * 60,
|
||||
true <- followers >= 20 do
|
||||
:public
|
||||
else
|
||||
_ -> :unlisted
|
||||
end
|
||||
end
|
||||
|
||||
@doc """
|
||||
A user changeset for github registration.
|
||||
"""
|
||||
def github_registration_changeset(info, primary_email, emails, token) do
|
||||
%{"login" => handle, "avatar_url" => avatar_url, "html_url" => external_homepage_url} = info
|
||||
|
||||
identity_changeset =
|
||||
Identity.github_registration_changeset(info, primary_email, emails, token)
|
||||
|
||||
if identity_changeset.valid? do
|
||||
params = %{
|
||||
"handle" => handle,
|
||||
"email" => primary_email,
|
||||
"name" => get_change(identity_changeset, :provider_name),
|
||||
"avatar_url" => avatar_url,
|
||||
"external_homepage_url" => external_homepage_url,
|
||||
"visibility" => get_visibility(info)
|
||||
}
|
||||
|
||||
%User{}
|
||||
|> cast(params, [:email, :name, :handle, :avatar_url, :external_homepage_url, :visibility])
|
||||
|> validate_required([:email, :name, :handle, :visibility])
|
||||
|> validate_handle()
|
||||
|> validate_email()
|
||||
|> put_assoc(:identities, [identity_changeset])
|
||||
else
|
||||
%User{}
|
||||
|> change()
|
||||
|> Map.put(:valid?, false)
|
||||
|> put_assoc(:identities, [identity_changeset])
|
||||
end
|
||||
end
|
||||
|
||||
def settings_changeset(%User{} = user, params) do
|
||||
user
|
||||
|> cast(params, [:handle, :channel_tagline])
|
||||
|> validate_required([:handle, :channel_tagline])
|
||||
|> validate_handle()
|
||||
end
|
||||
|
||||
defp validate_email(changeset) do
|
||||
changeset
|
||||
|> validate_required([:email])
|
||||
|> validate_format(:email, ~r/^[^\s]+@[^\s]+$/, message: "must have the @ sign and no spaces")
|
||||
|> validate_length(:email, max: 160)
|
||||
|> unsafe_validate_unique(:email, Algora.Repo)
|
||||
|> unique_constraint(:email)
|
||||
end
|
||||
|
||||
defp validate_handle(changeset) do
|
||||
changeset
|
||||
|> validate_format(:handle, ~r/^[a-zA-Z0-9_-]{2,32}$/)
|
||||
|> unsafe_validate_unique(:handle, Algora.Repo)
|
||||
|> unique_constraint(:handle)
|
||||
|> prepare_changes(fn changeset ->
|
||||
case fetch_change(changeset, :channel_tagline) do
|
||||
{:ok, _} ->
|
||||
changeset
|
||||
|
||||
:error ->
|
||||
handle = get_field(changeset, :handle)
|
||||
put_change(changeset, :channel_tagline, "#{handle}'s channel")
|
||||
end
|
||||
end)
|
||||
end
|
||||
end
|
67
lib/algora/application.ex
Normal file
67
lib/algora/application.ex
Normal file
@ -0,0 +1,67 @@
|
||||
defmodule Algora.Application do
|
||||
# See https://hexdocs.pm/elixir/Application.html
|
||||
# for more information on OTP Applications
|
||||
@moduledoc false
|
||||
|
||||
use Application
|
||||
|
||||
@impl true
|
||||
def start(_type, _args) do
|
||||
topologies = Application.get_env(:libcluster, :topologies) || []
|
||||
|
||||
tcp_server_options = %Membrane.RTMP.Source.TcpServer{
|
||||
port: Algora.config([:rtmp_port]),
|
||||
listen_options: [
|
||||
:binary,
|
||||
packet: :raw,
|
||||
active: false,
|
||||
ip: {0, 0, 0, 0, 0, 0, 0, 0}
|
||||
],
|
||||
socket_handler: fn socket ->
|
||||
{:ok, _sup, pid} =
|
||||
Membrane.Pipeline.start_link(Algora.Pipeline, socket: socket)
|
||||
|
||||
{:ok, pid}
|
||||
end
|
||||
}
|
||||
|
||||
children = [
|
||||
{Cluster.Supervisor, [topologies, [name: Algora.ClusterSupervisor]]},
|
||||
{Task.Supervisor, name: Algora.TaskSupervisor},
|
||||
# Start the Ecto repository
|
||||
Algora.Repo,
|
||||
Algora.ReplicaRepo,
|
||||
{Oban, Application.fetch_env!(:algora, Oban)},
|
||||
# Start the Telemetry supervisor
|
||||
AlgoraWeb.Telemetry,
|
||||
# Start the PubSub system
|
||||
{Phoenix.PubSub, name: Algora.PubSub},
|
||||
# Start presence
|
||||
AlgoraWeb.Presence,
|
||||
{Finch, name: Algora.Finch},
|
||||
# Start the Endpoint (http/https)
|
||||
AlgoraWeb.Endpoint,
|
||||
# Start the RTMP server
|
||||
%{
|
||||
id: Membrane.RTMP.Source.TcpServer,
|
||||
start: {Membrane.RTMP.Source.TcpServer, :start_link, [tcp_server_options]}
|
||||
}
|
||||
|
||||
# Start a worker by calling: Algora.Worker.start_link(arg)
|
||||
# {Algora.Worker, arg}
|
||||
]
|
||||
|
||||
# See https://hexdocs.pm/elixir/Supervisor.html
|
||||
# for other strategies and supported options
|
||||
opts = [strategy: :one_for_one, name: Algora.Supervisor]
|
||||
Supervisor.start_link(children, opts)
|
||||
end
|
||||
|
||||
# Tell Phoenix to update the endpoint configuration
|
||||
# whenever the application is updated.
|
||||
@impl true
|
||||
def config_change(changed, _new, removed) do
|
||||
AlgoraWeb.Endpoint.config_change(changed, removed)
|
||||
:ok
|
||||
end
|
||||
end
|
50
lib/algora/chat.ex
Normal file
50
lib/algora/chat.ex
Normal file
@ -0,0 +1,50 @@
|
||||
defmodule Algora.Chat do
|
||||
@moduledoc """
|
||||
The Chat context.
|
||||
"""
|
||||
|
||||
import Ecto.Query, warn: false
|
||||
alias Algora.Library.Video
|
||||
alias Algora.Accounts.User
|
||||
alias Algora.Repo
|
||||
|
||||
alias Algora.Chat.Message
|
||||
|
||||
def list_messages(%Video{} = video) do
|
||||
# TODO: add limit
|
||||
from(m in Message,
|
||||
join: u in User,
|
||||
on: m.user_id == u.id,
|
||||
where: m.video_id == ^video.id,
|
||||
select_merge: %{sender_handle: u.handle}
|
||||
)
|
||||
|> order_by_inserted(:asc)
|
||||
|> Repo.replica().all()
|
||||
end
|
||||
|
||||
defp order_by_inserted(%Ecto.Query{} = query, direction) when direction in [:asc, :desc] do
|
||||
from(s in query, order_by: [{^direction, s.inserted_at}])
|
||||
end
|
||||
|
||||
def get_message!(id), do: Repo.replica().get!(Message, id)
|
||||
|
||||
def create_message(attrs \\ %{}) do
|
||||
%Message{}
|
||||
|> Message.changeset(attrs)
|
||||
|> Repo.insert()
|
||||
end
|
||||
|
||||
def update_message(%Message{} = message, attrs) do
|
||||
message
|
||||
|> Message.changeset(attrs)
|
||||
|> Repo.update()
|
||||
end
|
||||
|
||||
def delete_message(%Message{} = message) do
|
||||
Repo.delete(message)
|
||||
end
|
||||
|
||||
def change_message(%Message{} = message, attrs \\ %{}) do
|
||||
Message.changeset(message, attrs)
|
||||
end
|
||||
end
|
22
lib/algora/chat/message.ex
Normal file
22
lib/algora/chat/message.ex
Normal file
@ -0,0 +1,22 @@
|
||||
defmodule Algora.Chat.Message do
|
||||
use Ecto.Schema
|
||||
alias Algora.Accounts
|
||||
alias Algora.Library
|
||||
import Ecto.Changeset
|
||||
|
||||
schema "messages" do
|
||||
field :body, :string
|
||||
field :sender_handle, :string, virtual: true
|
||||
belongs_to :user, Accounts.User
|
||||
belongs_to :video, Library.Video
|
||||
|
||||
timestamps()
|
||||
end
|
||||
|
||||
@doc false
|
||||
def changeset(message, attrs) do
|
||||
message
|
||||
|> cast(attrs, [:body])
|
||||
|> validate_required([:body])
|
||||
end
|
||||
end
|
134
lib/algora/github.ex
Normal file
134
lib/algora/github.ex
Normal file
@ -0,0 +1,134 @@
|
||||
defmodule Algora.Github do
|
||||
def authorize_url() do
|
||||
state = random_string()
|
||||
|
||||
"https://github.com/login/oauth/authorize?client_id=#{client_id()}&state=#{state}&scope=user:email"
|
||||
end
|
||||
|
||||
def exchange_access_token(opts) do
|
||||
code = Keyword.fetch!(opts, :code)
|
||||
state = Keyword.fetch!(opts, :state)
|
||||
|
||||
state
|
||||
|> fetch_exchange_response(code)
|
||||
|> fetch_user_info()
|
||||
|> fetch_emails()
|
||||
end
|
||||
|
||||
defp fetch_exchange_response(state, code) do
|
||||
resp =
|
||||
http(
|
||||
"github.com",
|
||||
"POST",
|
||||
"/login/oauth/access_token",
|
||||
[state: state, code: code, client_secret: secret()],
|
||||
[{"accept", "application/json"}]
|
||||
)
|
||||
|
||||
with {:ok, resp} <- resp,
|
||||
%{"access_token" => token} <- Jason.decode!(resp) do
|
||||
{:ok, token}
|
||||
else
|
||||
{:error, _reason} = err -> err
|
||||
%{} = resp -> {:error, {:bad_response, resp}}
|
||||
end
|
||||
end
|
||||
|
||||
defp fetch_user_info({:error, _reason} = error), do: error
|
||||
|
||||
defp fetch_user_info({:ok, token}) do
|
||||
resp =
|
||||
http(
|
||||
"api.github.com",
|
||||
"GET",
|
||||
"/user",
|
||||
[],
|
||||
[{"accept", "application/vnd.github.v3+json"}, {"Authorization", "token #{token}"}]
|
||||
)
|
||||
|
||||
case resp do
|
||||
{:ok, info} -> {:ok, %{info: Jason.decode!(info), token: token}}
|
||||
{:error, _reason} = err -> err
|
||||
end
|
||||
end
|
||||
|
||||
defp fetch_emails({:error, _} = err), do: err
|
||||
|
||||
defp fetch_emails({:ok, user}) do
|
||||
resp =
|
||||
http(
|
||||
"api.github.com",
|
||||
"GET",
|
||||
"/user/emails",
|
||||
[],
|
||||
[{"accept", "application/vnd.github.v3+json"}, {"Authorization", "token #{user.token}"}]
|
||||
)
|
||||
|
||||
case resp do
|
||||
{:ok, info} ->
|
||||
emails = Jason.decode!(info)
|
||||
{:ok, Map.merge(user, %{primary_email: primary_email(emails), emails: emails})}
|
||||
|
||||
{:error, _reason} = err ->
|
||||
err
|
||||
end
|
||||
end
|
||||
|
||||
def random_string do
|
||||
binary = <<
|
||||
System.system_time(:nanosecond)::64,
|
||||
:erlang.phash2({node(), self()})::16,
|
||||
:erlang.unique_integer()::16
|
||||
>>
|
||||
|
||||
binary
|
||||
|> Base.url_encode64()
|
||||
|> String.replace(["/", "+"], "-")
|
||||
end
|
||||
|
||||
defp client_id, do: Algora.config([:github, :client_id])
|
||||
defp secret, do: Algora.config([:github, :client_secret])
|
||||
|
||||
defp http(host, method, path, query, headers, body \\ "") do
|
||||
{:ok, conn} = Mint.HTTP.connect(:https, host, 443)
|
||||
|
||||
path = path <> "?" <> URI.encode_query([{:client_id, client_id()} | query])
|
||||
|
||||
{:ok, conn, ref} =
|
||||
Mint.HTTP.request(
|
||||
conn,
|
||||
method,
|
||||
path,
|
||||
headers,
|
||||
body
|
||||
)
|
||||
|
||||
receive_resp(conn, ref, nil, nil, false)
|
||||
end
|
||||
|
||||
defp receive_resp(conn, ref, status, data, done?) do
|
||||
receive do
|
||||
message ->
|
||||
{:ok, conn, responses} = Mint.HTTP.stream(conn, message)
|
||||
|
||||
{new_status, new_data, done?} =
|
||||
Enum.reduce(responses, {status, data, done?}, fn
|
||||
{:status, ^ref, new_status}, {_old_status, data, done?} -> {new_status, data, done?}
|
||||
{:headers, ^ref, _headers}, acc -> acc
|
||||
{:data, ^ref, binary}, {status, nil, done?} -> {status, binary, done?}
|
||||
{:data, ^ref, binary}, {status, data, done?} -> {status, data <> binary, done?}
|
||||
{:done, ^ref}, {status, data, _done?} -> {status, data, true}
|
||||
end)
|
||||
|
||||
cond do
|
||||
done? and new_status == 200 -> {:ok, new_data}
|
||||
done? -> {:error, {new_status, new_data}}
|
||||
!done? -> receive_resp(conn, ref, new_status, new_data, done?)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
defp primary_email(emails) do
|
||||
Enum.find(emails, fn email -> email["primary"] end)["email"] || Enum.at(emails, 0)
|
||||
end
|
||||
end
|
294
lib/algora/library.ex
Normal file
294
lib/algora/library.ex
Normal file
@ -0,0 +1,294 @@
|
||||
defmodule Algora.Library do
|
||||
@moduledoc """
|
||||
The Library context.
|
||||
"""
|
||||
|
||||
require Logger
|
||||
import Ecto.Query, warn: false
|
||||
import Ecto.Changeset
|
||||
alias Algora.Accounts.User
|
||||
alias Algora.Storage
|
||||
alias Algora.{Repo, Accounts}
|
||||
alias Algora.Library.{Channel, Video, Events}
|
||||
|
||||
@pubsub Algora.PubSub
|
||||
|
||||
def subscribe_to_livestreams() do
|
||||
Phoenix.PubSub.subscribe(@pubsub, topic_livestreams())
|
||||
end
|
||||
|
||||
def subscribe_to_channel(%Channel{} = channel) do
|
||||
Phoenix.PubSub.subscribe(@pubsub, topic(channel.user_id))
|
||||
end
|
||||
|
||||
def init_livestream!() do
|
||||
%Video{
|
||||
title: "",
|
||||
duration: 0,
|
||||
type: :livestream,
|
||||
is_live: true,
|
||||
visibility: :unlisted
|
||||
}
|
||||
|> change()
|
||||
|> Video.put_video_path(:livestream)
|
||||
|> Repo.insert!()
|
||||
end
|
||||
|
||||
def toggle_streamer_live(%Video{} = video, is_live) do
|
||||
video = get_video!(video.id)
|
||||
user = Accounts.get_user!(video.user_id)
|
||||
|
||||
if user.visibility == :public do
|
||||
Repo.update_all(from(u in Accounts.User, where: u.id == ^video.user_id),
|
||||
set: [is_live: is_live]
|
||||
)
|
||||
end
|
||||
|
||||
Repo.update_all(
|
||||
from(v in Video,
|
||||
where: v.user_id == ^video.user_id and (v.id != ^video.id or not (^is_live))
|
||||
),
|
||||
set: [is_live: false]
|
||||
)
|
||||
|
||||
video = get_video!(video.id)
|
||||
|
||||
video =
|
||||
with false <- is_live,
|
||||
{:ok, duration} <- get_duration(video),
|
||||
{:ok, video} <- video |> change() |> put_change(:duration, duration) |> Repo.update() do
|
||||
video
|
||||
else
|
||||
_ -> video
|
||||
end
|
||||
|
||||
msg =
|
||||
case is_live do
|
||||
true -> %Events.LivestreamStarted{video: video}
|
||||
false -> %Events.LivestreamEnded{video: video}
|
||||
end
|
||||
|
||||
Phoenix.PubSub.broadcast!(@pubsub, topic_livestreams(), {__MODULE__, msg})
|
||||
|
||||
sink_url = Algora.config([:event_sink, :url])
|
||||
|
||||
if sink_url && user.visibility == :public do
|
||||
identity =
|
||||
from(i in Algora.Accounts.Identity,
|
||||
join: u in assoc(i, :user),
|
||||
where: u.id == ^video.user_id and i.provider == "github",
|
||||
order_by: [asc: i.inserted_at]
|
||||
)
|
||||
|> Repo.one()
|
||||
|> Repo.preload(:user)
|
||||
|
||||
body =
|
||||
Jason.encode_to_iodata!(%{
|
||||
event_kind: if(is_live, do: :livestream_started, else: :livestream_ended),
|
||||
stream_id: video.uuid,
|
||||
url: "#{AlgoraWeb.Endpoint.url()}/#{identity.user.handle}",
|
||||
github_user: %{
|
||||
id: String.to_integer(identity.provider_id),
|
||||
login: identity.provider_login
|
||||
}
|
||||
})
|
||||
|
||||
{:ok, _} =
|
||||
Finch.build(:post, sink_url, [{"content-type", "application/json"}], body)
|
||||
|> Finch.request(Algora.Finch)
|
||||
end
|
||||
end
|
||||
|
||||
defp get_playlist(%Video{} = video) do
|
||||
url = "#{video.url_root}/index.m3u8"
|
||||
|
||||
with {:ok, resp} <- Finch.build(:get, url) |> Finch.request(Algora.Finch) do
|
||||
ExM3U8.deserialize_playlist(resp.body, [])
|
||||
end
|
||||
end
|
||||
|
||||
defp get_media_playlist(%Video{} = video, uri) do
|
||||
url = "#{video.url_root}/#{uri}"
|
||||
|
||||
with {:ok, resp} <- Finch.build(:get, url) |> Finch.request(Algora.Finch) do
|
||||
ExM3U8.deserialize_media_playlist(resp.body, [])
|
||||
end
|
||||
end
|
||||
|
||||
defp get_media_playlist(%Video{} = video) do
|
||||
with {:ok, playlist} <- get_playlist(video) do
|
||||
uri = playlist.items |> Enum.find(&match?(%{uri: _}, &1)) |> then(& &1.uri)
|
||||
get_media_playlist(video, uri)
|
||||
end
|
||||
end
|
||||
|
||||
def get_duration(%Video{type: :livestream} = video) do
|
||||
with {:ok, playlist} <- get_media_playlist(video) do
|
||||
duration =
|
||||
playlist.timeline
|
||||
|> Enum.filter(&match?(%{duration: _}, &1))
|
||||
|> Enum.reduce(0, fn x, acc -> acc + x.duration end)
|
||||
|
||||
{:ok, round(duration)}
|
||||
end
|
||||
end
|
||||
|
||||
def get_duration(%Video{type: :vod}) do
|
||||
{:error, :not_implemented}
|
||||
end
|
||||
|
||||
def to_hhmmss(duration) when is_integer(duration) do
|
||||
hours = div(duration, 60 * 60)
|
||||
minutes = div(duration - hours * 60 * 60, 60)
|
||||
seconds = rem(duration - hours * 60 * 60 - minutes * 60, 60)
|
||||
|
||||
if(hours == 0, do: [minutes, seconds], else: [hours, minutes, seconds])
|
||||
|> Enum.map_join(":", fn count -> String.pad_leading("#{count}", 2, ["0"]) end)
|
||||
end
|
||||
|
||||
def unsubscribe_to_channel(%Channel{} = channel) do
|
||||
Phoenix.PubSub.unsubscribe(@pubsub, topic(channel.user_id))
|
||||
end
|
||||
|
||||
defp create_thumbnail(%Video{} = video, contents) do
|
||||
input_path = Path.join(System.tmp_dir(), "#{video.uuid}.mp4")
|
||||
output_path = Path.join(System.tmp_dir(), "#{video.uuid}.jpeg")
|
||||
|
||||
with :ok <- File.write(input_path, contents),
|
||||
:ok <- Thumbnex.create_thumbnail(input_path, output_path) do
|
||||
File.read(output_path)
|
||||
end
|
||||
end
|
||||
|
||||
def store_thumbnail(%Video{} = video, contents) do
|
||||
with {:ok, thumbnail} <- create_thumbnail(video, contents),
|
||||
{:ok, _} <- Storage.upload_file("#{video.uuid}/index.jpeg", thumbnail) do
|
||||
:ok
|
||||
end
|
||||
end
|
||||
|
||||
def reconcile_livestream(%Video{} = video, stream_key) do
|
||||
user =
|
||||
Accounts.get_user_by!(stream_key: stream_key)
|
||||
|
||||
result =
|
||||
Repo.update_all(from(v in Video, where: v.id == ^video.id),
|
||||
set: [user_id: user.id, title: user.channel_tagline, visibility: user.visibility]
|
||||
)
|
||||
|
||||
case result do
|
||||
{1, _} ->
|
||||
{:ok, video}
|
||||
|
||||
_ ->
|
||||
{:error, :invalid}
|
||||
end
|
||||
end
|
||||
|
||||
def list_videos(limit \\ 100) do
|
||||
from(v in Video,
|
||||
join: u in User,
|
||||
on: v.user_id == u.id,
|
||||
limit: ^limit,
|
||||
# TODO: remove vod check once current vod durations are backfilled
|
||||
where:
|
||||
v.visibility == :public and
|
||||
(v.is_live == true or v.duration >= 120 or v.type == :vod),
|
||||
select_merge: %{channel_name: u.name}
|
||||
)
|
||||
|> order_by_inserted(:desc)
|
||||
|> Repo.replica().all()
|
||||
end
|
||||
|
||||
def list_channel_videos(%Channel{} = channel, limit \\ 100) do
|
||||
from(v in Video,
|
||||
limit: ^limit,
|
||||
join: u in User,
|
||||
on: v.user_id == u.id,
|
||||
select_merge: %{channel_name: u.name},
|
||||
where: v.user_id == ^channel.user_id
|
||||
)
|
||||
|> order_by_inserted(:desc)
|
||||
|> Repo.replica().all()
|
||||
end
|
||||
|
||||
def list_active_channels(opts) do
|
||||
from(u in Algora.Accounts.User,
|
||||
where: u.is_live,
|
||||
limit: ^Keyword.fetch!(opts, :limit),
|
||||
order_by: [desc: u.updated_at],
|
||||
select: struct(u, [:id, :handle, :channel_tagline, :avatar_url, :external_homepage_url])
|
||||
)
|
||||
|> Repo.replica().all()
|
||||
|> Enum.map(&get_channel!/1)
|
||||
end
|
||||
|
||||
def get_channel!(%Accounts.User{} = user) do
|
||||
%Channel{
|
||||
user_id: user.id,
|
||||
handle: user.handle,
|
||||
name: user.name || user.handle,
|
||||
tagline: user.channel_tagline,
|
||||
avatar_url: user.avatar_url,
|
||||
external_homepage_url: user.external_homepage_url,
|
||||
is_live: user.is_live,
|
||||
bounties_count: user.bounties_count,
|
||||
orgs_contributed: user.orgs_contributed,
|
||||
tech: user.tech
|
||||
}
|
||||
end
|
||||
|
||||
def owns_channel?(%Accounts.User{} = user, %Channel{} = channel) do
|
||||
user.id == channel.user_id
|
||||
end
|
||||
|
||||
defp youtube_id(%Video{url: url}) do
|
||||
url = URI.parse(url)
|
||||
root = ".#{url.host}"
|
||||
|
||||
cond do
|
||||
root |> String.ends_with?(".youtube.com") ->
|
||||
%{"v" => id} = URI.decode_query(url.query)
|
||||
id
|
||||
|
||||
root |> String.ends_with?(".youtu.be") ->
|
||||
"/" <> id = url.path
|
||||
id
|
||||
|
||||
true ->
|
||||
:not_found
|
||||
end
|
||||
end
|
||||
|
||||
def thumbnail_url(%Video{} = video) do
|
||||
case youtube_id(video) do
|
||||
:not_found -> video.url_root <> "/index.jpeg"
|
||||
id -> "https://i.ytimg.com/vi/#{id}/hqdefault.jpg"
|
||||
end
|
||||
end
|
||||
|
||||
def player_type(%Video{type: :livestream}), do: "application/x-mpegURL"
|
||||
|
||||
def player_type(%Video{} = video) do
|
||||
case youtube_id(video) do
|
||||
:not_found -> "video/mp4"
|
||||
_ -> "video/youtube"
|
||||
end
|
||||
end
|
||||
|
||||
def get_video!(id), do: Repo.replica().get!(Video, id)
|
||||
|
||||
def update_video(%Video{} = video, attrs) do
|
||||
video
|
||||
|> Video.changeset(attrs)
|
||||
|> Repo.update()
|
||||
end
|
||||
|
||||
defp order_by_inserted(%Ecto.Query{} = query, direction) when direction in [:asc, :desc] do
|
||||
from(s in query, order_by: [{^direction, s.inserted_at}])
|
||||
end
|
||||
|
||||
defp topic(user_id) when is_integer(user_id), do: "channel:#{user_id}"
|
||||
|
||||
def topic_livestreams(), do: "livestreams"
|
||||
end
|
12
lib/algora/library/channel.ex
Normal file
12
lib/algora/library/channel.ex
Normal file
@ -0,0 +1,12 @@
|
||||
defmodule Algora.Library.Channel do
|
||||
defstruct user_id: nil,
|
||||
handle: nil,
|
||||
name: nil,
|
||||
tagline: nil,
|
||||
avatar_url: nil,
|
||||
external_homepage_url: nil,
|
||||
is_live: nil,
|
||||
bounties_count: nil,
|
||||
orgs_contributed: nil,
|
||||
tech: nil
|
||||
end
|
13
lib/algora/library/events.ex
Normal file
13
lib/algora/library/events.ex
Normal file
@ -0,0 +1,13 @@
|
||||
defmodule Algora.Library.Events do
|
||||
defmodule LivestreamStarted do
|
||||
defstruct video: nil
|
||||
end
|
||||
|
||||
defmodule LivestreamEnded do
|
||||
defstruct video: nil
|
||||
end
|
||||
|
||||
defmodule ThumbnailsGenerated do
|
||||
defstruct video: nil
|
||||
end
|
||||
end
|
62
lib/algora/library/video.ex
Normal file
62
lib/algora/library/video.ex
Normal file
@ -0,0 +1,62 @@
|
||||
defmodule Algora.Library.Video do
|
||||
require Logger
|
||||
use Ecto.Schema
|
||||
import Ecto.Changeset
|
||||
|
||||
alias Algora.Accounts
|
||||
|
||||
@type t() :: %__MODULE__{}
|
||||
|
||||
schema "videos" do
|
||||
field :duration, :integer
|
||||
field :title, :string
|
||||
field :type, Ecto.Enum, values: [vod: 1, livestream: 2]
|
||||
field :is_live, :boolean, default: false
|
||||
field :thumbnails_ready, :boolean, default: false
|
||||
field :url, :string
|
||||
field :url_root, :string
|
||||
field :uuid, :string
|
||||
field :channel_name, :string, virtual: true
|
||||
field :visibility, Ecto.Enum, values: [public: 1, unlisted: 2]
|
||||
belongs_to :user, Accounts.User
|
||||
|
||||
timestamps()
|
||||
end
|
||||
|
||||
@doc false
|
||||
def changeset(video, attrs) do
|
||||
video
|
||||
|> cast(attrs, [:title])
|
||||
|> validate_required([:title])
|
||||
end
|
||||
|
||||
def put_user(%Ecto.Changeset{} = changeset, %Accounts.User{} = user) do
|
||||
put_assoc(changeset, :user, user)
|
||||
end
|
||||
|
||||
def put_video_path(%Ecto.Changeset{} = changeset, type)
|
||||
when type in [:vod, :livestream] do
|
||||
if changeset.valid? do
|
||||
uuid = Ecto.UUID.generate()
|
||||
filename = "index#{fileext(type)}"
|
||||
|
||||
changeset
|
||||
|> put_change(:uuid, uuid)
|
||||
|> put_change(:url, url(uuid, filename))
|
||||
|> put_change(:url_root, url_root(uuid))
|
||||
else
|
||||
changeset
|
||||
end
|
||||
end
|
||||
|
||||
defp fileext(:vod), do: ".mp4"
|
||||
defp fileext(:livestream), do: ".m3u8"
|
||||
|
||||
defp url_root(uuid) do
|
||||
bucket = Algora.config([:files, :bucket])
|
||||
%{scheme: scheme, host: host} = Application.fetch_env!(:ex_aws, :s3) |> Enum.into(%{})
|
||||
"#{scheme}#{host}/#{bucket}/#{uuid}"
|
||||
end
|
||||
|
||||
defp url(uuid, filename), do: "#{url_root(uuid)}/#{filename}"
|
||||
end
|
3
lib/algora/mailer.ex
Normal file
3
lib/algora/mailer.ex
Normal file
@ -0,0 +1,3 @@
|
||||
defmodule Algora.Mailer do
|
||||
use Swoosh.Mailer, otp_app: :algora
|
||||
end
|
69
lib/algora/pipeline.ex
Normal file
69
lib/algora/pipeline.ex
Normal file
@ -0,0 +1,69 @@
|
||||
defmodule Algora.Pipeline do
|
||||
alias Algora.Library
|
||||
use Membrane.Pipeline
|
||||
|
||||
@impl true
|
||||
def handle_init(_context, socket: socket) do
|
||||
video = Library.init_livestream!()
|
||||
|
||||
spec = [
|
||||
child(:src, %Membrane.RTMP.SourceBin{
|
||||
socket: socket,
|
||||
validator: %Algora.MessageValidator{video_id: video.id}
|
||||
})
|
||||
|> via_out(:audio)
|
||||
|> via_in(Pad.ref(:input, :audio),
|
||||
options: [encoding: :AAC, segment_duration: Membrane.Time.seconds(4)]
|
||||
)
|
||||
|> child(:sink, %Membrane.HTTPAdaptiveStream.SinkBin{
|
||||
manifest_module: Membrane.HTTPAdaptiveStream.HLS,
|
||||
target_window_duration: :infinity,
|
||||
persist?: false,
|
||||
storage: %Algora.Storage{video: video}
|
||||
}),
|
||||
get_child(:src)
|
||||
|> via_out(:video)
|
||||
|> via_in(Pad.ref(:input, :video),
|
||||
options: [encoding: :H264, segment_duration: Membrane.Time.seconds(4)]
|
||||
)
|
||||
|> get_child(:sink)
|
||||
]
|
||||
|
||||
{[spec: spec], %{socket: socket, video: video}}
|
||||
end
|
||||
|
||||
@impl true
|
||||
def handle_child_notification(
|
||||
{:socket_control_needed, _socket, _source} = notification,
|
||||
:src,
|
||||
_ctx,
|
||||
state
|
||||
) do
|
||||
send(self(), notification)
|
||||
{[], state}
|
||||
end
|
||||
|
||||
@impl true
|
||||
def handle_child_notification(:end_of_stream, _element, _ctx, state) do
|
||||
Algora.Library.toggle_streamer_live(state.video, false)
|
||||
{[], state}
|
||||
end
|
||||
|
||||
@impl true
|
||||
def handle_child_notification(_notification, _element, _ctx, state) do
|
||||
{[], state}
|
||||
end
|
||||
|
||||
@impl true
|
||||
def handle_info({:socket_control_needed, socket, source} = notification, _ctx, state) do
|
||||
case Membrane.RTMP.SourceBin.pass_control(socket, source) do
|
||||
:ok ->
|
||||
:ok
|
||||
|
||||
{:error, :not_owner} ->
|
||||
Process.send_after(self(), notification, 200)
|
||||
end
|
||||
|
||||
{[], state}
|
||||
end
|
||||
end
|
28
lib/algora/release.ex
Normal file
28
lib/algora/release.ex
Normal file
@ -0,0 +1,28 @@
|
||||
defmodule Algora.Release do
|
||||
@moduledoc """
|
||||
Used for executing DB release tasks when run in production without Mix
|
||||
installed.
|
||||
"""
|
||||
@app :algora
|
||||
|
||||
def migrate do
|
||||
load_app()
|
||||
|
||||
for repo <- repos() do
|
||||
{:ok, _, _} = Ecto.Migrator.with_repo(repo, &Ecto.Migrator.run(&1, :up, all: true))
|
||||
end
|
||||
end
|
||||
|
||||
def rollback(repo, version) do
|
||||
load_app()
|
||||
{:ok, _, _} = Ecto.Migrator.with_repo(repo, &Ecto.Migrator.run(&1, :down, to: version))
|
||||
end
|
||||
|
||||
defp repos do
|
||||
Application.fetch_env!(@app, :ecto_repos)
|
||||
end
|
||||
|
||||
defp load_app do
|
||||
Application.load(@app)
|
||||
end
|
||||
end
|
23
lib/algora/repo.ex
Normal file
23
lib/algora/repo.ex
Normal file
@ -0,0 +1,23 @@
|
||||
defmodule Algora.Repo do
|
||||
use Ecto.Repo,
|
||||
otp_app: :algora,
|
||||
adapter: Ecto.Adapters.Postgres
|
||||
|
||||
def replica, do: Algora.config([:replica])
|
||||
|
||||
@locks %{playlist: 1}
|
||||
|
||||
def multi_transaction_lock(multi, scope, id) when is_atom(scope) and is_integer(id) do
|
||||
scope_int = Map.fetch!(@locks, scope)
|
||||
|
||||
Ecto.Multi.run(multi, scope, fn repo, _changes ->
|
||||
repo.query("SELECT pg_advisory_xact_lock(#{scope_int}, #{id})")
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
||||
defmodule Algora.ReplicaRepo do
|
||||
use Ecto.Repo,
|
||||
otp_app: :algora,
|
||||
adapter: Ecto.Adapters.Postgres
|
||||
end
|
94
lib/algora/storage.ex
Normal file
94
lib/algora/storage.ex
Normal file
@ -0,0 +1,94 @@
|
||||
defmodule Algora.Storage do
|
||||
@behaviour Membrane.HTTPAdaptiveStream.Storage
|
||||
|
||||
import Ecto.Changeset
|
||||
require Membrane.Logger
|
||||
alias Algora.{Repo, Library}
|
||||
|
||||
@enforce_keys [:video]
|
||||
defstruct @enforce_keys ++ [video_header: <<>>]
|
||||
|
||||
@type t :: %__MODULE__{
|
||||
video: Library.Video.t(),
|
||||
video_header: <<>>
|
||||
}
|
||||
|
||||
@impl true
|
||||
def init(%__MODULE__{} = config), do: config
|
||||
|
||||
@impl true
|
||||
def store(
|
||||
parent_id,
|
||||
name,
|
||||
contents,
|
||||
metadata,
|
||||
ctx,
|
||||
%{video: video} = state
|
||||
) do
|
||||
path = "#{video.uuid}/#{name}"
|
||||
|
||||
with {:ok, _} <- upload_file(path, contents, upload_opts(ctx)),
|
||||
{:ok, state} <- process_contents(parent_id, name, contents, metadata, ctx, state) do
|
||||
{:ok, state}
|
||||
else
|
||||
{:error, reason} = err ->
|
||||
Membrane.Logger.error("Failed to upload #{path}: #{reason}")
|
||||
{err, state}
|
||||
end
|
||||
end
|
||||
|
||||
defp upload_opts(%{type: :manifest} = _ctx) do
|
||||
[{:cache_control, "no-cache, no-store, private"}]
|
||||
end
|
||||
|
||||
defp upload_opts(_ctx), do: []
|
||||
|
||||
@impl true
|
||||
def remove(_parent_id, _name, _ctx, state) do
|
||||
{{:error, :not_implemented}, state}
|
||||
end
|
||||
|
||||
defp process_contents(
|
||||
:video,
|
||||
_name,
|
||||
contents,
|
||||
_metadata,
|
||||
%{type: :header, mode: :binary},
|
||||
state
|
||||
) do
|
||||
{:ok, %{state | video_header: contents}}
|
||||
end
|
||||
|
||||
defp process_contents(
|
||||
:video,
|
||||
_name,
|
||||
contents,
|
||||
_metadata,
|
||||
%{type: :segment, mode: :binary},
|
||||
%{video: %{thumbnails_ready: false} = video, video_header: video_header} = state
|
||||
) do
|
||||
with :ok <- Library.store_thumbnail(video, video_header <> contents),
|
||||
{:ok, video} = video |> change() |> put_change(:thumbnails_ready, true) |> Repo.update(),
|
||||
:ok <- broadcast_thumbnails_generated(video) do
|
||||
{:ok, %{state | video: video}}
|
||||
end
|
||||
end
|
||||
|
||||
defp process_contents(_parent_id, _name, _contents, _metadata, _ctx, state) do
|
||||
{:ok, state}
|
||||
end
|
||||
|
||||
def upload_file(path, contents, opts \\ []) do
|
||||
Algora.config([:files, :bucket])
|
||||
|> ExAws.S3.put_object(path, contents, opts)
|
||||
|> ExAws.request([])
|
||||
end
|
||||
|
||||
defp broadcast_thumbnails_generated(video) do
|
||||
Phoenix.PubSub.broadcast(
|
||||
Algora.PubSub,
|
||||
Library.topic_livestreams(),
|
||||
{__MODULE__, %Library.Events.ThumbnailsGenerated{video: video}}
|
||||
)
|
||||
end
|
||||
end
|
32
lib/algora/validator.ex
Normal file
32
lib/algora/validator.ex
Normal file
@ -0,0 +1,32 @@
|
||||
defmodule Algora.MessageValidator do
|
||||
defstruct [:video_id]
|
||||
end
|
||||
|
||||
defimpl Membrane.RTMP.MessageValidator, for: Algora.MessageValidator do
|
||||
@impl true
|
||||
def validate_connect(impl, message) do
|
||||
{:ok, video} =
|
||||
Algora.Library.reconcile_livestream(
|
||||
%Algora.Library.Video{id: impl.video_id},
|
||||
message.app
|
||||
)
|
||||
|
||||
Algora.Library.toggle_streamer_live(video, true)
|
||||
{:ok, "connect success"}
|
||||
end
|
||||
|
||||
@impl true
|
||||
def validate_release_stream(_impl, _message) do
|
||||
{:ok, "release stream success"}
|
||||
end
|
||||
|
||||
@impl true
|
||||
def validate_publish(_impl, _message) do
|
||||
{:ok, "validate publish success"}
|
||||
end
|
||||
|
||||
@impl true
|
||||
def validate_set_data_frame(_impl, _message) do
|
||||
{:ok, "set data frame success"}
|
||||
end
|
||||
end
|
124
lib/algora_web.ex
Normal file
124
lib/algora_web.ex
Normal file
@ -0,0 +1,124 @@
|
||||
defmodule AlgoraWeb do
|
||||
@moduledoc """
|
||||
The entrypoint for defining your web interface, such
|
||||
as controllers, views, channels and so on.
|
||||
|
||||
This can be used in your application as:
|
||||
|
||||
use AlgoraWeb, :controller
|
||||
use AlgoraWeb, :html
|
||||
|
||||
The definitions below will be executed for every view,
|
||||
controller, etc, so keep them short and clean, focused
|
||||
on imports, uses and aliases.
|
||||
|
||||
Do NOT define functions inside the quoted expressions
|
||||
below. Instead, define any helper function in modules
|
||||
and import those modules here.
|
||||
"""
|
||||
|
||||
def static_paths, do: ~w(assets fonts images favicon.ico robots.txt)
|
||||
|
||||
def controller do
|
||||
quote do
|
||||
use Phoenix.Controller,
|
||||
namespace: AlgoraWeb,
|
||||
formats: [:html, :json],
|
||||
layouts: [html: AlgoraWeb.Layouts]
|
||||
|
||||
import Plug.Conn
|
||||
import AlgoraWeb.Gettext
|
||||
alias AlgoraWeb.Router.Helpers, as: Routes
|
||||
unquote(verified_routes())
|
||||
end
|
||||
end
|
||||
|
||||
def html do
|
||||
quote do
|
||||
use Phoenix.Component
|
||||
|
||||
# Import convenience functions from controllers
|
||||
import Phoenix.Controller,
|
||||
only: [get_csrf_token: 0, view_module: 1, view_template: 1]
|
||||
|
||||
# Include general helpers for rendering HTML
|
||||
unquote(html_helpers())
|
||||
end
|
||||
end
|
||||
|
||||
def verified_routes do
|
||||
quote do
|
||||
use Phoenix.VerifiedRoutes,
|
||||
endpoint: AlgoraWeb.Endpoint,
|
||||
router: AlgoraWeb.Router,
|
||||
statics: AlgoraWeb.static_paths()
|
||||
end
|
||||
end
|
||||
|
||||
def live_view(opts \\ []) do
|
||||
quote do
|
||||
@opts Keyword.merge(
|
||||
[
|
||||
layout: {AlgoraWeb.Layouts, :live},
|
||||
container: {:div, class: "relative h-screen flex overflow-hidden"}
|
||||
],
|
||||
unquote(opts)
|
||||
)
|
||||
use Phoenix.LiveView, @opts
|
||||
|
||||
unquote(html_helpers())
|
||||
end
|
||||
end
|
||||
|
||||
def live_component do
|
||||
quote do
|
||||
use Phoenix.LiveComponent
|
||||
|
||||
unquote(html_helpers())
|
||||
end
|
||||
end
|
||||
|
||||
def router do
|
||||
quote do
|
||||
use Phoenix.Router, helpers: false
|
||||
|
||||
import Plug.Conn
|
||||
import Phoenix.Controller
|
||||
import Phoenix.LiveView.Router
|
||||
end
|
||||
end
|
||||
|
||||
def channel do
|
||||
quote do
|
||||
use Phoenix.Channel
|
||||
import AlgoraWeb.Gettext
|
||||
end
|
||||
end
|
||||
|
||||
defp html_helpers do
|
||||
quote do
|
||||
# Use all HTML functionality (forms, tags, etc)
|
||||
use Phoenix.HTML
|
||||
|
||||
# Import LiveView and .heex helpers (live_render, live_patch, <.form>, etc)
|
||||
use Phoenix.Component
|
||||
|
||||
import AlgoraWeb.CoreComponents
|
||||
import AlgoraWeb.Gettext
|
||||
alias AlgoraWeb.Router.Helpers, as: Routes
|
||||
alias Phoenix.LiveView.JS
|
||||
unquote(verified_routes())
|
||||
end
|
||||
end
|
||||
|
||||
@doc """
|
||||
When used, dispatch to the appropriate controller/view/etc.
|
||||
"""
|
||||
defmacro __using__({which, opts}) when is_atom(which) do
|
||||
apply(__MODULE__, which, [opts])
|
||||
end
|
||||
|
||||
defmacro __using__(which) when is_atom(which) do
|
||||
apply(__MODULE__, which, [])
|
||||
end
|
||||
end
|
52
lib/algora_web/channels/presence.ex
Normal file
52
lib/algora_web/channels/presence.ex
Normal file
@ -0,0 +1,52 @@
|
||||
defmodule AlgoraWeb.Presence do
|
||||
@moduledoc """
|
||||
Provides presence tracking to channels and processes.
|
||||
|
||||
See the [`Phoenix.Presence`](https://hexdocs.pm/phoenix/Phoenix.Presence.html)
|
||||
docs for more details.
|
||||
"""
|
||||
use Phoenix.Presence,
|
||||
otp_app: :algora,
|
||||
pubsub_server: Algora.PubSub
|
||||
|
||||
def init(_opts) do
|
||||
{:ok, %{}}
|
||||
end
|
||||
|
||||
def fetch(_topic, presences) do
|
||||
for {key, %{metas: [meta | metas]}} <- presences, into: %{} do
|
||||
# user can be populated here from the database here we populate
|
||||
# the name for demonstration purposes
|
||||
{key, %{metas: [meta | metas], id: meta.id, user: %{name: meta.id}}}
|
||||
end
|
||||
end
|
||||
|
||||
def handle_metas(topic, %{joins: joins, leaves: leaves}, presences, state) do
|
||||
for {user_id, presence} <- joins do
|
||||
user_data = %{id: user_id, user: presence.user, metas: Map.fetch!(presences, user_id)}
|
||||
msg = {__MODULE__, {:join, user_data}}
|
||||
Phoenix.PubSub.local_broadcast(Algora.PubSub, "proxy:#{topic}", msg)
|
||||
end
|
||||
|
||||
for {user_id, presence} <- leaves do
|
||||
metas =
|
||||
case Map.fetch(presences, user_id) do
|
||||
{:ok, presence_metas} -> presence_metas
|
||||
:error -> []
|
||||
end
|
||||
|
||||
user_data = %{id: user_id, user: presence.user, metas: metas}
|
||||
msg = {__MODULE__, {:leave, user_data}}
|
||||
Phoenix.PubSub.local_broadcast(Algora.PubSub, "proxy:#{topic}", msg)
|
||||
end
|
||||
|
||||
{:ok, state}
|
||||
end
|
||||
|
||||
def list_online_users(topic),
|
||||
do: list(topic) |> Enum.map(fn {_id, presence} -> presence end)
|
||||
|
||||
def track_user(topic, params), do: track(self(), topic, topic, params)
|
||||
|
||||
def subscribe(topic), do: Phoenix.PubSub.subscribe(Algora.PubSub, "proxy:#{topic}")
|
||||
end
|
27
lib/algora_web/channels/room_channel.ex
Normal file
27
lib/algora_web/channels/room_channel.ex
Normal file
@ -0,0 +1,27 @@
|
||||
defmodule AlgoraWeb.RoomChannel do
|
||||
alias Algora.Chat.Message
|
||||
alias Algora.Repo
|
||||
|
||||
use Phoenix.Channel
|
||||
|
||||
def join("room:" <> _room_id, _params, socket) do
|
||||
{:ok, socket}
|
||||
end
|
||||
|
||||
def handle_in("new_msg", %{"body" => body}, socket) do
|
||||
user = socket.assigns.user
|
||||
"room:" <> video_id = socket.topic
|
||||
|
||||
if user do
|
||||
broadcast!(socket, "new_msg", %{user: %{id: user.id, handle: user.handle}, body: body})
|
||||
|
||||
Repo.insert!(%Message{
|
||||
body: body,
|
||||
user_id: user.id,
|
||||
video_id: String.to_integer(video_id)
|
||||
})
|
||||
end
|
||||
|
||||
{:noreply, socket}
|
||||
end
|
||||
end
|
35
lib/algora_web/channels/user_socket.ex
Normal file
35
lib/algora_web/channels/user_socket.ex
Normal file
@ -0,0 +1,35 @@
|
||||
defmodule AlgoraWeb.UserSocket do
|
||||
use Phoenix.Socket
|
||||
alias Algora.Accounts
|
||||
|
||||
channel "room:*", AlgoraWeb.RoomChannel
|
||||
|
||||
@impl true
|
||||
def connect(%{"token" => token}, socket, _connect_info) do
|
||||
# max_age: 1209600 is equivalent to two weeks in seconds
|
||||
case Phoenix.Token.verify(socket, "user socket", token, max_age: 1_209_600) do
|
||||
{:ok, 0} ->
|
||||
{:ok, socket}
|
||||
|
||||
{:ok, user_id} ->
|
||||
user = Accounts.get_user(user_id)
|
||||
{:ok, assign(socket, :user, user)}
|
||||
|
||||
{:error, _} = error ->
|
||||
error
|
||||
end
|
||||
end
|
||||
|
||||
# Socket id's are topics that allow you to identify all sockets for a given user:
|
||||
#
|
||||
# def id(socket), do: "user_socket:#{socket.assigns.user_id}"
|
||||
#
|
||||
# Would allow you to broadcast a "disconnect" event and terminate
|
||||
# all active sockets and channels for a given user:
|
||||
#
|
||||
# Elixir.AlgoraWeb.Endpoint.broadcast("user_socket:#{user.id}", "disconnect", %{})
|
||||
#
|
||||
# Returning `nil` makes this socket anonymous.
|
||||
@impl true
|
||||
def id(_socket), do: nil
|
||||
end
|
681
lib/algora_web/components/core_components.ex
Normal file
681
lib/algora_web/components/core_components.ex
Normal file
@ -0,0 +1,681 @@
|
||||
defmodule AlgoraWeb.CoreComponents do
|
||||
use Phoenix.Component
|
||||
use AlgoraWeb, :verified_routes
|
||||
|
||||
alias Phoenix.LiveView.JS
|
||||
alias Algora.{Accounts, Library}
|
||||
|
||||
def home_path(nil = _current_user), do: "/"
|
||||
def home_path(%Accounts.User{} = current_user), do: channel_path(current_user)
|
||||
|
||||
def channel_stream_path(%Accounts.User{} = user) do
|
||||
~p"/#{user.handle}/stream"
|
||||
end
|
||||
|
||||
def channel_path(handle) when is_binary(handle) do
|
||||
unverified_path(AlgoraWeb.Endpoint, AlgoraWeb.Router, ~p"/#{handle}")
|
||||
end
|
||||
|
||||
def channel_path(%Accounts.User{} = current_user) do
|
||||
channel_path(current_user.handle)
|
||||
end
|
||||
|
||||
def channel_path(%Library.Channel{} = channel) do
|
||||
channel_path(channel.handle)
|
||||
end
|
||||
|
||||
slot :inner_block
|
||||
|
||||
def connection_status(assigns) do
|
||||
~H"""
|
||||
<div
|
||||
id="connection-status"
|
||||
class="hidden rounded-md bg-red-900 p-4 fixed top-1 right-1 w-96 fade-in-scale z-50"
|
||||
js-show={show("#connection-status")}
|
||||
js-hide={hide("#connection-status")}
|
||||
>
|
||||
<div class="flex">
|
||||
<div class="flex-shrink-0">
|
||||
<svg
|
||||
class="animate-spin -ml-1 mr-3 h-5 w-5 text-red-100"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
fill="none"
|
||||
viewBox="0 0 24 24"
|
||||
aria-hidden="true"
|
||||
>
|
||||
<circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4">
|
||||
</circle>
|
||||
<path
|
||||
class="opacity-75"
|
||||
fill="currentColor"
|
||||
d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"
|
||||
>
|
||||
</path>
|
||||
</svg>
|
||||
</div>
|
||||
<div class="ml-3">
|
||||
<p class="text-sm font-medium text-red-100" role="alert">
|
||||
<%= render_slot(@inner_block) %>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
"""
|
||||
end
|
||||
|
||||
attr :class, :string, default: nil
|
||||
|
||||
def logo(assigns) do
|
||||
~H"""
|
||||
<.link navigate="/" aria-label="Algora TV">
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
viewBox="0 0 100.14 39.42"
|
||||
class={@class || "h-auto w-20 fill-white"}
|
||||
>
|
||||
<g>
|
||||
<path d="M19.25 9v19.24H16v-2.37a9.63 9.63 0 1 1 0-14.51V9ZM16 18.63A6.32 6.32 0 1 0 9.64 25 6.32 6.32 0 0 0 16 18.63ZM22.29 0h3.29v28.24h-3.29ZM47.6 34.27v.07a5.41 5.41 0 0 1-.69 2.52 4.78 4.78 0 0 1-1.39 1.54 5.61 5.61 0 0 1-3.25 1H34a5.21 5.21 0 0 1-3.88-1.5 6.25 6.25 0 0 1-1.53-4.2l3.29.11a2.58 2.58 0 0 0 .62 1.83 2 2 0 0 0 1.5.47h8.29c1.68 0 2-1.1 2-1.75a2 2 0 0 0-2-1.76h-8.2a5.35 5.35 0 0 1-5.52-5.51 6.07 6.07 0 0 1 1.24-3.62 9.5 9.5 0 0 1-1.31-4.86A9.62 9.62 0 0 1 38.11 9a9.72 9.72 0 0 1 5.37 1.61A5.78 5.78 0 0 1 47.53 9v3.28a2.54 2.54 0 0 0-1.72.63 9.67 9.67 0 0 1 1.86 5.7 9.79 9.79 0 0 1-5.44 8.7 10 10 0 0 1-4.16.91 9.75 9.75 0 0 1-6.07-2.1 3 3 0 0 0-.18.95 2.08 2.08 0 0 0 2.23 2.27h8.18a5.61 5.61 0 0 1 3.25 1.05 5.45 5.45 0 0 1 2.12 3.88ZM31.78 18.63a6.46 6.46 0 0 0 .84 3.15 5.88 5.88 0 0 0 1.43 1.71A6.34 6.34 0 0 0 38.11 25a6.26 6.26 0 0 0 6.32-6.32 6.27 6.27 0 0 0-2.16-4.71 6.2 6.2 0 0 0-4.16-1.61 6.35 6.35 0 0 0-6.33 6.27ZM68.54 18.63A9.63 9.63 0 1 1 58.93 9a9.62 9.62 0 0 1 9.61 9.63Zm-9.61-6.32a6.32 6.32 0 1 0 6.32 6.32 6.35 6.35 0 0 0-6.32-6.32ZM80.35 14.1h-3.28a1.9 1.9 0 0 0-.4-1.31 2 2 0 0 0-1.28-.48 1.83 1.83 0 0 0-2 1.57v14.36h-3.27V9h3.29v.4a5.24 5.24 0 0 1 1.9-.4 5.47 5.47 0 0 1 3.62 1.35 5 5 0 0 1 1.42 3.75ZM100.14 9v19.24h-3.29v-2.37a9.63 9.63 0 1 1 0-14.51V9Zm-3.29 9.64A6.32 6.32 0 1 0 90.53 25a6.32 6.32 0 0 0 6.32-6.37Z">
|
||||
</path>
|
||||
</g>
|
||||
</svg>
|
||||
</.link>
|
||||
"""
|
||||
end
|
||||
|
||||
attr :flash, :map
|
||||
attr :kind, :atom
|
||||
|
||||
def flash(%{kind: :error} = assigns) do
|
||||
~H"""
|
||||
<div
|
||||
:if={msg = Phoenix.Flash.get(@flash, @kind)}
|
||||
id="flash"
|
||||
class="rounded-md bg-red-900 p-4 fixed top-1 right-1 w-96 fade-in-scale z-50"
|
||||
phx-click={
|
||||
JS.push("lv:clear-flash")
|
||||
|> JS.remove_class("fade-in-scale", to: "#flash")
|
||||
|> hide("#flash")
|
||||
}
|
||||
phx-hook="Flash"
|
||||
>
|
||||
<div class="flex justify-between items-center space-x-3 text-red-200">
|
||||
<Heroicons.exclamation_circle solid class="w-5 h-5" />
|
||||
<p class="flex-1 text-sm font-medium" role="alert">
|
||||
<%= msg %>
|
||||
</p>
|
||||
<button
|
||||
type="button"
|
||||
class="inline-flex bg-red-900 rounded-md p-1.5 text-red-400 hover:bg-red-800 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-offset-red-900 focus:ring-red-300"
|
||||
>
|
||||
<Heroicons.x_mark solid class="w-4 h-4" />
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
"""
|
||||
end
|
||||
|
||||
def flash(%{kind: :info} = assigns) do
|
||||
~H"""
|
||||
<div
|
||||
:if={msg = Phoenix.Flash.get(@flash, @kind)}
|
||||
id="flash"
|
||||
class="rounded-md bg-green-900 p-4 fixed top-1 right-1 w-96 fade-in-scale z-50"
|
||||
phx-click={JS.push("lv:clear-flash") |> JS.remove_class("fade-in-scale") |> hide("#flash")}
|
||||
phx-value-key="info"
|
||||
phx-hook="Flash"
|
||||
>
|
||||
<div class="flex justify-between items-center space-x-3 text-green-200">
|
||||
<Heroicons.check_circle solid class="w-5 h-5" />
|
||||
<p class="flex-1 text-sm font-medium" role="alert">
|
||||
<%= msg %>
|
||||
</p>
|
||||
<button
|
||||
type="button"
|
||||
class="inline-flex bg-green-900 rounded-md p-1.5 text-green-400 hover:bg-green-800 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-offset-green-900 focus:ring-green-300"
|
||||
>
|
||||
<Heroicons.x_mark solid class="w-4 h-4" />
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
"""
|
||||
end
|
||||
|
||||
def spinner(assigns) do
|
||||
~H"""
|
||||
<svg
|
||||
class="inline-block animate-spin h-2.5 w-2.5 text-gray-500"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
fill="none"
|
||||
viewBox="0 0 24 24"
|
||||
aria-hidden="true"
|
||||
>
|
||||
<circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4">
|
||||
</circle>
|
||||
<path
|
||||
class="opacity-75"
|
||||
fill="currentColor"
|
||||
d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"
|
||||
>
|
||||
</path>
|
||||
</svg>
|
||||
"""
|
||||
end
|
||||
|
||||
@doc """
|
||||
Returns a button triggered dropdown with aria keyboard and focus supporrt.
|
||||
|
||||
Accepts the follow slots:
|
||||
|
||||
* `:id` - The id to uniquely identify this dropdown
|
||||
* `:img` - The optional img to show beside the button title
|
||||
* `:title` - The button title
|
||||
* `:subtitle` - The button subtitle
|
||||
|
||||
## Examples
|
||||
|
||||
<.dropdown id={@id}>
|
||||
<:img src={@current_user.avatar_url} alt={@current_user.handle}/>
|
||||
<:title><%= @current_user.name %></:title>
|
||||
<:subtitle>@<%= @current_user.handle %></:subtitle>
|
||||
|
||||
<:link navigate={channel_path(@current_user)}>View Channel</:link>
|
||||
<:link navigate={~p"/channel/settings"}Settings</:link>
|
||||
</.dropdown>
|
||||
"""
|
||||
attr :id, :string, required: true
|
||||
|
||||
slot :img do
|
||||
attr :src, :string
|
||||
attr :alt, :string
|
||||
end
|
||||
|
||||
slot :title
|
||||
slot :subtitle
|
||||
|
||||
slot :link do
|
||||
attr :navigate, :string
|
||||
attr :href, :string
|
||||
attr :method, :any
|
||||
end
|
||||
|
||||
def dropdown(assigns) do
|
||||
~H"""
|
||||
<!-- User account dropdown -->
|
||||
<div class="px-3 mt-6 w-full relative inline-block text-left">
|
||||
<div>
|
||||
<button
|
||||
id={@id}
|
||||
type="button"
|
||||
class="group w-full bg-gray-800 rounded-md px-3.5 py-2 text-sm text-left font-medium text-gray-200 hover:bg-gray-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-offset-gray-800 focus:ring-purple-400"
|
||||
phx-click={show_dropdown("##{@id}-dropdown")}
|
||||
phx-hook="Menu"
|
||||
data-active-class="bg-gray-800"
|
||||
aria-haspopup="true"
|
||||
>
|
||||
<span class="flex w-full justify-between items-center">
|
||||
<span class="flex min-w-0 items-center justify-between space-x-3">
|
||||
<%= for img <- @img do %>
|
||||
<img
|
||||
class="w-10 h-10 bg-gray-600 rounded-full flex-shrink-0"
|
||||
{assigns_to_attributes(img)}
|
||||
/>
|
||||
<% end %>
|
||||
<span class="flex-1 flex flex-col min-w-0">
|
||||
<span class="text-gray-50 text-sm font-medium truncate">
|
||||
<%= render_slot(@title) %>
|
||||
</span>
|
||||
<span class="text-gray-400 text-sm truncate"><%= render_slot(@subtitle) %></span>
|
||||
</span>
|
||||
</span>
|
||||
<svg
|
||||
class="flex-shrink-0 h-5 w-5 text-gray-500 group-hover:text-gray-400"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
viewBox="0 0 20 20"
|
||||
fill="currentColor"
|
||||
aria-hidden="true"
|
||||
>
|
||||
<path
|
||||
fill-rule="evenodd"
|
||||
d="M10 3a1 1 0 01.707.293l3 3a1 1 0 01-1.414 1.414L10 5.414 7.707 7.707a1 1 0 01-1.414-1.414l3-3A1 1 0 0110 3zm-3.707 9.293a1 1 0 011.414 0L10 14.586l2.293-2.293a1 1 0 011.414 1.414l-3 3a1 1 0 01-1.414 0l-3-3a1 1 0 010-1.414z"
|
||||
clip-rule="evenodd"
|
||||
>
|
||||
</path>
|
||||
</svg>
|
||||
</span>
|
||||
</button>
|
||||
</div>
|
||||
<div
|
||||
id={"#{@id}-dropdown"}
|
||||
phx-click-away={hide_dropdown("##{@id}-dropdown")}
|
||||
class="hidden z-10 mx-3 origin-top absolute right-0 left-0 mt-1 rounded-md shadow-lg bg-gray-900 ring-1 ring-gray-900 ring-opacity-5 divide-y divide-gray-700"
|
||||
role="menu"
|
||||
aria-labelledby={@id}
|
||||
>
|
||||
<div class="py-1" role="none">
|
||||
<%= for link <- @link do %>
|
||||
<.link
|
||||
tabindex="-1"
|
||||
role="menuitem"
|
||||
class="block px-4 py-2 text-sm text-gray-200 hover:bg-gray-800 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-offset-gray-800 focus:ring-purple-400"
|
||||
{link}
|
||||
>
|
||||
<%= render_slot(link) %>
|
||||
</.link>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
"""
|
||||
end
|
||||
|
||||
def show_mobile_sidebar(js \\ %JS{}) do
|
||||
js
|
||||
|> JS.show(to: "#mobile-sidebar-container", transition: "fade-in")
|
||||
|> JS.show(
|
||||
to: "#mobile-sidebar",
|
||||
display: "flex",
|
||||
time: 300,
|
||||
transition:
|
||||
{"transition ease-in-out duration-300 transform", "-translate-x-full", "translate-x-0"}
|
||||
)
|
||||
|> JS.hide(to: "#show-mobile-sidebar", transition: "fade-out")
|
||||
|> JS.dispatch("js:exec", to: "#hide-mobile-sidebar", detail: %{call: "focus", args: []})
|
||||
end
|
||||
|
||||
def hide_mobile_sidebar(js \\ %JS{}) do
|
||||
js
|
||||
|> JS.hide(to: "#mobile-sidebar-container", transition: "fade-out")
|
||||
|> JS.hide(
|
||||
to: "#mobile-sidebar",
|
||||
time: 300,
|
||||
transition:
|
||||
{"transition ease-in-out duration-300 transform", "translate-x-0", "-translate-x-full"}
|
||||
)
|
||||
|> JS.show(to: "#show-mobile-sidebar", transition: "fade-in")
|
||||
|> JS.dispatch("js:exec", to: "#show-mobile-sidebar", detail: %{call: "focus", args: []})
|
||||
end
|
||||
|
||||
def show(js \\ %JS{}, selector) do
|
||||
JS.show(js,
|
||||
to: selector,
|
||||
time: 300,
|
||||
display: "inline-block",
|
||||
transition:
|
||||
{"ease-out duration-300", "opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95",
|
||||
"opacity-100 translate-y-0 sm:scale-100"}
|
||||
)
|
||||
end
|
||||
|
||||
def hide(js \\ %JS{}, selector) do
|
||||
JS.hide(js,
|
||||
to: selector,
|
||||
time: 300,
|
||||
transition:
|
||||
{"transition ease-in duration-300", "transform opacity-100 scale-100",
|
||||
"transform opacity-0 scale-95"}
|
||||
)
|
||||
end
|
||||
|
||||
def show_dropdown(to) do
|
||||
JS.show(
|
||||
to: to,
|
||||
transition:
|
||||
{"transition ease-out duration-120", "transform opacity-0 scale-95",
|
||||
"transform opacity-100 scale-100"}
|
||||
)
|
||||
|> JS.set_attribute({"aria-expanded", "true"}, to: to)
|
||||
end
|
||||
|
||||
def hide_dropdown(to) do
|
||||
JS.hide(
|
||||
to: to,
|
||||
transition:
|
||||
{"transition ease-in duration-120", "transform opacity-100 scale-100",
|
||||
"transform opacity-0 scale-95"}
|
||||
)
|
||||
|> JS.remove_attribute("aria-expanded", to: to)
|
||||
end
|
||||
|
||||
def show_modal(js \\ %JS{}, id) when is_binary(id) do
|
||||
js
|
||||
|> JS.show(
|
||||
to: "##{id}",
|
||||
display: "inline-block",
|
||||
transition: {"ease-out duration-300", "opacity-0", "opacity-100"}
|
||||
)
|
||||
|> JS.show(
|
||||
to: "##{id}-container",
|
||||
display: "inline-block",
|
||||
transition:
|
||||
{"ease-out duration-300", "opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95",
|
||||
"opacity-100 translate-y-0 sm:scale-100"}
|
||||
)
|
||||
|> js_exec("##{id}-confirm", "focus", [])
|
||||
end
|
||||
|
||||
def hide_modal(js \\ %JS{}, id) do
|
||||
js
|
||||
|> JS.remove_class("fade-in", to: "##{id}")
|
||||
|> JS.hide(
|
||||
to: "##{id}",
|
||||
transition: {"ease-in duration-200", "opacity-100", "opacity-0"}
|
||||
)
|
||||
|> JS.hide(
|
||||
to: "##{id}-container",
|
||||
transition:
|
||||
{"ease-in duration-200", "opacity-100 translate-y-0 sm:scale-100",
|
||||
"opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95"}
|
||||
)
|
||||
|> JS.dispatch("click", to: "##{id} [data-modal-return]")
|
||||
end
|
||||
|
||||
attr :id, :string, required: true
|
||||
attr :show, :boolean, default: false
|
||||
attr :patch, :string, default: nil
|
||||
attr :navigate, :string, default: nil
|
||||
attr :on_cancel, JS, default: %JS{}
|
||||
attr :on_confirm, JS, default: %JS{}
|
||||
attr :rest, :global
|
||||
|
||||
slot :title
|
||||
slot :confirm
|
||||
slot :cancel
|
||||
|
||||
def modal(assigns) do
|
||||
~H"""
|
||||
<div
|
||||
id={@id}
|
||||
class={"fixed z-10 inset-0 overflow-y-auto #{if @show, do: "fade-in", else: "hidden"}"}
|
||||
{@rest}
|
||||
>
|
||||
<.focus_wrap id={"#{@id}-focus-wrap"}>
|
||||
<div
|
||||
class="flex items-end justify-center min-h-screen pt-4 px-4 pb-20 text-center sm:block sm:p-0"
|
||||
aria-labelledby={"#{@id}-title"}
|
||||
aria-describedby={"#{@id}-description"}
|
||||
role="dialog"
|
||||
aria-modal="true"
|
||||
tabindex="0"
|
||||
>
|
||||
<div class="fixed inset-0 bg-gray-700 bg-opacity-75 transition-opacity" aria-hidden="true">
|
||||
</div>
|
||||
<span class="hidden sm:inline-block sm:align-middle sm:h-screen" aria-hidden="true">
|
||||
​
|
||||
</span>
|
||||
<div
|
||||
id={"#{@id}-container"}
|
||||
class={
|
||||
"#{if @show, do: "fade-in-scale", else: "hidden"} sticky inline-block align-bottom bg-gray-900 rounded-lg px-4 pt-5 pb-4 text-left overflow-hidden shadow-xl transform sm:my-8 sm:align-middle sm:max-w-xl sm:w-full sm:p-6"
|
||||
}
|
||||
phx-window-keydown={hide_modal(@on_cancel, @id)}
|
||||
phx-key="escape"
|
||||
phx-click-away={hide_modal(@on_cancel, @id)}
|
||||
>
|
||||
<%= if @patch do %>
|
||||
<.link patch={@patch} data-modal-return class="hidden"></.link>
|
||||
<% end %>
|
||||
<%= if @navigate do %>
|
||||
<.link navigate={@navigate} data-modal-return class="hidden"></.link>
|
||||
<% end %>
|
||||
<div class="sm:flex sm:items-start">
|
||||
<div class="mx-auto flex-shrink-0 flex items-center justify-center h-8 w-8 rounded-full bg-purple-800 sm:mx-0">
|
||||
<Heroicons.information_circle class="h-6 w-6 text-purple-300" />
|
||||
</div>
|
||||
<div class="mt-3 text-center sm:mt-0 sm:ml-4 sm:text-left w-full mr-12">
|
||||
<h3 class="text-lg leading-6 font-medium text-gray-50" id={"#{@id}-title"}>
|
||||
<%= render_slot(@title) %>
|
||||
</h3>
|
||||
<div class="mt-2">
|
||||
<p id={"#{@id}-content"} class="text-sm text-gray-400">
|
||||
<%= render_slot(@inner_block) %>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="mt-5 sm:mt-4 sm:flex sm:flex-row-reverse">
|
||||
<%= for confirm <- @confirm do %>
|
||||
<button
|
||||
id={"#{@id}-confirm"}
|
||||
class="w-full inline-flex justify-center rounded-md border border-transparent shadow-sm px-4 py-2 bg-purple-600 text-base font-medium text-white hover:bg-purple-500 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-purple-400 sm:ml-3 sm:w-auto sm:text-sm"
|
||||
phx-click={@on_confirm}
|
||||
phx-disable-with
|
||||
{assigns_to_attributes(confirm)}
|
||||
>
|
||||
<%= render_slot(confirm) %>
|
||||
</button>
|
||||
<% end %>
|
||||
<%= for cancel <- @cancel do %>
|
||||
<button
|
||||
class="mt-3 w-full inline-flex justify-center rounded-md border border-gray-600 shadow-sm px-4 py-2 bg-gray-900 text-base font-medium text-gray-200 hover:bg-gray-900 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-purple-400 sm:mt-0 sm:w-auto sm:text-sm"
|
||||
phx-click={hide_modal(@on_cancel, @id)}
|
||||
{assigns_to_attributes(cancel)}
|
||||
>
|
||||
<%= render_slot(cancel) %>
|
||||
</button>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</.focus_wrap>
|
||||
</div>
|
||||
"""
|
||||
end
|
||||
|
||||
slot :actions
|
||||
|
||||
def title_bar(assigns) do
|
||||
~H"""
|
||||
<!-- Page title & actions -->
|
||||
<div class="border-b border-gray-700 px-4 py-4 flex items-center justify-between sm:px-6 lg:px-8 sm:h-24">
|
||||
<div class="flex-1 min-w-0">
|
||||
<h1 class="text-lg font-medium leading-6 text-gray-50 focus:outline-none">
|
||||
<%= render_slot(@inner_block) %>
|
||||
</h1>
|
||||
</div>
|
||||
<%= if Enum.count(@actions) > 0 do %>
|
||||
<div class="flex sm:ml-4 space-x-4">
|
||||
<%= render_slot(@actions) %>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
"""
|
||||
end
|
||||
|
||||
attr :patch, :string
|
||||
attr :primary, :boolean, default: false
|
||||
attr :rest, :global
|
||||
|
||||
slot :inner_block
|
||||
|
||||
def button(%{patch: _} = assigns) do
|
||||
~H"""
|
||||
<%= if @primary do %>
|
||||
<%= live_patch [to: @patch, class: "order-0 inline-flex items-center px-4 py-2 border border-transparent shadow-sm text-sm font-medium rounded-md text-white bg-purple-600 hover:bg-purple-500 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-purple-400 sm:order-1 sm:ml-3"] ++
|
||||
Map.to_list(@rest) do %>
|
||||
<%= render_slot(@inner_block) %>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<%= live_patch [to: @patch, class: "order-1 inline-flex items-center px-4 py-2 border border-gray-600 shadow-sm text-sm font-medium rounded-md text-gray-200 bg-gray-900 hover:bg-gray-900 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-purple-400 sm:order-0 sm:ml-0 lg:ml-3"] ++
|
||||
assigns_to_attributes(assigns, [:primary, :patch]) do %>
|
||||
<%= render_slot(@inner_block) %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
"""
|
||||
end
|
||||
|
||||
def button(%{} = assigns) do
|
||||
~H"""
|
||||
<%= if @primary do %>
|
||||
<button
|
||||
type="button"
|
||||
class="order-0 inline-flex items-center px-4 py-2 border border-transparent shadow-sm text-sm font-medium rounded-md text-white bg-purple-600 hover:bg-purple-500 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-purple-400 sm:order-1 sm:ml-3"
|
||||
{@rest}
|
||||
>
|
||||
<%= render_slot(@inner_block) %>
|
||||
</button>
|
||||
<% else %>
|
||||
<button
|
||||
type="button"
|
||||
class="order-1 inline-flex items-center px-4 py-2 border border-gray-600 shadow-sm text-sm font-medium rounded-md text-gray-200 bg-gray-900 hover:bg-gray-900 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-purple-400 sm:order-0 sm:ml-0 lg:ml-3"
|
||||
{@rest}
|
||||
>
|
||||
<%= render_slot(@inner_block) %>
|
||||
</button>
|
||||
<% end %>
|
||||
"""
|
||||
end
|
||||
|
||||
attr :id, :string, required: true
|
||||
attr :video, :any, required: true
|
||||
|
||||
def video_entry(assigns) do
|
||||
~H"""
|
||||
<div
|
||||
id={@id}
|
||||
class="cursor-pointer truncate"
|
||||
phx-click={
|
||||
JS.push("join", value: %{video_id: @video.id}, target: "#chat-box")
|
||||
|> JS.dispatch("js:play_video",
|
||||
to: "#video-player",
|
||||
detail: %{player: %{src: @video.url, type: Library.player_type(@video)}}
|
||||
)
|
||||
}
|
||||
>
|
||||
<div class="relative flex items-center justify-center overflow-hidden rounded-2xl aspect-[16/9] bg-gray-800">
|
||||
<Heroicons.play :if={!@video.thumbnails_ready} solid class="h-12 w-12 text-gray-500" />
|
||||
<img
|
||||
:if={@video.thumbnails_ready}
|
||||
src={Library.thumbnail_url(@video)}
|
||||
alt={@video.title}
|
||||
class="absolute w-full h-full object-cover transition-transform duration-200 scale-105 hover:scale-110 z-10"
|
||||
/>
|
||||
|
||||
<div
|
||||
:if={@video.is_live}
|
||||
class="absolute font-medium text-xs px-2 py-0.5 rounded-xl bottom-1 bg-gray-950/90 text-white right-1 z-20"
|
||||
>
|
||||
🔴 LIVE
|
||||
</div>
|
||||
<div
|
||||
:if={not @video.is_live and @video.duration != 0}
|
||||
class="absolute font-medium text-xs px-2 py-0.5 rounded-xl bottom-1 bg-gray-950/90 text-white right-1 z-20"
|
||||
>
|
||||
<%= Library.to_hhmmss(@video.duration) %>
|
||||
</div>
|
||||
</div>
|
||||
<div class="pt-2 text-base font-semibold truncate"><%= @video.title %></div>
|
||||
<div class="text-gray-300 text-sm font-medium"><%= @video.channel_name %></div>
|
||||
<div class="text-gray-300 text-sm"><%= Timex.from_now(@video.inserted_at) %></div>
|
||||
</div>
|
||||
"""
|
||||
end
|
||||
|
||||
attr :id, :string, required: true
|
||||
attr :videos, :list, required: true
|
||||
|
||||
slot :inner_block
|
||||
|
||||
def playlist(assigns) do
|
||||
~H"""
|
||||
<div class="mt-8 sm:block">
|
||||
<div class="align-middle inline-block min-w-full">
|
||||
<div id={@id} class="px-4 sm:px-6 lg:px-8 min-w-full">
|
||||
<h2 class="text-gray-400 text-xs font-medium uppercase tracking-wide">
|
||||
Library
|
||||
</h2>
|
||||
<div
|
||||
id={"#{@id}-body"}
|
||||
class="mt-3 gap-8 grid sm:grid-cols-2 lg:grid-cols-1 xl:grid-cols-2 2xl:grid-cols-3"
|
||||
phx-update="stream"
|
||||
>
|
||||
<.video_entry :for={{id, video} <- @videos} id={id} video={video} />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
"""
|
||||
end
|
||||
|
||||
@doc """
|
||||
Calls a wired up event listener to call a function with arguments.
|
||||
|
||||
window.addEventListener("js:exec", e => e.target[e.detail.call](...e.detail.args))
|
||||
"""
|
||||
def js_exec(js \\ %JS{}, to, call, args) do
|
||||
JS.dispatch(js, "js:exec", to: to, detail: %{call: call, args: args})
|
||||
end
|
||||
|
||||
def focus(js \\ %JS{}, parent, to) do
|
||||
JS.dispatch(js, "js:focus", to: to, detail: %{parent: parent})
|
||||
end
|
||||
|
||||
def focus_closest(js \\ %JS{}, to) do
|
||||
js
|
||||
|> JS.dispatch("js:focus-closest", to: to)
|
||||
|> hide(to)
|
||||
end
|
||||
|
||||
@doc """
|
||||
Generates tag for inlined form input errors.
|
||||
"""
|
||||
def error_tag(form, field) do
|
||||
error(%{
|
||||
errors: form.errors,
|
||||
field: field,
|
||||
input_name: Phoenix.HTML.Form.input_name(form, field)
|
||||
})
|
||||
end
|
||||
|
||||
def error(%{errors: errors, field: field} = assigns) do
|
||||
assigns =
|
||||
assigns
|
||||
|> assign(:error_values, Keyword.get_values(errors, field))
|
||||
|> assign_new(:class, fn -> "" end)
|
||||
|
||||
~H"""
|
||||
<%= for error <- @error_values do %>
|
||||
<span
|
||||
phx-feedback-for={@input_name}
|
||||
class={
|
||||
"invalid-feedback inline-block text-sm text-red-400 #{@class}"
|
||||
}
|
||||
>
|
||||
<%= translate_error(error) %>
|
||||
</span>
|
||||
<% end %>
|
||||
"""
|
||||
end
|
||||
|
||||
@doc """
|
||||
Translates an error message using gettext.
|
||||
"""
|
||||
def translate_error({msg, opts}) do
|
||||
# When using gettext, we typically pass the strings we want
|
||||
# to translate as a static argument:
|
||||
#
|
||||
# # Translate "is invalid" in the "errors" domain
|
||||
# dgettext("errors", "is invalid")
|
||||
#
|
||||
# # Translate the number of files with plural rules
|
||||
# dngettext("errors", "1 file", "%{count} files", count)
|
||||
#
|
||||
# Because the error messages we show in our forms and APIs
|
||||
# are defined inside Ecto, we need to translate them dynamically.
|
||||
# This requires us to call the Gettext module passing our gettext
|
||||
# backend as first argument.
|
||||
#
|
||||
# Note we use the "errors" domain, which means translations
|
||||
# should be written to the errors.po file. The :count option is
|
||||
# set by Ecto and indicates we should also apply plural rules.
|
||||
if count = opts[:count] do
|
||||
Gettext.dngettext(AlgoraWeb.Gettext, "errors", msg, msg, count, opts)
|
||||
else
|
||||
Gettext.dgettext(AlgoraWeb.Gettext, "errors", msg, opts)
|
||||
end
|
||||
end
|
||||
|
||||
def translate_changeset_errors(changeset) do
|
||||
changeset.errors
|
||||
|> Enum.map_join("\n", fn {key, value} -> "#{key} #{translate_error(value)}" end)
|
||||
end
|
||||
end
|
136
lib/algora_web/components/layouts.ex
Normal file
136
lib/algora_web/components/layouts.ex
Normal file
@ -0,0 +1,136 @@
|
||||
defmodule AlgoraWeb.Layouts do
|
||||
use AlgoraWeb, :html
|
||||
|
||||
embed_templates "layouts/*"
|
||||
|
||||
attr :id, :string
|
||||
attr :users, :list
|
||||
|
||||
def sidebar_active_users(assigns) do
|
||||
~H"""
|
||||
<div :if={length(@users) > 0} class="mt-8">
|
||||
<h3 class="text-xs font-semibold text-gray-400 uppercase tracking-wider" id={@id}>
|
||||
For you
|
||||
</h3>
|
||||
<ul class="mt-2 space-y-1" role="group" aria-labelledby={@id}>
|
||||
<%= for user <- @users do %>
|
||||
<li class="relative col-span-1 flex shadow-sm rounded-md overflow-hidden">
|
||||
<.link
|
||||
navigate={channel_path(user)}
|
||||
class="pr-3 flex-1 flex items-center justify-between border-t border-r border-b border-gray-700 bg-gray-900 rounded-r-md truncate"
|
||||
>
|
||||
<img
|
||||
class="w-12 h-12 flex-shrink-0 flex items-center justify-center rounded-l-md bg-purple-300"
|
||||
src={user.avatar_url}
|
||||
alt={user.handle}
|
||||
/>
|
||||
<div class="flex-1 flex items-center justify-between text-gray-50 text-sm font-medium hover:text-gray-300 pl-3">
|
||||
<div class="flex-1 py-1 text-sm truncate">
|
||||
<%= user.handle %>
|
||||
</div>
|
||||
</div>
|
||||
<span class="w-2.5 h-2.5 bg-red-500 rounded-full" aria-hidden="true" />
|
||||
</.link>
|
||||
</li>
|
||||
<% end %>
|
||||
</ul>
|
||||
</div>
|
||||
"""
|
||||
end
|
||||
|
||||
attr :id, :string
|
||||
attr :current_user, :any
|
||||
attr :active_tab, :atom
|
||||
|
||||
def sidebar_nav_links(assigns) do
|
||||
~H"""
|
||||
<div class="space-y-1">
|
||||
<.link
|
||||
navigate="/"
|
||||
class={
|
||||
"text-gray-200 hover:text-gray-50 group flex items-center px-2 py-2 text-sm font-medium rounded-md #{if @active_tab == :home, do: "bg-gray-800", else: "hover:bg-gray-900"}"
|
||||
}
|
||||
aria-current={if @active_tab == :home, do: "true", else: "false"}
|
||||
>
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
class="text-gray-400 group-hover:text-gray-300 mr-3 flex-shrink-0 h-6 w-6"
|
||||
width="24"
|
||||
height="24"
|
||||
viewBox="0 0 24 24"
|
||||
stroke-width="1.5"
|
||||
stroke="currentColor"
|
||||
fill="none"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
>
|
||||
<path stroke="none" d="M0 0h24v24H0z" fill="none" /><path d="M5 12l-2 0l9 -9l9 9l-2 0" /><path d="M5 12v7a2 2 0 0 0 2 2h10a2 2 0 0 0 2 -2v-7" /><path d="M9 21v-6a2 2 0 0 1 2 -2h2a2 2 0 0 1 2 2v6" />
|
||||
</svg>
|
||||
Home
|
||||
</.link>
|
||||
<.link
|
||||
navigate={channel_path(@current_user)}
|
||||
class={
|
||||
"text-gray-200 hover:text-gray-50 group flex items-center px-2 py-2 text-sm font-medium rounded-md #{if @active_tab == :channel, do: "bg-gray-800", else: "hover:bg-gray-900"}"
|
||||
}
|
||||
aria-current={if @active_tab == :channel, do: "true", else: "false"}
|
||||
>
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
class="text-gray-400 group-hover:text-gray-300 mr-3 flex-shrink-0 h-6 w-6"
|
||||
width="24"
|
||||
height="24"
|
||||
viewBox="0 0 24 24"
|
||||
stroke-width="1.5"
|
||||
stroke="currentColor"
|
||||
fill="none"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
>
|
||||
<path stroke="none" d="M0 0h24v24H0z" fill="none" /><path d="M12 13a3 3 0 1 0 0 -6a3 3 0 0 0 0 6z" /><path d="M12 3c7.2 0 9 1.8 9 9s-1.8 9 -9 9s-9 -1.8 -9 -9s1.8 -9 9 -9z" /><path d="M6 20.05v-.05a4 4 0 0 1 4 -4h4a4 4 0 0 1 4 4v.05" />
|
||||
</svg>
|
||||
Your channel
|
||||
</.link>
|
||||
<.link
|
||||
navigate={~p"/channel/settings"}
|
||||
class={
|
||||
"text-gray-200 hover:text-gray-50 group flex items-center px-2 py-2 text-sm font-medium rounded-md #{if @active_tab == :settings, do: "bg-gray-800", else: "hover:bg-gray-900"}"
|
||||
}
|
||||
aria-current={if @active_tab == :settings, do: "true", else: "false"}
|
||||
>
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
class="text-gray-400 group-hover:text-gray-300 mr-3 flex-shrink-0 h-6 w-6"
|
||||
width="24"
|
||||
height="24"
|
||||
viewBox="0 0 24 24"
|
||||
stroke-width="1.5"
|
||||
stroke="currentColor"
|
||||
fill="none"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
>
|
||||
<path stroke="none" d="M0 0h24v24H0z" fill="none" /><path d="M10.325 4.317c.426 -1.756 2.924 -1.756 3.35 0a1.724 1.724 0 0 0 2.573 1.066c1.543 -.94 3.31 .826 2.37 2.37a1.724 1.724 0 0 0 1.065 2.572c1.756 .426 1.756 2.924 0 3.35a1.724 1.724 0 0 0 -1.066 2.573c.94 1.543 -.826 3.31 -2.37 2.37a1.724 1.724 0 0 0 -2.572 1.065c-.426 1.756 -2.924 1.756 -3.35 0a1.724 1.724 0 0 0 -2.573 -1.066c-1.543 .94 -3.31 -.826 -2.37 -2.37a1.724 1.724 0 0 0 -1.065 -2.572c-1.756 -.426 -1.756 -2.924 0 -3.35a1.724 1.724 0 0 0 1.066 -2.573c-.94 -1.543 .826 -3.31 2.37 -2.37c1 .608 2.296 .07 2.572 -1.065z" /><path d="M9 12a3 3 0 1 0 6 0a3 3 0 0 0 -6 0" />
|
||||
</svg>
|
||||
Settings
|
||||
</.link>
|
||||
</div>
|
||||
"""
|
||||
end
|
||||
|
||||
attr :id, :string
|
||||
attr :current_user, :any
|
||||
|
||||
def sidebar_account_dropdown(assigns) do
|
||||
~H"""
|
||||
<.dropdown id={@id}>
|
||||
<:img src={@current_user.avatar_url} alt={@current_user.handle} />
|
||||
<:title><%= @current_user.name %></:title>
|
||||
<:subtitle>@<%= @current_user.handle %></:subtitle>
|
||||
<:link navigate={channel_path(@current_user)}>Channel</:link>
|
||||
<:link navigate={~p"/channel/settings"}>Settings</:link>
|
||||
<:link href={~p"/auth/logout"} method={:delete}>Sign out</:link>
|
||||
</.dropdown>
|
||||
"""
|
||||
end
|
||||
end
|
5
lib/algora_web/components/layouts/app.html.heex
Normal file
5
lib/algora_web/components/layouts/app.html.heex
Normal file
@ -0,0 +1,5 @@
|
||||
<main>
|
||||
<p class="alert alert-info" role="alert"><%= Phoenix.Flash.get(@flash, :info) %></p>
|
||||
<p class="alert alert-danger" role="alert"><%= Phoenix.Flash.get(@flash, :error) %></p>
|
||||
<%= @inner_content %>
|
||||
</main>
|
125
lib/algora_web/components/layouts/live.html.heex
Normal file
125
lib/algora_web/components/layouts/live.html.heex
Normal file
@ -0,0 +1,125 @@
|
||||
<div
|
||||
id="mobile-sidebar-container"
|
||||
class="fixed inset-0 flex z-40 lg:hidden"
|
||||
aria-modal="true"
|
||||
style="display: none;"
|
||||
role="region"
|
||||
>
|
||||
<div class="fixed inset-0 bg-gray-900 bg-opacity-75" phx-click={hide_mobile_sidebar()}></div>
|
||||
|
||||
<div
|
||||
id="mobile-sidebar"
|
||||
class="relative flex-1 flex-col w-full pt-5 pb-4 bg-gray-950 hidden min-h-screen sm:max-w-md"
|
||||
>
|
||||
<div class="absolute top-0 right-2 pt-4">
|
||||
<button
|
||||
type="button"
|
||||
id="hide-mobile-sidebar"
|
||||
aria-expanded="true"
|
||||
aria-controls="mobile-sidebar"
|
||||
class="ml-1 flex items-center justify-center h-10 w-10 rounded-full"
|
||||
phx-click={hide_mobile_sidebar()}
|
||||
>
|
||||
<span class="sr-only">Close sidebar</span>
|
||||
<svg
|
||||
class="h-6 w-6 text-white"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
fill="none"
|
||||
viewBox="0 0 24 24"
|
||||
stroke="currentColor"
|
||||
aria-hidden="true"
|
||||
>
|
||||
<path
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
stroke-width="2"
|
||||
d="M6 18L18 6M6 6l12 12"
|
||||
>
|
||||
</path>
|
||||
</svg>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="flex-shrink-0 flex items-center px-4">
|
||||
<.logo />
|
||||
</div>
|
||||
<div class="mt-5 flex-1 h-0 overflow-y-auto">
|
||||
<%= if @current_user do %>
|
||||
<.sidebar_account_dropdown id="mobile-account-dropdown" current_user={@current_user} />
|
||||
<% end %>
|
||||
|
||||
<nav class="px-3 pt-1">
|
||||
<%= if @current_user do %>
|
||||
<.sidebar_nav_links current_user={@current_user} active_tab={@active_tab} />
|
||||
<% end %>
|
||||
<.sidebar_active_users id="desktop-active-users" users={@active_users} />
|
||||
</nav>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex-shrink-0 w-14" aria-hidden="true">
|
||||
<!-- Dummy element to force sidebar to shrink to fit close icon -->
|
||||
</div>
|
||||
</div>
|
||||
<!-- Static sidebar for desktop -->
|
||||
<div :if={@current_user} class="hidden lg:flex lg:flex-shrink-0" role="region">
|
||||
<div class="flex flex-col w-64 border-r border-gray-800 pt-5 pb-4 bg-gray-950/50">
|
||||
<div class="flex items-center flex-shrink-0 px-6">
|
||||
<.logo />
|
||||
</div>
|
||||
<!-- Sidebar component, swap this element with another sidebar if you like -->
|
||||
<div class="h-0 flex-1 flex flex-col overflow-y-auto">
|
||||
<%= if @current_user do %>
|
||||
<.sidebar_account_dropdown id="account-dropdown" current_user={@current_user} />
|
||||
<% end %>
|
||||
<!-- Navigation -->
|
||||
<nav class="px-3 mt-6">
|
||||
<%= if @current_user do %>
|
||||
<.sidebar_nav_links current_user={@current_user} active_tab={@active_tab} />
|
||||
<% end %>
|
||||
<!-- Secondary navigation -->
|
||||
<.sidebar_active_users id="mobile-active-users" users={@active_users} />
|
||||
</nav>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Main column -->
|
||||
<div class="flex flex-col w-0 flex-1 overflow-hidden">
|
||||
<!-- Search header -->
|
||||
<div
|
||||
:if={@current_user}
|
||||
class="relative z-10 flex-shrink-0 flex h-16 border-b border-gray-800 lg:hidden"
|
||||
role="navigation"
|
||||
>
|
||||
<div class="flex-1 flex justify-between px-4 sm:px-6 lg:px-8">
|
||||
<div class="my-auto">
|
||||
<.logo />
|
||||
</div>
|
||||
<button
|
||||
type="button"
|
||||
id="show-mobile-sidebar"
|
||||
aria-expanded="false"
|
||||
aria-controls="mobile-sidebar"
|
||||
class="ml-auto -mr-4 px-4 text-gray-400 focus:outline-none focus:ring-2 focus:ring-inset focus:ring-purple-500 lg:hidden"
|
||||
phx-click={show_mobile_sidebar()}
|
||||
>
|
||||
<span class="sr-only">Open sidebar</span>
|
||||
<Heroicons.bars_2 class="h-6 w-6" />
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<.flash flash={@flash} kind={:info} />
|
||||
<.flash flash={@flash} kind={:error} />
|
||||
<.connection_status>
|
||||
Re-establishing connection...
|
||||
</.connection_status>
|
||||
|
||||
<.live_component module={AlgoraWeb.LayoutComponent} id="layout" />
|
||||
|
||||
<%= live_render(@socket, AlgoraWeb.ChatLive, id: "chat", session: %{}, sticky: true) %>
|
||||
<main class="flex-1 relative z-0 overflow-y-auto focus:outline-none pb-4">
|
||||
<%= live_render(@socket, AlgoraWeb.PlayerLive, id: "player", session: %{}, sticky: true) %>
|
||||
<%= @inner_content %>
|
||||
</main>
|
||||
</div>
|
57
lib/algora_web/components/layouts/root.html.heex
Normal file
57
lib/algora_web/components/layouts/root.html.heex
Normal file
@ -0,0 +1,57 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta name="csrf-token" content={get_csrf_token()} />
|
||||
|
||||
<.live_title suffix={assigns[:page_title] && " | Algora TV"}>
|
||||
<%= assigns[:page_title] || "Algora TV" %>
|
||||
</.live_title>
|
||||
|
||||
<%= if assigns[:channel_handle] && assigns[:channel_uname] && assigns[:channel_tagline] do %>
|
||||
<meta name="description" content={assigns[:channel_tagline]} />
|
||||
<meta
|
||||
name="twitter:image:src"
|
||||
content={"#{AlgoraWeb.Endpoint.url()}/images/og/#{assigns[:channel_handle]}.png"}
|
||||
/>
|
||||
<meta name="twitter:site" content="@algoraio" />
|
||||
<meta name="twitter:card" content="summary_large_image" />
|
||||
<meta name="twitter:title" content={"#{assigns[:channel_name]} | Algora TV"} />
|
||||
<meta name="twitter:description" content={assigns[:channel_tagline]} />
|
||||
<meta
|
||||
property="og:image"
|
||||
content={"#{AlgoraWeb.Endpoint.url()}/images/og/#{assigns[:channel_handle]}.png"}
|
||||
/>
|
||||
<meta property="og:image:width" content="1200" />
|
||||
<meta property="og:image:height" content="630" />
|
||||
<meta property="og:site_name" content="Algora TV" />
|
||||
<meta property="og:type" content="website" />
|
||||
<meta property="og:title" content={"#{assigns[:channel_name]} | Algora TV"} />
|
||||
<meta property="og:url" content={"#{AlgoraWeb.Endpoint.url()}/#{assigns[:channel_handle]}"} />
|
||||
<meta property="og:description" content={assigns[:channel_tagline]} />
|
||||
<% else %>
|
||||
<meta
|
||||
name="description"
|
||||
content="Algora TV is an interactive livestreaming & video sharing service for developers."
|
||||
/>
|
||||
<% end %>
|
||||
|
||||
<link href="https://vjs.zencdn.net/8.10.0/video-js.css" rel="stylesheet" />
|
||||
<link phx-track-static rel="stylesheet" href={~p"/assets/app.css"} />
|
||||
<script>
|
||||
window.userToken = "<%= assigns[:user_token] %>";
|
||||
</script>
|
||||
<script defer phx-track-static type="text/javascript" src={~p"/assets/app.js"}>
|
||||
</script>
|
||||
<script defer data-domain="tv.algora.io" src="https://plausible.io/js/script.js">
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<div class="fixed left-0 top-0 z-0 h-full w-full bg-[radial-gradient(ellipse_at_top_left,_var(--tw-gradient-stops))] from-gray-800 via-gray-900 to-gray-950" />
|
||||
<div class="relative">
|
||||
<%= @inner_content %>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
7
lib/algora_web/controllers/error_html.ex
Normal file
7
lib/algora_web/controllers/error_html.ex
Normal file
@ -0,0 +1,7 @@
|
||||
defmodule AlgoraWeb.ErrorHTML do
|
||||
use AlgoraWeb, :html
|
||||
|
||||
def render(template, _assigns) do
|
||||
Phoenix.Controller.status_message_from_template(template)
|
||||
end
|
||||
end
|
47
lib/algora_web/controllers/oauth_callback_controller.ex
Normal file
47
lib/algora_web/controllers/oauth_callback_controller.ex
Normal file
@ -0,0 +1,47 @@
|
||||
defmodule AlgoraWeb.OAuthCallbackController do
|
||||
use AlgoraWeb, :controller
|
||||
require Logger
|
||||
|
||||
alias Algora.Accounts
|
||||
|
||||
def new(conn, %{"provider" => "github", "code" => code, "state" => state}) do
|
||||
client = github_client(conn)
|
||||
|
||||
with {:ok, info} <- client.exchange_access_token(code: code, state: state),
|
||||
%{info: info, primary_email: primary, emails: emails, token: token} = info,
|
||||
{:ok, user} <- Accounts.register_github_user(primary, info, emails, token) do
|
||||
conn
|
||||
|> put_flash(:info, "Welcome, #{user.handle}!")
|
||||
|> AlgoraWeb.UserAuth.log_in_user(user)
|
||||
else
|
||||
{:error, %Ecto.Changeset{} = changeset} ->
|
||||
Logger.debug("failed GitHub insert #{inspect(changeset.errors)}")
|
||||
|
||||
conn
|
||||
|> put_flash(
|
||||
:error,
|
||||
"We were unable to fetch the necessary information from your GithHub account"
|
||||
)
|
||||
|> redirect(to: "/")
|
||||
|
||||
{:error, reason} ->
|
||||
Logger.debug("failed GitHub exchange #{inspect(reason)}")
|
||||
|
||||
conn
|
||||
|> put_flash(:error, "We were unable to contact GitHub. Please try again later")
|
||||
|> redirect(to: "/")
|
||||
end
|
||||
end
|
||||
|
||||
def new(conn, %{"provider" => "github", "error" => "access_denied"}) do
|
||||
redirect(conn, to: "/")
|
||||
end
|
||||
|
||||
def sign_out(conn, _) do
|
||||
AlgoraWeb.UserAuth.log_out_user(conn)
|
||||
end
|
||||
|
||||
defp github_client(conn) do
|
||||
conn.assigns[:github_client] || Algora.Github
|
||||
end
|
||||
end
|
0
lib/algora_web/controllers/page_html.ex
Normal file
0
lib/algora_web/controllers/page_html.ex
Normal file
15
lib/algora_web/controllers/redirect_controller.ex
Normal file
15
lib/algora_web/controllers/redirect_controller.ex
Normal file
@ -0,0 +1,15 @@
|
||||
defmodule AlgoraWeb.RedirectController do
|
||||
use AlgoraWeb, :controller
|
||||
|
||||
import AlgoraWeb.UserAuth, only: [fetch_current_user: 2]
|
||||
|
||||
plug :fetch_current_user
|
||||
|
||||
def redirect_authenticated(conn, _) do
|
||||
if conn.assigns.current_user do
|
||||
AlgoraWeb.UserAuth.redirect_if_user_is_authenticated(conn, [])
|
||||
else
|
||||
redirect(conn, to: ~p"/auth/login")
|
||||
end
|
||||
end
|
||||
end
|
157
lib/algora_web/controllers/user_auth.ex
Normal file
157
lib/algora_web/controllers/user_auth.ex
Normal file
@ -0,0 +1,157 @@
|
||||
defmodule AlgoraWeb.UserAuth do
|
||||
use AlgoraWeb, :verified_routes
|
||||
import Plug.Conn
|
||||
import Phoenix.Controller
|
||||
|
||||
alias Phoenix.LiveView
|
||||
alias Algora.Accounts
|
||||
|
||||
def on_mount(:current_user, _params, session, socket) do
|
||||
case session do
|
||||
%{"user_id" => user_id} ->
|
||||
{:cont,
|
||||
Phoenix.Component.assign_new(socket, :current_user, fn -> Accounts.get_user(user_id) end)}
|
||||
|
||||
%{} ->
|
||||
{:cont, Phoenix.Component.assign(socket, :current_user, nil)}
|
||||
end
|
||||
end
|
||||
|
||||
def on_mount(:ensure_authenticated, _params, session, socket) do
|
||||
case session do
|
||||
%{"user_id" => user_id} ->
|
||||
new_socket =
|
||||
Phoenix.Component.assign_new(socket, :current_user, fn ->
|
||||
Accounts.get_user!(user_id)
|
||||
end)
|
||||
|
||||
%Accounts.User{} = new_socket.assigns.current_user
|
||||
{:cont, new_socket}
|
||||
|
||||
%{} ->
|
||||
{:halt, redirect_require_login(socket)}
|
||||
end
|
||||
rescue
|
||||
Ecto.NoResultsError -> {:halt, redirect_require_login(socket)}
|
||||
end
|
||||
|
||||
defp redirect_require_login(socket) do
|
||||
socket
|
||||
|> LiveView.put_flash(:error, "Please sign in")
|
||||
|> LiveView.redirect(to: ~p"/auth/login")
|
||||
end
|
||||
|
||||
@doc """
|
||||
Logs the user in.
|
||||
|
||||
It renews the session ID and clears the whole session
|
||||
to avoid fixation attacks. See the renew_session
|
||||
function to customize this behaviour.
|
||||
|
||||
It also sets a `:live_socket_id` key in the session,
|
||||
so LiveView sessions are identified and automatically
|
||||
disconnected on log out. The line can be safely removed
|
||||
if you are not using LiveView.
|
||||
"""
|
||||
def log_in_user(conn, user) do
|
||||
user_return_to = get_session(conn, :user_return_to)
|
||||
conn = assign(conn, :current_user, user)
|
||||
|
||||
conn
|
||||
|> renew_session()
|
||||
|> put_session(:user_id, user.id)
|
||||
|> put_session(:live_socket_id, "users_sessions:#{user.id}")
|
||||
|> redirect(to: user_return_to || signed_in_path(conn))
|
||||
end
|
||||
|
||||
defp renew_session(conn) do
|
||||
conn
|
||||
|> configure_session(renew: true)
|
||||
|> clear_session()
|
||||
end
|
||||
|
||||
@doc """
|
||||
Logs the user out.
|
||||
|
||||
It clears all session data for safety. See renew_session.
|
||||
"""
|
||||
def log_out_user(conn) do
|
||||
if live_socket_id = get_session(conn, :live_socket_id) do
|
||||
AlgoraWeb.Endpoint.broadcast(live_socket_id, "disconnect", %{})
|
||||
end
|
||||
|
||||
conn
|
||||
|> renew_session()
|
||||
|> redirect(to: ~p"/auth/login")
|
||||
end
|
||||
|
||||
@doc """
|
||||
Authenticates the user by looking into the session.
|
||||
"""
|
||||
def fetch_current_user(conn, _opts) do
|
||||
user_id = get_session(conn, :user_id)
|
||||
user = user_id && Accounts.get_user(user_id)
|
||||
token = Phoenix.Token.sign(conn, "user socket", user_id || 0)
|
||||
|
||||
conn
|
||||
|> assign(:current_user, user)
|
||||
|> assign(:user_token, token)
|
||||
end
|
||||
|
||||
@doc """
|
||||
Used for routes that require the user to not be authenticated.
|
||||
"""
|
||||
def redirect_if_user_is_authenticated(conn, _opts) do
|
||||
if conn.assigns[:current_user] do
|
||||
conn
|
||||
|> redirect(to: signed_in_path(conn))
|
||||
|> halt()
|
||||
else
|
||||
conn
|
||||
end
|
||||
end
|
||||
|
||||
@doc """
|
||||
Used for routes that require the user to be authenticated.
|
||||
|
||||
If you want to enforce the user email is confirmed before
|
||||
they use the application at all, here would be a good place.
|
||||
"""
|
||||
def require_authenticated_user(conn, _opts) do
|
||||
if conn.assigns[:current_user] do
|
||||
conn
|
||||
else
|
||||
conn
|
||||
|> put_flash(:error, "You must log in to access this page.")
|
||||
|> maybe_store_return_to()
|
||||
|> redirect(to: ~p"/auth/login")
|
||||
|> halt()
|
||||
end
|
||||
end
|
||||
|
||||
def require_authenticated_admin(conn, _opts) do
|
||||
user = conn.assigns[:current_user]
|
||||
|
||||
if user && Algora.Accounts.admin?(user) do
|
||||
assign(conn, :current_admin, user)
|
||||
else
|
||||
conn
|
||||
|> put_flash(:error, "You must be logged into access that page")
|
||||
|> maybe_store_return_to()
|
||||
|> redirect(to: "/")
|
||||
|> halt()
|
||||
end
|
||||
end
|
||||
|
||||
defp maybe_store_return_to(%{method: "GET"} = conn) do
|
||||
%{request_path: request_path, query_string: query_string} = conn
|
||||
return_to = if query_string == "", do: request_path, else: request_path <> "?" <> query_string
|
||||
put_session(conn, :user_return_to, return_to)
|
||||
end
|
||||
|
||||
defp maybe_store_return_to(conn), do: conn
|
||||
|
||||
def signed_in_path(conn) do
|
||||
AlgoraWeb.CoreComponents.channel_path(conn.assigns.current_user)
|
||||
end
|
||||
end
|
54
lib/algora_web/endpoint.ex
Normal file
54
lib/algora_web/endpoint.ex
Normal file
@ -0,0 +1,54 @@
|
||||
defmodule AlgoraWeb.Endpoint do
|
||||
use Phoenix.Endpoint, otp_app: :algora
|
||||
|
||||
socket "/socket", AlgoraWeb.UserSocket,
|
||||
websocket: true,
|
||||
longpoll: false
|
||||
|
||||
# The session will be stored in the cookie and signed,
|
||||
# this means its contents can be read but not tampered with.
|
||||
# Set :encryption_salt if you would also like to encrypt it.
|
||||
@session_options [
|
||||
store: :cookie,
|
||||
key: "_algora_key_v1",
|
||||
signing_salt: "WCC/F/SKdA2YFt9qhULZeyo2ITCmFzYt"
|
||||
]
|
||||
|
||||
socket "/live", Phoenix.LiveView.Socket, websocket: [connect_info: [session: @session_options]]
|
||||
|
||||
# Serve at "/" the static files from "priv/static" directory.
|
||||
#
|
||||
# You should set gzip to true if you are running phx.digest
|
||||
# when deploying your static files in production.
|
||||
plug Plug.Static,
|
||||
at: "/",
|
||||
from: :algora,
|
||||
gzip: false,
|
||||
only: AlgoraWeb.static_paths()
|
||||
|
||||
# Code reloading can be explicitly enabled under the
|
||||
# :code_reloader configuration of your endpoint.
|
||||
if code_reloading? do
|
||||
socket "/phoenix/live_reload/socket", Phoenix.LiveReloader.Socket
|
||||
plug Phoenix.LiveReloader
|
||||
plug Phoenix.CodeReloader
|
||||
plug Phoenix.Ecto.CheckRepoStatus, otp_app: :algora
|
||||
end
|
||||
|
||||
plug Phoenix.LiveDashboard.RequestLogger,
|
||||
param_key: "request_logger",
|
||||
cookie_key: "request_logger"
|
||||
|
||||
plug Plug.RequestId
|
||||
plug Plug.Telemetry, event_prefix: [:phoenix, :endpoint]
|
||||
|
||||
plug Plug.Parsers,
|
||||
parsers: [:urlencoded, :multipart, :json],
|
||||
pass: ["*/*"],
|
||||
json_decoder: Phoenix.json_library()
|
||||
|
||||
plug Plug.MethodOverride
|
||||
plug Plug.Head
|
||||
plug Plug.Session, @session_options
|
||||
plug AlgoraWeb.Router
|
||||
end
|
24
lib/algora_web/gettext.ex
Normal file
24
lib/algora_web/gettext.ex
Normal file
@ -0,0 +1,24 @@
|
||||
defmodule AlgoraWeb.Gettext do
|
||||
@moduledoc """
|
||||
A module providing Internationalization with a gettext-based API.
|
||||
|
||||
By using [Gettext](https://hexdocs.pm/gettext),
|
||||
your module gains a set of macros for translations, for example:
|
||||
|
||||
import AlgoraWeb.Gettext
|
||||
|
||||
# Simple translation
|
||||
gettext("Here is the string to translate")
|
||||
|
||||
# Plural translation
|
||||
ngettext("Here is the string to translate",
|
||||
"Here are the strings to translate",
|
||||
3)
|
||||
|
||||
# Domain-based translation
|
||||
dgettext("errors", "Here is the error message to translate")
|
||||
|
||||
See the [Gettext Docs](https://hexdocs.pm/gettext) for detailed usage.
|
||||
"""
|
||||
use Gettext, otp_app: :algora
|
||||
end
|
336
lib/algora_web/live/channel_live.ex
Normal file
336
lib/algora_web/live/channel_live.ex
Normal file
@ -0,0 +1,336 @@
|
||||
defmodule AlgoraWeb.ChannelLive do
|
||||
use AlgoraWeb, :live_view
|
||||
require Logger
|
||||
|
||||
alias Algora.{Accounts, Library, Storage}
|
||||
alias AlgoraWeb.{LayoutComponent, Presence}
|
||||
alias AlgoraWeb.ChannelLive.{StreamFormComponent}
|
||||
|
||||
def render(assigns) do
|
||||
~H"""
|
||||
<%!-- <:actions>
|
||||
<.button
|
||||
:if={@owns_channel? && not @channel.is_live}
|
||||
id="stream-btn"
|
||||
primary
|
||||
patch={channel_stream_path(@current_user)}
|
||||
>
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
class="-ml-1 w-6 h-6 inline-block"
|
||||
width="24"
|
||||
height="24"
|
||||
viewBox="0 0 24 24"
|
||||
stroke-width="1.5"
|
||||
stroke="currentColor"
|
||||
fill="none"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
>
|
||||
<path stroke="none" d="M0 0h24v24H0z" fill="none" /><path d="M12 12l0 .01" /><path d="M14.828 9.172a4 4 0 0 1 0 5.656" /><path d="M17.657 6.343a8 8 0 0 1 0 11.314" /><path d="M9.168 14.828a4 4 0 0 1 0 -5.656" /><path d="M6.337 17.657a8 8 0 0 1 0 -11.314" />
|
||||
</svg>
|
||||
<span class="ml-2">
|
||||
Start streaming!
|
||||
</span>
|
||||
</.button>
|
||||
</:actions> --%>
|
||||
|
||||
<div class="lg:mr-[20rem]">
|
||||
<div class="border-b border-gray-700 px-4 py-8 sm:px-6 lg:px-8">
|
||||
<figure :if={@channel.is_live} class="relative isolate -mt-4 pt-4 pb-4">
|
||||
<svg
|
||||
viewBox="0 0 162 128"
|
||||
fill="none"
|
||||
aria-hidden="true"
|
||||
class="absolute left-0 top-0 -z-10 h-12 stroke-white/75"
|
||||
>
|
||||
<path
|
||||
id="b56e9dab-6ccb-4d32-ad02-6b4bb5d9bbeb"
|
||||
d="M65.5697 118.507L65.8918 118.89C68.9503 116.314 71.367 113.253 73.1386 109.71C74.9162 106.155 75.8027 102.28 75.8027 98.0919C75.8027 94.237 75.16 90.6155 73.8708 87.2314C72.5851 83.8565 70.8137 80.9533 68.553 78.5292C66.4529 76.1079 63.9476 74.2482 61.0407 72.9536C58.2795 71.4949 55.276 70.767 52.0386 70.767C48.9935 70.767 46.4686 71.1668 44.4872 71.9924L44.4799 71.9955L44.4726 71.9988C42.7101 72.7999 41.1035 73.6831 39.6544 74.6492C38.2407 75.5916 36.8279 76.455 35.4159 77.2394L35.4047 77.2457L35.3938 77.2525C34.2318 77.9787 32.6713 78.3634 30.6736 78.3634C29.0405 78.3634 27.5131 77.2868 26.1274 74.8257C24.7483 72.2185 24.0519 69.2166 24.0519 65.8071C24.0519 60.0311 25.3782 54.4081 28.0373 48.9335C30.703 43.4454 34.3114 38.345 38.8667 33.6325C43.5812 28.761 49.0045 24.5159 55.1389 20.8979C60.1667 18.0071 65.4966 15.6179 71.1291 13.7305C73.8626 12.8145 75.8027 10.2968 75.8027 7.38572C75.8027 3.6497 72.6341 0.62247 68.8814 1.1527C61.1635 2.2432 53.7398 4.41426 46.6119 7.66522C37.5369 11.6459 29.5729 17.0612 22.7236 23.9105C16.0322 30.6019 10.618 38.4859 6.47981 47.558L6.47976 47.558L6.47682 47.5647C2.4901 56.6544 0.5 66.6148 0.5 77.4391C0.5 84.2996 1.61702 90.7679 3.85425 96.8404L3.8558 96.8445C6.08991 102.749 9.12394 108.02 12.959 112.654L12.959 112.654L12.9646 112.661C16.8027 117.138 21.2829 120.739 26.4034 123.459L26.4033 123.459L26.4144 123.465C31.5505 126.033 37.0873 127.316 43.0178 127.316C47.5035 127.316 51.6783 126.595 55.5376 125.148L55.5376 125.148L55.5477 125.144C59.5516 123.542 63.0052 121.456 65.9019 118.881L65.5697 118.507Z"
|
||||
>
|
||||
</path>
|
||||
<use href="#b56e9dab-6ccb-4d32-ad02-6b4bb5d9bbeb" x="86"></use>
|
||||
</svg>
|
||||
<blockquote class="text-xl font-semibold leading-8 text-white sm:text-2xl sm:leading-9">
|
||||
<p><%= @channel.tagline %></p>
|
||||
</blockquote>
|
||||
</figure>
|
||||
|
||||
<div class="flex flex-col items-start justify-start lg:flex-col lg:items-start lg:justify-start md:flex-row md:items-center md:justify-between xl:items-center xl:justify-between xl:flex-row gap-8">
|
||||
<div class="flex items-center gap-4">
|
||||
<div class="relative h-20 w-20 shrink-0">
|
||||
<img
|
||||
src={@channel.avatar_url}
|
||||
alt={@channel.handle}
|
||||
class={[
|
||||
"w-full h-full p-1 ring-4 rounded-full",
|
||||
if(@channel.is_live, do: "ring-red-500", else: "ring-transparent")
|
||||
]}
|
||||
/>
|
||||
<div
|
||||
:if={@channel.is_live}
|
||||
class="absolute bottom-0 translate-y-1/2 ring-[3px] ring-gray-800 left-1/2 -translate-x-1/2 rounded px-1 font-medium mx-auto bg-red-500 text-xs"
|
||||
>
|
||||
LIVE
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<div class="text-2xl font-semibold">
|
||||
<%= @channel.name %>
|
||||
</div>
|
||||
<div
|
||||
:if={@channel.tech}
|
||||
class="mt-2 relative flex flex-col overflow-hidden max-w-[256px]"
|
||||
>
|
||||
<div class="relative flex h-1.5 w-full items-center">
|
||||
<div class="flex h-full flex-1 items-center gap-2 overflow-hidden">
|
||||
<div
|
||||
:for={lang <- @channel.tech}
|
||||
class="h-full rounded-full"
|
||||
style={"width:#{lang.pct}%;background-color:#{lang.color}"}
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<ol class="relative mt-0.5 items-start overflow-hidden text-xs">
|
||||
<div tabindex="0" class="-ml-2 flex h-full flex-wrap">
|
||||
<li
|
||||
:for={lang <- @channel.tech}
|
||||
class="group inline-flex cursor-default items-center truncate whitespace-nowrap px-2 py-0.5 transition"
|
||||
>
|
||||
<svg
|
||||
class="mr-1.5 h-2 w-2 flex-none opacity-100"
|
||||
fill={lang.color}
|
||||
viewBox="0 0 8 8"
|
||||
>
|
||||
<circle cx="4" cy="4" r="4"></circle>
|
||||
</svg>
|
||||
<p class="truncate whitespace-nowrap font-medium text-sm"><%= lang.name %></p>
|
||||
</li>
|
||||
</div>
|
||||
</ol>
|
||||
</div>
|
||||
<div :if={!@channel.tech} class="text-sm text-gray-300">@<%= @channel.handle %></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex gap-6">
|
||||
<div>
|
||||
<div class="text-xs font-medium text-gray-300 sm:text-sm">
|
||||
Watching now
|
||||
</div>
|
||||
<div class="flex items-center gap-1.5">
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
class="h-8 w-8"
|
||||
width="24"
|
||||
height="24"
|
||||
viewBox="0 0 24 24"
|
||||
stroke-width="1.5"
|
||||
stroke="currentColor"
|
||||
fill="none"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
>
|
||||
<path stroke="none" d="M0 0h24v24H0z" fill="none" /><path d="M8 7a4 4 0 1 0 8 0a4 4 0 0 0 -8 0" /><path d="M6 21v-2a4 4 0 0 1 4 -4h4a4 4 0 0 1 4 4v2" />
|
||||
</svg>
|
||||
<div class="font-display text-2xl font-semibold md:text-3xl">
|
||||
<div id="viewer-count" phx-update="stream">
|
||||
<div
|
||||
:for={{dom_id, %{id: id, metas: metas}} <- @streams.presences}
|
||||
:if={id == @channel.handle}
|
||||
id={dom_id}
|
||||
>
|
||||
<%= metas
|
||||
|> Enum.filter(fn meta -> meta.id != @channel.handle end)
|
||||
|> length() %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div :if={@channel.bounties_count}>
|
||||
<div class="text-xs font-medium text-gray-300 sm:text-sm">
|
||||
Bounties collected
|
||||
</div>
|
||||
<div class="flex items-center gap-1.5">
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
class="h-8 w-8"
|
||||
width="24"
|
||||
height="24"
|
||||
viewBox="0 0 24 24"
|
||||
stroke-width="1.5"
|
||||
stroke="currentColor"
|
||||
fill="none"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
>
|
||||
<path stroke="none" d="M0 0h24v24H0z" fill="none" /><path d="M6 5h12l3 5l-8.5 9.5a.7 .7 0 0 1 -1 0l-8.5 -9.5l3 -5" /><path d="M10 12l-2 -2.2l.6 -1" />
|
||||
</svg>
|
||||
<div class="font-display text-2xl font-semibold md:text-3xl">
|
||||
<%= @channel.bounties_count %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div :if={length(@channel.orgs_contributed) > 0}>
|
||||
<div class="text-xs font-medium text-gray-300 sm:text-sm">
|
||||
OSS projects contributed
|
||||
</div>
|
||||
<div class="mt-2 line-clamp-1 space-x-2">
|
||||
<a
|
||||
:for={project <- @channel.orgs_contributed}
|
||||
href={"https://console.algora.io/org/#{project.handle}"}
|
||||
class="inline-flex items-center gap-2"
|
||||
>
|
||||
<span class="relative shrink-0 overflow-hidden flex h-6 w-6 items-center justify-center rounded-lg sm:h-8 sm:w-8">
|
||||
<img
|
||||
class="aspect-square h-full w-full"
|
||||
alt={project.handle}
|
||||
src={project.avatar_url}
|
||||
/>
|
||||
</span>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<.playlist id="playlist" videos={@streams.videos} />
|
||||
</div>
|
||||
"""
|
||||
end
|
||||
|
||||
def mount(%{"channel_handle" => channel_handle}, _session, socket) do
|
||||
%{current_user: current_user} = socket.assigns
|
||||
|
||||
channel =
|
||||
Accounts.get_user_by!(handle: channel_handle)
|
||||
|> Library.get_channel!()
|
||||
|
||||
if connected?(socket) do
|
||||
Library.subscribe_to_livestreams()
|
||||
Library.subscribe_to_channel(channel)
|
||||
|
||||
Presence.track_user(channel_handle, %{
|
||||
id: if(current_user, do: current_user.handle, else: "")
|
||||
})
|
||||
|
||||
Presence.subscribe(channel_handle)
|
||||
end
|
||||
|
||||
videos = Library.list_channel_videos(channel, 50)
|
||||
|
||||
socket =
|
||||
socket
|
||||
|> assign(
|
||||
channel: channel,
|
||||
owns_channel?: current_user && Library.owns_channel?(current_user, channel),
|
||||
videos_count: Enum.count(videos)
|
||||
)
|
||||
|> stream(:videos, videos)
|
||||
|> stream(:presences, Presence.list_online_users(channel_handle))
|
||||
|
||||
{:ok, socket}
|
||||
end
|
||||
|
||||
def handle_params(params, _url, socket) do
|
||||
LayoutComponent.hide_modal()
|
||||
{:noreply, socket |> apply_action(socket.assigns.live_action, params)}
|
||||
end
|
||||
|
||||
def handle_info({Presence, {:join, presence}}, socket) do
|
||||
{:noreply, stream_insert(socket, :presences, presence)}
|
||||
end
|
||||
|
||||
def handle_info({Presence, {:leave, presence}}, socket) do
|
||||
if presence.metas == [] do
|
||||
{:noreply, stream_delete(socket, :presences, presence)}
|
||||
else
|
||||
{:noreply, stream_insert(socket, :presences, presence)}
|
||||
end
|
||||
end
|
||||
|
||||
def handle_info(
|
||||
{Storage, %Library.Events.ThumbnailsGenerated{video: video}},
|
||||
socket
|
||||
) do
|
||||
{:noreply,
|
||||
if video.user_id == socket.assigns.channel.user_id do
|
||||
socket
|
||||
|> stream_insert(:videos, video, at: 0)
|
||||
else
|
||||
socket
|
||||
end}
|
||||
end
|
||||
|
||||
def handle_info(
|
||||
{Library, %Library.Events.LivestreamStarted{video: video}},
|
||||
socket
|
||||
) do
|
||||
%{channel: channel} = socket.assigns
|
||||
|
||||
{:noreply,
|
||||
if video.user_id == channel.user_id do
|
||||
socket
|
||||
|> assign(channel: %{channel | is_live: true})
|
||||
|> stream_insert(:videos, video, at: 0)
|
||||
else
|
||||
socket
|
||||
end}
|
||||
end
|
||||
|
||||
def handle_info(
|
||||
{Library, %Library.Events.LivestreamEnded{video: video}},
|
||||
socket
|
||||
) do
|
||||
%{channel: channel} = socket.assigns
|
||||
|
||||
{:noreply,
|
||||
if video.user_id == channel.user_id do
|
||||
socket
|
||||
|> assign(channel: %{channel | is_live: false})
|
||||
|> stream_insert(:videos, video)
|
||||
else
|
||||
socket
|
||||
end}
|
||||
end
|
||||
|
||||
def handle_info({Library, _}, socket), do: {:noreply, socket}
|
||||
|
||||
defp apply_action(socket, :stream, _params) do
|
||||
if socket.assigns.owns_channel? do
|
||||
socket
|
||||
|> assign(:page_title, "Start streaming")
|
||||
|> assign(:video, %Library.Video{})
|
||||
|> show_stream_modal()
|
||||
else
|
||||
socket
|
||||
|> put_flash(:error, "You can't do that")
|
||||
|> redirect(to: channel_path(socket.assigns.current_user))
|
||||
end
|
||||
end
|
||||
|
||||
defp apply_action(socket, :show, params) do
|
||||
socket
|
||||
|> assign(:page_title, socket.assigns.channel.name || params["channel_handle"])
|
||||
|> assign(:channel_handle, socket.assigns.channel.handle)
|
||||
|> assign(:channel_name, socket.assigns.channel.name)
|
||||
|> assign(:channel_tagline, socket.assigns.channel.tagline)
|
||||
|> assign(:video, nil)
|
||||
end
|
||||
|
||||
defp show_stream_modal(socket) do
|
||||
LayoutComponent.show_modal(StreamFormComponent, %{
|
||||
id: :stream,
|
||||
confirm: {"Save", type: "submit", form: "stream-form"},
|
||||
patch: channel_path(socket.assigns.current_user),
|
||||
video: socket.assigns.video,
|
||||
title: socket.assigns.page_title,
|
||||
current_user: socket.assigns.current_user,
|
||||
changeset: Accounts.change_settings(socket.assigns.current_user, %{})
|
||||
})
|
||||
|
||||
socket
|
||||
end
|
||||
end
|
23
lib/algora_web/live/channel_live/stream_form_component.ex
Normal file
23
lib/algora_web/live/channel_live/stream_form_component.ex
Normal file
@ -0,0 +1,23 @@
|
||||
defmodule AlgoraWeb.ChannelLive.StreamFormComponent do
|
||||
use AlgoraWeb, :live_component
|
||||
|
||||
alias Algora.Accounts
|
||||
|
||||
def handle_event("validate", %{"user" => params}, socket) do
|
||||
changeset = Accounts.change_settings(socket.assigns.current_user, params)
|
||||
{:noreply, assign(socket, changeset: Map.put(changeset, :action, :validate))}
|
||||
end
|
||||
|
||||
def handle_event("save", %{"user" => params}, socket) do
|
||||
case Accounts.update_settings(socket.assigns.current_user, params) do
|
||||
{:ok, user} ->
|
||||
{:noreply,
|
||||
socket
|
||||
|> assign(current_user: user)
|
||||
|> put_flash(:info, "settings updated!")}
|
||||
|
||||
{:error, changeset} ->
|
||||
{:noreply, assign(socket, changeset: changeset)}
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,42 @@
|
||||
<div>
|
||||
<.form
|
||||
:let={f}
|
||||
id="stream-form"
|
||||
for={@changeset}
|
||||
class="space-y-8"
|
||||
phx-target={@myself}
|
||||
phx-change="validate"
|
||||
phx-submit="save"
|
||||
>
|
||||
<div class="space-y-8 divide-y divide-gray-700 sm:space-y-5">
|
||||
<div class="space-y-2 sm:space-y-2">
|
||||
<div class="sm:col-span-4">
|
||||
<label for="about" class="block text-sm font-medium text-gray-200">
|
||||
Stream title
|
||||
</label>
|
||||
<div class="mt-1">
|
||||
<%= text_input(f, :channel_tagline,
|
||||
class:
|
||||
"bg-gray-950 text-white flex-1 focus:ring-purple-400 focus:border-purple-400 block w-full min-w-0 rounded-md sm:text-sm border-gray-600"
|
||||
) %>
|
||||
<.error field={:channel_tagline} input_name="user[channel_tagline]" errors={f.errors} />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="sm:col-span-4">
|
||||
<label for="about" class="block text-sm font-medium text-gray-200">
|
||||
Stream URL
|
||||
</label>
|
||||
<div class="mt-1">
|
||||
<div class="py-2 border px-3 border-1 bg-gray-950 text-white flex-1 focus:ring-purple-400 focus:border-purple-400 block w-full min-w-0 rounded-md sm:text-sm border-gray-600">
|
||||
<%= "rtmp://#{URI.parse(AlgoraWeb.Endpoint.url()).host}:#{Algora.config([:rtmp_port])}/#{@current_user.stream_key}" %>
|
||||
</div>
|
||||
</div>
|
||||
<p class="mt-2 text-sm text-gray-400">
|
||||
<%= "Paste into OBS Studio > File > Settings > Stream > Server" %>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</.form>
|
||||
</div>
|
68
lib/algora_web/live/chat_live.ex
Normal file
68
lib/algora_web/live/chat_live.ex
Normal file
@ -0,0 +1,68 @@
|
||||
defmodule AlgoraWeb.ChatLive do
|
||||
alias Algora.Chat.Message
|
||||
alias Algora.{Library, Chat}
|
||||
alias Algora.Library.Video
|
||||
use AlgoraWeb, {:live_view, container: {:div, []}}
|
||||
|
||||
on_mount {AlgoraWeb.UserAuth, :current_user}
|
||||
|
||||
defp system_message?(%Message{} = message) do
|
||||
message.sender_handle == "algora"
|
||||
end
|
||||
|
||||
def render(assigns) do
|
||||
~H"""
|
||||
<aside
|
||||
id="chat-box"
|
||||
class="z-50 absolute top-0 right-0 lg:flex w-0 flex-col bg-gray-950 ring-1 ring-gray-800"
|
||||
>
|
||||
<div class="p-4">
|
||||
<div class="pb-2 text-center text-gray-400 text-xs font-medium uppercase tracking-wide">
|
||||
Stream chat
|
||||
</div>
|
||||
<div id="chat-messages" class="break-all flex-1 overflow-y-auto h-[calc(100vh-5.75rem)]">
|
||||
<div :for={message <- @messages} id={"message-#{message.id}"}>
|
||||
<span class={"font-semibold #{if(system_message?(message), do: "text-emerald-400", else: "text-indigo-400")}"}>
|
||||
<%= message.sender_handle %>:
|
||||
</span>
|
||||
<span class="font-medium text-gray-100">
|
||||
<%= message.body %>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<input
|
||||
:if={@current_user}
|
||||
id="chat-input"
|
||||
placeholder="Send a message"
|
||||
disabled={@current_user == nil}
|
||||
class="mt-2 bg-gray-950 h-[30px] text-white focus:outline-none focus:ring-purple-400 block w-full min-w-0 rounded-md sm:text-sm ring-1 ring-gray-600 px-2"
|
||||
/>
|
||||
<a
|
||||
:if={!@current_user}
|
||||
href={Algora.Github.authorize_url()}
|
||||
class="mt-2 w-full flex justify-center py-2 px-4 border border-transparent rounded-md shadow-sm text-sm font-medium text-white bg-purple-600 hover:bg-purple-500 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-purple-400"
|
||||
>
|
||||
Sign in to chat
|
||||
</a>
|
||||
</div>
|
||||
</aside>
|
||||
"""
|
||||
end
|
||||
|
||||
def mount(_params, _session, socket) do
|
||||
{:ok, socket, layout: false, temporary_assigns: [messages: []]}
|
||||
end
|
||||
|
||||
def handle_info({Library, _}, socket), do: {:noreply, socket}
|
||||
|
||||
def handle_event("join", %{"video_id" => video_id}, socket) do
|
||||
video = Library.get_video!(video_id)
|
||||
|
||||
socket =
|
||||
socket
|
||||
|> assign(messages: Chat.list_messages(%Video{id: video.id}))
|
||||
|> push_event("join_chat", %{id: video.id, type: video.type})
|
||||
|
||||
{:noreply, socket}
|
||||
end
|
||||
end
|
87
lib/algora_web/live/home_live.ex
Normal file
87
lib/algora_web/live/home_live.ex
Normal file
@ -0,0 +1,87 @@
|
||||
defmodule AlgoraWeb.HomeLive do
|
||||
use AlgoraWeb, :live_view
|
||||
require Logger
|
||||
|
||||
alias Algora.{Library, Storage}
|
||||
|
||||
def render(assigns) do
|
||||
~H"""
|
||||
<div class="lg:mr-[20rem]">
|
||||
<.title_bar :if={!@current_user}>
|
||||
<.logo />
|
||||
<:actions>
|
||||
<.button primary patch="/auth/login">Login</.button>
|
||||
</:actions>
|
||||
</.title_bar>
|
||||
<.playlist id="playlist" videos={@streams.videos} />
|
||||
</div>
|
||||
"""
|
||||
end
|
||||
|
||||
def mount(_map, _session, socket) do
|
||||
if connected?(socket) do
|
||||
Library.subscribe_to_livestreams()
|
||||
end
|
||||
|
||||
videos = Library.list_videos(150)
|
||||
|
||||
{:ok, socket |> stream(:videos, videos)}
|
||||
end
|
||||
|
||||
def handle_params(params, _url, socket) do
|
||||
{:noreply, socket |> apply_action(socket.assigns.live_action, params)}
|
||||
end
|
||||
|
||||
def handle_info(
|
||||
{Storage, %Library.Events.ThumbnailsGenerated{video: video}},
|
||||
socket
|
||||
) do
|
||||
{:noreply,
|
||||
if video.user_id == socket.assigns.channel.user_id do
|
||||
socket
|
||||
|> stream_insert(:videos, video, at: 0)
|
||||
else
|
||||
socket
|
||||
end}
|
||||
end
|
||||
|
||||
def handle_info(
|
||||
{Library, %Library.Events.LivestreamStarted{video: video}},
|
||||
socket
|
||||
) do
|
||||
%{channel: channel} = socket.assigns
|
||||
|
||||
{:noreply,
|
||||
if video.user_id == channel.user_id do
|
||||
socket
|
||||
|> assign(channel: %{channel | is_live: true})
|
||||
|> stream_insert(:videos, video, at: 0)
|
||||
else
|
||||
socket
|
||||
end}
|
||||
end
|
||||
|
||||
def handle_info(
|
||||
{Library, %Library.Events.LivestreamEnded{video: video}},
|
||||
socket
|
||||
) do
|
||||
%{channel: channel} = socket.assigns
|
||||
|
||||
{:noreply,
|
||||
if video.user_id == channel.user_id do
|
||||
socket
|
||||
|> assign(channel: %{channel | is_live: false})
|
||||
|> stream_insert(:videos, video)
|
||||
else
|
||||
socket
|
||||
end}
|
||||
end
|
||||
|
||||
def handle_info({Library, _}, socket), do: {:noreply, socket}
|
||||
|
||||
defp apply_action(socket, :show, _params) do
|
||||
socket
|
||||
|> assign(:page_title, nil)
|
||||
|> assign(:video, nil)
|
||||
end
|
||||
end
|
55
lib/algora_web/live/layout_component.ex
Normal file
55
lib/algora_web/live/layout_component.ex
Normal file
@ -0,0 +1,55 @@
|
||||
defmodule AlgoraWeb.LayoutComponent do
|
||||
@moduledoc """
|
||||
Component for rendering content inside layout without full DOM patch.
|
||||
"""
|
||||
use AlgoraWeb, :live_component
|
||||
|
||||
def show_modal(module, attrs) do
|
||||
send_update(__MODULE__, id: "layout", show: Enum.into(attrs, %{module: module}))
|
||||
end
|
||||
|
||||
def hide_modal do
|
||||
send_update(__MODULE__, id: "layout", show: nil)
|
||||
end
|
||||
|
||||
def update(%{id: id} = assigns, socket) do
|
||||
show =
|
||||
case assigns[:show] do
|
||||
%{module: _module, confirm: {text, attrs}} = show ->
|
||||
show
|
||||
|> Map.put_new(:title, show[:title])
|
||||
|> Map.put_new(:on_cancel, show[:on_cancel] || %JS{})
|
||||
|> Map.put_new(:on_confirm, show[:on_confirm] || %JS{})
|
||||
|> Map.put_new(:patch, nil)
|
||||
|> Map.put_new(:navigate, nil)
|
||||
|> Map.merge(%{confirm_text: text, confirm_attrs: attrs})
|
||||
|
||||
nil ->
|
||||
nil
|
||||
end
|
||||
|
||||
{:ok, assign(socket, id: id, show: show)}
|
||||
end
|
||||
|
||||
def render(assigns) do
|
||||
~H"""
|
||||
<div class={unless @show, do: "hidden"}>
|
||||
<%= if @show do %>
|
||||
<.modal
|
||||
show
|
||||
id={@id}
|
||||
navigate={@show.navigate}
|
||||
patch={@show.patch}
|
||||
on_cancel={@show.on_cancel}
|
||||
on_confirm={@show.on_confirm}
|
||||
>
|
||||
<:title><%= @show.title %></:title>
|
||||
<.live_component module={@show.module} {@show} />
|
||||
<:cancel>Cancel</:cancel>
|
||||
<:confirm {@show.confirm_attrs}><%= @show.confirm_text %></:confirm>
|
||||
</.modal>
|
||||
<% end %>
|
||||
</div>
|
||||
"""
|
||||
end
|
||||
end
|
42
lib/algora_web/live/nav.ex
Normal file
42
lib/algora_web/live/nav.ex
Normal file
@ -0,0 +1,42 @@
|
||||
defmodule AlgoraWeb.Nav do
|
||||
import Phoenix.LiveView
|
||||
use Phoenix.Component
|
||||
|
||||
alias Algora.{Library}
|
||||
alias AlgoraWeb.{ChannelLive, HomeLive, SettingsLive}
|
||||
|
||||
def on_mount(:default, _params, _session, socket) do
|
||||
{:cont,
|
||||
socket
|
||||
|> assign(active_users: Library.list_active_channels(limit: 20))
|
||||
|> assign(:region, System.get_env("FLY_REGION") || "iad")
|
||||
|> attach_hook(:active_tab, :handle_params, &handle_active_tab_params/3)}
|
||||
end
|
||||
|
||||
defp handle_active_tab_params(params, _url, socket) do
|
||||
active_tab =
|
||||
case {socket.view, socket.assigns.live_action} do
|
||||
{ChannelLive, _} ->
|
||||
if params["channel_handle"] == current_user_channel_handle(socket) do
|
||||
:channel
|
||||
end
|
||||
|
||||
{HomeLive, _} ->
|
||||
:home
|
||||
|
||||
{SettingsLive, _} ->
|
||||
:settings
|
||||
|
||||
{_, _} ->
|
||||
nil
|
||||
end
|
||||
|
||||
{:cont, assign(socket, active_tab: active_tab)}
|
||||
end
|
||||
|
||||
defp current_user_channel_handle(socket) do
|
||||
if user = socket.assigns.current_user do
|
||||
user.handle
|
||||
end
|
||||
end
|
||||
end
|
24
lib/algora_web/live/player_live.ex
Normal file
24
lib/algora_web/live/player_live.ex
Normal file
@ -0,0 +1,24 @@
|
||||
defmodule AlgoraWeb.PlayerLive do
|
||||
use AlgoraWeb, {:live_view, container: {:div, []}}
|
||||
|
||||
on_mount {AlgoraWeb.UserAuth, :current_user}
|
||||
|
||||
def render(assigns) do
|
||||
~H"""
|
||||
<div class="w-full hidden lg:pr-[20rem]">
|
||||
<video
|
||||
id="video-player"
|
||||
phx-hook="VideoPlayer"
|
||||
class="video-js vjs-default-skin min-w-xl aspect-video h-full w-full flex-1"
|
||||
controls
|
||||
/>
|
||||
</div>
|
||||
"""
|
||||
end
|
||||
|
||||
def mount(_params, _session, socket) do
|
||||
{:ok, socket, layout: false, temporary_assigns: []}
|
||||
end
|
||||
|
||||
def handle_info({Library, _}, socket), do: {:noreply, socket}
|
||||
end
|
141
lib/algora_web/live/settings_live.ex
Normal file
141
lib/algora_web/live/settings_live.ex
Normal file
@ -0,0 +1,141 @@
|
||||
defmodule AlgoraWeb.SettingsLive do
|
||||
use AlgoraWeb, :live_view
|
||||
|
||||
alias Algora.Accounts
|
||||
|
||||
def render(assigns) do
|
||||
~H"""
|
||||
<.title_bar>
|
||||
Settings
|
||||
</.title_bar>
|
||||
|
||||
<div class="max-w-3xl px-4 sm:px-6 lg:px-8 mt-6">
|
||||
<.form
|
||||
:let={f}
|
||||
id="settings-form"
|
||||
for={@changeset}
|
||||
phx-change="validate"
|
||||
phx-submit="save"
|
||||
class="space-y-8 divide-y divide-gray-700"
|
||||
>
|
||||
<div class="space-y-8 divide-y divide-gray-700">
|
||||
<div>
|
||||
<div class="mt-6 flex flex-col gap-y-6">
|
||||
<div class="sm:col-span-4">
|
||||
<label for="handle" class="block text-sm font-medium text-gray-200">
|
||||
Handle
|
||||
</label>
|
||||
<div class="mt-1 flex rounded-md shadow-sm">
|
||||
<span class="inline-flex items-center px-3 rounded-l-md border border-r-0 border-gray-600 bg-gray-900 text-gray-400 sm:text-sm">
|
||||
<%= URI.parse(AlgoraWeb.Endpoint.url()).host %>/
|
||||
</span>
|
||||
<%= text_input(f, :handle,
|
||||
class:
|
||||
"bg-gray-950 text-white flex-1 focus:ring-purple-400 focus:border-purple-400 block w-full min-w-0 rounded-none rounded-r-md sm:text-sm border-gray-600"
|
||||
) %>
|
||||
</div>
|
||||
<.error field={:handle} input_name="user[handle]" errors={f.errors} />
|
||||
</div>
|
||||
|
||||
<div class="sm:col-span-4">
|
||||
<label for="handle" class="block text-sm font-medium text-gray-200">
|
||||
Email
|
||||
</label>
|
||||
<div class="mt-1 flex rounded-md shadow-sm">
|
||||
<%= text_input(f, :email,
|
||||
disabled: true,
|
||||
class:
|
||||
"bg-gray-950 text-white flex-1 focus:ring-purple-400 focus:border-purple-400 block w-full min-w-0 rounded-md sm:text-sm border-gray-600 bg-gray-900"
|
||||
) %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="sm:col-span-4">
|
||||
<label for="about" class="block text-sm font-medium text-gray-200">
|
||||
Stream title
|
||||
</label>
|
||||
<div class="mt-1">
|
||||
<%= text_input(f, :channel_tagline,
|
||||
class:
|
||||
"bg-gray-950 text-white flex-1 focus:ring-purple-400 focus:border-purple-400 block w-full min-w-0 rounded-md sm:text-sm border-gray-600"
|
||||
) %>
|
||||
<.error
|
||||
field={:channel_tagline}
|
||||
input_name="user[channel_tagline]"
|
||||
errors={f.errors}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="sm:col-span-4">
|
||||
<label for="about" class="block text-sm font-medium text-gray-200">
|
||||
Stream URL
|
||||
</label>
|
||||
<div class="mt-1">
|
||||
<div class="py-2 border px-3 border-1 bg-gray-950 text-white flex-1 focus:ring-purple-400 focus:border-purple-400 block w-full min-w-0 rounded-md sm:text-sm border-gray-600">
|
||||
<%= "rtmp://#{URI.parse(AlgoraWeb.Endpoint.url()).host}:#{Algora.config([:rtmp_port])}/#{@current_user.stream_key}" %>
|
||||
</div>
|
||||
</div>
|
||||
<p class="mt-2 text-sm text-gray-400">
|
||||
<%= "Paste into OBS Studio > File > Settings > Stream > Server" %>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="pt-5">
|
||||
<div class="flex justify-end">
|
||||
<button
|
||||
type="submit"
|
||||
class="ml-3 inline-flex justify-center py-2 px-4 border border-transparent shadow-sm text-sm font-medium rounded-md text-white bg-purple-600 hover:bg-purple-500 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-purple-400"
|
||||
>
|
||||
Save
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</.form>
|
||||
</div>
|
||||
"""
|
||||
end
|
||||
|
||||
def mount(_params, _session, socket) do
|
||||
%{current_user: current_user} = socket.assigns
|
||||
|
||||
{:ok, current_user} =
|
||||
if current_user.stream_key do
|
||||
{:ok, current_user}
|
||||
else
|
||||
Accounts.gen_stream_key(current_user)
|
||||
end
|
||||
|
||||
changeset = Accounts.change_settings(current_user, %{})
|
||||
{:ok, assign(socket, current_user: current_user, changeset: changeset)}
|
||||
end
|
||||
|
||||
def handle_event("validate", %{"user" => params}, socket) do
|
||||
changeset = Accounts.change_settings(socket.assigns.current_user, params)
|
||||
{:noreply, assign(socket, changeset: Map.put(changeset, :action, :validate))}
|
||||
end
|
||||
|
||||
def handle_event("save", %{"user" => params}, socket) do
|
||||
case Accounts.update_settings(socket.assigns.current_user, params) do
|
||||
{:ok, user} ->
|
||||
{:noreply,
|
||||
socket
|
||||
|> assign(current_user: user)
|
||||
|> put_flash(:info, "settings updated!")}
|
||||
|
||||
{:error, changeset} ->
|
||||
{:noreply, assign(socket, changeset: changeset)}
|
||||
end
|
||||
end
|
||||
|
||||
def handle_params(params, _url, socket) do
|
||||
{:noreply, socket |> apply_action(socket.assigns.live_action, params)}
|
||||
end
|
||||
|
||||
defp apply_action(socket, :edit, _params) do
|
||||
socket |> assign(:page_title, "Settings")
|
||||
end
|
||||
end
|
25
lib/algora_web/live/sign_in_live.ex
Normal file
25
lib/algora_web/live/sign_in_live.ex
Normal file
@ -0,0 +1,25 @@
|
||||
defmodule AlgoraWeb.SignInLive do
|
||||
use AlgoraWeb, :live_view
|
||||
|
||||
def render(assigns) do
|
||||
~H"""
|
||||
<div class="min-h-screen bg-gray-900 flex flex-col justify-center py-12 sm:px-6 lg:px-8">
|
||||
<div class="sm:mx-auto sm:w-full sm:max-w-sm">
|
||||
<h2 class="mt-6 text-center text-3xl font-extrabold text-gray-50">
|
||||
Algora TV
|
||||
</h2>
|
||||
<a
|
||||
href={Algora.Github.authorize_url()}
|
||||
class="mt-8 w-full flex justify-center py-2 px-4 border border-transparent rounded-md shadow-sm text-sm font-medium text-white bg-purple-600 hover:bg-purple-500 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-purple-400"
|
||||
>
|
||||
Sign in with GitHub
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
"""
|
||||
end
|
||||
|
||||
def mount(_params, _session, socket) do
|
||||
{:ok, socket}
|
||||
end
|
||||
end
|
61
lib/algora_web/router.ex
Normal file
61
lib/algora_web/router.ex
Normal file
@ -0,0 +1,61 @@
|
||||
defmodule AlgoraWeb.Router do
|
||||
use AlgoraWeb, :router
|
||||
|
||||
import AlgoraWeb.UserAuth,
|
||||
only: [redirect_if_user_is_authenticated: 2, fetch_current_user: 2]
|
||||
|
||||
pipeline :browser do
|
||||
plug :accepts, ["html"]
|
||||
plug :fetch_session
|
||||
plug :fetch_live_flash
|
||||
plug :fetch_current_user
|
||||
plug :put_root_layout, {AlgoraWeb.Layouts, :root}
|
||||
plug :protect_from_forgery
|
||||
plug :put_secure_browser_headers
|
||||
end
|
||||
|
||||
pipeline :api do
|
||||
plug :accepts, ["json"]
|
||||
end
|
||||
|
||||
scope "/", AlgoraWeb do
|
||||
pipe_through [:browser, :redirect_if_user_is_authenticated]
|
||||
|
||||
get "/oauth/callbacks/:provider", OAuthCallbackController, :new
|
||||
end
|
||||
|
||||
if Mix.env() in [:dev, :test] do
|
||||
import Phoenix.LiveDashboard.Router
|
||||
|
||||
scope "/" do
|
||||
pipe_through :browser
|
||||
live_dashboard "/dashboard", metrics: AlgoraWeb.Telemetry
|
||||
end
|
||||
end
|
||||
|
||||
if Mix.env() == :dev do
|
||||
scope "/dev" do
|
||||
pipe_through :browser
|
||||
|
||||
forward "/mailbox", Plug.Swoosh.MailboxPreview
|
||||
end
|
||||
end
|
||||
|
||||
scope "/", AlgoraWeb do
|
||||
pipe_through :browser
|
||||
|
||||
delete "/auth/logout", OAuthCallbackController, :sign_out
|
||||
|
||||
live_session :authenticated,
|
||||
on_mount: [{AlgoraWeb.UserAuth, :ensure_authenticated}, AlgoraWeb.Nav] do
|
||||
live "/channel/settings", SettingsLive, :edit
|
||||
live "/:channel_handle/stream", ChannelLive, :stream
|
||||
end
|
||||
|
||||
live_session :default, on_mount: [{AlgoraWeb.UserAuth, :current_user}, AlgoraWeb.Nav] do
|
||||
live "/", HomeLive, :show
|
||||
live "/auth/login", SignInLive, :index
|
||||
live "/:channel_handle", ChannelLive, :show
|
||||
end
|
||||
end
|
||||
end
|
71
lib/algora_web/telemetry.ex
Normal file
71
lib/algora_web/telemetry.ex
Normal file
@ -0,0 +1,71 @@
|
||||
defmodule AlgoraWeb.Telemetry do
|
||||
use Supervisor
|
||||
import Telemetry.Metrics
|
||||
|
||||
def start_link(arg) do
|
||||
Supervisor.start_link(__MODULE__, arg, name: __MODULE__)
|
||||
end
|
||||
|
||||
@impl true
|
||||
def init(_arg) do
|
||||
children = [
|
||||
# Telemetry poller will execute the given period measurements
|
||||
# every 10_000ms. Learn more here: https://hexdocs.pm/telemetry_metrics
|
||||
{:telemetry_poller, measurements: periodic_measurements(), period: 10_000}
|
||||
# Add reporters as children of your supervision tree.
|
||||
# {Telemetry.Metrics.ConsoleReporter, metrics: metrics()}
|
||||
]
|
||||
|
||||
Supervisor.init(children, strategy: :one_for_one)
|
||||
end
|
||||
|
||||
def metrics do
|
||||
[
|
||||
# Phoenix Metrics
|
||||
summary("phoenix.endpoint.stop.duration",
|
||||
unit: {:native, :millisecond}
|
||||
),
|
||||
summary("phoenix.router_dispatch.stop.duration",
|
||||
tags: [:route],
|
||||
unit: {:native, :millisecond}
|
||||
),
|
||||
|
||||
# Database Metrics
|
||||
summary("algora.repo.query.total_time",
|
||||
unit: {:native, :millisecond},
|
||||
description: "The sum of the other measurements"
|
||||
),
|
||||
summary("algora.repo.query.decode_time",
|
||||
unit: {:native, :millisecond},
|
||||
description: "The time spent decoding the data received from the database"
|
||||
),
|
||||
summary("algora.repo.query.query_time",
|
||||
unit: {:native, :millisecond},
|
||||
description: "The time spent executing the query"
|
||||
),
|
||||
summary("algora.repo.query.queue_time",
|
||||
unit: {:native, :millisecond},
|
||||
description: "The time spent waiting for a database connection"
|
||||
),
|
||||
summary("algora.repo.query.idle_time",
|
||||
unit: {:native, :millisecond},
|
||||
description:
|
||||
"The time the connection spent waiting before being checked out for the query"
|
||||
),
|
||||
|
||||
# VM Metrics
|
||||
summary("vm.memory.total", unit: {:byte, :kilobyte}),
|
||||
summary("vm.total_run_queue_lengths.total"),
|
||||
summary("vm.total_run_queue_lengths.cpu"),
|
||||
summary("vm.total_run_queue_lengths.io")
|
||||
]
|
||||
end
|
||||
|
||||
defp periodic_measurements do
|
||||
[
|
||||
# A module, function and arguments to be invoked periodically.
|
||||
# This function must call :telemetry.execute/3 and a metric must be added above.
|
||||
# {AlgoraWeb, :count_users, []}
|
||||
]
|
||||
end
|
||||
end
|
96
mix.exs
Normal file
96
mix.exs
Normal file
@ -0,0 +1,96 @@
|
||||
defmodule Algora.MixProject do
|
||||
use Mix.Project
|
||||
|
||||
def project do
|
||||
[
|
||||
app: :algora,
|
||||
version: "0.1.0",
|
||||
elixir: "~> 1.12",
|
||||
elixirc_paths: elixirc_paths(Mix.env()),
|
||||
start_permanent: Mix.env() == :prod,
|
||||
aliases: aliases(),
|
||||
deps: deps()
|
||||
]
|
||||
end
|
||||
|
||||
# Configuration for the OTP application.
|
||||
#
|
||||
# Type `mix help compile.app` for more information.
|
||||
def application do
|
||||
[
|
||||
mod: {Algora.Application, []},
|
||||
extra_applications: [:logger, :runtime_tools]
|
||||
]
|
||||
end
|
||||
|
||||
# Specifies which paths to compile per environment.
|
||||
defp elixirc_paths(:test), do: ["lib", "test/support"]
|
||||
defp elixirc_paths(_), do: ["lib"]
|
||||
|
||||
# Specifies your project dependencies.
|
||||
#
|
||||
# Type `mix help deps` for examples and options.
|
||||
defp deps do
|
||||
[
|
||||
{:castore, "~> 0.1.13"},
|
||||
{:credo, "~> 1.7", only: [:dev, :test], runtime: false},
|
||||
{:dialyxir, "~> 1.3", only: [:dev], runtime: false},
|
||||
{:ecto_network, "~> 1.3.0"},
|
||||
{:ecto_sql, "~> 3.6"},
|
||||
{:esbuild, "~> 0.2", runtime: Mix.env() == :dev},
|
||||
{:ex_m3u8, "~> 0.9.0"},
|
||||
{:exsync, "~> 0.2", only: :dev},
|
||||
{:ffmpex, "~> 0.10.0"},
|
||||
{:finch, "~> 0.13"},
|
||||
{:floki, ">= 0.30.0", only: :test},
|
||||
{:gettext, "~> 0.18"},
|
||||
{:heroicons, "~> 0.5.0"},
|
||||
{:jason, "~> 1.2"},
|
||||
{:libcluster, "~> 3.3.1"},
|
||||
{:membrane_core, "~> 1.0"},
|
||||
{:membrane_http_adaptive_stream_plugin, "~> 0.18.0"},
|
||||
{:membrane_rtmp_plugin, "~> 0.20.0"},
|
||||
{:mint, "~> 1.0"},
|
||||
{:oban, "~> 2.16"},
|
||||
{:phoenix_ecto, "~> 4.4"},
|
||||
{:phoenix_html, "~> 3.3", override: true},
|
||||
{:phoenix_live_dashboard, "~> 0.7.2"},
|
||||
{:phoenix_live_reload, "~> 1.2", only: :dev},
|
||||
{:phoenix_live_view, "~> 0.18.16"},
|
||||
{:phoenix, "~> 1.7.1"},
|
||||
{:plug_cowboy, "~> 2.5"},
|
||||
{:postgrex, ">= 0.0.0"},
|
||||
{:swoosh, "~> 1.3"},
|
||||
{:tailwind, "~> 0.1"},
|
||||
{:telemetry_metrics, "~> 0.6"},
|
||||
{:telemetry_poller, "~> 1.0"},
|
||||
{:thumbnex, "~> 0.5.0"},
|
||||
{:timex, "~> 3.0"},
|
||||
# ex_aws
|
||||
{:ex_aws_s3, "~> 2.3"},
|
||||
{:ex_doc, "~> 0.29.0"},
|
||||
{:hackney, ">= 0.0.0"},
|
||||
{:sweet_xml, ">= 0.0.0", optional: true}
|
||||
]
|
||||
end
|
||||
|
||||
# Aliases are shortcuts or tasks specific to the current project.
|
||||
# For example, to install project dependencies and perform other setup tasks, run:
|
||||
#
|
||||
# $ mix setup
|
||||
#
|
||||
# See the documentation for `Mix` for more info on aliases.
|
||||
defp aliases do
|
||||
[
|
||||
setup: ["deps.get", "ecto.setup"],
|
||||
"ecto.setup": ["ecto.create", "ecto.migrate", "run priv/repo/seeds.exs"],
|
||||
"ecto.reset": ["ecto.drop", "ecto.setup"],
|
||||
test: ["ecto.create --quiet", "ecto.migrate --quiet", "test"],
|
||||
"assets.deploy": [
|
||||
"tailwind default --minify",
|
||||
"esbuild default --minify",
|
||||
"phx.digest"
|
||||
]
|
||||
]
|
||||
end
|
||||
end
|
113
mix.lock
Normal file
113
mix.lock
Normal file
@ -0,0 +1,113 @@
|
||||
%{
|
||||
"bimap": {:hex, :bimap, "1.3.0", "3ea4832e58dc83a9b5b407c6731e7bae87458aa618e6d11d8e12114a17afa4b3", [:mix], [], "hexpm", "bf5a2b078528465aa705f405a5c638becd63e41d280ada41e0f77e6d255a10b4"},
|
||||
"bunch": {:hex, :bunch, "1.6.1", "5393d827a64d5f846092703441ea50e65bc09f37fd8e320878f13e63d410aec7", [:mix], [], "hexpm", "286cc3add551628b30605efbe2fca4e38cc1bea89bcd0a1a7226920b3364fe4a"},
|
||||
"bunch_native": {:hex, :bunch_native, "0.5.0", "8ac1536789a597599c10b652e0b526d8833348c19e4739a0759a2bedfd924e63", [:mix], [{:bundlex, "~> 1.0", [hex: :bundlex, repo: "hexpm", optional: false]}], "hexpm", "24190c760e32b23b36edeb2dc4852515c7c5b3b8675b1a864e0715bdd1c8f80d"},
|
||||
"bundlex": {:hex, :bundlex, "1.4.5", "ea06cb441af636baaf5232dced24c6b1ee5ccbe7a7cad8a348eb3100fa1d7b52", [:mix], [{:bunch, "~> 1.0", [hex: :bunch, repo: "hexpm", optional: false]}, {:elixir_uuid, "~> 1.2", [hex: :elixir_uuid, repo: "hexpm", optional: false]}, {:qex, "~> 0.5", [hex: :qex, repo: "hexpm", optional: false]}, {:req, "~> 0.4.0", [hex: :req, repo: "hexpm", optional: false]}, {:zarex, "~> 1.0", [hex: :zarex, repo: "hexpm", optional: false]}], "hexpm", "bd4136100d3120740bf8eaa73ad74859d5ccd659cf0b27aa1645590a67a0172b"},
|
||||
"bunt": {:hex, :bunt, "1.0.0", "081c2c665f086849e6d57900292b3a161727ab40431219529f13c4ddcf3e7a44", [:mix], [], "hexpm", "dc5f86aa08a5f6fa6b8096f0735c4e76d54ae5c9fa2c143e5a1fc7c1cd9bb6b5"},
|
||||
"castore": {:hex, :castore, "0.1.22", "4127549e411bedd012ca3a308dede574f43819fe9394254ca55ab4895abfa1a2", [:mix], [], "hexpm", "c17576df47eb5aa1ee40cc4134316a99f5cad3e215d5c77b8dd3cfef12a22cac"},
|
||||
"certifi": {:hex, :certifi, "2.12.0", "2d1cca2ec95f59643862af91f001478c9863c2ac9cb6e2f89780bfd8de987329", [:rebar3], [], "hexpm", "ee68d85df22e554040cdb4be100f33873ac6051387baf6a8f6ce82272340ff1c"},
|
||||
"coerce": {:hex, :coerce, "1.0.1", "211c27386315dc2894ac11bc1f413a0e38505d808153367bd5c6e75a4003d096", [:mix], [], "hexpm", "b44a691700f7a1a15b4b7e2ff1fa30bebd669929ac8aa43cffe9e2f8bf051cf1"},
|
||||
"combine": {:hex, :combine, "0.10.0", "eff8224eeb56498a2af13011d142c5e7997a80c8f5b97c499f84c841032e429f", [:mix], [], "hexpm", "1b1dbc1790073076580d0d1d64e42eae2366583e7aecd455d1215b0d16f2451b"},
|
||||
"connection": {:hex, :connection, "1.1.0", "ff2a49c4b75b6fb3e674bfc5536451607270aac754ffd1bdfe175abe4a6d7a68", [:mix], [], "hexpm", "722c1eb0a418fbe91ba7bd59a47e28008a189d47e37e0e7bb85585a016b2869c"},
|
||||
"cowboy": {:hex, :cowboy, "2.9.0", "865dd8b6607e14cf03282e10e934023a1bd8be6f6bacf921a7e2a96d800cd452", [:make, :rebar3], [{:cowlib, "2.11.0", [hex: :cowlib, repo: "hexpm", optional: false]}, {:ranch, "1.8.0", [hex: :ranch, repo: "hexpm", optional: false]}], "hexpm", "2c729f934b4e1aa149aff882f57c6372c15399a20d54f65c8d67bef583021bde"},
|
||||
"cowboy_telemetry": {:hex, :cowboy_telemetry, "0.4.0", "f239f68b588efa7707abce16a84d0d2acf3a0f50571f8bb7f56a15865aae820c", [:rebar3], [{:cowboy, "~> 2.7", [hex: :cowboy, repo: "hexpm", optional: false]}, {:telemetry, "~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "7d98bac1ee4565d31b62d59f8823dfd8356a169e7fcbb83831b8a5397404c9de"},
|
||||
"cowlib": {:hex, :cowlib, "2.11.0", "0b9ff9c346629256c42ebe1eeb769a83c6cb771a6ee5960bd110ab0b9b872063", [:make, :rebar3], [], "hexpm", "2b3e9da0b21c4565751a6d4901c20d1b4cc25cbb7fd50d91d2ab6dd287bc86a9"},
|
||||
"credo": {:hex, :credo, "1.7.4", "68ca5cf89071511c12fd9919eb84e388d231121988f6932756596195ccf7fd35", [:mix], [{:bunt, "~> 0.2.1 or ~> 1.0", [hex: :bunt, repo: "hexpm", optional: false]}, {:file_system, "~> 0.2 or ~> 1.0", [hex: :file_system, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "9cf776d062c78bbe0f0de1ecaee183f18f2c3ec591326107989b054b7dddefc2"},
|
||||
"db_connection": {:hex, :db_connection, "2.4.2", "f92e79aff2375299a16bcb069a14ee8615c3414863a6fef93156aee8e86c2ff3", [:mix], [{:connection, "~> 1.0", [hex: :connection, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "4fe53ca91b99f55ea249693a0229356a08f4d1a7931d8ffa79289b145fe83668"},
|
||||
"decimal": {:hex, :decimal, "2.1.1", "5611dca5d4b2c3dd497dec8f68751f1f1a54755e8ed2a966c2633cf885973ad6", [:mix], [], "hexpm", "53cfe5f497ed0e7771ae1a475575603d77425099ba5faef9394932b35020ffcc"},
|
||||
"dialyxir": {:hex, :dialyxir, "1.4.3", "edd0124f358f0b9e95bfe53a9fcf806d615d8f838e2202a9f430d59566b6b53b", [:mix], [{:erlex, ">= 0.2.6", [hex: :erlex, repo: "hexpm", optional: false]}], "hexpm", "bf2cfb75cd5c5006bec30141b131663299c661a864ec7fbbc72dfa557487a986"},
|
||||
"earmark_parser": {:hex, :earmark_parser, "1.4.39", "424642f8335b05bb9eb611aa1564c148a8ee35c9c8a8bba6e129d51a3e3c6769", [:mix], [], "hexpm", "06553a88d1f1846da9ef066b87b57c6f605552cfbe40d20bd8d59cc6bde41944"},
|
||||
"ecto": {:hex, :ecto, "3.9.6", "2f420c173efcb2e22fa4f8fc41e75e02b3c5bd4cffef12085cae5418c12e530d", [:mix], [{:decimal, "~> 1.6 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "df17bc06ba6f78a7b764e4a14ef877fe5f4499332c5a105ace11fe7013b72c84"},
|
||||
"ecto_network": {:hex, :ecto_network, "1.3.0", "1e77fa37c20e0f6a426d3862732f3317b0fa4c18f123d325f81752a491d7304e", [:mix], [{:ecto_sql, ">= 3.0.0", [hex: :ecto_sql, repo: "hexpm", optional: false]}, {:phoenix_html, ">= 0.0.0", [hex: :phoenix_html, repo: "hexpm", optional: true]}, {:postgrex, ">= 0.14.0", [hex: :postgrex, repo: "hexpm", optional: false]}], "hexpm", "053a5e46ef2837e8ea5ea97c82fa0f5494699209eddd764e663c85f11b2865bd"},
|
||||
"ecto_sql": {:hex, :ecto_sql, "3.9.0", "2bb21210a2a13317e098a420a8c1cc58b0c3421ab8e3acfa96417dab7817918c", [:mix], [{:db_connection, "~> 2.5 or ~> 2.4.1", [hex: :db_connection, repo: "hexpm", optional: false]}, {:ecto, "~> 3.9.0", [hex: :ecto, repo: "hexpm", optional: false]}, {:myxql, "~> 0.6.0", [hex: :myxql, repo: "hexpm", optional: true]}, {:postgrex, "~> 0.16.0 or ~> 1.0", [hex: :postgrex, repo: "hexpm", optional: true]}, {:tds, "~> 2.1.1 or ~> 2.2", [hex: :tds, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4.0 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "a8f3f720073b8b1ac4c978be25fa7960ed7fd44997420c304a4a2e200b596453"},
|
||||
"elixir_uuid": {:hex, :elixir_uuid, "1.2.1", "dce506597acb7e6b0daeaff52ff6a9043f5919a4c3315abb4143f0b00378c097", [:mix], [], "hexpm", "f7eba2ea6c3555cea09706492716b0d87397b88946e6380898c2889d68585752"},
|
||||
"erlex": {:hex, :erlex, "0.2.6", "c7987d15e899c7a2f34f5420d2a2ea0d659682c06ac607572df55a43753aa12e", [:mix], [], "hexpm", "2ed2e25711feb44d52b17d2780eabf998452f6efda104877a3881c2f8c0c0c75"},
|
||||
"esbuild": {:hex, :esbuild, "0.5.0", "d5bb08ff049d7880ee3609ed5c4b864bd2f46445ea40b16b4acead724fb4c4a3", [:mix], [{:castore, ">= 0.0.0", [hex: :castore, repo: "hexpm", optional: false]}], "hexpm", "f183a0b332d963c4cfaf585477695ea59eef9a6f2204fdd0efa00e099694ffe5"},
|
||||
"ex_aws": {:hex, :ex_aws, "2.5.1", "7418917974ea42e9e84b25e88b9f3d21a861d5f953ad453e212f48e593d8d39f", [:mix], [{:configparser_ex, "~> 4.0", [hex: :configparser_ex, repo: "hexpm", optional: true]}, {:hackney, "~> 1.16", [hex: :hackney, repo: "hexpm", optional: true]}, {:jason, "~> 1.1", [hex: :jason, repo: "hexpm", optional: true]}, {:jsx, "~> 2.8 or ~> 3.0", [hex: :jsx, repo: "hexpm", optional: true]}, {:mime, "~> 1.2 or ~> 2.0", [hex: :mime, repo: "hexpm", optional: false]}, {:sweet_xml, "~> 0.7", [hex: :sweet_xml, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4.3 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "1b95431f70c446fa1871f0eb9b183043c5a625f75f9948a42d25f43ae2eff12b"},
|
||||
"ex_aws_s3": {:hex, :ex_aws_s3, "2.5.3", "422468e5c3e1a4da5298e66c3468b465cfd354b842e512cb1f6fbbe4e2f5bdaf", [:mix], [{:ex_aws, "~> 2.0", [hex: :ex_aws, repo: "hexpm", optional: false]}, {:sweet_xml, ">= 0.0.0", [hex: :sweet_xml, repo: "hexpm", optional: true]}], "hexpm", "4f09dd372cc386550e484808c5ac5027766c8d0cd8271ccc578b82ee6ef4f3b8"},
|
||||
"ex_doc": {:hex, :ex_doc, "0.29.4", "6257ecbb20c7396b1fe5accd55b7b0d23f44b6aa18017b415cb4c2b91d997729", [:mix], [{:earmark_parser, "~> 1.4.31", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.14", [hex: :makeup_elixir, repo: "hexpm", optional: false]}, {:makeup_erlang, "~> 0.1", [hex: :makeup_erlang, repo: "hexpm", optional: false]}], "hexpm", "2c6699a737ae46cb61e4ed012af931b57b699643b24dabe2400a8168414bc4f5"},
|
||||
"ex_m3u8": {:hex, :ex_m3u8, "0.9.0", "54a12463320236aab09402bc69676f665e692636235a2b186a22df507ebc5643", [:mix], [{:nimble_parsec, "~> 1.3", [hex: :nimble_parsec, repo: "hexpm", optional: false]}, {:typed_struct, "~> 0.3.0", [hex: :typed_struct, repo: "hexpm", optional: false]}], "hexpm", "d57939a90d8da5956264d27a516c5e2ac80b09c8adbe4e3199d7d14c79549b5c"},
|
||||
"exsync": {:hex, :exsync, "0.3.0", "39ab8b3d4e5fe779a34ad930135145283ebf56069513dfdfaad4e30a04b158c7", [:mix], [{:file_system, "~> 0.2", [hex: :file_system, repo: "hexpm", optional: false]}], "hexpm", "2030d085a14fa5f685d53d97171a21345dddaf2b67a0927263efc6b2cd2bb09f"},
|
||||
"ffmpex": {:hex, :ffmpex, "0.10.0", "ce29281eac60bf109c05acb4342eecf813a3cd3f08c1bce350423caad86128af", [:mix], [{:jason, "~> 1.2", [hex: :jason, repo: "hexpm", optional: false]}, {:rambo, "~> 0.3.0", [hex: :rambo, repo: "hexpm", optional: false]}], "hexpm", "de8d81f8c51cc258dcee9a3e0b1568b0659c97be004557d9af47795206cff53b"},
|
||||
"file_system": {:hex, :file_system, "0.2.10", "fb082005a9cd1711c05b5248710f8826b02d7d1784e7c3451f9c1231d4fc162d", [:mix], [], "hexpm", "41195edbfb562a593726eda3b3e8b103a309b733ad25f3d642ba49696bf715dc"},
|
||||
"finch": {:hex, :finch, "0.13.0", "c881e5460ec563bf02d4f4584079e62201db676ed4c0ef3e59189331c4eddf7b", [:mix], [{:castore, "~> 0.1", [hex: :castore, repo: "hexpm", optional: false]}, {:mime, "~> 1.0 or ~> 2.0", [hex: :mime, repo: "hexpm", optional: false]}, {:mint, "~> 1.3", [hex: :mint, repo: "hexpm", optional: false]}, {:nimble_options, "~> 0.4.0", [hex: :nimble_options, repo: "hexpm", optional: false]}, {:nimble_pool, "~> 0.2.6", [hex: :nimble_pool, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "49957dcde10dcdc042a123a507a9c5ec5a803f53646d451db2f7dea696fba6cc"},
|
||||
"floki": {:hex, :floki, "0.34.0", "002d0cc194b48794d74711731db004fafeb328fe676976f160685262d43706a8", [:mix], [], "hexpm", "9c3a9f43f40dde00332a589bd9d389b90c1f518aef500364d00636acc5ebc99c"},
|
||||
"gettext": {:hex, :gettext, "0.20.0", "75ad71de05f2ef56991dbae224d35c68b098dd0e26918def5bb45591d5c8d429", [:mix], [], "hexpm", "1c03b177435e93a47441d7f681a7040bd2a816ece9e2666d1c9001035121eb3d"},
|
||||
"hackney": {:hex, :hackney, "1.20.1", "8d97aec62ddddd757d128bfd1df6c5861093419f8f7a4223823537bad5d064e2", [:rebar3], [{:certifi, "~> 2.12.0", [hex: :certifi, repo: "hexpm", optional: false]}, {:idna, "~> 6.1.0", [hex: :idna, repo: "hexpm", optional: false]}, {:metrics, "~> 1.0.0", [hex: :metrics, repo: "hexpm", optional: false]}, {:mimerl, "~> 1.1", [hex: :mimerl, repo: "hexpm", optional: false]}, {:parse_trans, "3.4.1", [hex: :parse_trans, repo: "hexpm", optional: false]}, {:ssl_verify_fun, "~> 1.1.0", [hex: :ssl_verify_fun, repo: "hexpm", optional: false]}, {:unicode_util_compat, "~> 0.7.0", [hex: :unicode_util_compat, repo: "hexpm", optional: false]}], "hexpm", "fe9094e5f1a2a2c0a7d10918fee36bfec0ec2a979994cff8cfe8058cd9af38e3"},
|
||||
"heroicons": {:hex, :heroicons, "0.5.3", "ee8ae8335303df3b18f2cc07f46e1cb6e761ba4cf2c901623fbe9a28c0bc51dd", [:mix], [{:castore, ">= 0.0.0", [hex: :castore, repo: "hexpm", optional: false]}, {:phoenix_live_view, ">= 0.18.2", [hex: :phoenix_live_view, repo: "hexpm", optional: false]}], "hexpm", "a210037e8a09ac17e2a0a0779d729e89c821c944434c3baa7edfc1f5b32f3502"},
|
||||
"hpax": {:hex, :hpax, "0.1.2", "09a75600d9d8bbd064cdd741f21fc06fc1f4cf3d0fcc335e5aa19be1a7235c84", [:mix], [], "hexpm", "2c87843d5a23f5f16748ebe77969880e29809580efdaccd615cd3bed628a8c13"},
|
||||
"idna": {:hex, :idna, "6.1.1", "8a63070e9f7d0c62eb9d9fcb360a7de382448200fbbd1b106cc96d3d8099df8d", [:rebar3], [{:unicode_util_compat, "~> 0.7.0", [hex: :unicode_util_compat, repo: "hexpm", optional: false]}], "hexpm", "92376eb7894412ed19ac475e4a86f7b413c1b9fbb5bd16dccd57934157944cea"},
|
||||
"jason": {:hex, :jason, "1.4.1", "af1504e35f629ddcdd6addb3513c3853991f694921b1b9368b0bd32beb9f1b63", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "fbb01ecdfd565b56261302f7e1fcc27c4fb8f32d56eab74db621fc154604a7a1"},
|
||||
"libcluster": {:hex, :libcluster, "3.3.1", "e7a4875cd1290cee7a693d6bd46076863e9e433708b01339783de6eff5b7f0aa", [:mix], [{:jason, "~> 1.1", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "b575ca63c1cd84e01f3fa0fc45e6eb945c1ee7ae8d441d33def999075e9e5398"},
|
||||
"makeup": {:hex, :makeup, "1.1.1", "fa0bc768698053b2b3869fa8a62616501ff9d11a562f3ce39580d60860c3a55e", [:mix], [{:nimble_parsec, "~> 1.2.2 or ~> 1.3", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "5dc62fbdd0de44de194898b6710692490be74baa02d9d108bc29f007783b0b48"},
|
||||
"makeup_elixir": {:hex, :makeup_elixir, "0.16.1", "cc9e3ca312f1cfeccc572b37a09980287e243648108384b97ff2b76e505c3555", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 1.2.3 or ~> 1.3", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "e127a341ad1b209bd80f7bd1620a15693a9908ed780c3b763bccf7d200c767c6"},
|
||||
"makeup_erlang": {:hex, :makeup_erlang, "0.1.4", "29563475afa9b8a2add1b7a9c8fb68d06ca7737648f28398e04461f008b69521", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "f4ed47ecda66de70dd817698a703f8816daa91272e7e45812469498614ae8b29"},
|
||||
"membrane_aac_format": {:hex, :membrane_aac_format, "0.8.0", "515631eabd6e584e0e9af2cea80471fee6246484dbbefc4726c1d93ece8e0838", [:mix], [{:bimap, "~> 1.1", [hex: :bimap, repo: "hexpm", optional: false]}], "hexpm", "a30176a94491033ed32be45e51d509fc70a5ee6e751f12fd6c0d60bd637013f6"},
|
||||
"membrane_aac_plugin": {:hex, :membrane_aac_plugin, "0.18.1", "30433bffd4d5d773f79448dd9afd55d77338721688f09a89b20d742a68cc2c3d", [:mix], [{:bunch, "~> 1.0", [hex: :bunch, repo: "hexpm", optional: false]}, {:membrane_aac_format, "~> 0.8.0", [hex: :membrane_aac_format, repo: "hexpm", optional: false]}, {:membrane_core, "~> 1.0", [hex: :membrane_core, repo: "hexpm", optional: false]}], "hexpm", "8fd048c47d5d2949eb557e19f43f62d534d3af5096187f1a1a3a1694d14b772c"},
|
||||
"membrane_cmaf_format": {:hex, :membrane_cmaf_format, "0.7.0", "573bfff6acf2371c5046b9174569f6316f4205e3d6e13e814bf7e613e5653a54", [:mix], [], "hexpm", "4ac6a24a33f61347a2714c982a5f84aa6207641f4de2ad5afde68a8b800da8de"},
|
||||
"membrane_common_c": {:hex, :membrane_common_c, "0.16.0", "caf3f29d2f5a1d32d8c2c122866110775866db2726e4272be58e66dfdf4bce40", [:mix], [{:membrane_core, "~> 1.0", [hex: :membrane_core, repo: "hexpm", optional: false]}, {:shmex, "~> 0.5.0", [hex: :shmex, repo: "hexpm", optional: false]}, {:unifex, "~> 1.0", [hex: :unifex, repo: "hexpm", optional: false]}], "hexpm", "a3c7e91de1ce1f8b23b9823188a5d13654d317235ea0ca781c05353ed3be9b1c"},
|
||||
"membrane_core": {:hex, :membrane_core, "1.0.0", "1b543aefd952283be1f2a215a1db213aa4d91222722ba03cd35280622f1905ee", [:mix], [{:bunch, "~> 1.6", [hex: :bunch, repo: "hexpm", optional: false]}, {:qex, "~> 0.3", [hex: :qex, repo: "hexpm", optional: false]}, {:ratio, "~> 3.0", [hex: :ratio, repo: "hexpm", optional: false]}, {:telemetry, "~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "352c90fd0a29942143c4bf7a727cc05c632e323f50a1a4e99321b1e8982f1533"},
|
||||
"membrane_fake_plugin": {:hex, :membrane_fake_plugin, "0.11.0", "3a2d26f15ad4940a4d44cee3354dff38fa9a39963e9b2dcb49802e150ff9a9dc", [:mix], [{:membrane_core, "~> 1.0", [hex: :membrane_core, repo: "hexpm", optional: false]}], "hexpm", "7c6b6a06eaa4e820d1e4836510ddb4bcb386c8918d0b37542a21caf6b87cbe72"},
|
||||
"membrane_file_plugin": {:hex, :membrane_file_plugin, "0.16.0", "7917f6682c22b9bcfc2ca20ed960eee0f7d03ad31fd5f59ed850f1fe3ddd545a", [:mix], [{:membrane_core, "~> 1.0", [hex: :membrane_core, repo: "hexpm", optional: false]}], "hexpm", "b0727998f75a9b4dab8a2baefdfc13c3eac00a04e061ab1b0e61dc5566927acc"},
|
||||
"membrane_flv_plugin": {:hex, :membrane_flv_plugin, "0.12.0", "d715ad405af86dcaf4b2f479e34088e1f6738c7280366828e1066b39d2aa493a", [:mix], [{:membrane_aac_format, "~> 0.8.0", [hex: :membrane_aac_format, repo: "hexpm", optional: false]}, {:membrane_core, "~> 1.0", [hex: :membrane_core, repo: "hexpm", optional: false]}, {:membrane_h264_format, "~> 0.6.1", [hex: :membrane_h264_format, repo: "hexpm", optional: false]}], "hexpm", "a317872d6d394e550c7bfd8979f12a3a1cc1e89b547d75360321025b403d3279"},
|
||||
"membrane_h264_ffmpeg_plugin": {:hex, :membrane_h264_ffmpeg_plugin, "0.31.4", "a037365fb23ad4dea73c9176a90f777fb2f8537516530a583a1e2617da7f1b71", [:mix], [{:bunch, "~> 1.6", [hex: :bunch, repo: "hexpm", optional: false]}, {:bundlex, "~> 1.3", [hex: :bundlex, repo: "hexpm", optional: false]}, {:membrane_common_c, "~> 0.16.0", [hex: :membrane_common_c, repo: "hexpm", optional: false]}, {:membrane_core, "~> 1.0", [hex: :membrane_core, repo: "hexpm", optional: false]}, {:membrane_h264_format, "~> 0.6.1", [hex: :membrane_h264_format, repo: "hexpm", optional: false]}, {:membrane_precompiled_dependency_provider, "~> 0.1.0", [hex: :membrane_precompiled_dependency_provider, repo: "hexpm", optional: false]}, {:membrane_raw_video_format, "~> 0.3.0", [hex: :membrane_raw_video_format, repo: "hexpm", optional: false]}, {:ratio, "~> 3.0", [hex: :ratio, repo: "hexpm", optional: false]}, {:unifex, "~> 1.1", [hex: :unifex, repo: "hexpm", optional: false]}], "hexpm", "168275f146fbd3ef0490f012921a6b6e14b820cf06990d250c0909d4efc2e46d"},
|
||||
"membrane_h264_format": {:hex, :membrane_h264_format, "0.6.1", "44836cd9de0abe989b146df1e114507787efc0cf0da2368f17a10c47b4e0738c", [:mix], [], "hexpm", "4b79be56465a876d2eac2c3af99e115374bbdc03eb1dea4f696ee9a8033cd4b0"},
|
||||
"membrane_h264_plugin": {:hex, :membrane_h264_plugin, "0.9.1", "ea140ab1ca21c528563675fdd7e14c80607e120e320dc930cac3dcfb4db3fc2b", [:mix], [{:bunch, "~> 1.4", [hex: :bunch, repo: "hexpm", optional: false]}, {:membrane_core, "~> 1.0", [hex: :membrane_core, repo: "hexpm", optional: false]}, {:membrane_h264_format, "~> 0.6.0", [hex: :membrane_h264_format, repo: "hexpm", optional: false]}], "hexpm", "8f10db817e691fc1234ed85fe674b3f8718d3a410e4582736dcdd53664cae725"},
|
||||
"membrane_h265_format": {:hex, :membrane_h265_format, "0.2.0", "1903c072cf7b0980c4d0c117ab61a2cd33e88782b696290de29570a7fab34819", [:mix], [], "hexpm", "6df418bdf242c0d9f7dbf2e5aea4c2d182e34ac9ad5a8b8cef2610c290002e83"},
|
||||
"membrane_http_adaptive_stream_plugin": {:hex, :membrane_http_adaptive_stream_plugin, "0.18.2", "420519e956540d00bfe97594bcda893f0616c4251297500c855290fccc5f899a", [:mix], [{:bunch, "~> 1.6", [hex: :bunch, repo: "hexpm", optional: false]}, {:membrane_aac_plugin, "~> 0.18.0", [hex: :membrane_aac_plugin, repo: "hexpm", optional: false]}, {:membrane_core, "~> 1.0", [hex: :membrane_core, repo: "hexpm", optional: false]}, {:membrane_h264_plugin, "~> 0.9.0", [hex: :membrane_h264_plugin, repo: "hexpm", optional: false]}, {:membrane_mp4_plugin, "~> 0.31.0", [hex: :membrane_mp4_plugin, repo: "hexpm", optional: false]}, {:membrane_tee_plugin, "~> 0.12.0", [hex: :membrane_tee_plugin, repo: "hexpm", optional: false]}, {:qex, "~> 0.5", [hex: :qex, repo: "hexpm", optional: false]}], "hexpm", "540cf54a85410aa2f4dd40c420a4a7da7493c0c14c5d935e84857c02ff1096fb"},
|
||||
"membrane_mp4_format": {:hex, :membrane_mp4_format, "0.8.0", "8c6e7d68829228117d333b4fbb030e7be829aab49dd8cb047fdc664db1812e6a", [:mix], [], "hexpm", "148dea678a1f82ccfd44dbde6f936d2f21255f496cb45a22cc6eec427f025522"},
|
||||
"membrane_mp4_plugin": {:hex, :membrane_mp4_plugin, "0.31.0", "1932c86e2f4a24aca1b99ee531a131fd0da1128db8975ba8f8738e3b1bbcfabd", [:mix], [{:bunch, "~> 1.5", [hex: :bunch, repo: "hexpm", optional: false]}, {:membrane_aac_format, "~> 0.8.0", [hex: :membrane_aac_format, repo: "hexpm", optional: false]}, {:membrane_cmaf_format, "~> 0.7.0", [hex: :membrane_cmaf_format, repo: "hexpm", optional: false]}, {:membrane_core, "~> 1.0", [hex: :membrane_core, repo: "hexpm", optional: false]}, {:membrane_file_plugin, "~> 0.16.0", [hex: :membrane_file_plugin, repo: "hexpm", optional: false]}, {:membrane_h264_format, "~> 0.6.1", [hex: :membrane_h264_format, repo: "hexpm", optional: false]}, {:membrane_h264_plugin, "~> 0.9.0", [hex: :membrane_h264_plugin, repo: "hexpm", optional: false]}, {:membrane_h265_format, "~> 0.2.0", [hex: :membrane_h265_format, repo: "hexpm", optional: false]}, {:membrane_mp4_format, "~> 0.8.0", [hex: :membrane_mp4_format, repo: "hexpm", optional: false]}, {:membrane_opus_format, "~> 0.3.0", [hex: :membrane_opus_format, repo: "hexpm", optional: false]}], "hexpm", "9968e56e02085228974bf6a59c8858f3c0d9800a4e767c1b3b2f2890050c72f4"},
|
||||
"membrane_opus_format": {:hex, :membrane_opus_format, "0.3.0", "3804d9916058b7cfa2baa0131a644d8186198d64f52d592ae09e0942513cb4c2", [:mix], [], "hexpm", "8fc89c97be50de23ded15f2050fe603dcce732566fe6fdd15a2de01cb6b81afe"},
|
||||
"membrane_precompiled_dependency_provider": {:hex, :membrane_precompiled_dependency_provider, "0.1.1", "a0d5b7942f8be452c30744207f78284f6a0e0c84c968aba7d76e206fbf75bc5d", [:mix], [{:bundlex, "~> 1.4", [hex: :bundlex, repo: "hexpm", optional: false]}], "hexpm", "87ad44752e2cf0fa3b31c5aac15b863343c2f6e0f0fd201f5ec4c0bcda8c6fa3"},
|
||||
"membrane_raw_video_format": {:hex, :membrane_raw_video_format, "0.3.0", "ba10f475e0814a6fe79602a74536b796047577c7ef5b0e33def27cd344229699", [:mix], [], "hexpm", "2f08760061c8a5386ecf04273480f10e48d25a1a40aa99476302b0bcd34ccb1c"},
|
||||
"membrane_rtmp_plugin": {:hex, :membrane_rtmp_plugin, "0.20.2", "b586dfb876a1af8cd9ecbf42f979df04a7ff35adefbd69c7fba067a3f3fd72d3", [:mix], [{:membrane_aac_plugin, "~> 0.18.0", [hex: :membrane_aac_plugin, repo: "hexpm", optional: false]}, {:membrane_core, "~> 1.0", [hex: :membrane_core, repo: "hexpm", optional: false]}, {:membrane_file_plugin, "~> 0.16.0", [hex: :membrane_file_plugin, repo: "hexpm", optional: false]}, {:membrane_flv_plugin, "~> 0.12.0", [hex: :membrane_flv_plugin, repo: "hexpm", optional: false]}, {:membrane_h264_format, "~> 0.6.1", [hex: :membrane_h264_format, repo: "hexpm", optional: false]}, {:membrane_h264_plugin, "~> 0.9.0", [hex: :membrane_h264_plugin, repo: "hexpm", optional: false]}, {:membrane_precompiled_dependency_provider, "~> 0.1.0", [hex: :membrane_precompiled_dependency_provider, repo: "hexpm", optional: false]}, {:unifex, "~> 1.1.0", [hex: :unifex, repo: "hexpm", optional: false]}], "hexpm", "bf6cbd5c5790fe4b8caff4a5ad0c258de2ba11e20915d43b2cbb67013bffd74f"},
|
||||
"membrane_scissors_plugin": {:hex, :membrane_scissors_plugin, "0.8.0", "c8ee6d5b2d452d034d17a65a629bb13872dccb9fa9d232dc9bb85738d5723305", [:mix], [{:membrane_core, "~> 1.0", [hex: :membrane_core, repo: "hexpm", optional: false]}, {:stream_split, "~> 0.1.3", [hex: :stream_split, repo: "hexpm", optional: false]}], "hexpm", "22487e6a4d45f4c85a50a93ff5c63e196175c04007365e3bb070d91b8e93ad02"},
|
||||
"membrane_tee_plugin": {:hex, :membrane_tee_plugin, "0.12.0", "f94989b4080ef4b7937d74c1a14d3379577c7bd4c6d06e5a2bb41c351ad604d4", [:mix], [{:bunch, "~> 1.0", [hex: :bunch, repo: "hexpm", optional: false]}, {:membrane_core, "~> 1.0", [hex: :membrane_core, repo: "hexpm", optional: false]}], "hexpm", "0d61c9ed5e68e5a75d54200e1c6df5739c0bcb52fee0974183ad72446a179887"},
|
||||
"metrics": {:hex, :metrics, "1.0.1", "25f094dea2cda98213cecc3aeff09e940299d950904393b2a29d191c346a8486", [:rebar3], [], "hexpm", "69b09adddc4f74a40716ae54d140f93beb0fb8978d8636eaded0c31b6f099f16"},
|
||||
"mime": {:hex, :mime, "2.0.5", "dc34c8efd439abe6ae0343edbb8556f4d63f178594894720607772a041b04b02", [:mix], [], "hexpm", "da0d64a365c45bc9935cc5c8a7fc5e49a0e0f9932a761c55d6c52b142780a05c"},
|
||||
"mimerl": {:hex, :mimerl, "1.2.0", "67e2d3f571088d5cfd3e550c383094b47159f3eee8ffa08e64106cdf5e981be3", [:rebar3], [], "hexpm", "f278585650aa581986264638ebf698f8bb19df297f66ad91b18910dfc6e19323"},
|
||||
"mint": {:hex, :mint, "1.4.2", "50330223429a6e1260b2ca5415f69b0ab086141bc76dc2fbf34d7c389a6675b2", [:mix], [{:castore, "~> 0.1.0", [hex: :castore, repo: "hexpm", optional: true]}, {:hpax, "~> 0.1.1", [hex: :hpax, repo: "hexpm", optional: false]}], "hexpm", "ce75a5bbcc59b4d7d8d70f8b2fc284b1751ffb35c7b6a6302b5192f8ab4ddd80"},
|
||||
"mogrify": {:hex, :mogrify, "0.9.3", "238c782f00271dace01369ad35ae2e9dd020feee3443b9299ea5ea6bed559841", [:mix], [], "hexpm", "0189b1e1de27455f2b9ae8cf88239cefd23d38de9276eb5add7159aea51731e6"},
|
||||
"nimble_options": {:hex, :nimble_options, "0.4.0", "c89babbab52221a24b8d1ff9e7d838be70f0d871be823165c94dd3418eea728f", [:mix], [], "hexpm", "e6701c1af326a11eea9634a3b1c62b475339ace9456c1a23ec3bc9a847bca02d"},
|
||||
"nimble_parsec": {:hex, :nimble_parsec, "1.4.0", "51f9b613ea62cfa97b25ccc2c1b4216e81df970acd8e16e8d1bdc58fef21370d", [:mix], [], "hexpm", "9c565862810fb383e9838c1dd2d7d2c437b3d13b267414ba6af33e50d2d1cf28"},
|
||||
"nimble_pool": {:hex, :nimble_pool, "0.2.6", "91f2f4c357da4c4a0a548286c84a3a28004f68f05609b4534526871a22053cde", [:mix], [], "hexpm", "1c715055095d3f2705c4e236c18b618420a35490da94149ff8b580a2144f653f"},
|
||||
"numbers": {:hex, :numbers, "5.2.4", "f123d5bb7f6acc366f8f445e10a32bd403c8469bdbce8ce049e1f0972b607080", [:mix], [{:coerce, "~> 1.0", [hex: :coerce, repo: "hexpm", optional: false]}, {:decimal, "~> 1.9 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "eeccf5c61d5f4922198395bf87a465b6f980b8b862dd22d28198c5e6fab38582"},
|
||||
"oban": {:hex, :oban, "2.17.3", "ddfd5710aadcd550d2e174c8d73ce5f1865601418cf54a91775f20443fb832b7", [:mix], [{:ecto_sql, "~> 3.6", [hex: :ecto_sql, repo: "hexpm", optional: false]}, {:ecto_sqlite3, "~> 0.9", [hex: :ecto_sqlite3, repo: "hexpm", optional: true]}, {:jason, "~> 1.1", [hex: :jason, repo: "hexpm", optional: false]}, {:postgrex, "~> 0.16", [hex: :postgrex, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "452eada8bfe0d0fefd0740ab5fa8cf3ef6c375df0b4a3c3805d179022a04738a"},
|
||||
"parse_trans": {:hex, :parse_trans, "3.4.1", "6e6aa8167cb44cc8f39441d05193be6e6f4e7c2946cb2759f015f8c56b76e5ff", [:rebar3], [], "hexpm", "620a406ce75dada827b82e453c19cf06776be266f5a67cff34e1ef2cbb60e49a"},
|
||||
"phoenix": {:hex, :phoenix, "1.7.1", "a029bde19d9c3b559e5c3d06c78b76e81396bedd456a6acedb42f9c7b2e535a9", [:mix], [{:castore, ">= 0.0.0", [hex: :castore, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:phoenix_pubsub, "~> 2.1", [hex: :phoenix_pubsub, repo: "hexpm", optional: false]}, {:phoenix_template, "~> 1.0", [hex: :phoenix_template, repo: "hexpm", optional: false]}, {:phoenix_view, "~> 2.0", [hex: :phoenix_view, repo: "hexpm", optional: true]}, {:plug, "~> 1.14", [hex: :plug, repo: "hexpm", optional: false]}, {:plug_cowboy, "~> 2.6", [hex: :plug_cowboy, repo: "hexpm", optional: true]}, {:plug_crypto, "~> 1.2", [hex: :plug_crypto, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}, {:websock_adapter, "~> 0.4", [hex: :websock_adapter, repo: "hexpm", optional: false]}], "hexpm", "ea9d4a85c3592e37efa07d0dc013254fda445885facaefddcbf646375c116457"},
|
||||
"phoenix_ecto": {:hex, :phoenix_ecto, "4.4.0", "0672ed4e4808b3fbed494dded89958e22fb882de47a97634c0b13e7b0b5f7720", [:mix], [{:ecto, "~> 3.3", [hex: :ecto, repo: "hexpm", optional: false]}, {:phoenix_html, "~> 2.14.2 or ~> 3.0", [hex: :phoenix_html, repo: "hexpm", optional: true]}, {:plug, "~> 1.9", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm", "09864e558ed31ee00bd48fcc1d4fc58ae9678c9e81649075431e69dbabb43cc1"},
|
||||
"phoenix_html": {:hex, :phoenix_html, "3.3.3", "380b8fb45912b5638d2f1d925a3771b4516b9a78587249cabe394e0a5d579dc9", [:mix], [{:plug, "~> 1.5", [hex: :plug, repo: "hexpm", optional: true]}], "hexpm", "923ebe6fec6e2e3b3e569dfbdc6560de932cd54b000ada0208b5f45024bdd76c"},
|
||||
"phoenix_live_dashboard": {:hex, :phoenix_live_dashboard, "0.7.2", "97cc4ff2dba1ebe504db72cb45098cb8e91f11160528b980bd282cc45c73b29c", [:mix], [{:ecto, "~> 3.6.2 or ~> 3.7", [hex: :ecto, repo: "hexpm", optional: true]}, {:ecto_mysql_extras, "~> 0.5", [hex: :ecto_mysql_extras, repo: "hexpm", optional: true]}, {:ecto_psql_extras, "~> 0.7", [hex: :ecto_psql_extras, repo: "hexpm", optional: true]}, {:mime, "~> 1.6 or ~> 2.0", [hex: :mime, repo: "hexpm", optional: false]}, {:phoenix_live_view, "~> 0.18.3", [hex: :phoenix_live_view, repo: "hexpm", optional: false]}, {:telemetry_metrics, "~> 0.6 or ~> 1.0", [hex: :telemetry_metrics, repo: "hexpm", optional: false]}], "hexpm", "0e5fdf063c7a3b620c566a30fcf68b7ee02e5e46fe48ee46a6ec3ba382dc05b7"},
|
||||
"phoenix_live_reload": {:hex, :phoenix_live_reload, "1.4.0", "4fe222c0be55fdc3f9c711e24955fc42a7cd9b7a2f5f406f2580a567c335a573", [:mix], [{:file_system, "~> 0.2.1 or ~> 0.3", [hex: :file_system, repo: "hexpm", optional: false]}, {:phoenix, "~> 1.4", [hex: :phoenix, repo: "hexpm", optional: false]}], "hexpm", "bebf0fc2d2113b61cb5968f585367234b7b4c21d963d691de7b4b2dc6cdaae6f"},
|
||||
"phoenix_live_view": {:hex, :phoenix_live_view, "0.18.16", "781c6a3ac49e0451ca403848b40807171caea400896fe8ed8e5ddd6106ad5580", [:mix], [{:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:phoenix, "~> 1.6.15 or ~> 1.7.0", [hex: :phoenix, repo: "hexpm", optional: false]}, {:phoenix_html, "~> 3.3", [hex: :phoenix_html, repo: "hexpm", optional: false]}, {:phoenix_template, "~> 1.0", [hex: :phoenix_template, repo: "hexpm", optional: false]}, {:phoenix_view, "~> 2.0", [hex: :phoenix_view, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4.2 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "09e6ae2babe62f74bfcd1e3cac1a9b0e2c262557cc566300a843425c9cb6842a"},
|
||||
"phoenix_pubsub": {:hex, :phoenix_pubsub, "2.1.1", "ba04e489ef03763bf28a17eb2eaddc2c20c6d217e2150a61e3298b0f4c2012b5", [:mix], [], "hexpm", "81367c6d1eea5878ad726be80808eb5a787a23dee699f96e72b1109c57cdd8d9"},
|
||||
"phoenix_template": {:hex, :phoenix_template, "1.0.1", "85f79e3ad1b0180abb43f9725973e3b8c2c3354a87245f91431eec60553ed3ef", [:mix], [{:phoenix_html, "~> 2.14.2 or ~> 3.0", [hex: :phoenix_html, repo: "hexpm", optional: true]}], "hexpm", "157dc078f6226334c91cb32c1865bf3911686f8bcd6bcff86736f6253e6993ee"},
|
||||
"plug": {:hex, :plug, "1.15.3", "712976f504418f6dff0a3e554c40d705a9bcf89a7ccef92fc6a5ef8f16a30a97", [:mix], [{:mime, "~> 1.0 or ~> 2.0", [hex: :mime, repo: "hexpm", optional: false]}, {:plug_crypto, "~> 1.1.1 or ~> 1.2 or ~> 2.0", [hex: :plug_crypto, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4.3 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "cc4365a3c010a56af402e0809208873d113e9c38c401cabd88027ef4f5c01fd2"},
|
||||
"plug_cowboy": {:hex, :plug_cowboy, "2.6.0", "d1cf12ff96a1ca4f52207c5271a6c351a4733f413803488d75b70ccf44aebec2", [:mix], [{:cowboy, "~> 2.7", [hex: :cowboy, repo: "hexpm", optional: false]}, {:cowboy_telemetry, "~> 0.3", [hex: :cowboy_telemetry, repo: "hexpm", optional: false]}, {:plug, "~> 1.14", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm", "073cf20b753ce6682ed72905cd62a2d4bd9bad1bf9f7feb02a1b8e525bd94fa6"},
|
||||
"plug_crypto": {:hex, :plug_crypto, "1.2.5", "918772575e48e81e455818229bf719d4ab4181fcbf7f85b68a35620f78d89ced", [:mix], [], "hexpm", "26549a1d6345e2172eb1c233866756ae44a9609bd33ee6f99147ab3fd87fd842"},
|
||||
"postgrex": {:hex, :postgrex, "0.16.5", "fcc4035cc90e23933c5d69a9cd686e329469446ef7abba2cf70f08e2c4b69810", [:mix], [{:connection, "~> 1.1", [hex: :connection, repo: "hexpm", optional: false]}, {:db_connection, "~> 2.1", [hex: :db_connection, repo: "hexpm", optional: false]}, {:decimal, "~> 1.5 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:table, "~> 0.1.0", [hex: :table, repo: "hexpm", optional: true]}], "hexpm", "edead639dc6e882618c01d8fc891214c481ab9a3788dfe38dd5e37fd1d5fb2e8"},
|
||||
"qex": {:hex, :qex, "0.5.1", "0d82c0f008551d24fffb99d97f8299afcb8ea9cf99582b770bd004ed5af63fd6", [:mix], [], "hexpm", "935a39fdaf2445834b95951456559e9dc2063d0a055742c558a99987b38d6bab"},
|
||||
"rambo": {:hex, :rambo, "0.3.4", "8962ac3bd1a633ee9d0e8b44373c7913e3ce3d875b4151dcd060886092d2dce7", [:mix], [], "hexpm", "0cc54ed089fbbc84b65f4b8a774224ebfe60e5c80186fafc7910b3e379ad58f1"},
|
||||
"ranch": {:hex, :ranch, "1.8.0", "8c7a100a139fd57f17327b6413e4167ac559fbc04ca7448e9be9057311597a1d", [:make, :rebar3], [], "hexpm", "49fbcfd3682fab1f5d109351b61257676da1a2fdbe295904176d5e521a2ddfe5"},
|
||||
"ratio": {:hex, :ratio, "3.0.2", "60a5976872a4dc3d873ecc57eed1738589e99d1094834b9c935b118231297cfb", [:mix], [{:decimal, "~> 1.6 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}, {:numbers, "~> 5.2.0", [hex: :numbers, repo: "hexpm", optional: false]}], "hexpm", "3a13ed5a30ad0bfd7e4a86bf86d93d2b5a06f5904417d38d3f3ea6406cdfc7bb"},
|
||||
"req": {:hex, :req, "0.4.8", "2b754a3925ddbf4ad78c56f30208ced6aefe111a7ea07fb56c23dccc13eb87ae", [:mix], [{:brotli, "~> 0.3.1", [hex: :brotli, repo: "hexpm", optional: true]}, {:ezstd, "~> 1.0", [hex: :ezstd, repo: "hexpm", optional: true]}, {:finch, "~> 0.9", [hex: :finch, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}, {:mime, "~> 1.6 or ~> 2.0", [hex: :mime, repo: "hexpm", optional: false]}, {:nimble_csv, "~> 1.0", [hex: :nimble_csv, repo: "hexpm", optional: true]}, {:plug, "~> 1.0", [hex: :plug, repo: "hexpm", optional: true]}], "hexpm", "7146e51d52593bb7f20d00b5308a5d7d17d663d6e85cd071452b613a8277100c"},
|
||||
"shmex": {:hex, :shmex, "0.5.0", "7dc4fb1a8bd851085a652605d690bdd070628717864b442f53d3447326bcd3e8", [:mix], [{:bunch_native, "~> 0.5.0", [hex: :bunch_native, repo: "hexpm", optional: false]}, {:bundlex, "~> 1.0", [hex: :bundlex, repo: "hexpm", optional: false]}], "hexpm", "b67bb1e22734758397c84458dbb746519e28eac210423c267c7248e59fc97bdc"},
|
||||
"ssl_verify_fun": {:hex, :ssl_verify_fun, "1.1.7", "354c321cf377240c7b8716899e182ce4890c5938111a1296add3ec74cf1715df", [:make, :mix, :rebar3], [], "hexpm", "fe4c190e8f37401d30167c8c405eda19469f34577987c76dde613e838bbc67f8"},
|
||||
"stream_split": {:hex, :stream_split, "0.1.7", "2d3fd1fd21697da7f91926768d65f79409086052c9ec7ae593987388f52425f8", [:mix], [], "hexpm", "1dc072ff507a64404a0ad7af90df97096183fee8eeac7b300320cea7c4679147"},
|
||||
"sweet_xml": {:hex, :sweet_xml, "0.7.4", "a8b7e1ce7ecd775c7e8a65d501bc2cd933bff3a9c41ab763f5105688ef485d08", [:mix], [], "hexpm", "e7c4b0bdbf460c928234951def54fe87edf1a170f6896675443279e2dbeba167"},
|
||||
"swoosh": {:hex, :swoosh, "1.8.2", "af9a22ab2c0d20b266f61acca737fa11a121902de9466a39e91bacdce012101c", [:mix], [{:cowboy, "~> 1.1 or ~> 2.4", [hex: :cowboy, repo: "hexpm", optional: true]}, {:ex_aws, "~> 2.1", [hex: :ex_aws, repo: "hexpm", optional: true]}, {:finch, "~> 0.6", [hex: :finch, repo: "hexpm", optional: true]}, {:gen_smtp, "~> 0.13 or ~> 1.0", [hex: :gen_smtp, repo: "hexpm", optional: true]}, {:hackney, "~> 1.9", [hex: :hackney, repo: "hexpm", optional: true]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}, {:mail, "~> 0.2", [hex: :mail, repo: "hexpm", optional: true]}, {:mime, "~> 1.1 or ~> 2.0", [hex: :mime, repo: "hexpm", optional: false]}, {:plug_cowboy, ">= 1.0.0", [hex: :plug_cowboy, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4.2 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "d058ba750eafadb6c09a84a352c14c5d1eeeda6e84945fcc95785b7f3067b7db"},
|
||||
"tailwind": {:hex, :tailwind, "0.1.9", "25ba09d42f7bfabe170eb67683a76d6ec2061952dc9bd263a52a99ba3d24bd4d", [:mix], [{:castore, ">= 0.0.0", [hex: :castore, repo: "hexpm", optional: false]}], "hexpm", "9213f87709c458aaec313bb5f2df2b4d2cedc2b630e4ae821bf3c54c47a56d0b"},
|
||||
"telemetry": {:hex, :telemetry, "1.2.1", "68fdfe8d8f05a8428483a97d7aab2f268aaff24b49e0f599faa091f1d4e7f61c", [:rebar3], [], "hexpm", "dad9ce9d8effc621708f99eac538ef1cbe05d6a874dd741de2e689c47feafed5"},
|
||||
"telemetry_metrics": {:hex, :telemetry_metrics, "0.6.1", "315d9163a1d4660aedc3fee73f33f1d355dcc76c5c3ab3d59e76e3edf80eef1f", [:mix], [{:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "7be9e0871c41732c233be71e4be11b96e56177bf15dde64a8ac9ce72ac9834c6"},
|
||||
"telemetry_poller": {:hex, :telemetry_poller, "1.0.0", "db91bb424e07f2bb6e73926fcafbfcbcb295f0193e0a00e825e589a0a47e8453", [:rebar3], [{:telemetry, "~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "b3a24eafd66c3f42da30fc3ca7dda1e9d546c12250a2d60d7b81d264fbec4f6e"},
|
||||
"thumbnex": {:hex, :thumbnex, "0.5.0", "9f3c20c8c70d17e108710830e1495548b45c7433f30dc318f1075d76eb6f7f00", [:mix], [{:ffmpex, "~> 0.10.0", [hex: :ffmpex, repo: "hexpm", optional: false]}, {:mogrify, "~> 0.9.0", [hex: :mogrify, repo: "hexpm", optional: false]}], "hexpm", "a187948110e2de8dc2e9a73d5a3489398ba6a44d285293c174b6285717c5e5fc"},
|
||||
"timex": {:hex, :timex, "3.7.11", "bb95cb4eb1d06e27346325de506bcc6c30f9c6dea40d1ebe390b262fad1862d1", [:mix], [{:combine, "~> 0.10", [hex: :combine, repo: "hexpm", optional: false]}, {:gettext, "~> 0.20", [hex: :gettext, repo: "hexpm", optional: false]}, {:tzdata, "~> 1.1", [hex: :tzdata, repo: "hexpm", optional: false]}], "hexpm", "8b9024f7efbabaf9bd7aa04f65cf8dcd7c9818ca5737677c7b76acbc6a94d1aa"},
|
||||
"turbojpeg": {:hex, :turbojpeg, "0.4.0", "02616e44a70788e40bfc1fdbbdd8bc4e4615cd7d5ced5614b2aefb60a8acbda7", [:mix], [{:bundlex, "~> 1.4.0", [hex: :bundlex, repo: "hexpm", optional: false]}, {:membrane_core, "~> 1.0", [hex: :membrane_core, repo: "hexpm", optional: false]}, {:membrane_raw_video_format, "~> 0.3.0", [hex: :membrane_raw_video_format, repo: "hexpm", optional: false]}, {:unifex, "~> 1.1.0", [hex: :unifex, repo: "hexpm", optional: false]}], "hexpm", "53759d41f6e7d63805dc014db11b5c8e9274c5e67caea46d8b7f314dcdf51431"},
|
||||
"typed_struct": {:hex, :typed_struct, "0.3.0", "939789e3c1dca39d7170c87f729127469d1315dcf99fee8e152bb774b17e7ff7", [:mix], [], "hexpm", "c50bd5c3a61fe4e198a8504f939be3d3c85903b382bde4865579bc23111d1b6d"},
|
||||
"tzdata": {:hex, :tzdata, "1.1.1", "20c8043476dfda8504952d00adac41c6eda23912278add38edc140ae0c5bcc46", [:mix], [{:hackney, "~> 1.17", [hex: :hackney, repo: "hexpm", optional: false]}], "hexpm", "a69cec8352eafcd2e198dea28a34113b60fdc6cb57eb5ad65c10292a6ba89787"},
|
||||
"unicode_util_compat": {:hex, :unicode_util_compat, "0.7.0", "bc84380c9ab48177092f43ac89e4dfa2c6d62b40b8bd132b1059ecc7232f9a78", [:rebar3], [], "hexpm", "25eee6d67df61960cf6a794239566599b09e17e668d3700247bc498638152521"},
|
||||
"unifex": {:hex, :unifex, "1.1.0", "26b1bcb6c3b3454e1ea15f85b2e570aaa5b5c609566aa9f5c2e0a8b213379d6b", [:mix], [{:bunch, "~> 1.0", [hex: :bunch, repo: "hexpm", optional: false]}, {:bundlex, "~> 1.0", [hex: :bundlex, repo: "hexpm", optional: false]}, {:shmex, "~> 0.5.0", [hex: :shmex, repo: "hexpm", optional: false]}], "hexpm", "d8f47e9e3240301f5b20eec5792d1d4341e1a3a268d94f7204703b48da4aaa06"},
|
||||
"websock": {:hex, :websock, "0.5.0", "f6bbce90226121d62a0715bca7c986c5e43de0ccc9475d79c55381d1796368cc", [:mix], [], "hexpm", "b51ac706df8a7a48a2c622ee02d09d68be8c40418698ffa909d73ae207eb5fb8"},
|
||||
"websock_adapter": {:hex, :websock_adapter, "0.4.5", "30038a3715067f51a9580562c05a3a8d501126030336ffc6edb53bf57d6d2d26", [:mix], [{:bandit, "~> 0.6", [hex: :bandit, repo: "hexpm", optional: true]}, {:plug, "~> 1.14", [hex: :plug, repo: "hexpm", optional: false]}, {:plug_cowboy, "~> 2.6", [hex: :plug_cowboy, repo: "hexpm", optional: true]}, {:websock, "~> 0.4", [hex: :websock, repo: "hexpm", optional: false]}], "hexpm", "1d9812dc7e703c205049426fd4fe0852a247a825f91b099e53dc96f68bafe4c8"},
|
||||
"zarex": {:hex, :zarex, "1.0.5", "58239e3ee5d75f343262bb4df5cf466555a1c689f920e5d3651a9333972f7c7e", [:mix], [], "hexpm", "9fb72ef0567c2b2742f5119a1ba8a24a2fabb21b8d09820aefbf3e592fa9a46a"},
|
||||
}
|
97
priv/gettext/en/LC_MESSAGES/errors.po
Normal file
97
priv/gettext/en/LC_MESSAGES/errors.po
Normal file
@ -0,0 +1,97 @@
|
||||
## `msgid`s in this file come from POT (.pot) files.
|
||||
##
|
||||
## Do not add, change, or remove `msgid`s manually here as
|
||||
## they're tied to the ones in the corresponding POT file
|
||||
## (with the same domain).
|
||||
##
|
||||
## Use `mix gettext.extract --merge` or `mix gettext.merge`
|
||||
## to merge POT files into PO files.
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Language: en\n"
|
||||
|
||||
## From Ecto.Changeset.cast/4
|
||||
msgid "can't be blank"
|
||||
msgstr ""
|
||||
|
||||
## From Ecto.Changeset.unique_constraint/3
|
||||
msgid "has already been taken"
|
||||
msgstr ""
|
||||
|
||||
## From Ecto.Changeset.put_change/3
|
||||
msgid "is invalid"
|
||||
msgstr ""
|
||||
|
||||
## From Ecto.Changeset.validate_acceptance/3
|
||||
msgid "must be accepted"
|
||||
msgstr ""
|
||||
|
||||
## From Ecto.Changeset.validate_format/3
|
||||
msgid "has invalid format"
|
||||
msgstr ""
|
||||
|
||||
## From Ecto.Changeset.validate_subset/3
|
||||
msgid "has an invalid entry"
|
||||
msgstr ""
|
||||
|
||||
## From Ecto.Changeset.validate_exclusion/3
|
||||
msgid "is reserved"
|
||||
msgstr ""
|
||||
|
||||
## From Ecto.Changeset.validate_confirmation/3
|
||||
msgid "does not match confirmation"
|
||||
msgstr ""
|
||||
|
||||
## From Ecto.Changeset.no_assoc_constraint/3
|
||||
msgid "is still associated with this entry"
|
||||
msgstr ""
|
||||
|
||||
msgid "are still associated with this entry"
|
||||
msgstr ""
|
||||
|
||||
## From Ecto.Changeset.validate_length/3
|
||||
msgid "should be %{count} character(s)"
|
||||
msgid_plural "should be %{count} character(s)"
|
||||
msgstr[0] ""
|
||||
msgstr[1] ""
|
||||
|
||||
msgid "should have %{count} item(s)"
|
||||
msgid_plural "should have %{count} item(s)"
|
||||
msgstr[0] ""
|
||||
msgstr[1] ""
|
||||
|
||||
msgid "should be at least %{count} character(s)"
|
||||
msgid_plural "should be at least %{count} character(s)"
|
||||
msgstr[0] ""
|
||||
msgstr[1] ""
|
||||
|
||||
msgid "should have at least %{count} item(s)"
|
||||
msgid_plural "should have at least %{count} item(s)"
|
||||
msgstr[0] ""
|
||||
msgstr[1] ""
|
||||
|
||||
msgid "should be at most %{count} character(s)"
|
||||
msgid_plural "should be at most %{count} character(s)"
|
||||
msgstr[0] ""
|
||||
msgstr[1] ""
|
||||
|
||||
msgid "should have at most %{count} item(s)"
|
||||
msgid_plural "should have at most %{count} item(s)"
|
||||
msgstr[0] ""
|
||||
msgstr[1] ""
|
||||
|
||||
## From Ecto.Changeset.validate_number/3
|
||||
msgid "must be less than %{number}"
|
||||
msgstr ""
|
||||
|
||||
msgid "must be greater than %{number}"
|
||||
msgstr ""
|
||||
|
||||
msgid "must be less than or equal to %{number}"
|
||||
msgstr ""
|
||||
|
||||
msgid "must be greater than or equal to %{number}"
|
||||
msgstr ""
|
||||
|
||||
msgid "must be equal to %{number}"
|
||||
msgstr ""
|
95
priv/gettext/errors.pot
Normal file
95
priv/gettext/errors.pot
Normal file
@ -0,0 +1,95 @@
|
||||
## This is a PO Template file.
|
||||
##
|
||||
## `msgid`s here are often extracted from source code.
|
||||
## Add new translations manually only if they're dynamic
|
||||
## translations that can't be statically extracted.
|
||||
##
|
||||
## Run `mix gettext.extract` to bring this file up to
|
||||
## date. Leave `msgstr`s empty as changing them here has no
|
||||
## effect: edit them in PO (`.po`) files instead.
|
||||
|
||||
## From Ecto.Changeset.cast/4
|
||||
msgid "can't be blank"
|
||||
msgstr ""
|
||||
|
||||
## From Ecto.Changeset.unique_constraint/3
|
||||
msgid "has already been taken"
|
||||
msgstr ""
|
||||
|
||||
## From Ecto.Changeset.put_change/3
|
||||
msgid "is invalid"
|
||||
msgstr ""
|
||||
|
||||
## From Ecto.Changeset.validate_acceptance/3
|
||||
msgid "must be accepted"
|
||||
msgstr ""
|
||||
|
||||
## From Ecto.Changeset.validate_format/3
|
||||
msgid "has invalid format"
|
||||
msgstr ""
|
||||
|
||||
## From Ecto.Changeset.validate_subset/3
|
||||
msgid "has an invalid entry"
|
||||
msgstr ""
|
||||
|
||||
## From Ecto.Changeset.validate_exclusion/3
|
||||
msgid "is reserved"
|
||||
msgstr ""
|
||||
|
||||
## From Ecto.Changeset.validate_confirmation/3
|
||||
msgid "does not match confirmation"
|
||||
msgstr ""
|
||||
|
||||
## From Ecto.Changeset.no_assoc_constraint/3
|
||||
msgid "is still associated with this entry"
|
||||
msgstr ""
|
||||
|
||||
msgid "are still associated with this entry"
|
||||
msgstr ""
|
||||
|
||||
## From Ecto.Changeset.validate_length/3
|
||||
msgid "should be %{count} character(s)"
|
||||
msgid_plural "should be %{count} character(s)"
|
||||
msgstr[0] ""
|
||||
msgstr[1] ""
|
||||
|
||||
msgid "should have %{count} item(s)"
|
||||
msgid_plural "should have %{count} item(s)"
|
||||
msgstr[0] ""
|
||||
msgstr[1] ""
|
||||
|
||||
msgid "should be at least %{count} character(s)"
|
||||
msgid_plural "should be at least %{count} character(s)"
|
||||
msgstr[0] ""
|
||||
msgstr[1] ""
|
||||
|
||||
msgid "should have at least %{count} item(s)"
|
||||
msgid_plural "should have at least %{count} item(s)"
|
||||
msgstr[0] ""
|
||||
msgstr[1] ""
|
||||
|
||||
msgid "should be at most %{count} character(s)"
|
||||
msgid_plural "should be at most %{count} character(s)"
|
||||
msgstr[0] ""
|
||||
msgstr[1] ""
|
||||
|
||||
msgid "should have at most %{count} item(s)"
|
||||
msgid_plural "should have at most %{count} item(s)"
|
||||
msgstr[0] ""
|
||||
msgstr[1] ""
|
||||
|
||||
## From Ecto.Changeset.validate_number/3
|
||||
msgid "must be less than %{number}"
|
||||
msgstr ""
|
||||
|
||||
msgid "must be greater than %{number}"
|
||||
msgstr ""
|
||||
|
||||
msgid "must be less than or equal to %{number}"
|
||||
msgstr ""
|
||||
|
||||
msgid "must be greater than or equal to %{number}"
|
||||
msgstr ""
|
||||
|
||||
msgid "must be equal to %{number}"
|
||||
msgstr ""
|
4
priv/repo/migrations/.formatter.exs
Normal file
4
priv/repo/migrations/.formatter.exs
Normal file
@ -0,0 +1,4 @@
|
||||
[
|
||||
import_deps: [:ecto_sql],
|
||||
inputs: ["*.exs"]
|
||||
]
|
13
priv/repo/migrations/20240229191000_init_oban.exs
Normal file
13
priv/repo/migrations/20240229191000_init_oban.exs
Normal file
@ -0,0 +1,13 @@
|
||||
defmodule MyApp.Repo.Migrations.InitOban do
|
||||
use Ecto.Migration
|
||||
|
||||
def up do
|
||||
Oban.Migration.up(version: 11)
|
||||
end
|
||||
|
||||
# We specify `version: 1` in `down`, ensuring that we'll roll all the way back down if
|
||||
# necessary, regardless of which version we've migrated `up` to.
|
||||
def down do
|
||||
Oban.Migration.down(version: 1)
|
||||
end
|
||||
end
|
72
priv/repo/migrations/20240229191100_init_core.exs
Normal file
72
priv/repo/migrations/20240229191100_init_core.exs
Normal file
@ -0,0 +1,72 @@
|
||||
defmodule Algora.Repo.Migrations.InitCore do
|
||||
use Ecto.Migration
|
||||
|
||||
def change do
|
||||
execute "CREATE EXTENSION IF NOT EXISTS citext", ""
|
||||
|
||||
create table(:users) do
|
||||
add :email, :citext, null: false
|
||||
add :name, :string
|
||||
add :handle, :citext, null: false
|
||||
add :channel_tagline, :string
|
||||
add :avatar_url, :string
|
||||
add :external_homepage_url, :string
|
||||
add :videos_count, :integer, null: false, default: 0
|
||||
add :is_live, :boolean, null: false, default: false
|
||||
add :stream_key, :string
|
||||
add :visibility, :integer, null: false, default: 1
|
||||
add :bounties_count, :integer
|
||||
add :tech, :map
|
||||
add :orgs_contributed, :map
|
||||
|
||||
timestamps()
|
||||
end
|
||||
|
||||
create unique_index(:users, [:email])
|
||||
create unique_index(:users, [:handle])
|
||||
|
||||
create table(:identities) do
|
||||
add :user_id, references(:users, on_delete: :delete_all), null: false
|
||||
add :provider, :string, null: false
|
||||
add :provider_token, :string, null: false
|
||||
add :provider_email, :string, null: false
|
||||
add :provider_login, :string, null: false
|
||||
add :provider_id, :string, null: false
|
||||
add :provider_meta, :map, default: "{}", null: false
|
||||
|
||||
timestamps()
|
||||
end
|
||||
|
||||
create index(:identities, [:user_id])
|
||||
create index(:identities, [:provider])
|
||||
create unique_index(:identities, [:user_id, :provider])
|
||||
|
||||
create table(:videos) do
|
||||
add :duration, :integer, default: 0, null: false
|
||||
add :title, :string, null: false
|
||||
add :type, :integer, null: false
|
||||
add :is_live, :boolean, null: false, default: false
|
||||
add :thumbnails_ready, :boolean, null: false, default: false
|
||||
add :url, :string, null: false
|
||||
add :url_root, :string
|
||||
add :uuid, :string
|
||||
add :visibility, :integer, null: false, default: 1
|
||||
add :user_id, references(:users, on_delete: :nothing)
|
||||
|
||||
timestamps()
|
||||
end
|
||||
|
||||
create index(:videos, [:user_id])
|
||||
|
||||
create table(:messages) do
|
||||
add :body, :text
|
||||
add :user_id, references(:users, on_delete: :nothing)
|
||||
add :video_id, references(:videos, on_delete: :nothing)
|
||||
|
||||
timestamps()
|
||||
end
|
||||
|
||||
create index(:messages, [:user_id])
|
||||
create index(:messages, [:video_id])
|
||||
end
|
||||
end
|
18
priv/repo/seeds.exs
Normal file
18
priv/repo/seeds.exs
Normal file
@ -0,0 +1,18 @@
|
||||
# Script for populating the database. You can run it as:
|
||||
#
|
||||
# mix run priv/repo/seeds.exs
|
||||
#
|
||||
# Inside the script, you can read and write to any of your
|
||||
# repositories directly:
|
||||
#
|
||||
# Algora.Repo.insert!(%Algora.SomeSchema{})
|
||||
#
|
||||
# We recommend using the bang functions (`insert!`, `update!`
|
||||
# and so on) as they will fail if something goes wrong.
|
||||
|
||||
# for i <- 1..200 do
|
||||
# filename = Ecto.UUID.generate()
|
||||
|
||||
# {:ok, _} =
|
||||
# Algora.Repo.insert(%Algora.Library.Video{})
|
||||
# end
|
BIN
priv/static/favicon.ico
Normal file
BIN
priv/static/favicon.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 15 KiB |
5
priv/static/robots.txt
Normal file
5
priv/static/robots.txt
Normal file
@ -0,0 +1,5 @@
|
||||
# See http://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file
|
||||
#
|
||||
# To ban all spiders from the entire site uncomment the next two lines:
|
||||
# User-agent: *
|
||||
# Disallow: /
|
3
rel/env.sh.eex
Normal file
3
rel/env.sh.eex
Normal file
@ -0,0 +1,3 @@
|
||||
ip=$(grep fly-local-6pn /etc/hosts | cut -f 1)
|
||||
export RELEASE_DISTRIBUTION=name
|
||||
export RELEASE_NODE=$FLY_APP_NAME@$ip
|
3
rel/overlays/bin/migrate
Executable file
3
rel/overlays/bin/migrate
Executable file
@ -0,0 +1,3 @@
|
||||
#!/bin/sh
|
||||
cd -P -- "$(dirname -- "$0")"
|
||||
exec ./algora eval Algora.Release.migrate
|
1
rel/overlays/bin/migrate.bat
Executable file
1
rel/overlays/bin/migrate.bat
Executable file
@ -0,0 +1 @@
|
||||
call "%~dp0\algora" eval Algora.Release.migrate
|
3
rel/overlays/bin/server
Executable file
3
rel/overlays/bin/server
Executable file
@ -0,0 +1,3 @@
|
||||
#!/bin/sh
|
||||
cd -P -- "$(dirname -- "$0")"
|
||||
PHX_SERVER=true exec ./algora start
|
2
rel/overlays/bin/server.bat
Executable file
2
rel/overlays/bin/server.bat
Executable file
@ -0,0 +1,2 @@
|
||||
set PHX_SERVER=true
|
||||
call "%~dp0\algora" start
|
Loading…
Reference in New Issue
Block a user