18 Commits
1.0.2 ... 1.0.4

Author SHA1 Message Date
flarum-bot
f3e8fc0243 Bundled output for commit 8f82fbe078
Includes transpiled JS/TS.

[skip ci]
2022-03-29 14:53:48 +00:00
Rafael Horvat
8f82fbe078 Added the ability to configure horizon 2022-03-29 16:51:03 +02:00
Rafael Horvat
4e668a4098 conventions 2022-03-29 16:31:44 +02:00
Rafael Horvat
68b5b8f871 Updated license and authors 2022-03-29 16:09:13 +02:00
flarum-bot
27601d7f61 Bundled output for commit 4d7828548b
Includes transpiled JS/TS.

[skip ci]
2022-03-29 12:17:48 +00:00
Rafael Horvat
4d7828548b fix package name, mistake 🙈 2022-03-29 14:16:20 +02:00
Rafael Horvat
9a0fe54c37 Conventions & best practices update 2022-03-29 14:08:12 +02:00
Rafael Horvat
b308a07d8d Added and/or updated config files 2021-12-29 12:02:32 +01:00
flarum-bot
c167010796 Bundled output for commit e94701d39c
Includes transpiled JS/TS.

[skip ci]
2021-12-21 17:35:48 +00:00
iPurpl3x
e94701d39c fixed build workflow 2021-12-21 18:34:33 +01:00
iPurpl3x
57f7647fc3 Prettier 2021-12-21 18:05:25 +01:00
iPurpl3x
8c976e3fc0 Added Discuss link for Extiverse 2021-12-21 18:03:54 +01:00
iPurpl3x
590d0084c5 Conventions & code formating 2021-12-21 17:44:27 +01:00
iPurpl3x
fcd833a248 Use yarn and updated dependencies 2021-12-21 17:44:07 +01:00
Ian Morland
3284a36926 Cleanup 2021-07-05 14:12:08 +01:00
Ian Morland
68af330669 Add optional prefix 2021-07-01 21:28:35 +01:00
Ian Morland
09a30f786d Update usage 2021-07-01 21:26:55 +01:00
Ian Morland
68a5cafdfc Address failure when only running selected redis services 2021-07-01 21:23:57 +01:00
23 changed files with 4797 additions and 5195 deletions

16
.editorconfig Normal file
View File

@@ -0,0 +1,16 @@
root = true
[*]
charset = utf-8
end_of_line = lf
max_line_length = 100
insert_final_newline = true
trim_trailing_whitespace = true
quote_type = single
indent_style = tab
indent_size = 4
[*.{json,yml,yaml}]
indent_style = space
indent_size = 2
insert_final_newline = false

View File

@@ -1,16 +0,0 @@
name: Build JavaScript assets
on:
push:
branches:
- master
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- uses: flarum/action-build@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

91
.github/workflows/js.yml vendored Normal file
View File

@@ -0,0 +1,91 @@
name: JS
on: [workflow_dispatch, push, pull_request]
env:
NODE_VERSION: 16
jobs:
prettier:
name: Prettier
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v2
- name: Set up Node
uses: actions/setup-node@v2
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'yarn'
cache-dependency-path: js/yarn.lock
- name: Install JS dependencies
run: yarn install --immutable
working-directory: ./js
- name: Check JS formatting
run: yarn run format-check
working-directory: ./js
build-prod:
name: Build and commit
runs-on: ubuntu-latest
needs: [prettier]
# Only commit JS on push to master branch
# Remember to change in `build-test` job too
if: github.ref == 'refs/heads/master' && github.event_name == 'push'
steps:
- name: Check out code
uses: actions/checkout@v2
- name: Set up Node
uses: actions/setup-node@v2
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'yarn'
cache-dependency-path: js/yarn.lock
# Our action will install node, npm and yarn, cd into `./js`, run `yarn run build` (and
# `yarn run build-typings` if desired), then commit and upload any changes
- name: Build production JS
uses: flarum/action-build@2
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
build_script: build
package_manager: yarn
# typings_script: build-typings
build-test:
name: Test build
runs-on: ubuntu-latest
needs: [prettier]
# Inverse check of `build-prod`
# Remember to change in `build-prod` job too
if: github.ref != 'refs/heads/master' || github.event_name != 'push'
steps:
- name: Check out code
uses: actions/checkout@v2
- name: Set up Node
uses: actions/setup-node@v2
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'yarn'
cache-dependency-path: js/yarn.lock
# Our action will install node, npm and yarn, cd into `./js`, run `yarn run build` (and
# `yarn run build-typings` if desired). It will NOT commit and upload.
- name: Build production JS
uses: flarum/action-build@2
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
build_script: build
package_manager: yarn
# typings_script: build-typings
do_not_commit: true

