-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #35 from CaptainFact/staging
Release 0.8.17
- Loading branch information
Showing
43 changed files
with
298 additions
and
208 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,23 @@ | ||
.git | ||
.gitignore | ||
.gitlab-ci.yml | ||
.idea | ||
.travis.yml | ||
|
||
tmp | ||
erl_crash.dump | ||
*.ez | ||
|
||
# Elixir | ||
.elixir_ls | ||
_build | ||
deps | ||
|
||
# Project-specific | ||
rel/docker | ||
resources | ||
dev | ||
|
||
# Secrets | ||
apps/*/priv/secrets/* | ||
!apps/*/priv/secrets/.keep | ||
!apps/*/priv/secrets/.keep | ||
|
||
# File types | ||
tmp | ||
erl_crash.dump | ||
*.ez |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
FROM bitwalker/alpine-elixir:1.6.6 | ||
RUN apk add bash imagemagick curl gcc make libc-dev libgcc && rm -rf /var/cache/apk/* | ||
|
||
ENV HOME=/opt/app/ SHELL=/bin/bash MIX_ENV=prod | ||
WORKDIR /opt/build | ||
|
||
ARG APP | ||
|
||
# Cache dependencies | ||
COPY mix.exs mix.lock ./ | ||
COPY apps/captain_fact/mix.exs ./apps/captain_fact/ | ||
COPY apps/cf_atom_feed/mix.exs ./apps/cf_atom_feed/ | ||
COPY apps/cf_graphql/mix.exs ./apps/cf_graphql/ | ||
COPY apps/cf_opengraph/mix.exs ./apps/cf_opengraph/ | ||
COPY apps/cf_utils/mix.exs ./apps/cf_utils/ | ||
COPY apps/db/mix.exs ./apps/db/ | ||
RUN HEX_HTTP_CONCURRENCY=4 HEX_HTTP_TIMEOUT=180 mix deps.get | ||
|
||
COPY . . | ||
RUN mix release --name ${APP} --env=$MIX_ENV | ||
|
||
WORKDIR /opt/app | ||
RUN cp -R /opt/build/_build/$MIX_ENV/rel/${APP}/* /opt/app/ | ||
RUN rm -rf /opt/build | ||
RUN ln -s /opt/app/bin/${APP} bin/entrypoint | ||
|
||
EXPOSE 80 | ||
ENTRYPOINT ["./bin/entrypoint"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
apps/captain_fact/lib/captain_fact/videos/captions_fetcher.ex
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
defmodule CaptainFact.Videos.CaptionsFetcher do | ||
@moduledoc """ | ||
Fetch captions for videos. | ||
""" | ||
|
||
@callback fetch(String.t(), String.t()) :: | ||
{:ok, DB.Schema.VideoCaption.t()} | {:error, binary()} | ||
end |
17 changes: 17 additions & 0 deletions
17
apps/captain_fact/lib/captain_fact/videos/captions_fetcher_test.ex
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
defmodule CaptainFact.Videos.CaptionsFetcherTest do | ||
@moduledoc """ | ||
A mock for faking captions fetching requests. | ||
""" | ||
|
||
@behaviour CaptainFact.Videos.CaptionsFetcher | ||
|
||
@impl true | ||
def fetch(_provider_id, _locale) do | ||
captions = %DB.Schema.VideoCaption{ | ||
content: "__TEST-CONTENT__", | ||
format: "xml" | ||
} | ||
|
||
{:ok, captions} | ||
end | ||
end |
38 changes: 38 additions & 0 deletions
38
apps/captain_fact/lib/captain_fact/videos/captions_fetcher_youtube.ex
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
defmodule CaptainFact.Videos.CaptionsFetcherYoutube do | ||
@moduledoc """ | ||
A captions fetcher for YouTube. | ||
""" | ||
|
||
@behaviour CaptainFact.Videos.CaptionsFetcher | ||
|
||
@impl true | ||
def fetch(youtube_id, locale) do | ||
with {:ok, content} <- fetch_captions_content(youtube_id, locale) do | ||
captions = %DB.Schema.VideoCaption{ | ||
content: content, | ||
format: "xml" | ||
} | ||
|
||
{:ok, captions} | ||
end | ||
end | ||
|
||
defp fetch_captions_content(video_id, locale) do | ||
case HTTPoison.get("http://video.google.com/timedtext?lang=#{locale}&v=#{video_id}") do | ||
{:ok, %HTTPoison.Response{status_code: 200, body: ""}} -> | ||
{:error, :not_found} | ||
|
||
{:ok, %HTTPoison.Response{status_code: 200, body: body}} -> | ||
{:ok, body} | ||
|
||
{:ok, %HTTPoison.Response{status_code: 404}} -> | ||
{:error, :not_found} | ||
|
||
{:ok, %HTTPoison.Response{status_code: _}} -> | ||
{:error, :unknown} | ||
|
||
{:error, %HTTPoison.Error{reason: reason}} -> | ||
{:error, reason} | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,12 @@ | ||
defmodule CaptainFactWeb.CORS do | ||
@spec check_origin(String.t()) :: boolean() | ||
def check_origin(origin) do | ||
origin in Application.get_env(:captain_fact, :cors_origins) | ||
case Application.get_env(:captain_fact, :cors_origins) do | ||
"*" -> | ||
true | ||
|
||
origins -> | ||
origin in origins | ||
end | ||
end | ||
end |
Oops, something went wrong.