Skip to content

Commit 194dde5

Browse files
committed
Add welcome screen after install
Signed-off-by: Andrew Welch <andrew@nystudio107.com>
1 parent 18f1e08 commit 194dde5

File tree

53 files changed

+8969
-24
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+8969
-24
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ If you have managed hosting, contact your sysadmin to get `ffmpeg` installed.
3636

3737
## Transcoder Overview
3838

39-
The Transcoder plugin allows you to take any video (local or remote), and transcode it into any size, bitrate, framerate, and save it out as a web-ready video in a variety of file formats.
39+
The Transcoder plugin allows you to transcode any video (local or remote) to any size, bitrate, framerate, and save it out as a web-ready video in a variety of file formats.
4040

4141
It can also transcode audio files to any bitrate & sample rate, to a variety of file formats. It can even extract audio tracks from video files.
4242

package.json

Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
{
2+
"name": "transcoder",
3+
"version": "1.0.0",
4+
"description": "Transcode video & audio files to various formats, and provide video thumbnails",
5+
"copyright": "nystudio107",
6+
"main": "index.js",
7+
"scripts": {
8+
"dev": "webpack --config webpack.dev.js --progress --hide-modules",
9+
"watch": "webpack --config webpack.dev.js --progress --watch --hide-modules",
10+
"build": "webpack --config webpack.prod.js"
11+
},
12+
"repository": {
13+
"type": "git",
14+
"url": "git+https://github.com/nystudio107/craft-transcoder.git"
15+
},
16+
"author": "andrew@nystudio107.com",
17+
"license": "proprietary",
18+
"bugs": {
19+
"url": "https://github.com/nystudio107/craft-transcoder/issues"
20+
},
21+
"homepage": "https://github.com/nystudio107/craft-transcoder",
22+
"paths": {
23+
"src": {
24+
"base": "./src/assetbundles/transcoder/src/",
25+
"js": "./src/assetbundles/transcoder/src/js/",
26+
"css": "./src/assetbundles/transcoder/src/css/"
27+
},
28+
"dist": {
29+
"base": "./src/assetbundles/transcoder/dist/",
30+
"public": "/cpresources/transcoder/",
31+
"clean": [
32+
"./js",
33+
"./css"
34+
]
35+
},
36+
"copyFiles": [
37+
],
38+
"manifest": {
39+
"basePath": "",
40+
"template": {
41+
"twigCss": "./src/templates/_src/include-css-module.twig",
42+
"twigModern": "./src/templates/_src/include-modern-module.twig",
43+
"twigLegacy": "./src/templates/_src/include-legacy-module.twig"
44+
},
45+
"filename": {
46+
"twigCss": "./src/templates/_includes/include-css-module.twig",
47+
"twigModern": "./src/templates/_includes/include-modern-module.twig",
48+
"twigLegacy": "./src/templates/_includes/include-legacy-module.twig"
49+
}
50+
},
51+
"templates": "./src/templates/"
52+
},
53+
"entries": {
54+
"transcoder": "Transcoder.js",
55+
"welcome": "Welcome.js"
56+
},
57+
"babelConfig": {
58+
"legacyBrowsers": [
59+
"> 1%",
60+
"last 2 versions",
61+
"Firefox ESR"
62+
],
63+
"modernBrowsers": [
64+
"last 2 Chrome versions",
65+
"not Chrome < 60",
66+
"last 2 Safari versions",
67+
"not Safari < 10.1",
68+
"last 2 iOS versions",
69+
"not iOS < 10.3",
70+
"last 2 Firefox versions",
71+
"not Firefox < 54",
72+
"last 2 Edge versions",
73+
"not Edge < 15"
74+
]
75+
},
76+
"purgeCss": {
77+
"paths": [
78+
"./src/templates/**/*.{twig,html}"
79+
],
80+
"whitelist": [
81+
"../css/components.pcss"
82+
],
83+
"whitelistPatterns": [],
84+
"extensions": [
85+
"html",
86+
"js",
87+
"twig",
88+
"vue"
89+
]
90+
},
91+
"urls": {},
92+
"vars": {
93+
"cssName": "transcoder.css",
94+
"jsName": "transcoder.js"
95+
},
96+
"devDependencies": {
97+
"autoprefixer": "^8.1.0",
98+
"babel-core": "^6.26.0",
99+
"babel-loader": "^7.1.4",
100+
"babel-plugin-syntax-dynamic-import": "^6.18.0",
101+
"babel-plugin-transform-runtime": "^6.23.0",
102+
"babel-polyfill": "^6.26.0",
103+
"babel-preset-env": "^1.7.0",
104+
"clean-webpack-plugin": "^0.1.19",
105+
"copy-webpack-plugin": "^4.5.1",
106+
"css-loader": "^0.28.10",
107+
"cssnano": "^3.10.0",
108+
"extract-text-webpack-plugin": "^4.0.0-beta.0",
109+
"file-loader": "^1.1.11",
110+
"git-rev-sync": "^1.10.0",
111+
"glob-all": "^3.1.0",
112+
"html-webpack-plugin": "^3.2.0",
113+
"ignore-loader": "^0.1.2",
114+
"mini-css-extract-plugin": "^0.4.0",
115+
"moment": "^2.21.0",
116+
"optimize-css-assets-webpack-plugin": "^4.0.3",
117+
"postcss": "^6.0.19",
118+
"postcss-extend": "^1.0.5",
119+
"postcss-hexrgba": "^1.0.0",
120+
"postcss-import": "^11.1.0",
121+
"postcss-loader": "^2.1.1",
122+
"postcss-nested": "^3.0.0",
123+
"postcss-nested-ancestors": "^1.0.0",
124+
"postcss-simple-vars": "^4.1.0",
125+
"purgecss-webpack-plugin": "^1.2.0",
126+
"purgecss-whitelister": "^2.1.0",
127+
"resolve-url-loader": "^2.3.0",
128+
"tailwindcss": "^0.6.4",
129+
"uglifyjs-webpack-plugin": "^1.2.7",
130+
"vue-loader": "^15.3.0",
131+
"vue-style-loader": "^4.1.2",
132+
"vue-template-compiler": "^2.5.17",
133+
"webpack": "^4.1.1",
134+
"webpack-bundle-analyzer": "^2.13.1",
135+
"webpack-cli": "^2.0.11",
136+
"webpack-manifest-plugin": "^2.0.3",
137+
"webpack-merge": "^4.1.2"
138+
},
139+
"dependencies": {
140+
"vue": "^2.5.17",
141+
"vue-confetti": "^0.4.1"
142+
}
143+
}