154
.gitignore vendored
View File

@@ -1,5 +1,5 @@
# Created by https://www.toptal.com/developers/gitignore/api/vim,yarn,node,linux,macos,windows,visualstudiocode,composer # Created by https://www.toptal.com/developers/gitignore/api/vim,yarn,node,macos,linux,windows,composer,visualstudiocode,jetbrains
# Edit at https://www.toptal.com/developers/gitignore?templates=vim,yarn,node,linux,macos,windows,visualstudiocode,composer # Edit at https://www.toptal.com/developers/gitignore?templates=vim,yarn,node,macos,linux,windows,composer,visualstudiocode,jetbrains
### Composer ### ### Composer ###
composer.phar composer.phar
@@ -7,7 +7,110 @@ composer.phar
# Commit your application's lock file https://getcomposer.org/doc/01-basic-usage.md#commit-your-composer-lock-file-to-version-control # Commit your application's lock file https://getcomposer.org/doc/01-basic-usage.md#commit-your-composer-lock-file-to-version-control
# You may choose to ignore a library lock file http://getcomposer.org/doc/02-libraries.md#lock-file # You may choose to ignore a library lock file http://getcomposer.org/doc/02-libraries.md#lock-file
# composer.lock composer.lock
### JetBrains ###
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
# User-specific stuff
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/**/usage.statistics.xml
.idea/**/dictionaries
.idea/**/shelf
# Generated files
.idea/**/contentModel.xml
# Sensitive or high-churn files
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
.idea/**/dbnavigator.xml
# Gradle
.idea/**/gradle.xml
.idea/**/libraries
# Gradle and Maven with auto-import
# When using Gradle or Maven with auto-import, you should exclude module files,
# since they will be recreated, and may cause churn. Uncomment if using
# auto-import.
# .idea/artifacts
# .idea/compiler.xml
# .idea/jarRepositories.xml
# .idea/modules.xml
# .idea/*.iml
# .idea/modules
# *.iml
# *.ipr
# CMake
cmake-build-*/
# Mongo Explorer plugin
.idea/**/mongoSettings.xml
# File-based project format
*.iws
# IntelliJ
out/
# mpeltonen/sbt-idea plugin
.idea_modules/
# JIRA plugin
atlassian-ide-plugin.xml
# Cursive Clojure plugin
.idea/replstate.xml
# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties
# Editor-based Rest Client
.idea/httpRequests
# Android studio 3.1+ serialized cache file
.idea/caches/build_file_checksums.ser
### JetBrains Patch ###
# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721
# *.iml
# modules.xml
# .idea/misc.xml
# *.ipr
# Sonarlint plugin
# https://plugins.jetbrains.com/plugin/7973-sonarlint
.idea/**/sonarlint/
# SonarQube Plugin
# https://plugins.jetbrains.com/plugin/7238-sonarqube-community-plugin
.idea/**/sonarIssues.xml
# Markdown Navigator plugin
# https://plugins.jetbrains.com/plugin/7896-markdown-navigator-enhanced
.idea/**/markdown-navigator.xml
.idea/**/markdown-navigator-enh.xml
.idea/**/markdown-navigator/
# Cache file creation bug
# See https://youtrack.jetbrains.com/issue/JBR-2257
.idea/$CACHE_FILE$
# CodeStream plugin
# https://plugins.jetbrains.com/plugin/12206-codestream
.idea/codestream.xml
### Linux ### ### Linux ###
*~ *~
@@ -33,6 +136,7 @@ composer.phar
# Icon must end with two \r # Icon must end with two \r
Icon Icon
# Thumbnails # Thumbnails
._* ._*
@@ -61,6 +165,9 @@ yarn-debug.log*
yarn-error.log* yarn-error.log*
lerna-debug.log* lerna-debug.log*
# Lock file => as we don't use npm, but yarn.
package-lock.json
# Diagnostic reports (https://nodejs.org/api/report.html) # Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
@@ -108,6 +215,9 @@ typings/
# Optional eslint cache # Optional eslint cache
.eslintcache .eslintcache
# Optional stylelint cache
.stylelintcache
# Microbundle cache # Microbundle cache
.rpt2_cache/ .rpt2_cache/
.rts2_cache_cjs/ .rts2_cache_cjs/
@@ -126,9 +236,11 @@ typings/
# dotenv environment variables file # dotenv environment variables file
.env .env
.env.test .env.test
.env*.local
# parcel-bundler cache (https://parceljs.org/) # parcel-bundler cache (https://parceljs.org/)
.cache .cache
.parcel-cache
# Next.js build output # Next.js build output
.next .next
@@ -137,6 +249,14 @@ typings/
.nuxt .nuxt
# dist # dist
# Storybook build outputs
.out
.storybook-out
storybook-static
# rollup.js default build output
# dist/
# Gatsby files # Gatsby files
.cache/ .cache/
# Comment in the public line in if your project uses Gatsby and not Next.js # Comment in the public line in if your project uses Gatsby and not Next.js
@@ -161,6 +281,10 @@ typings/
# Stores VSCode versions used for testing VSCode extensions # Stores VSCode versions used for testing VSCode extensions
.vscode-test .vscode-test
# Temporary folders
tmp/
temp/
### Vim ### ### Vim ###
# Swap # Swap
[._]*.s[a-v][a-z] [._]*.s[a-v][a-z]
@@ -183,15 +307,14 @@ tags
### VisualStudioCode ### ### VisualStudioCode ###
.vscode/* .vscode/*
!.vscode/settings.json
!.vscode/tasks.json !.vscode/tasks.json
!.vscode/launch.json !.vscode/launch.json
!.vscode/extensions.json
*.code-workspace *.code-workspace
### VisualStudioCode Patch ### ### VisualStudioCode Patch ###
# Ignore all local history of files # Ignore all local history of files
.history .history
.ionide
### Windows ### ### Windows ###
# Windows thumbnail cache files # Windows thumbnail cache files
@@ -222,16 +345,17 @@ $RECYCLE.BIN/
### yarn ### ### yarn ###
# https://yarnpkg.com/advanced/qa#which-files-should-be-gitignored # https://yarnpkg.com/advanced/qa#which-files-should-be-gitignored
# .yarn/unplugged and .yarn/build-state.yml should likely always be ignored since .yarn/*
# they typically hold machine-specific build artifacts. Ignoring them might however !.yarn/releases
# prevent Zero-Installs from working (to prevent this, set enableScripts to false). !.yarn/plugins
.yarn/unplugged !.yarn/sdks
.yarn/build-state.yml !.yarn/versions
# .yarn/cache and .pnp.* may be safely ignored, but you'll need to run yarn install # if you are NOT using Zero-installs, then:
# to regenerate them between each branch switch. # comment the following lines
# Uncomment the following lines if you're not using Zero-Installs: !.yarn/cache
# .yarn/cache
# and uncomment the following lines
# .pnp.* # .pnp.*
# End of https://www.toptal.com/developers/gitignore/api/vim,yarn,node,linux,macos,windows,visualstudiocode,composer # End of https://www.toptal.com/developers/gitignore/api/vim,yarn,node,macos,linux,windows,composer,visualstudiocode,jetbrains

19
.prettierrc Normal file
View File

@@ -0,0 +1,19 @@
bracketSameLine: true
jsxBracketSameLine: true
jsxSingleQuote: true
printWidth: 100
proseWrap: "always"
semi: true
singleQuote: true
tabWidth: 4
trailingComma: "all"
useTabs: true
overrides:
- files:
- "*.json"
- "*.yml"
- "*.yaml"
options:
useTabs: false
tabWidth: 2

11
.vscode/extension.json vendored Normal file
View File

@@ -0,0 +1,11 @@
{
"recommendations": [
"bmewburn.vscode-intelephense-client",
"dbaeumer.vscode-eslint",
"editorconfig.editorconfig",
"esbenp.prettier-vscode",
"felixfbecker.php-debug",
"glowingblue.composer-package-name",
"firefox-devtools.vscode-firefox-debug"
]
}

17
.vscode/launch.json vendored Normal file
View File

@@ -0,0 +1,17 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "Attach to Flarum",
"type": "firefox",
"request": "attach",
"url": "http://localhost:8888",
"pathMappings": [
{
"url": "webpack://${command:glowingblue-composer-package-name.getName}/src/",
"path": "${workspaceFolder}/js/src/"
}
]
}
]
}

70
.vscode/settings.json vendored Normal file
View File

@@ -0,0 +1,70 @@
{
"editor.insertSpaces": false,
"editor.wordWrapColumn": 100,
"files.insertFinalNewline": true,
"editor.detectIndentation": false,
"[javascript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.insertSpaces": false
},
"[typescript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[jsonc]": {
"editor.defaultFormatter": "esbenp.prettier-vscode",
"files.insertFinalNewline": true
},
"[json]": {
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.insertSpaces": true,
"editor.tabSize": 2,
"files.insertFinalNewline": true
},
"[yaml]": {
"editor.insertSpaces": true,
"editor.tabSize": 2,
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[html]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[css]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[less]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[scss]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[markdown]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[php]": {
"editor.defaultFormatter": "bmewburn.vscode-intelephense-client",
"editor.insertSpaces": false
},
"files.associations": {
"*.html": "html",
"*.md": "markdown"
},
"prettier.bracketSameLine": true,
"prettier.jsxBracketSameLine": true,
"prettier.jsxSingleQuote": true,
"prettier.printWidth": 100,
"prettier.proseWrap": "always",
"prettier.semi": true,
"prettier.singleQuote": true,
"prettier.tabWidth": 4,
"prettier.trailingComma": "all",
"prettier.useTabs": true,
"js/ts.implicitProjectConfig.experimentalDecorators": true,
"eslint.packageManager": "yarn",
"remote.containers.workspaceMountConsistency": "consistent",
"remote.containers.defaultExtensions": [
"bmewburn.vscode-intelephense-client",
"dbaeumer.vscode-eslint",
"esbenp.prettier-vscode",
"felixfbecker.php-debug"
]
}

View File

@@ -1,7 +1,16 @@
MIT License Copyright (c) 2021 Glowing Blue AG MIT License Copyright (c) 2022 Glowing Blue AG
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
associated documentation files (the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge, publish, distribute,
sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice (including the next paragraph) shall be included in all copies or substantial portions of the Software. The above copyright notice and this permission notice (including the next paragraph) shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES
OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View File

@@ -1,6 +1,8 @@
# ⚡️ Redis Setup # ⚡️ Redis Setup
[![MIT license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/glowingblue/flarum-ext-redis-setup/blob/master/LICENSE.md) [![Latest Stable Version](https://img.shields.io/packagist/v/glowingblue/redis-setup.svg)](https://packagist.org/packages/glowingblue/redis-setup) [![Total Downloads](https://img.shields.io/packagist/dt/glowingblue/redis-setup.svg)](https://packagist.org/packages/glowingblue/redis-setup) [![MIT license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/glowingblue/flarum-ext-redis-setup/blob/master/LICENSE.md)
[![Latest Stable Version](https://img.shields.io/packagist/v/glowingblue/redis-setup.svg)](https://packagist.org/packages/glowingblue/redis-setup)
[![Total Downloads](https://img.shields.io/packagist/dt/glowingblue/redis-setup.svg)](https://packagist.org/packages/glowingblue/redis-setup)
A [Flarum](http://flarum.org) extension. A [Flarum](http://flarum.org) extension.
@@ -10,15 +12,17 @@ Makes it easy to enable/disable Redis features:
- Queue - Queue
- Sessions - Sessions
For this to work, environment variables have to be set on your host: If you are using a local redis setup, you will likely be able to simply use the defaults provided.
Any of these can be overridden using environment variables as follows:
```ini ```ini
REDIS_HOST=null # Required REDIS_HOST='127.0.0.1 # Optional, else uses default
REDIS_PORT=6379 # Optional, else uses default REDIS_PORT=6379 # Optional, else uses default
REDIS_PASSWORD=null # Required, can be an empty string REDIS_PASSWORD=null # Optional, otherwise null
REDIS_DATABASE_CACHE=1 # Optional, else uses default REDIS_DATABASE_CACHE=1 # Optional, else uses default
REDIS_DATABASE_QUEUE=2 # Optional, else uses default REDIS_DATABASE_QUEUE=2 # Optional, else uses default
REDIS_DATABASE_SESSION=3 # Optional, else uses default REDIS_DATABASE_SESSION=3 # Optional, else uses default
REDIS_PREFIX='flarum_' # Optional, else uses default
``` ```
## 📥 Installation ## 📥 Installation

View File

@@ -2,7 +2,11 @@
"name": "glowingblue/redis-setup", "name": "glowingblue/redis-setup",
"description": "Makes it easy to enable/disable Redis features: Cache, Queue & Sessions", "description": "Makes it easy to enable/disable Redis features: Cache, Queue & Sessions",
"keywords": [ "keywords": [
"flarum", "redis", "cache", "queue", "session" "flarum",
"redis",
"cache",
"queue",
"session"
], ],
"type": "flarum-extension", "type": "flarum-extension",
"license": "MIT", "license": "MIT",
@@ -14,7 +18,7 @@
}, },
"homepage": "https://glowingblue.com", "homepage": "https://glowingblue.com",
"require": { "require": {
"flarum/core": "^1.0.0", "flarum/core": "^1.0.4",
"blomstra/flarum-redis": "^0.4.0" "blomstra/flarum-redis": "^0.4.0"
}, },
"authors": [ "authors": [
@@ -22,6 +26,15 @@
"name": "IanM", "name": "IanM",
"homepage": "https://discuss.flarum.org/u/ianm", "homepage": "https://discuss.flarum.org/u/ianm",
"role": "Developer" "role": "Developer"
},
{
"name": "Glowing Blue AG",
"homepage": "https://glowingblue.com",
"role": "Developer"
},
{
"name": "Rafael Horvat",
"role": "Developer"
} }
], ],
"autoload": { "autoload": {
@@ -37,7 +50,13 @@
"name": "fas fa-tasks", "name": "fas fa-tasks",
"backgroundColor": "#00a7e3", "backgroundColor": "#00a7e3",
"color": "#fff" "color": "#fff"
} },
"optional-dependencies": [
"blomstra/horizon"
]
},
"extiverse": {
"discuss": "https://discuss.flarum.org/d/27455"
} }
} }
} }

View File

@@ -3,7 +3,8 @@
/* /*
* This file is part of glowingblue/redis-setup. * This file is part of glowingblue/redis-setup.
* *
* Copyright (c) 2021 Ian Morland. * Copyright (c) 2022 Glowing Blue AG.
* Authors: Ian Morland, iPurpl3x, Rafael Horvat.
* *
* For the full copyright and license information, please view the LICENSE.md * For the full copyright and license information, please view the LICENSE.md
* file that was distributed with this source code. * file that was distributed with this source code.
@@ -12,7 +13,7 @@
namespace GlowingBlue\RedisSetup; namespace GlowingBlue\RedisSetup;
use Flarum\Extend; use Flarum\Extend;
use GlowingBlue\RedisSetup\Extend\EnableRedis; use GlowingBlue\RedisSetup\Extend as GBExtend;
use GlowingBlue\RedisSetup\Provider\QueueProvider; use GlowingBlue\RedisSetup\Provider\QueueProvider;
return [ return [
@@ -21,8 +22,9 @@ return [
new Extend\Locales(__DIR__ . '/resources/locale'), new Extend\Locales(__DIR__ . '/resources/locale'),
new GBExtend\ConfigureHorizon(),
new GBExtend\EnableRedis(),
(new Extend\ServiceProvider()) (new Extend\ServiceProvider())
->register(QueueProvider::class), ->register(QueueProvider::class),
new EnableRedis()
]; ];

2
js/dist/admin.js vendored
View File

@@ -1,2 +1,2 @@
module.exports=function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=3)}([function(e,t){e.exports=flarum.core.compat["admin/app"]},function(e,t){e.exports=flarum.core.compat["common/extend"]},function(e,t){e.exports=flarum.core.compat["admin/components/StatusWidget"]},function(e,t,n){"use strict";n.r(t);var r=n(0),o=n.n(r),a=n(1),i=n(2),u=n.n(i);function l(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return s(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return s(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function s(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}o.a.initializers.add("glowingblue-redis-setup",(function(){o.a.extensionData.for("glowingblue-redis-setup").registerSetting({setting:"glowingblue-redis.enableCache",type:"boolean",label:o.a.translator.trans("glowingblue-redis-setup.admin.settings.enable_cache")}).registerSetting({setting:"glowingblue-redis.redisSessions",type:"boolean",label:o.a.translator.trans("glowingblue-redis-setup.admin.settings.enable_redis_sessions")}).registerSetting({setting:"glowingblue-redis.enableQueue",type:"boolean",label:o.a.translator.trans("glowingblue-redis-setup.admin.settings.enable_queue")}),Object(a.extend)(u.a.prototype,"items",(function(e){var t=o.a.data.blomstraQueuesLoad;if(void 0!==t)for(var n,r=l(o.a.data.blomstraQueuesSeen);!(n=r()).done;){var a=n.value,i=t[a]||null;e.add("blomstra-queue-size-"+a,[m("strong",null,"Queue ",a),m("br",null),i||"0"])}}))}))}]); module.exports=function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=3)}([function(e,t){e.exports=flarum.core.compat["admin/app"]},function(e,t){e.exports=flarum.core.compat["common/extend"]},function(e,t){e.exports=flarum.core.compat["admin/components/StatusWidget"]},function(e,t,r){"use strict";r.r(t);var n=r(0),o=r.n(n),a=r(1),i=r(2),l=r.n(i),u="glowingblue-redis-setup";function s(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(r)return(r=r.call(e)).next.bind(r);if(Array.isArray(e)||(r=function(e,t){if(!e)return;if("string"==typeof e)return c(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return c(e,t)}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function c(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}var f=o.a.translator.trans.bind(o.a.translator),d=u+".admin.settings";o.a.initializers.add(u,(function(){o.a.extensionData.for(u).registerSetting({setting:"glowingblue-redis.enableCache",type:"boolean",label:f(d+".enable_cache")}).registerSetting({setting:"glowingblue-redis.redisSessions",type:"boolean",label:f(d+".enable_redis_sessions")}).registerSetting({setting:"glowingblue-redis.enableQueue",type:"boolean",label:f(d+".enable_queue")}),o.a.initializers.has("blomstra/horizon")&&o.a.extensionData.for(u).registerSetting({setting:"glowingblue-redis.horizonConfig",type:"textarea",label:f(d+".horizon_config"),help:f(d+".horizon_help_text")}),Object(a.extend)(l.a.prototype,"items",(function(e){var t=o.a.data.blomstraQueuesLoad;if(void 0!==t)for(var r,n=s(o.a.data.blomstraQueuesSeen);!(r=n()).done;){var a=r.value,i=t[a]||null;e.add("blomstra-queue-size-"+a,[m("strong",null,"Queue ",a),m("br",null),i||"0"])}}))}))}]);
//# sourceMappingURL=admin.js.map //# sourceMappingURL=admin.js.map

File diff suppressed because one or more lines are too long

4953
js/package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -2,17 +2,20 @@
"name": "@glowingblue/redis-setup", "name": "@glowingblue/redis-setup",
"version": "0.0.0", "version": "0.0.0",
"private": true, "private": true,
"prettier": "@glowingblue-dev/prettier-config",
"dependencies": { "dependencies": {
"flarum-webpack-config": "^0.1.0-beta.10", "flarum-webpack-config": "^1.0.0",
"webpack": "^4.26.0", "webpack": "^4.26.0",
"webpack-cli": "^3.0.7" "webpack-cli": "^4.9.2"
},
"devDependencies": {
"@glowingblue-dev/prettier-config": "^1.0.0",
"prettier": "^2.6.1"
}, },
"scripts": { "scripts": {
"dev": "webpack --mode development --watch", "dev": "webpack --mode development --watch",
"build": "webpack --mode production", "build": "webpack --mode production",
"lint": "prettier --single-quote --jsx-single-quote --trailing-comma es5 --print-width 100 --use-tabs --tab-width 4 --write src" "format": "prettier --write src",
}, "format-check": "prettier --check src"
"devDependencies": {
"prettier": "^2.3.0"
} }
} }

View File

@@ -1,28 +1,50 @@
/*
* This file is part of glowingblue/redis-setup.
*
* Copyright (c) 2022 Glowing Blue AG.
* Authors: Ian Morland, iPurpl3x, Rafael Horvat.
*
* For the full copyright and license information, please view the LICENSE.md
* file that was distributed with this source code.
*/
import app from 'flarum/admin/app'; import app from 'flarum/admin/app';
import { extend } from 'flarum/common/extend'; import { extend } from 'flarum/common/extend';
import StatusWidget from 'flarum/admin/components/StatusWidget'; import StatusWidget from 'flarum/admin/components/StatusWidget';
import { slug } from '../common';
app.initializers.add('glowingblue-redis-setup', () => { // Make translation calls shorter
const t = app.translator.trans.bind(app.translator);
const prfx = `${slug}.admin.settings`;
app.initializers.add(slug, () => {
app.extensionData app.extensionData
.for('glowingblue-redis-setup') .for(slug)
.registerSetting({ .registerSetting({
setting: 'glowingblue-redis.enableCache', setting: 'glowingblue-redis.enableCache',
type: 'boolean', type: 'boolean',
label: app.translator.trans('glowingblue-redis-setup.admin.settings.enable_cache'), label: t(`${prfx}.enable_cache`),
}) })
.registerSetting({ .registerSetting({
setting: 'glowingblue-redis.redisSessions', setting: 'glowingblue-redis.redisSessions',
type: 'boolean', type: 'boolean',
label: app.translator.trans( label: t(`${prfx}.enable_redis_sessions`),
'glowingblue-redis-setup.admin.settings.enable_redis_sessions'
),
}) })
.registerSetting({ .registerSetting({
setting: 'glowingblue-redis.enableQueue', setting: 'glowingblue-redis.enableQueue',
type: 'boolean', type: 'boolean',
label: app.translator.trans('glowingblue-redis-setup.admin.settings.enable_queue'), label: t(`${prfx}.enable_queue`),
}); });
if (app.initializers.has('blomstra/horizon')) {
app.extensionData.for(slug).registerSetting({
setting: 'glowingblue-redis.horizonConfig',
type: 'textarea',
label: t(`${prfx}.horizon_config`),
help: t(`${prfx}.horizon_help_text`),
});
}
extend(StatusWidget.prototype, 'items', (items) => { extend(StatusWidget.prototype, 'items', (items) => {
const loads = app.data.blomstraQueuesLoad; const loads = app.data.blomstraQueuesLoad;

11
js/src/common/index.js Normal file
View File

@@ -0,0 +1,11 @@
/*
* This file is part of glowingblue/redis-setup.
*
* Copyright (c) 2022 Glowing Blue AG.
* Authors: Rafael Horvat.
*
* For the full copyright and license information, please view the LICENSE.md
* file that was distributed with this source code.
*/
export const slug = 'glowingblue-redis-setup';

4083
js/yarn.lock Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -2,5 +2,8 @@ glowingblue-redis-setup:
admin: admin:
settings: settings:
enable_cache: Enable Redis cache enable_cache: Enable Redis cache
enable_redis_sessions: Enable Redis sessions (all users will be logged out after changing this setting) enable_redis_sessions:
Enable Redis sessions (all users will be logged out after changing this setting)
enable_queue: Enable Redis queue enable_queue: Enable Redis queue
horizon_config: "Horizon config (format: JSON)."
horizon_help_text: This will be passed to <code>(new \Blomstra\Horizon\Extend\Horizon)->config(...))</code>

View File

@@ -0,0 +1,45 @@
<?php
/*
* This file is part of glowingblue/redis-setup.
*
* Copyright (c) 2022 Glowing Blue AG.
* Authors: Rafael Horvat.
*
* For the full copyright and license information, please view the LICENSE.md
* file that was distributed with this source code.
*/
namespace GlowingBlue\RedisSetup\Extend;
use Blomstra\Horizon\Extend\Horizon;
use Flarum\Extend\ExtenderInterface;
use Flarum\Extension\Extension;
use Flarum\Extension\ExtensionManager;
use Flarum\Settings\SettingsRepositoryInterface;
use Illuminate\Contracts\Container\Container;
class ConfigureHorizon implements ExtenderInterface
{
public function extend(Container $container, Extension $extension = null)
{
$extensions = resolve(ExtensionManager::class);
if (!$extensions->isEnabled('blomstra-horizon') || !class_exists(Horizon::class)) {
return;
}
/** @var SettingsRepositoryInterface */
$settings = resolve(SettingsRepositoryInterface::class);
$config = json_decode($settings->get('glowingblue-redis.horizonConfig', '[]'), true);
if (!is_array($config) || empty($config)) {
return;
}
(new Horizon())
->config($config)
->extend($container, $extension);
}
}

View File

@@ -1,5 +1,15 @@
<?php <?php
/*
* This file is part of glowingblue/redis-setup.
*
* Copyright (c) 2022 Glowing Blue AG.
* Authors: Ian Morland, iPurpl3x, Rafael Horvat.
*
* For the full copyright and license information, please view the LICENSE.md
* file that was distributed with this source code.
*/
namespace GlowingBlue\RedisSetup\Extend; namespace GlowingBlue\RedisSetup\Extend;
use Blomstra\Redis\Extend\Redis; use Blomstra\Redis\Extend\Redis;
@@ -19,9 +29,9 @@ class EnableRedis implements ExtenderInterface
{ {
$config = $this->buildConfig(); $config = $this->buildConfig();
if (Arr::hasAny($config, [self::CACHE_KEY, self::QUEUE_KEY, self::SESSION_KEY])) { (new Redis($config))
(new Redis($config))->disable($this->getDisabledServices())->extend($container, $extension); ->disable($this->getDisabledServices())
} ->extend($container, $extension);
} }
private function getDisabledServices(): array private function getDisabledServices(): array
@@ -46,19 +56,14 @@ class EnableRedis implements ExtenderInterface
return $disabled; return $disabled;
} }
private function buildConfig(): array private function buildConfig($config = []): array
{ {
if ($this->getHost() === null) {
return [];
}
$config = [];
$cache = [ $cache = [
'host' => $this->getHost(), 'host' => $this->getHost(),
'password' => $this->getPassword(), 'password' => $this->getPassword(),
'port' => $this->getPort(), 'port' => $this->getPort(),
'database' => $this->getCacheDatabase(), 'database' => $this->getCacheDatabase(),
'prefix' => $this->getPrefix(),
]; ];
$queue = [ $queue = [
@@ -66,6 +71,7 @@ class EnableRedis implements ExtenderInterface
'password' => $this->getPassword(), 'password' => $this->getPassword(),
'port' => $this->getPort(), 'port' => $this->getPort(),
'database' => $this->getQueueDatabase(), 'database' => $this->getQueueDatabase(),
'prefix' => $this->getPrefix(),
]; ];
$session = [ $session = [
@@ -73,6 +79,7 @@ class EnableRedis implements ExtenderInterface
'password' => $this->getPassword(), 'password' => $this->getPassword(),
'port' => $this->getPort(), 'port' => $this->getPort(),
'database' => $this->getSessionDatabase(), 'database' => $this->getSessionDatabase(),
'prefix' => $this->getPrefix(),
]; ];
$config = Arr::add($config, self::CACHE_KEY, $cache); $config = Arr::add($config, self::CACHE_KEY, $cache);
@@ -82,9 +89,9 @@ class EnableRedis implements ExtenderInterface
return $config; return $config;
} }
private function getHost(): ?string private function getHost(): string
{ {
return getenv('REDIS_HOST') ? getenv('REDIS_HOST') : null; return getenv('REDIS_HOST') ? getenv('REDIS_HOST') : '127.0.0.1';
} }
private function getPassword(): ?string private function getPassword(): ?string
@@ -111,4 +118,9 @@ class EnableRedis implements ExtenderInterface
{ {
return (int) getenv('REDIS_DATABASE_SESSION') ? getenv('REDIS_DATABASE_SESSION') : 3; return (int) getenv('REDIS_DATABASE_SESSION') ? getenv('REDIS_DATABASE_SESSION') : 3;
} }
private function getPrefix(): string
{
return getenv('REDIS_PREFIX') ? getenv('REDIS_PREFIX') : 'flarum_';
}
} }

View File

@@ -1,5 +1,15 @@
<?php <?php
/*
* This file is part of glowingblue/redis-setup.
*
* Copyright (c) 2022 Glowing Blue AG.
* Authors: iPurpl3x, Ian Morland, Rafael Horvat.
*
* For the full copyright and license information, please view the LICENSE.md
* file that was distributed with this source code.
*/
namespace GlowingBlue\RedisSetup\Provider; namespace GlowingBlue\RedisSetup\Provider;
use Flarum\Extend\Frontend; use Flarum\Extend\Frontend;