From f6f9beb7865cb6e2ca4217b70bf2e7116408b6ac Mon Sep 17 00:00:00 2001 From: Boaz Poolman Date: Fri, 19 Mar 2021 19:04:22 +0100 Subject: [PATCH] Initial commit --- .editorconfig | 7 ++ .gitattributes | 103 ++++++++++++++++++++++ .gitignore | 10 +++ README.md | 3 + admin/src/containers/App/index.js | 27 ++++++ admin/src/containers/HomePage/index.js | 20 +++++ admin/src/containers/Initializer/index.js | 26 ++++++ admin/src/index.js | 52 +++++++++++ admin/src/lifecycles.js | 3 + admin/src/pluginId.js | 7 ++ admin/src/translations/ar.json | 1 + admin/src/translations/cs.json | 1 + admin/src/translations/de.json | 1 + admin/src/translations/en.json | 1 + admin/src/translations/es.json | 1 + admin/src/translations/fr.json | 1 + admin/src/translations/id.json | 1 + admin/src/translations/index.js | 49 ++++++++++ admin/src/translations/it.json | 1 + admin/src/translations/ko.json | 1 + admin/src/translations/ms.json | 1 + admin/src/translations/nl.json | 1 + admin/src/translations/pl.json | 1 + admin/src/translations/pt-BR.json | 1 + admin/src/translations/pt.json | 1 + admin/src/translations/ru.json | 1 + admin/src/translations/sk.json | 1 + admin/src/translations/th.json | 1 + admin/src/translations/tr.json | 1 + admin/src/translations/uk.json | 1 + admin/src/translations/vi.json | 1 + admin/src/translations/zh-Hans.json | 1 + admin/src/translations/zh.json | 1 + admin/src/utils/getTrad.js | 5 ++ config/routes.json | 12 +++ controllers/config.js | 25 ++++++ package.json | 28 ++++++ services/config.js | 11 +++ 38 files changed, 410 insertions(+) create mode 100644 .editorconfig create mode 100644 .gitattributes create mode 100644 .gitignore create mode 100644 README.md create mode 100644 admin/src/containers/App/index.js create mode 100644 admin/src/containers/HomePage/index.js create mode 100644 admin/src/containers/Initializer/index.js create mode 100644 admin/src/index.js create mode 100644 admin/src/lifecycles.js create mode 100644 admin/src/pluginId.js create mode 100644 admin/src/translations/ar.json create mode 100644 admin/src/translations/cs.json create mode 100644 admin/src/translations/de.json create mode 100644 admin/src/translations/en.json create mode 100644 admin/src/translations/es.json create mode 100644 admin/src/translations/fr.json create mode 100644 admin/src/translations/id.json create mode 100644 admin/src/translations/index.js create mode 100644 admin/src/translations/it.json create mode 100644 admin/src/translations/ko.json create mode 100644 admin/src/translations/ms.json create mode 100644 admin/src/translations/nl.json create mode 100644 admin/src/translations/pl.json create mode 100644 admin/src/translations/pt-BR.json create mode 100644 admin/src/translations/pt.json create mode 100644 admin/src/translations/ru.json create mode 100644 admin/src/translations/sk.json create mode 100644 admin/src/translations/th.json create mode 100644 admin/src/translations/tr.json create mode 100644 admin/src/translations/uk.json create mode 100644 admin/src/translations/vi.json create mode 100644 admin/src/translations/zh-Hans.json create mode 100644 admin/src/translations/zh.json create mode 100644 admin/src/utils/getTrad.js create mode 100644 config/routes.json create mode 100644 controllers/config.js create mode 100644 package.json create mode 100644 services/config.js diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..d4eed84 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,7 @@ +root = true + +[*] +end_of_line = lf +insert_final_newline = false +indent_style = space +indent_size = 2 diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..065a11c --- /dev/null +++ b/.gitattributes @@ -0,0 +1,103 @@ +# From https://github.com/Danimoth/gitattributes/blob/master/Web.gitattributes + +# Handle line endings automatically for files detected as text +# and leave all files detected as binary untouched. +* text=auto + +# +# The above will handle all files NOT found below +# + +# +## These files are text and should be normalized (Convert crlf => lf) +# + +# source code +*.php text +*.css text +*.sass text +*.scss text +*.less text +*.styl text +*.js text eol=lf +*.coffee text +*.json text +*.htm text +*.html text +*.xml text +*.svg text +*.txt text +*.ini text +*.inc text +*.pl text +*.rb text +*.py text +*.scm text +*.sql text +*.sh text +*.bat text + +# templates +*.ejs text +*.hbt text +*.jade text +*.haml text +*.hbs text +*.dot text +*.tmpl text +*.phtml text + +# git config +.gitattributes text +.gitignore text +.gitconfig text + +# code analysis config +.jshintrc text +.jscsrc text +.jshintignore text +.csslintrc text + +# misc config +*.yaml text +*.yml text +.editorconfig text + +# build config +*.npmignore text +*.bowerrc text + +# Heroku +Procfile text +.slugignore text + +# Documentation +*.md text +LICENSE text +AUTHORS text + + +# +## These files are binary and should be left untouched +# + +# (binary is a macro for -text -diff) +*.png binary +*.jpg binary +*.jpeg binary +*.gif binary +*.ico binary +*.mov binary +*.mp4 binary +*.mp3 binary +*.flv binary +*.fla binary +*.swf binary +*.gz binary +*.zip binary +*.7z binary +*.ttf binary +*.eot binary +*.woff binary +*.pyc binary +*.pdf binary diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..afe256b --- /dev/null +++ b/.gitignore @@ -0,0 +1,10 @@ +# Don't check auto-generated stuff into git +coverage +node_modules +stats.json +package-lock.json + +# Cruft +.DS_Store +npm-debug.log +.idea diff --git a/README.md b/README.md new file mode 100644 index 0000000..7a81ce3 --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# Strapi plugin config + +A quick description of config. diff --git a/admin/src/containers/App/index.js b/admin/src/containers/App/index.js new file mode 100644 index 0000000..9755fb0 --- /dev/null +++ b/admin/src/containers/App/index.js @@ -0,0 +1,27 @@ +/** + * + * This component is the skeleton around the actual pages, and should only + * contain code that should be seen on all pages. (e.g. navigation bar) + * + */ + +import React from 'react'; +import { Switch, Route } from 'react-router-dom'; +import { NotFound } from 'strapi-helper-plugin'; +// Utils +import pluginId from '../../pluginId'; +// Containers +import HomePage from '../HomePage'; + +const App = () => { + return ( +
+ + + + +
+ ); +}; + +export default App; diff --git a/admin/src/containers/HomePage/index.js b/admin/src/containers/HomePage/index.js new file mode 100644 index 0000000..05c5a6a --- /dev/null +++ b/admin/src/containers/HomePage/index.js @@ -0,0 +1,20 @@ +/* + * + * HomePage + * + */ + +import React, { memo } from 'react'; +// import PropTypes from 'prop-types'; +import pluginId from '../../pluginId'; + +const HomePage = () => { + return ( +
+

