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

Add frontend infrastructure for video player app #905

Merged
merged 7 commits into from
May 2, 2023
Merged

Conversation

robertknight
Copy link
Member

@robertknight robertknight commented Apr 28, 2023

This PR updates the frontend asset building and serving infrastructure in Via to align with how it works in lms and h, using the h-assets package, and then leverages that to set up a basic skeleton for a client-rendered video player app. Please pardon the large size of this PR, that's mostly due to changes in the npm/yarn lockfiles.

There is some existing Via-specific setup for serving PDF.js from files in via/static/js/ which I left as-is in this PR. In future it would make sense to unify these two static asset serving systems. PDF.js is a very large JS app however so some changes to our standard build tools might be required to support it.

Summary of changes:

  1. Set up frontend asset serving using the h-assets package that we also use in lms and h. The use of h-assets in this PR closely follows that of the lms repo.
  2. Add frontend build infrastructure using our standard tech stack (Rollup, Preact etc.). As part of this, the npm package manager was changed from npm to yarn (package-lock.json => yarn.lock), to match the client/lms repos
  3. Add a basic skeleton for a video player app in via/static/scripts/video_player using Preact. This doesn't have tests yet. Those will come after I add testing infrastructure in a subsequent PR.
  4. Add a Pyramid route for /video/{id} that serves the video player app. At some point in future we will need to support video providers other than YouTube. This might look something like /video/{provider}/{id}.

There are two pieces of frontend infrastructure that are not included in this PR:

I will add these in subsequent PRs.

Testing:

  1. Check out this PR and go to http://localhost:9083/video/{youtube_video_id} where youtube_video_id is a valid ID for any public YouTube video
  2. You should see an unstyled page that contains the Hypothesis client, a YouTube video player iframe and a couple of lines from a dummy transcript. Please ignore the lack of styling. The point of this PR is just to get basic infrastructure and plumbing in place.
  3. Kill Via's dev server, run make docker, then make run-docker, then repeat steps (1) and (2) to see that this all works in the Docker container as well.

@robertknight robertknight force-pushed the video-player branch 3 times, most recently from dcbeb35 to 16e3d32 Compare May 1, 2023 11:35
@robertknight robertknight marked this pull request as ready for review May 1, 2023 13:22
@@ -0,0 +1,32 @@
import type { Transcript } from './components/Transcript';
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This module follows the same pattern as frontend_apps/config.ts in the LMS repo, but is much simpler since we only have one app with very simple configuration.

videoId: string;

/** Set the current timestamp of the video. */
time: number;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This timestamp and the callbacks below are not actually used yet. They will be once more of the UI is fleshed out in subsequent PRs.

} from '@hypothesis/frontend-build';
import gulp from 'gulp';

// import tailwindConfig from './tailwind.config.mjs';
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The CSS and testing parts of this are not used yet. This will come in follow-up PRs.

@@ -1,3 +1,15 @@
# Stage 1: Build frontend assets
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The structure here matches the lms app's Dockerfile.

…keleton

Add the standard Hypothesis frontend build tooling for rich client apps (gulp,
Rollup, Preact etc.) and an initial skeleton of a video player app which uses
it.
The presence of the "dev" setting is assumed by the h-assets package.
The logic to set it up was taken from the lms app.
Enable Via to serve static frontend assets using the same setup as we use in the
h and lms apps.
Without this, the browser will try to parse the client's config script element
as JS when it is inserted into the page, causing a syntax error to be reported
in the console.
Copy link
Contributor

@acelaya acelaya left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍🏼

@robertknight robertknight merged commit 7f06637 into main May 2, 2023
@robertknight robertknight deleted the video-player branch May 2, 2023 12:44
seanh added a commit that referenced this pull request May 30, 2023
This is the result of running `make --always-make requirements` on
Linux. This fixes a couple of issues that were added to the requirements
files by #905:

1. #905 added a macOS-specific
   dependency ([appnope](https://pypi.org/project/appnope/)) to Via's
   `dev.txt`.

   This happened because the requirements files had been compiled on
   macOS for #905. Requirements
   files have to be compiled on Linux!

2. #905 removed the
   `--allow-unsafe` argument from the `pip-compile` command. This option
   should be used, see: https://github.com/jazzband/pip-tools#deprecations
seanh added a commit that referenced this pull request May 30, 2023
This is the result of running `make --always-make requirements` on
Linux. This fixes a couple of issues that were added to the requirements
files by #905:

1. #905 added a macOS-specific
   dependency ([appnope](https://pypi.org/project/appnope/)) to Via's
   `dev.txt`.

   This happened because the requirements files had been compiled on
   macOS for #905. Requirements
   files have to be compiled on Linux!

2. #905 removed the
   `--allow-unsafe` argument from the `pip-compile` command. This option
   should be used, see: https://github.com/jazzband/pip-tools#deprecations
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants