Skip to content

Commit

Permalink
Merge branch 'release/1.0.12' into v1
Browse files Browse the repository at this point in the history
  • Loading branch information
khalwat committed Jan 4, 2025
2 parents 7db9eed + 131e256 commit 5f18bee
Show file tree
Hide file tree
Showing 24 changed files with 5,826 additions and 1,726 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/build-and-deploy-docs.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Build and Deploy Docs
env:
DOCS_DEST_DIR: /youtubeliveembed/v3/
DOCS_DEST_DIR: /youtubeliveembed/v1/
on:
push:
branches:
Expand All @@ -22,11 +22,11 @@ jobs:
strategy:
fail-fast: true
matrix:
node-version: [ 14.x ]
node-version: [ 20.x ]
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- run: npm ci
Expand All @@ -35,7 +35,7 @@ jobs:
- name: rsync deployments
uses: burnett01/[email protected]
with:
switches: -avzr
switches: -avzr --delete
path: ./dist/
remote_path: ${{ secrets.NYS_DOCS_ROOT }}${{ env.DOCS_DEST_DIR }}
remote_host: ${{ secrets.NYS_DEPLOY_REMOTE_HOST }}
Expand Down
42 changes: 42 additions & 0 deletions .github/workflows/code-analysis.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Code Analysis

