Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trigger Prod w Youtube PRs #19

Closed
wants to merge 30 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
fe58e27
Add route to show specific <chap, verse>
rtshkmr Dec 5, 2023
714834b
Add JS-hook for WebShare-API/clipboard-copy
rtshkmr Dec 6, 2023
3ea3a4f
Cleanups based on PR review suggestions
rtshkmr Dec 19, 2023
f5b2b05
Use external heex template for show_verse
rtshkmr Dec 19, 2023
ee769e9
Support the addition of meta tags in the html head
rtshkmr Dec 20, 2023
fbc0162
Add meta tags to other views in gita_live
rtshkmr Dec 20, 2023
6dfa835
Add image generation & routing
rtshkmr Dec 24, 2023
3a6e44b
Attempt minor fixes
rtshkmr Dec 24, 2023
d25475f
Navigate from chapter to individual verse
rtshkmr Dec 29, 2023
69da68f
Improve clipboard content
rtshkmr Dec 29, 2023
ea810ef
Add just-in-time image creation for og-images
rtshkmr Dec 30, 2023
733852c
enable 404 templates
Dec 30, 2023
49487aa
Consolidate Fallback Controller
Dec 30, 2023
8594bf3
Fix text
rtshkmr Dec 30, 2023
3239319
Add OgAdapter with filename encoder-decoder pair
rtshkmr Dec 31, 2023
6dbc7fb
Temporarily use atoms as text-id
rtshkmr Dec 31, 2023
6404adc
[sync] prod to quotation-enginge-v0 (#14)
rtshkmr Jan 2, 2024
38352c3
Hide issue template's helping words in dropdown.
rtshkmr Jan 2, 2024
05317c2
[WIP] Attempt @ YT Iframe Embed
rtshkmr Jan 3, 2024
cd8b297
Successfully use iframe embed
rtshkmr Jan 4, 2024
6b22a5c
Add v0 of quotation engine (#9)
rtshkmr Jan 6, 2024
64b1f24
Merge branch 'master' into ritesh/operation/#10-youtube-player
rtshkmr Jan 6, 2024
565a8ad
Add reference to obj via window.youtubePlayer
rtshkmr Jan 6, 2024
9315974
Add examples of interfacing w playr's playback fns
rtshkmr Jan 7, 2024
91e7c75
Add examples of playr's videoStats APIs
rtshkmr Jan 7, 2024
1b8f095
Add demonstration of using Floating UI (#20)
rtshkmr Jan 11, 2024
9bacc24
Merge branch 'master' into ritesh/operation/#10-youtube-player
rtshkmr Jan 12, 2024
726d114
Add basic version of a mini-player
rtshkmr Jan 13, 2024
1ea9f5a
Make improvements from code review
rtshkmr Jan 14, 2024
cc9ef5d
Cleanup code
rtshkmr Jan 14, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# This file excludes paths from the Docker build context.
#
# By default, Docker's build context includes all files (and folders) in the
# current directory. Even if a file isn't copied into the container it is still sent to
# the Docker daemon.
#
# There are multiple reasons to exclude files from the build context:
#
# 1. Prevent nested folders from being copied into the container (ex: exclude
# /assets/node_modules when copying /assets)
# 2. Reduce the size of the build context and improve build time (ex. /build, /deps, /doc)
# 3. Avoid sending files containing sensitive information
#
# More information on using .dockerignore is available here:
# https://docs.docker.com/engine/reference/builder/#dockerignore-file

.dockerignore

# Ignore git, but keep git HEAD and refs to access current commit hash if needed:
#
# $ cat .git/HEAD | awk '{print ".git/"$2}' | xargs cat
# d0b8727759e1e0e7aa3d41707d12376e373d5ecc
.git
!.git/HEAD
!.git/refs

# Common development/test artifacts
/cover/
/doc/
/test/
/tmp/
.elixir_ls

# Mix artifacts
/_build/
/deps/
*.ez

# Generated on crash by the VM
erl_crash.dump

# Static artifacts - These should be fetched and built inside the Docker image
/assets/node_modules/
/priv/static/assets/
/priv/static/cache_manifest.json
21 changes: 21 additions & 0 deletions .github/ISSUE_TEMPLATE/alchemy.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ assignees: ''

### Present Context

<details>
<summary>Helping words...</summary>

Where we collectively investigate and interrogate the problem space and iteratively scope our approach.

Breakdown to landmarks that communicate shared context we are working towards through 2-tiered task list, CRUD list elements as development unfolds.
Expand All @@ -25,8 +28,16 @@ Strike the scope of code that reveals the most about the problem/solution FIRST

```
---

</details>

### Groundwork

<details>
<summary> Helping words...</summary>



Introduce us to the problem space. Write out what you already know about the terrain you are the recce commander enriching us with details beyond the fog of war.

Where have you tried applying and encountered difficulties?
Expand All @@ -42,8 +53,15 @@ Emphasis on previous or current practice to discover what is ugly, missing, or u
INPUT UR ANSWER HERE
```
---


</details>


### Reflection

<details>
<summary> Helping words...</summary>
Where the eternal wheel returns back to practice and what we finally implemented is to be outlined. You are the historian or archivist bringing clarity to future-yous and us about your foray.

Emphasis on approaching timeless solutions for well-defined problem space through distillation by decanting that which is un-needed and abstracting that which is essential to approaching the problem space.
Expand All @@ -54,4 +72,7 @@ Add any reflections and internal links to future potential and blindsides.
INPUT UR ANSWER HERE
```

</details>



67 changes: 67 additions & 0 deletions .github/workflows/prod.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: Prod in Flight

on:
pull_request:
branches: [ prod ]

jobs:
test:

name: Build and Run Mix Test
runs-on: ubuntu-latest
services:
postgres:
image: postgres:latest
env:
POSTGRES_DB: postgres
POSTGRES_PASSWORD: root
POSTGRES_USER: postgres
ports:
- 5432:5432
# Set health checks to wait until postgres has started
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- uses: actions/checkout@v2
- name: Install dependecies for build
run: sudo apt-get install -y libncurses-dev libtinfo5
- name: Set up Elixir
uses: erlef/setup-elixir@885971a72ed1f9240973bd92ab57af8c1aa68f24
with:
elixir-version: '1.15.7' # Define the elixir version [required]
otp-version: '25' # Define the OTP version [required]
- name: Restore dependencies cache
uses: actions/cache@v2
with:
path: deps
key: ${{ runner.os }}-mix-${{ hashFiles('**/mix.lock') }}
restore-keys: ${{ runner.os }}-mix-
- name: Install dependencies
working-directory: ./
run: mix deps.get
- name: Run tests
env:
# use localhost for the host here because we are running the job on the VM.
# If we were running the job on in a container this would be postgres
POSTGRES_HOST: localhost
POSTGRES_PORT: ${{ job.services.postgres.ports[5432] }}
working-directory: ./
run: mix test


deploy:
needs: test
name: Build & Deploy to Fly
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: superfly/flyctl-actions@master
env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
FLY_APP: vyasa
with:
args: "deploy"
105 changes: 105 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
# 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-20230612-slim - for the release image
# - https://pkgs.org/ - resource for finding needed packages
# - Ex: hexpm/elixir:1.15.7-erlang-26.1.1-debian-bullseye-20230612-slim
#
ARG ELIXIR_VERSION=1.15.7
ARG OTP_VERSION=26.1.1
ARG DEBIAN_VERSION=bullseye-20230612-slim

ARG BUILDER_IMAGE="hexpm/elixir:${ELIXIR_VERSION}-erlang-${OTP_VERSION}-debian-${DEBIAN_VERSION}"
ARG RUNNER_IMAGE="debian:${DEBIAN_VERSION}"

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

COPY lib lib

COPY assets assets

# compile assets
RUN mix assets.deploy

# Compile the release
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 ca-certificates \
&& 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


# copies over font files, updates debian runner's font cache:
RUN echo "...syncing font file(s)"
COPY ./priv/static/fonts/gotu/* /usr/share/fonts/truetype/
RUN apt-get update && apt-get install -y fontconfig
RUN fc-cache -f -v
RUN echo "...[DONE] syncing font file(s)"

# set runner ENV
ENV MIX_ENV="prod"

# Only copy the final release from the build stage
COPY --from=builder --chown=nobody:root /app/_build/${MIX_ENV}/rel/vyasa ./

USER nobody

# If using an environment that doesn't automatically reap zombie processes, it is
# advised to add an init process such as tini via `apt-get install`
# above and adding an entrypoint. See https://github.com/krallin/tini for details
# ENTRYPOINT ["/tini", "--"]

CMD ["/app/bin/server"]
29 changes: 17 additions & 12 deletions assets/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,31 @@
//

// Include phoenix_html to handle method=PUT/DELETE in forms and buttons.
import "phoenix_html"
import "phoenix_html";
// Establish Phoenix Socket and LiveView configuration.
import {Socket} from "phoenix"
import {LiveSocket} from "phoenix_live_view"
import topbar from "../vendor/topbar"
import { Socket } from "phoenix";
import { LiveSocket } from "phoenix_live_view";
import topbar from "../vendor/topbar";
import Hooks from "./hooks";

let csrfToken = document.querySelector("meta[name='csrf-token']").getAttribute("content")
let liveSocket = new LiveSocket("/live", Socket, {params: {_csrf_token: csrfToken}})
let csrfToken = document.querySelector("meta[name='csrf-token']").getAttribute(
"content",
);
let liveSocket = new LiveSocket("/live", Socket, {
params: { _csrf_token: csrfToken },
hooks: Hooks,
});

// Show progress bar on live navigation and form submits
topbar.config({barColors: {0: "#29d"}, shadowColor: "rgba(0, 0, 0, .3)"})
window.addEventListener("phx:page-loading-start", _info => topbar.show(300))
window.addEventListener("phx:page-loading-stop", _info => topbar.hide())
topbar.config({ barColors: { 0: "#29d" }, shadowColor: "rgba(0, 0, 0, .3)" });
window.addEventListener("phx:page-loading-start", (_info) => topbar.show(300));
window.addEventListener("phx:page-loading-stop", (_info) => topbar.hide());

// connect if there are any LiveViews on the page
liveSocket.connect()
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

window.liveSocket = liveSocket;
14 changes: 14 additions & 0 deletions assets/js/hooks/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import ShareQuoteButton from "./share_quote.js";
import {
RenderYouTubePlayer,
TriggerYouTubeFunction,
} from "./youtube_player.js";
import MiniPlayer from "./mini_player.js";

let Hooks = {};
Hooks.ShareQuoteButton = ShareQuoteButton;
Hooks.RenderYouTubePlayer = RenderYouTubePlayer;
Hooks.TriggerYouTubeFunction = TriggerYouTubeFunction;
Hooks.MiniPlayer = MiniPlayer;

export default Hooks;
Loading
Loading