mirror of
https://github.com/webmasterskaya/joomla-oauth-server.git
synced 2024-11-23 18:24:50 +03:00
Добавил поле "copy"
This commit is contained in:
parent
366ddf3534
commit
6ed72e5eb6
3
.gitignore
vendored
3
.gitignore
vendored
@ -5,11 +5,14 @@
|
||||
.vscode
|
||||
/tmp
|
||||
/.php-cs-fixer.cache
|
||||
/com_oauthserver/media
|
||||
|
||||
composer.phar
|
||||
com_oauthserver/administrator/vendor
|
||||
!com_oauthserver/administrator/vendor/.gitkeep
|
||||
|
||||
node_modules/
|
||||
|
||||
._*
|
||||
.Spotlight-V100
|
||||
.Trashes
|
||||
|
18
babel.config.es2017.json
Normal file
18
babel.config.es2017.json
Normal file
@ -0,0 +1,18 @@
|
||||
{
|
||||
"presets": [
|
||||
[
|
||||
"@babel/preset-env",
|
||||
{
|
||||
"targets": {
|
||||
"browsers": [
|
||||
"> 1%",
|
||||
"not ie 11",
|
||||
"not op_mini all"
|
||||
]
|
||||
},
|
||||
"bugfixes": true,
|
||||
"loose": true
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
17
babel.config.es5.json
Normal file
17
babel.config.es5.json
Normal file
@ -0,0 +1,17 @@
|
||||
{
|
||||
"presets": [
|
||||
[
|
||||
"@babel/preset-env",
|
||||
{
|
||||
"corejs": "3.8",
|
||||
"useBuiltIns": "entry",
|
||||
"targets": {
|
||||
"ie": "11"
|
||||
},
|
||||
"loose": true,
|
||||
"bugfixes": false,
|
||||
"modules": false
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
32
build/src/com_oauthserver/joomla.asset.json
Normal file
32
build/src/com_oauthserver/joomla.asset.json
Normal file
@ -0,0 +1,32 @@
|
||||
{
|
||||
"$schema": "https://developer.joomla.org/schemas/json-schema/web_assets.json",
|
||||
"name": "com_oauthserver",
|
||||
"version": "version",
|
||||
"description": "Joomla CMS",
|
||||
"license": "MIT",
|
||||
"assets": [
|
||||
{
|
||||
"name": "com_oauthserver.field.copy.es5",
|
||||
"type": "script",
|
||||
"uri": "com_oauthserver/field-copy-es5.min.js",
|
||||
"dependencies": [
|
||||
"core"
|
||||
],
|
||||
"attributes": {
|
||||
"nomodule": true,
|
||||
"defer": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "com_oauthserver.field.copy",
|
||||
"type": "script",
|
||||
"uri": "com_oauthserver/field-copy.min.js",
|
||||
"dependencies": [
|
||||
"com_oauthserver.field.copy.es5"
|
||||
],
|
||||
"attributes": {
|
||||
"type": "module"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
56
build/src/com_oauthserver/js/field/copy.es6.js
Normal file
56
build/src/com_oauthserver/js/field/copy.es6.js
Normal file
@ -0,0 +1,56 @@
|
||||
/**
|
||||
* @copyright (c) 2024. Webmasterskaya. <https://webmasterskaya.xyz>
|
||||
* @license MIT; see LICENSE.txt
|
||||
*/
|
||||
|
||||
((document, Joomla) => {
|
||||
'use strict';
|
||||
|
||||
const copyToClipboardFallback = (input) => {
|
||||
input.focus();
|
||||
input.select();
|
||||
|
||||
try {
|
||||
const copy = document.execCommand('copy');
|
||||
if (copy) {
|
||||
Joomla.renderMessages({message: [Joomla.Text._('COM_OAUTHSERVER_FIELD_COPY_SUCCESS')]});
|
||||
} else {
|
||||
Joomla.renderMessages({error: [Joomla.Text._('COM_OAUTHSERVER_FIELD_COPY_FAIL')]});
|
||||
}
|
||||
} catch (err) {
|
||||
Joomla.renderMessages({error: [err]});
|
||||
}
|
||||
};
|
||||
|
||||
const copyToClipboard = () => {
|
||||
const buttons = document.querySelectorAll('[data-field-copy]');
|
||||
|
||||
[].forEach.call(buttons, (button) => {
|
||||
button.addEventListener('click', ({currentTarget}) => {
|
||||
const selector = currentTarget.getAttribute('data-field-copy')
|
||||
const input = selector ? document.querySelector(selector) : currentTarget.previousElementSibling;
|
||||
|
||||
if (!navigator.clipboard) {
|
||||
copyToClipboardFallback(input);
|
||||
return;
|
||||
}
|
||||
|
||||
navigator.clipboard.writeText(input.value).then(() => {
|
||||
Joomla.renderMessages({message: [Joomla.Text._('COM_OAUTHSERVER_FIELD_COPY_SUCCESS')]});
|
||||
}, () => {
|
||||
Joomla.renderMessages({error: [Joomla.Text._('COM_OAUTHSERVER_FIELD_COPY_FAIL')]});
|
||||
});
|
||||
});
|
||||
})
|
||||
|
||||
|
||||
};
|
||||
|
||||
const onBoot = () => {
|
||||
copyToClipboard();
|
||||
|
||||
document.removeEventListener('DOMContentLoaded', onBoot);
|
||||
};
|
||||
|
||||
document.addEventListener('DOMContentLoaded', onBoot);
|
||||
})(document, Joomla);
|
41
com_oauthserver/layouts/field/copy/text.php
Normal file
41
com_oauthserver/layouts/field/copy/text.php
Normal file
@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\Language\Text;
|
||||
|
||||
extract($displayData);
|
||||
|
||||
/**
|
||||
* Layout variables
|
||||
* -----------------
|
||||
* @var string $id DOM id of the field.
|
||||
* @var string $label Label of the field.
|
||||
* @var string $name Name of the input field.
|
||||
* @var string $value Value attribute of the field.
|
||||
*/
|
||||
|
||||
Text::script('ERROR');
|
||||
Text::script('MESSAGE');
|
||||
Text::script('COM_OAUTHSERVER_FIELD_COPY_SUCCESS');
|
||||
Text::script('COM_OAUTHSERVER_FIELD_COPY_FAIL');
|
||||
|
||||
Factory::getApplication()->getDocument()->getWebAssetManager()
|
||||
->useScript('com_oauthserver.field.copy');
|
||||
|
||||
?>
|
||||
<div class="input-group">
|
||||
<input
|
||||
type="text"
|
||||
class="form-control"
|
||||
name="<?php echo $name; ?>"
|
||||
id="<?php echo $id; ?>"
|
||||
readonly
|
||||
value="<?php echo htmlspecialchars($value, ENT_COMPAT, 'UTF-8'); ?>">
|
||||
<button
|
||||
class="btn btn-primary"
|
||||
type="button"
|
||||
data-field-copy="#<?php echo $id; ?>"
|
||||
title="<?php echo Text::_('COM_OAUTHSERVER_FIELD_COPY_DESC'); ?>"><?php echo Text::_('COM_OAUTHSERVER_FIELD_COPY'); ?></button>
|
||||
</div>
|
@ -1,68 +1,75 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<extension type="component" method="upgrade">
|
||||
<name>COM_OAUTHSERVER</name>
|
||||
<description>COM_OAUTHSERVER_DESCRIPTION</description>
|
||||
<author>Artem Vasilev</author>
|
||||
<authorEmail>kern.usr@gmial.com</authorEmail>
|
||||
<authorUrl>https://webmasterskaya.xyz</authorUrl>
|
||||
<creationDate>March 2024</creationDate>
|
||||
<copyright>Copyright (C) 2024 Webmasterskaya. All rights reserved.</copyright>
|
||||
<license>MIT; see LICENSE.txt</license>
|
||||
<version>RELEASE_VERSION</version>
|
||||
<namespace path="src">Webmasterskaya\Component\OauthServer</namespace>
|
||||
<install>
|
||||
<sql>
|
||||
<file driver="mysql" charset="utf8">sql/install.mysql.utf8.sql</file>
|
||||
</sql>
|
||||
</install>
|
||||
<uninstall>
|
||||
<sql>
|
||||
<file driver="mysql" charset="utf8">sql/uninstall.mysql.utf8.sql</file>
|
||||
</sql>
|
||||
</uninstall>
|
||||
<update>
|
||||
<schemas>
|
||||
<schemapath type="mysql">sql/updates/mysql</schemapath>
|
||||
</schemas>
|
||||
</update>
|
||||
<files folder="site">
|
||||
<folder>forms</folder>
|
||||
<folder>src</folder>
|
||||
<folder>tmpl</folder>
|
||||
</files>
|
||||
<languages folder="site">
|
||||
<language tag="en-GB">language/en-GB/en-GB.com_oauthserver.ini</language>
|
||||
<language tag="en-GB">language/en-GB/en-GB.com_oauthserver.sys.ini</language>
|
||||
<language tag="ru-RU">language/ru-RU/ru-RU.com_oauthserver.ini</language>
|
||||
<language tag="ru-RU">language/ru-RU/ru-RU.com_oauthserver.sys.ini</language>
|
||||
</languages>
|
||||
<administration>
|
||||
<menu>COM_OAUTHSERVER</menu>
|
||||
<submenu>
|
||||
<menu
|
||||
link="option=com_oauthserver"
|
||||
view="clients"
|
||||
img="class:clients"
|
||||
alt="Oauth Server/Clients"
|
||||
>
|
||||
com_oauthserver_clients
|
||||
</menu>
|
||||
</submenu>
|
||||
<files folder="administrator">
|
||||
<folder>forms</folder>
|
||||
<folder>services</folder>
|
||||
<folder>sql</folder>
|
||||
<folder>src</folder>
|
||||
<folder>tmpl</folder>
|
||||
<folder>vendor</folder>
|
||||
<filename>access.xml</filename>
|
||||
<filename>config.xml</filename>
|
||||
</files>
|
||||
<languages folder="admin">
|
||||
<language tag="en-GB">language/en-GB/en-GB.com_oauthserver.ini</language>
|
||||
<language tag="en-GB">language/en-GB/en-GB.com_oauthserver.sys.ini</language>
|
||||
<language tag="ru-RU">language/ru-RU/ru-RU.com_oauthserver.ini</language>
|
||||
<language tag="ru-RU">language/ru-RU/ru-RU.com_oauthserver.sys.ini</language>
|
||||
</languages>
|
||||
</administration>
|
||||
<name>COM_OAUTHSERVER</name>
|
||||
<description>COM_OAUTHSERVER_DESCRIPTION</description>
|
||||
<author>Artem Vasilev</author>
|
||||
<authorEmail>kern.usr@gmial.com</authorEmail>
|
||||
<authorUrl>https://webmasterskaya.xyz</authorUrl>
|
||||
<creationDate>March 2024</creationDate>
|
||||
<copyright>Copyright (C) 2024 Webmasterskaya. All rights reserved.</copyright>
|
||||
<license>MIT; see LICENSE.txt</license>
|
||||
<version>VERSION</version>
|
||||
<namespace path="src">Webmasterskaya\Component\OauthServer</namespace>
|
||||
<install>
|
||||
<sql>
|
||||
<file driver="mysql" charset="utf8">sql/install.mysql.utf8.sql</file>
|
||||
</sql>
|
||||
</install>
|
||||
<uninstall>
|
||||
<sql>
|
||||
<file driver="mysql" charset="utf8">sql/uninstall.mysql.utf8.sql</file>
|
||||
</sql>
|
||||
</uninstall>
|
||||
<update>
|
||||
<schemas>
|
||||
<schemapath type="mysql">sql/updates/mysql</schemapath>
|
||||
</schemas>
|
||||
</update>
|
||||
<files folder="site">
|
||||
<folder>forms</folder>
|
||||
<folder>src</folder>
|
||||
<folder>tmpl</folder>
|
||||
</files>
|
||||
<languages folder="site">
|
||||
<language tag="en-GB">language/en-GB/en-GB.com_oauthserver.ini</language>
|
||||
<language tag="en-GB">language/en-GB/en-GB.com_oauthserver.sys.ini</language>
|
||||
<language tag="ru-RU">language/ru-RU/ru-RU.com_oauthserver.ini</language>
|
||||
<language tag="ru-RU">language/ru-RU/ru-RU.com_oauthserver.sys.ini</language>
|
||||
</languages>
|
||||
<administration>
|
||||
<menu>COM_OAUTHSERVER</menu>
|
||||
<submenu>
|
||||
<menu
|
||||
link="option=com_oauthserver"
|
||||
view="clients"
|
||||
img="class:clients"
|
||||
alt="Oauth Server/Clients"
|
||||
>
|
||||
com_oauthserver_clients
|
||||
</menu>
|
||||
</submenu>
|
||||
<files folder="administrator">
|
||||
<folder>forms</folder>
|
||||
<folder>services</folder>
|
||||
<folder>sql</folder>
|
||||
<folder>src</folder>
|
||||
<folder>tmpl</folder>
|
||||
<folder>vendor</folder>
|
||||
<filename>access.xml</filename>
|
||||
<filename>config.xml</filename>
|
||||
</files>
|
||||
<languages folder="admin">
|
||||
<language tag="en-GB">language/en-GB/en-GB.com_oauthserver.ini</language>
|
||||
<language tag="en-GB">language/en-GB/en-GB.com_oauthserver.sys.ini</language>
|
||||
<language tag="ru-RU">language/ru-RU/ru-RU.com_oauthserver.ini</language>
|
||||
<language tag="ru-RU">language/ru-RU/ru-RU.com_oauthserver.sys.ini</language>
|
||||
</languages>
|
||||
</administration>
|
||||
<media destination="com_oauthserver" folder="media">
|
||||
<folder>js</folder>
|
||||
<filename>joomla.asset.json</filename>
|
||||
</media>
|
||||
<layouts destination="components/oauthserver" folder="layouts">
|
||||
<folder>field</folder>
|
||||
</layouts>
|
||||
</extension>
|
4610
package-lock.json
generated
Normal file
4610
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
35
package.json
Normal file
35
package.json
Normal file
@ -0,0 +1,35 @@
|
||||
{
|
||||
"name": "joomla-oauth-server",
|
||||
"version": "1.0.0",
|
||||
"description": "OAuth Server for Joomla",
|
||||
"scripts": {
|
||||
"clean": "rimraf com_oauthserver/media",
|
||||
"copy:asset": "cpy 'build/src/*/joomla.asset.json' . --rename=media/{{basename}}",
|
||||
"build:uncompressed:es5": "cross-env BABEL_CONFIG=babel.config.es5.json webpack",
|
||||
"build:compressed:es5": "cross-env BABEL_CONFIG=babel.config.es5.json NODE_ENV=production webpack",
|
||||
"build:es5": "npm run build:uncompressed:es5 && npm run build:compressed:es5",
|
||||
"build:uncompressed:es2017": "cross-env BABEL_CONFIG=babel.config.es2017.json webpack",
|
||||
"build:compressed:es2017": "cross-env BABEL_CONFIG=babel.config.es2017.json NODE_ENV=production webpack",
|
||||
"build:es2017": "npm run build:uncompressed:es2017 && npm run build:compressed:es2017",
|
||||
"build": "npm run clean && npm run build:es5 && npm run build:es2017 && npm run copy:asset",
|
||||
"install": "npm run build",
|
||||
"update": "npm run build"
|
||||
},
|
||||
"author": {
|
||||
"name": "Artem Vasilev",
|
||||
"email": "dev@webmasterskaya.xyz",
|
||||
"url": "https://webmasterskaya.xyz/"
|
||||
},
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.24.0",
|
||||
"@babel/preset-env": "^7.24.0",
|
||||
"babel-loader": "^9.1.3",
|
||||
"cpy-cli": "^5.0.0",
|
||||
"cross-env": "^7.0.3",
|
||||
"rimraf": "^5.0.5",
|
||||
"terser-webpack-plugin": "^5.3.10",
|
||||
"webpack": "^5.90.3",
|
||||
"webpack-cli": "^5.1.4"
|
||||
}
|
||||
}
|
0
pkg_oauthsever.xml
Normal file
0
pkg_oauthsever.xml
Normal file
64
webpack.config.js
Normal file
64
webpack.config.js
Normal file
@ -0,0 +1,64 @@
|
||||
const path = require('path');
|
||||
const babelConfig = require(`./${process.env.BABEL_CONFIG}`);
|
||||
|
||||
const production = process.env.NODE_ENV === 'production';
|
||||
const ES5 = process.env.BABEL_CONFIG.includes('es5');
|
||||
|
||||
const TerserPlugin = require('terser-webpack-plugin');
|
||||
|
||||
const publicPath = path.join(__dirname, '/com_oauthserver/media');
|
||||
const sourcePath = path.join(__dirname, '/build/src');
|
||||
|
||||
const entry = {
|
||||
"field/copy": {
|
||||
import: path.join(sourcePath, '/com_oauthserver/js/field/copy.es6'),
|
||||
filename: `js/field-copy${ES5 ? '-es5' : ''}${production ? '.min' : ''}.js`
|
||||
}
|
||||
}
|
||||
|
||||
const webpackConfig = {
|
||||
mode: production ? 'production' : 'development',
|
||||
output: {
|
||||
path: publicPath,
|
||||
},
|
||||
entry: entry,
|
||||
devtool: false,
|
||||
module: {
|
||||
rules: [
|
||||
{
|
||||
test: /\.(es6|js)$/,
|
||||
use: {
|
||||
loader: 'babel-loader',
|
||||
options: babelConfig
|
||||
},
|
||||
}
|
||||
]
|
||||
},
|
||||
plugins: [],
|
||||
optimization: {
|
||||
minimize: production,
|
||||
minimizer: production ? [
|
||||
new TerserPlugin({
|
||||
test: /\.js(\?.*)?$/i,
|
||||
parallel: true,
|
||||
terserOptions: {
|
||||
compress: {
|
||||
pure_getters: true,
|
||||
unsafe_comps: true,
|
||||
unsafe: true,
|
||||
passes: 2,
|
||||
keep_fargs: false,
|
||||
drop_console: true
|
||||
},
|
||||
output: {
|
||||
beautify: false,
|
||||
comments: false,
|
||||
},
|
||||
},
|
||||
extractComments: false,
|
||||
}),
|
||||
] : []
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = webpackConfig;
|
Loading…
Reference in New Issue
Block a user