on:
pull_request: null
push:
branches:
- develop
workflow_dispatch:
permissions:
contents: read
jobs:
code_analysis:
strategy:
fail-fast: false
matrix:
actions:
-
name: 'PHPStan'
run: composer phpstan
-
name: 'Coding Standards'
run: composer fix-cs
name: ${{ matrix.actions.name }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Cache Composer dependencies
uses: actions/cache@v4
with:
path: /tmp/composer-cache
key: ${{ runner.os }}-${{ hashFiles('**/composer.lock') }}
- name: Setup PHP
id: setup-php
uses: shivammathur/setup-php@v2
with:
php-version: 8.2
extensions: 'ctype,curl,dom,iconv,imagick,intl,json,mbstring,openssl,pcre,pdo,reflection,spl,zip'
ini-values: post_max_size=256M, max_execution_time=180, memory_limit=512M
tools: composer:v2
- name: Install Composer dependencies
run: composer install --no-interaction --no-ansi --no-progress
- run: ${{ matrix.actions.run }}
21 changes: 21 additions & 0 deletions .github/workflows/create-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Create Release
run-name: Create release for ${{ github.event.client_payload.version }}

on:
repository_dispatch:
types:
- craftcms/new-release

jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: ncipollo/release-action@v1
with:
body: ${{ github.event.client_payload.notes }}
makeLatest: ${{ github.event.client_payload.latest }}
name: ${{ github.event.client_payload.version }}
prerelease: ${{ github.event.client_payload.prerelease }}
tag: ${{ github.event.client_payload.tag }}
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# YouTube Live Embed Changelog

## 1.0.12 - 2025.01.04
### Added
* Add `phpstan` and `ecs` code linting
* Add `code-analysis.yaml` GitHub action

## 1.0.11 - 2023.04.19
### Changed
* Updated the docs to use VitePress `^1.0.0-alpha.29`
Expand Down
24 changes: 24 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
MAJOR_VERSION?=3
PLUGINDEV_PROJECT_DIR?=/Users/andrew/webdev/sites/plugindev/cms_v${MAJOR_VERSION}/
VENDOR?=nystudio107
PROJECT_PATH?=${VENDOR}/$(shell basename $(CURDIR))

.PHONY: dev docs release

# Start up the buildchain dev server
dev:
# Start up the docs dev server
docs:
${MAKE} -C docs/ dev
# Run code quality tools, tests, and build the buildchain & docs in preparation for a release
release: --code-quality --code-tests --buildchain-clean-build --docs-clean-build
# The internal targets used by the dev & release targets
--buildchain-clean-build:
--code-quality:
${MAKE} -C ${PLUGINDEV_PROJECT_DIR} -- ecs check vendor/${PROJECT_PATH}/src --fix
${MAKE} -C ${PLUGINDEV_PROJECT_DIR} -- phpstan analyze -c vendor/${PROJECT_PATH}/phpstan.neon
--code-tests:
--docs-clean-build:
${MAKE} -C docs/ clean
${MAKE} -C docs/ image-build
${MAKE} -C docs/ fix
12 changes: 11 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "nystudio107/craft-youtubeliveembed",
"description": "This plugin allows you to embed a YouTube live stream and/or live chat on your webpage",
"type": "craft-plugin",
"version": "1.0.11",
"version": "1.0.12",
"keywords": [
"craft",
"cms",
Expand All @@ -29,6 +29,16 @@
"require": {
"craftcms/cms": "^3.0.0"
},
"require-dev": {
"craftcms/ecs": "dev-main",
"craftcms/phpstan": "dev-main",
"craftcms/rector": "dev-main"
},
"scripts": {
"phpstan": "phpstan --ansi --memory-limit=1G",
"check-cs": "ecs check --ansi",
"fix-cs": "ecs check --fix --ansi"
},
"config": {
"allow-plugins": {
"craftcms/plugin-installer": true,
Expand Down
4 changes: 2 additions & 2 deletions docs/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
ARG TAG=14-alpine
ARG TAG=20-alpine
FROM node:$TAG

USER node
RUN npm install -g npm@^11.0.0

WORKDIR /app/

Expand Down
4 changes: 2 additions & 2 deletions docs/Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
MAJOR_VERSION?=3
TAG?=14-alpine
TAG?=20-alpine
CONTAINER?=$(shell basename $(dir $(CURDIR)))-v${MAJOR_VERSION}-docs
DOCS_DEV_PORT?=400${MAJOR_VERSION}
DOCS_DEST?=../../../sites/nystudio107/web/docs/code-field
DOCS_DEST?=../../../sites/nystudio107/web/docs/youtube-live-embed/v1
IMAGE_INFO=$(shell docker image inspect $(CONTAINER):$(TAG))
IMAGE_NAME=${CONTAINER}:${TAG}
DOCKER_RUN=docker container run --rm -it -v "${CURDIR}":/app
Expand Down
74 changes: 74 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# `youtube-live-embed` docs

This buildchain is a self-contained build system for the `youtube-live-embed` documentation.

## Overview

The buildchain uses [VitePress](https://vitepress.dev/) via a Docker container to facilitate writing the docs as [markdown](https://vitepress.dev/guide/markdown), linting them via [textlint](https://textlint.github.io/), building them as HTML files with bundled assets, and publishing them automatically via a [GitHub action](https://docs.github.com/en/actions).

It also uses a [Rollup](https://rollupjs.org/) [sitemap plugin](https://github.com/aminnairi/rollup-plugin-sitemap) to generate a `sitemap.xml` for the generated docs.

The markdown sources for the docs and assets are in the `docs/docs/` directory.

The built distribution docs are created via the `build-and-deploy-docs.yaml`

## Prerequisites

To run the buildchain for development purposes:

- You must have [Docker Desktop](https://www.docker.com/products/docker-desktop/) (or the equivalent) installed

## Commands

This buildchain uses `make` as an interface to the buildchain. The following commands are available from the `buildchain/` directory:

- `make image-build` - Build the Docker image & run `npm install`. This command must be run once before using the Docker container.
- `make dev` - Start Vite HMR dev server while writing/editing the docs. Click on the link displayed in the terminal to open the docs up
- `make lint` - Run `textlint` on the docs, reporting on any errors and warnings
- `make fix` - Run `textlint` on the docs, automatically fixing any errors, and reporting any warnings
- `make clean` - Remove `node_modules/` and `package-lock.json` to start clean (need to run `make image-build` after doing this, see below)
- `make npm XXX` - Run an `npm` command inside the container, e.g.: `make npm run lint` or `make npm install`
- `make ssh` - Open up a shell session into the buildchain Docker container
- `make build` - Do a local distribution build of the docs; normally not needed since they are built & deployed via GitHub action

## Docs versioning

Each major version of the plugin corresponds to a major version of Craft.

Each major version of the plugin has separate documentation that needs to be updated when changes span plugin versions.

The latest version of the docs that correspond to the latest version of the plugin is always the root of the docs tree, with older versions appearing in sub-directories:

```
│ index.html
├── v4
│ └── index.html
├── v3
│ └── index.html
```

The docs are entirely separate, but linked to eachother via a version menu, configured in the `docs/docs/.vitepress/config.ts` file.

## Algolia Docsearch

The docs uses [Algolia Docsearch](https://docsearch.algolia.com/) to index them, and allow for easy searching via a search field with auto-complete.

Algolia Docsearch is configured in the `docs/docs/.vitepress/config.ts` file.

## textlint

The buildchain uses [textlint](https://textlint.github.io/) to automatically fix errors on build, and also issue writing style warnings.

`textlint` automatically uses any rules added to the `docs/package.json` file, which can be overridden or customized via the `docs/.textlintrc.js` file.

See the [textlint docs](https://textlint.github.io/docs/getting-started.html) for details.

## Overriding environment variables

The `Makefile` contains sane defaults for most things, but you can override them via environment variables if you need to.

For instance, if you want to change the `DOCS_DEST` environment variable to change where `make build` builds the docs locally, you can set it before running any buildchain `make` commands:
```bash
env DOCS_DEST=../path/to/some/dir make build
```
...or use any other method for [setting environment variables](https://www.twilio.com/blog/how-to-set-environment-variables.html). This environment variable needs to be set in the shell where you run the buildchain's various `make` commands from, so setting it in your project's `.env` file won't work.
14 changes: 9 additions & 5 deletions docs/docs/.vitepress/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {defineConfig} from 'vitepress'
export default defineConfig({
title: 'YouTube Live Embed Plugin',
description: 'Documentation for the YouTube Live Embed plugin',
base: '/docs/youtubeliveembed/v3/',
base: '/docs/youtubeliveembed/v1/',
lang: 'en-US',
head: [
['meta', {content: 'https://github.com/nystudio107', property: 'og:see_also',}],
Expand All @@ -24,7 +24,10 @@ export default defineConfig({
algolia: {
appId: '9WVGU2S0Q9',
apiKey: 'f3e0e6146b913085e5b5f9fc8408d4a6',
indexName: 'nystudio107-youtubeliveembed'
indexName: 'nystudio107-youtubeliveembed',
searchParameters: {
facetFilters: ["version:v1"],
},
},
lastUpdatedText: 'Last Updated',
sidebar: [],
Expand All @@ -34,9 +37,10 @@ export default defineConfig({
{text: 'Changelog', link: 'https://nystudio107.com/plugins/youtube-live-embed/changelog'},
{text: 'Issues', link: 'https://github.com/nystudio107/craft-youtubeliveembed/issues'},
{
text: 'v3', items: [
{text: 'v4', link: 'https://nystudio107.com/docs/youtubeliveembed/'},
{text: 'v3', link: '/'},
text: 'v1', items: [
{text: 'v5', link: 'https://nystudio107.com/docs/youtubeliveembed/'},
{text: 'v4', link: 'https://nystudio107.com/docs/youtubeliveembed/v4/'},
{text: 'v1', link: '/'},
],
},
]
Expand Down
1 change: 0 additions & 1 deletion docs/docs/@types/sitemap-plugin.d.ts

This file was deleted.

16 changes: 8 additions & 8 deletions docs/docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# YouTube Live Embed plugin for Craft CMS

This plugin allows you to embed a YouTube live stream and/or live chat on your webpage
This plugin allows you to embed a YouTube live stream and/or live chat on your web page

Check warning on line 5 in docs/docs/index.md

View workflow job for this annotation

GitHub Actions / build (20.x)

Avoid using “and/or”

![Screenshot](./resources/img/plugin-logo.png)

Expand All @@ -28,7 +28,7 @@ You can also install YouTube Live Embed via the **Plugin Store** in the Craft Co

## YouTube Live Embed Overview

YouTube Live Embed allows you to embed a YouTube live stream and/or live chat on your webpage.
YouTube Live Embed allows you to embed a YouTube live stream and/or live chat on your web page.

Check warning on line 31 in docs/docs/index.md

View workflow job for this annotation

GitHub Actions / build (20.x)

Avoid using “and/or”

Both the live stream and the live stream chat are embedded as responsive `<iframe>` elements, that you can control the aspect ratio of should you so wish.

Check warning on line 33 in docs/docs/index.md

View workflow job for this annotation

GitHub Actions / build (20.x)

"are embedded" may be passive voice

Expand All @@ -44,22 +44,22 @@ You can also override this setting in the `config.php` or at runtime via Twig, s

You can see an example of YouTube Live Embed being used live on at [nystudio107.com/live](https://nystudio107.com/live).

Check warning on line 45 in docs/docs/index.md

View workflow job for this annotation

GitHub Actions / build (20.x)

"being used" may be passive voice

In order to embed a YouTube Live Stream on a website, you need:
To embed a YouTube Live Stream on a website, you need:
1. Live Streaming is enabled

Check warning on line 48 in docs/docs/index.md

View workflow job for this annotation

GitHub Actions / build (20.x)

"is enabled" may be passive voice
2. Embedding of Live Streaming is enabled

Check warning on line 49 in docs/docs/index.md

View workflow job for this annotation

GitHub Actions / build (20.x)

"is enabled" may be passive voice
3. Monetization is enabled

Check warning on line 50 in docs/docs/index.md

View workflow job for this annotation

GitHub Actions / build (20.x)

"is enabled" may be passive voice

You can find these on the [YouTube Features](https://www.youtube.com/features) page, and read more about it in the [Enable embedded live streams from YouTube](http://docs.crowdcast.io/other/enable-embedded-live-streams-from-youtube)

If you haven't satisfied the above requirements, when someone goes to play your live stream embedded on your website, they will see this message (you can test it with an Incognito browser):
If you havent satisfied the above requirements, when someone goes to play your live stream embedded on your website, they will see this message (you can test it with an Incognito browser):

```
Video unavailable
Watch this video on YouTube.
Playback on other websites has been disabled by the video owner.
```

N.B. That in order to enable Monetization, you must have a linked AdSense account. Just enabling monetization is enough, and ads must be enabled, but they will not appear in your videos unless you specifically enable them.
N.B. That to enable Monetization, you must have a linked AdSense account. Just enabling monetization is enough, and ads must be enabled, but they will not appear in your videos unless you specifically enable them.

Check warning on line 62 in docs/docs/index.md

View workflow job for this annotation

GitHub Actions / build (20.x)

"Just" can weaken meaning

Check warning on line 62 in docs/docs/index.md

View workflow job for this annotation

GitHub Actions / build (20.x)

"be enabled" may be passive voice

### Embedding a Live Stream Video

Expand Down Expand Up @@ -107,13 +107,13 @@ If you have a Google AMP page, you can use:

### Changing the Channel ID

By default, the YouTube Channel ID you specify in the plugin's settings will be used, but you can also change it dynamically via:
By default, the YouTube Channel ID you specify in the plugins settings will be used, but you can also change it dynamically via:

```twig
{% do craft.youtubelive.setChannelId(CHANNEL_ID) %}
```

This could be useful if you had a website where you had more than one streaming channel to contend with.
This could be useful if you had a site where you had more than one streaming channel to contend with.

If you do not know your YouTube Channel ID, [here is how to find it](https://support.google.com/youtube/answer/3250431?hl=en).

Expand All @@ -138,6 +138,6 @@ This keys off of the manual **Is Live** CP setting, since YouTube [removed the l

YouTube removed the `live_stats` endpoint, so the only way to do this now would be through the [Live Streaming API](https://developers.google.com/youtube/v3/live/docs/liveBroadcasts).

It's possible that future versions of the plugin will support that.
Its possible that future versions of the plugin will support that.

Brought to you by [nystudio107](https://nystudio107.com)
1 change: 0 additions & 1 deletion docs/docs/resources/img/nys-logo.svg

This file was deleted.

18 changes: 9 additions & 9 deletions docs/docs/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
import {defineConfig} from 'vite'
import SitemapPlugin from 'rollup-plugin-sitemap'
import { sitemap, Url as SitemapUrl } from '@aminnairi/rollup-plugin-sitemap'
import VitePressConfig from './.vitepress/config'
import {DefaultTheme} from "vitepress/types/default-theme";

const docsSiteBaseUrl = 'https://nystudio107.com'
const docsBaseUrl = new URL(VitePressConfig.base!, docsSiteBaseUrl).href.replace(/\/$/, '') + '/'
const siteMapRoutes = [{
path: '',
name: VitePressConfig.title
}]
const docsBaseUrl = new URL(VitePressConfig.base!, docsSiteBaseUrl).href.replace(/\/$/, '') + '/';
let siteMapUrls: SitemapUrl[] = [{
location: '',
lastModified: new Date(),
}];

// https://vitejs.dev/config/
export default defineConfig({
plugins: [
SitemapPlugin({
sitemap({
baseUrl: docsBaseUrl,
contentBase: './docs/.vitepress/dist',
routes: siteMapRoutes,
urls: siteMapUrls,
})
],
server: {
Expand Down
Loading

0 comments on commit 5f18bee

Please sign in to comment.