{pluginId}'s HomePage

+

Happy coding

+
+ ); +}; + +export default memo(HomePage); diff --git a/admin/src/containers/Initializer/index.js b/admin/src/containers/Initializer/index.js new file mode 100644 index 0000000..06b5488 --- /dev/null +++ b/admin/src/containers/Initializer/index.js @@ -0,0 +1,26 @@ +/** + * + * Initializer + * + */ + +import { useEffect, useRef } from 'react'; +import PropTypes from 'prop-types'; +import pluginId from '../../pluginId'; + +const Initializer = ({ updatePlugin }) => { + const ref = useRef(); + ref.current = updatePlugin; + + useEffect(() => { + ref.current(pluginId, 'isReady', true); + }, []); + + return null; +}; + +Initializer.propTypes = { + updatePlugin: PropTypes.func.isRequired, +}; + +export default Initializer; diff --git a/admin/src/index.js b/admin/src/index.js new file mode 100644 index 0000000..6c5be5b --- /dev/null +++ b/admin/src/index.js @@ -0,0 +1,52 @@ +import pluginPkg from '../../package.json'; +import pluginId from './pluginId'; +import App from './containers/App'; +import Initializer from './containers/Initializer'; +import lifecycles from './lifecycles'; +import trads from './translations'; + +export default strapi => { + const pluginDescription = pluginPkg.strapi.description || pluginPkg.description; + const icon = pluginPkg.strapi.icon; + const name = pluginPkg.strapi.name; + + const plugin = { + blockerComponent: null, + blockerComponentProps: {}, + description: pluginDescription, + icon, + id: pluginId, + initializer: Initializer, + injectedComponents: [], + isReady: false, + isRequired: pluginPkg.strapi.required || false, + layout: null, + lifecycles, + mainComponent: App, + name, + preventComponentRendering: false, + trads, + menu: { + pluginsSectionLinks: [ + { + destination: `/plugins/${pluginId}`, + icon, + label: { + id: `${pluginId}.plugin.name`, + defaultMessage: name, + }, + name, + permissions: [ + // Uncomment to set the permissions of the plugin here + // { + // action: '', // the action name should be plugins::plugin-name.actionType + // subject: null, + // }, + ], + }, + ], + }, + }; + + return strapi.registerPlugin(plugin); +}; diff --git a/admin/src/lifecycles.js b/admin/src/lifecycles.js new file mode 100644 index 0000000..81b0172 --- /dev/null +++ b/admin/src/lifecycles.js @@ -0,0 +1,3 @@ +function lifecycles() {} + +export default lifecycles; diff --git a/admin/src/pluginId.js b/admin/src/pluginId.js new file mode 100644 index 0000000..1b059dd --- /dev/null +++ b/admin/src/pluginId.js @@ -0,0 +1,7 @@ +const pluginPkg = require('../../package.json'); +const pluginId = pluginPkg.name.replace( + /^strapi-plugin-/i, + '' +); + +module.exports = pluginId; diff --git a/admin/src/translations/ar.json b/admin/src/translations/ar.json new file mode 100644 index 0000000..9e26dfe --- /dev/null +++ b/admin/src/translations/ar.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/admin/src/translations/cs.json b/admin/src/translations/cs.json new file mode 100644 index 0000000..9e26dfe --- /dev/null +++ b/admin/src/translations/cs.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/admin/src/translations/de.json b/admin/src/translations/de.json new file mode 100644 index 0000000..0967ef4 --- /dev/null +++ b/admin/src/translations/de.json @@ -0,0 +1 @@ +{} diff --git a/admin/src/translations/en.json b/admin/src/translations/en.json new file mode 100644 index 0000000..9e26dfe --- /dev/null +++ b/admin/src/translations/en.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/admin/src/translations/es.json b/admin/src/translations/es.json new file mode 100644 index 0000000..9e26dfe --- /dev/null +++ b/admin/src/translations/es.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/admin/src/translations/fr.json b/admin/src/translations/fr.json new file mode 100644 index 0000000..9e26dfe --- /dev/null +++ b/admin/src/translations/fr.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/admin/src/translations/id.json b/admin/src/translations/id.json new file mode 100644 index 0000000..9e26dfe --- /dev/null +++ b/admin/src/translations/id.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/admin/src/translations/index.js b/admin/src/translations/index.js new file mode 100644 index 0000000..d990d5a --- /dev/null +++ b/admin/src/translations/index.js @@ -0,0 +1,49 @@ +import ar from './ar.json'; +import cs from './cs.json'; +import de from './de.json'; +import en from './en.json'; +import es from './es.json'; +import fr from './fr.json'; +import id from './id.json'; +import it from './it.json'; +import ko from './ko.json'; +import ms from './ms.json'; +import nl from './nl.json'; +import pl from './pl.json'; +import ptBR from './pt-BR.json'; +import pt from './pt.json'; +import ru from './ru.json'; +import th from './th.json'; +import tr from './tr.json'; +import uk from './uk.json'; +import vi from './vi.json'; +import zhHans from './zh-Hans.json'; +import zh from './zh.json'; +import sk from './sk.json'; + +const trads = { + ar, + cs, + de, + en, + es, + fr, + id, + it, + ko, + ms, + nl, + pl, + 'pt-BR': ptBR, + pt, + ru, + th, + tr, + uk, + vi, + 'zh-Hans': zhHans, + zh, + sk, +}; + +export default trads; diff --git a/admin/src/translations/it.json b/admin/src/translations/it.json new file mode 100644 index 0000000..9e26dfe --- /dev/null +++ b/admin/src/translations/it.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/admin/src/translations/ko.json b/admin/src/translations/ko.json new file mode 100644 index 0000000..9e26dfe --- /dev/null +++ b/admin/src/translations/ko.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/admin/src/translations/ms.json b/admin/src/translations/ms.json new file mode 100644 index 0000000..9e26dfe --- /dev/null +++ b/admin/src/translations/ms.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/admin/src/translations/nl.json b/admin/src/translations/nl.json new file mode 100644 index 0000000..9e26dfe --- /dev/null +++ b/admin/src/translations/nl.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/admin/src/translations/pl.json b/admin/src/translations/pl.json new file mode 100644 index 0000000..0967ef4 --- /dev/null +++ b/admin/src/translations/pl.json @@ -0,0 +1 @@ +{} diff --git a/admin/src/translations/pt-BR.json b/admin/src/translations/pt-BR.json new file mode 100644 index 0000000..9e26dfe --- /dev/null +++ b/admin/src/translations/pt-BR.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/admin/src/translations/pt.json b/admin/src/translations/pt.json new file mode 100644 index 0000000..9e26dfe --- /dev/null +++ b/admin/src/translations/pt.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/admin/src/translations/ru.json b/admin/src/translations/ru.json new file mode 100644 index 0000000..0967ef4 --- /dev/null +++ b/admin/src/translations/ru.json @@ -0,0 +1 @@ +{} diff --git a/admin/src/translations/sk.json b/admin/src/translations/sk.json new file mode 100644 index 0000000..9e26dfe --- /dev/null +++ b/admin/src/translations/sk.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/admin/src/translations/th.json b/admin/src/translations/th.json new file mode 100644 index 0000000..9e26dfe --- /dev/null +++ b/admin/src/translations/th.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/admin/src/translations/tr.json b/admin/src/translations/tr.json new file mode 100644 index 0000000..0967ef4 --- /dev/null +++ b/admin/src/translations/tr.json @@ -0,0 +1 @@ +{} diff --git a/admin/src/translations/uk.json b/admin/src/translations/uk.json new file mode 100644 index 0000000..0967ef4 --- /dev/null +++ b/admin/src/translations/uk.json @@ -0,0 +1 @@ +{} diff --git a/admin/src/translations/vi.json b/admin/src/translations/vi.json new file mode 100644 index 0000000..9e26dfe --- /dev/null +++ b/admin/src/translations/vi.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/admin/src/translations/zh-Hans.json b/admin/src/translations/zh-Hans.json new file mode 100644 index 0000000..0967ef4 --- /dev/null +++ b/admin/src/translations/zh-Hans.json @@ -0,0 +1 @@ +{} diff --git a/admin/src/translations/zh.json b/admin/src/translations/zh.json new file mode 100644 index 0000000..0967ef4 --- /dev/null +++ b/admin/src/translations/zh.json @@ -0,0 +1 @@ +{} diff --git a/admin/src/utils/getTrad.js b/admin/src/utils/getTrad.js new file mode 100644 index 0000000..a2b8632 --- /dev/null +++ b/admin/src/utils/getTrad.js @@ -0,0 +1,5 @@ +import pluginId from '../pluginId'; + +const getTrad = id => `${pluginId}.${id}`; + +export default getTrad; diff --git a/config/routes.json b/config/routes.json new file mode 100644 index 0000000..6a09017 --- /dev/null +++ b/config/routes.json @@ -0,0 +1,12 @@ +{ + "routes": [ + { + "method": "GET", + "path": "/", + "handler": "config.index", + "config": { + "policies": [] + } + } + ] +} diff --git a/controllers/config.js b/controllers/config.js new file mode 100644 index 0000000..b4afee2 --- /dev/null +++ b/controllers/config.js @@ -0,0 +1,25 @@ +'use strict'; + +/** + * config.js controller + * + * @description: A set of functions called "actions" of the `config` plugin. + */ + +module.exports = { + + /** + * Default action. + * + * @return {Object} + */ + + index: async (ctx) => { + // Add your own logic here. + + // Send 200 `ok` + ctx.send({ + message: 'ok' + }); + } +}; diff --git a/package.json b/package.json new file mode 100644 index 0000000..e67fd58 --- /dev/null +++ b/package.json @@ -0,0 +1,28 @@ +{ + "name": "strapi-plugin-config", + "version": "0.0.0", + "description": "This is the description of the plugin.", + "strapi": { + "name": "config", + "icon": "plug", + "description": "Description of config plugin." + }, + "dependencies": {}, + "author": { + "name": "A Strapi developer", + "email": "", + "url": "" + }, + "maintainers": [ + { + "name": "A Strapi developer", + "email": "", + "url": "" + } + ], + "engines": { + "node": ">=10.16.0 <=14.x.x", + "npm": ">=6.0.0" + }, + "license": "MIT" +} diff --git a/services/config.js b/services/config.js new file mode 100644 index 0000000..c992ee6 --- /dev/null +++ b/services/config.js @@ -0,0 +1,11 @@ +'use strict'; + +/** + * config.js service + * + * @description: A set of functions similar to controller's actions to avoid code duplication. + */ + +module.exports = { + +};