mirror of
https://github.com/LamGC/wp-asciiplayer.git
synced 2025-12-16 07:00:44 +00:00
Compare commits
14 Commits
v1.0.0
...
dependabot
| Author | SHA1 | Date | |
|---|---|---|---|
| 022558b9e3 | |||
| 40e2bf0733 | |||
| c059193e68 | |||
| ac193bf521 | |||
| bb93413eda | |||
|
93343e6958
|
|||
|
03b83a3f69
|
|||
|
a2ac3e6c05
|
|||
| 6bca884750 | |||
|
125fbc9c7c
|
|||
|
90acf62446
|
|||
|
79cb9dfbee
|
|||
| dc20a6f305 | |||
| 8d121b9028 |
11
.github/dependabot.yml
vendored
Normal file
11
.github/dependabot.yml
vendored
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
# To get started with Dependabot version updates, you'll need to specify which
|
||||||
|
# package ecosystems to update and where the package manifests are located.
|
||||||
|
# Please see the documentation for all configuration options:
|
||||||
|
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
|
||||||
|
|
||||||
|
version: 2
|
||||||
|
updates:
|
||||||
|
- package-ecosystem: "npm" # See documentation for possible values
|
||||||
|
directory: "/asciiplayer" # Location of package manifests
|
||||||
|
schedule:
|
||||||
|
interval: "daily"
|
||||||
@ -10,14 +10,14 @@ Author URI: https://blog.lamgc.moe
|
|||||||
License: GNU GENERAL PUBLIC LICENSE Version 3.0
|
License: GNU GENERAL PUBLIC LICENSE Version 3.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const PLUGIN_VERSION = "1.0.0";
|
const PLUGIN_VERSION = '1.0.1';
|
||||||
|
|
||||||
const ASCIIPLAYER_TAG = "asciiplayer";
|
const ASCIIPLAYER_TAG = 'asciiplayer';
|
||||||
|
|
||||||
const AP_OPTION_USE_LOCAL_RESOURCES = "ap_use_local_resources";
|
const AP_OPTION_USE_LOCAL_RESOURCES = 'ap_use_local_resources';
|
||||||
|
|
||||||
// 是否使用本地资源, 如果可以的话, 建议使用 CDN.
|
// 是否使用本地资源, 如果可以的话, 建议使用 CDN.
|
||||||
add_option(AP_OPTION_USE_LOCAL_RESOURCES, false);
|
add_option(AP_OPTION_USE_LOCAL_RESOURCES, false, $autoload = true);
|
||||||
|
|
||||||
function handle_asciiplayer_code($attr = [], string $content = null): string
|
function handle_asciiplayer_code($attr = [], string $content = null): string
|
||||||
{
|
{
|
||||||
@ -55,7 +55,8 @@ function is_assoc($arr): bool
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function set_default_value(array &$array, string $key, $value) {
|
function set_default_value(array &$array, string $key, $value)
|
||||||
|
{
|
||||||
if (!isset($array[$key])) {
|
if (!isset($array[$key])) {
|
||||||
$array[$key] = $value;
|
$array[$key] = $value;
|
||||||
}
|
}
|
||||||
@ -65,24 +66,35 @@ add_shortcode(ASCIIPLAYER_TAG, 'handle_asciiplayer_code');
|
|||||||
|
|
||||||
function load_scripts()
|
function load_scripts()
|
||||||
{
|
{
|
||||||
if (!is_single())
|
if (!is_single()) {
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
global $post;
|
global $post;
|
||||||
if( has_shortcode( $post->post_content, ASCIIPLAYER_TAG ) ) {
|
if (has_shortcode($post->post_content, ASCIIPLAYER_TAG)) {
|
||||||
wp_enqueue_script(
|
wp_enqueue_script(
|
||||||
'asciiplayer-adapter-js',
|
'asciiplayer-adapter-js',
|
||||||
plugin_dir_url(__FILE__) . '/asciiplayer/dist/bundle.js',
|
get_adapter_url() . '/dist/bundle.js',
|
||||||
array(),
|
array(),
|
||||||
PLUGIN_VERSION
|
PLUGIN_VERSION
|
||||||
);
|
);
|
||||||
wp_enqueue_style(
|
wp_enqueue_style(
|
||||||
'asciiplayer-adapter-css',
|
'asciiplayer-adapter-css',
|
||||||
plugin_dir_url(__FILE__) . '/asciiplayer/dist/styles.css',
|
get_adapter_url() . '/dist/styles.css',
|
||||||
array(),
|
array(),
|
||||||
PLUGIN_VERSION
|
PLUGIN_VERSION
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
add_action( 'wp_enqueue_scripts', 'load_scripts' );
|
|
||||||
|
add_action('wp_enqueue_scripts', 'load_scripts');
|
||||||
|
|
||||||
|
function get_adapter_url(): string
|
||||||
|
{
|
||||||
|
$use_local_resources = boolval(get_option(AP_OPTION_USE_LOCAL_RESOURCES, true));
|
||||||
|
$version = PLUGIN_VERSION;
|
||||||
|
if ($use_local_resources) {
|
||||||
|
return plugin_dir_url(__FILE__) . '/asciiplayer';
|
||||||
|
} else {
|
||||||
|
return "https://cdn.jsdelivr.net/npm/wp-asciiplayer-adapter@$version";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
679
asciiplayer/package-lock.json
generated
679
asciiplayer/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "wp-asciiplayer-adapter",
|
"name": "wp-asciiplayer-adapter",
|
||||||
"version": "1.0.0",
|
"version": "1.0.1",
|
||||||
"description": "asciinema-player for wordpress.",
|
"description": "asciinema-player for wordpress.",
|
||||||
"main": "dist/bundle.js",
|
"main": "dist/bundle.js",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
@ -21,7 +21,7 @@
|
|||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"css-loader": "^6.8.1",
|
"css-loader": "^6.8.1",
|
||||||
"mini-css-extract-plugin": "^2.7.6",
|
"mini-css-extract-plugin": "^2.7.6",
|
||||||
"webpack": "^5.85.0",
|
"webpack": "^5.85.1",
|
||||||
"webpack-cli": "^5.1.3"
|
"webpack-cli": "^5.1.3"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,7 +3,7 @@ Contributors: lamgc
|
|||||||
Tags: asciicast, asciiplayer, asciinema, ascii
|
Tags: asciicast, asciiplayer, asciinema, ascii
|
||||||
Requires at least: 5.2
|
Requires at least: 5.2
|
||||||
Tested up to: 6.2
|
Tested up to: 6.2
|
||||||
Stable tag: 1.0.0
|
Stable tag: 1.0.1
|
||||||
Requires PHP: 7.4
|
Requires PHP: 7.4
|
||||||
License: GPLv3
|
License: GPLv3
|
||||||
License URI: https://www.gnu.org/licenses/gpl-3.0.html
|
License URI: https://www.gnu.org/licenses/gpl-3.0.html
|
||||||
@ -12,6 +12,8 @@ Play Asciicast files in WordPress posts.
|
|||||||
|
|
||||||
== Description ==
|
== Description ==
|
||||||
|
|
||||||
|
You can find the source code for all versions on [Github](https://github.com/LamGC/wp-asciiplayer).
|
||||||
|
|
||||||
This plugin helps you insert Asciicast files into the post, better presenting terminal operations to readers.
|
This plugin helps you insert Asciicast files into the post, better presenting terminal operations to readers.
|
||||||
|
|
||||||
## Quick start
|
## Quick start
|
||||||
|
|||||||
Reference in New Issue
Block a user