postcss.config.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
module.exports = {
2+
plugins: [
3+
require('postcss-import'),
4+
require('postcss-extend'),
5+
require('postcss-simple-vars'),
6+
require('postcss-nested-ancestors'),
7+
require('postcss-nested'),
8+
require('postcss-hexrgba'),
9+
require('autoprefixer'),
10+
require('tailwindcss')('./tailwind.config.js')
11+
]
12+
}

src/Transcoder.php

Lines changed: 91 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,16 @@
1919
use craft\console\Application as ConsoleApplication;
2020
use craft\elements\Asset;
2121
use craft\events\AssetThumbEvent;
22+
use craft\events\PluginEvent;
23+
use craft\events\RegisterUrlRulesEvent;
2224
use craft\events\RegisterCacheOptionsEvent;
2325
use craft\helpers\Assets as AssetsHelper;
26+
use craft\helpers\UrlHelper;
2427
use craft\services\Assets;
28+
use craft\services\Plugins;
2529
use craft\utilities\ClearCaches;
2630
use craft\web\twig\variables\CraftVariable;
31+
use craft\web\UrlManager;
2732

2833
use yii\base\Event;
2934

@@ -56,12 +61,41 @@ public function init()
5661
{
5762
parent::init();
5863
self::$plugin = $this;
64+
// Handle console commands
65+
if (Craft::$app instanceof ConsoleApplication) {
66+
$this->controllerNamespace = 'nystudio107\transcoder\console\controllers';
67+
}
68+
// Add in our Craft components
69+
$this->addComponents();
70+
// Install our global event handlers
71+
$this->installEventHandlers();
72+
// We've loaded!
73+
Craft::info(
74+
Craft::t(
75+
'transcoder',
76+
'{name} plugin loaded',
77+
['name' => $this->name]
78+
),
79+
__METHOD__
80+
);
81+
}
82+
83+
// Protected Methods
84+
// =========================================================================
5985

60-
// Load plugin components
61-
$this->setComponents([
62-
'get' => Transcode::class
63-
]);
86+
/**
87+
* @inheritdoc
88+
*/
89+
protected function createSettingsModel()
90+
{
91+
return new Settings();
92+
}
6493

94+
/**
95+
* Add in our Craft components
96+
*/
97+
protected function addComponents()
98+
{
6599
// Register our variables
66100
Event::on(
67101
CraftVariable::class,
@@ -72,7 +106,13 @@ function (Event $event) {
72106
$variable->set('transcoder', TranscoderVariable::class);
73107
}
74108
);
109+
}
75110

111+
/**
112+
* Install our event handlers
113+
*/
114+
protected function installEventHandlers()
115+
{
76116
// Handler: Assets::EVENT_GET_THUMB_PATH
77117
Event::on(
78118
Assets::class,
@@ -89,12 +129,6 @@ function (AssetThumbEvent $event) {
89129
}
90130
}
91131
);
92-
93-
// Handle console commands
94-
if (Craft::$app instanceof ConsoleApplication) {
95-
$this->controllerNamespace = 'nystudio107\transcoder\console\controllers';
96-
}
97-
98132
// Add the Transcode path to the list of things the Clear Caches tool can delete.
99133
Event::on(
100134
ClearCaches::class,
@@ -107,25 +141,59 @@ function (RegisterCacheOptionsEvent $event) {
107141
];
108142
}
109143
);
110-
111-
Craft::info(
112-
Craft::t(
113-
'transcoder',
114-
'{name} plugin loaded',
115-
['name' => $this->name]
116-
),
117-
__METHOD__
144+
// Handler: Plugins::EVENT_AFTER_INSTALL_PLUGIN
145+
Event::on(
146+
Plugins::class,
147+
Plugins::EVENT_AFTER_INSTALL_PLUGIN,
148+
function (PluginEvent $event) {
149+
if ($event->plugin === $this) {
150+
$request = Craft::$app->getRequest();
151+
if ($request->isCpRequest) {
152+
Craft::$app->getResponse()->redirect(UrlHelper::cpUrl('transcoder/welcome'))->send();
153+
}
154+
}
155+
}
118156
);
157+
$request = Craft::$app->getRequest();
158+
// Install only for non-console site requests
159+
if ($request->getIsSiteRequest() && !$request->getIsConsoleRequest()) {
160+
$this->installSiteEventListeners();
161+
}
119162
}
120163

121-
// Protected Methods
122-
// =========================================================================
164+
/**
165+
* Install site event listeners for site requests only
166+
*/
167+
protected function installSiteEventListeners()
168+
{
169+
// Handler: UrlManager::EVENT_REGISTER_SITE_URL_RULES
170+
Event::on(
171+
UrlManager::class,
172+
UrlManager::EVENT_REGISTER_SITE_URL_RULES,
173+
function (RegisterUrlRulesEvent $event) {
174+
Craft::debug(
175+
'UrlManager::EVENT_REGISTER_SITE_URL_RULES',
176+
__METHOD__
177+
);
178+
// Register our AdminCP routes
179+
$event->rules = array_merge(
180+
$event->rules,
181+
$this->customFrontendRoutes()
182+
);
183+
}
184+
);
185+
}
123186

124187
/**
125-
* @inheritdoc
188+
* Return the custom frontend routes
189+
*
190+
* @return array
126191
*/
127-
protected function createSettingsModel()
192+
protected function customFrontendRoutes(): array
128193
{
129-
return new Settings();
194+
return [
195+
// Make webpack async bundle loading work out of published AssetBundles
196+
'/cpresources/transcoder/<resourceType:{handle}>/<fileName>' => 'transcoder/cp-nav/resource',
197+
];
130198
}
131199
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?php
2+
/**
3+
* Image Optimize plugin for Craft CMS 3.x
4+
*
5+
* Automatically optimize images after they've been transformed
6+
*
7+
* @link https://nystudio107.com
8+
* @copyright Copyright (c) 2017 nystudio107
9+
*/
10+
11+
namespace nystudio107\transcoder\assetbundles\transcoder;
12+
13+
use craft\web\AssetBundle;
14+
use craft\web\assets\cp\CpAsset;
15+
16+
/**
17+
* @author nystudio107
18+
* @package ImageOptimize
19+
* @since 1.2.0
20+
*/
21+
class TranscoderAsset extends AssetBundle
22+
{
23+
// Public Methods
24+
// =========================================================================
25+
26+
/**
27+
* @inheritdoc
28+
*/
29+
public function init()
30+
{
31+
$this->sourcePath = '@nystudio107/transcoder/assetbundles/transcoder/dist';
32+
33+
$this->depends = [
34+
CpAsset::class,
35+
];
36+
37+
parent::init();
38+
}
39+
}

0 commit comments

Comments
 (0)