forked from clone/flarum-ext-redis-setup
Compare commits
20 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
69c73e2397 | ||
|
|
c2ddd30cd7 | ||
|
|
f3e8fc0243 | ||
|
|
8f82fbe078 | ||
|
|
4e668a4098 | ||
|
|
68b5b8f871 | ||
|
|
27601d7f61 | ||
|
|
4d7828548b | ||
|
|
9a0fe54c37 | ||
|
|
b308a07d8d | ||
|
|
c167010796 | ||
|
|
e94701d39c | ||
|
|
57f7647fc3 | ||
|
|
8c976e3fc0 | ||
|
|
590d0084c5 | ||
|
|
fcd833a248 | ||
|
|
3284a36926 | ||
|
|
68af330669 | ||
|
|
09a30f786d | ||
|
|
68a5cafdfc |
16
.editorconfig
Normal file
16
.editorconfig
Normal 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
|
||||
95
.github/workflows/build.yml
vendored
95
.github/workflows/build.yml
vendored
@@ -1,16 +1,91 @@
|
||||
name: Build JavaScript assets
|
||||
name: JS
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
on: [workflow_dispatch, push, pull_request]
|
||||
|
||||
env:
|
||||
NODE_VERSION: 16
|
||||
|
||||
jobs:
|
||||
build:
|
||||
prettier:
|
||||
name: Prettier
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@master
|
||||
- uses: flarum/action-build@master
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
- 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
154
.gitignore
vendored
@@ -1,5 +1,5 @@
|
||||
# Created by https://www.toptal.com/developers/gitignore/api/vim,yarn,node,linux,macos,windows,visualstudiocode,composer
|
||||
# Edit at https://www.toptal.com/developers/gitignore?templates=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,macos,linux,windows,composer,visualstudiocode,jetbrains
|
||||
|
||||
### Composer ###
|
||||
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
|
||||
# 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 ###
|
||||
*~
|
||||
@@ -33,6 +136,7 @@ composer.phar
|
||||
# Icon must end with two \r
|
||||
Icon
|
||||
|
||||
|
||||
# Thumbnails
|
||||
._*
|
||||
|
||||
@@ -61,6 +165,9 @@ yarn-debug.log*
|
||||
yarn-error.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)
|
||||
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
|
||||
|
||||
@@ -108,6 +215,9 @@ typings/
|
||||
# Optional eslint cache
|
||||
.eslintcache
|
||||
|
||||
# Optional stylelint cache
|
||||
.stylelintcache
|
||||
|
||||
# Microbundle cache
|
||||
.rpt2_cache/
|
||||
.rts2_cache_cjs/
|
||||
@@ -126,9 +236,11 @@ typings/
|
||||
# dotenv environment variables file
|
||||
.env
|
||||
.env.test
|
||||
.env*.local
|
||||
|
||||
# parcel-bundler cache (https://parceljs.org/)
|
||||
.cache
|
||||
.parcel-cache
|
||||
|
||||
# Next.js build output
|
||||
.next
|
||||
@@ -137,6 +249,14 @@ typings/
|
||||
.nuxt
|
||||
# dist
|
||||
|
||||
# Storybook build outputs
|
||||
.out
|
||||
.storybook-out
|
||||
storybook-static
|
||||
|
||||
# rollup.js default build output
|
||||
# dist/
|
||||
|
||||
# Gatsby files
|
||||
.cache/
|
||||
# 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
|
||||
.vscode-test
|
||||
|
||||
# Temporary folders
|
||||
tmp/
|
||||
temp/
|
||||
|
||||
### Vim ###
|
||||
# Swap
|
||||
[._]*.s[a-v][a-z]
|
||||
@@ -183,15 +307,14 @@ tags
|
||||
|
||||
### VisualStudioCode ###
|
||||
.vscode/*
|
||||
!.vscode/settings.json
|
||||
!.vscode/tasks.json
|
||||
!.vscode/launch.json
|
||||
!.vscode/extensions.json
|
||||
*.code-workspace
|
||||
|
||||
### VisualStudioCode Patch ###
|
||||
# Ignore all local history of files
|
||||
.history
|
||||
.ionide
|
||||
|
||||
### Windows ###
|
||||
# Windows thumbnail cache files
|
||||
@@ -222,16 +345,17 @@ $RECYCLE.BIN/
|
||||
### yarn ###
|
||||
# https://yarnpkg.com/advanced/qa#which-files-should-be-gitignored
|
||||
|
||||
# .yarn/unplugged and .yarn/build-state.yml should likely always be ignored since
|
||||
# they typically hold machine-specific build artifacts. Ignoring them might however
|
||||
# prevent Zero-Installs from working (to prevent this, set enableScripts to false).
|
||||
.yarn/unplugged
|
||||
.yarn/build-state.yml
|
||||
.yarn/*
|
||||
!.yarn/releases
|
||||
!.yarn/plugins
|
||||
!.yarn/sdks
|
||||
!.yarn/versions
|
||||
|
||||
# .yarn/cache and .pnp.* may be safely ignored, but you'll need to run yarn install
|
||||
# to regenerate them between each branch switch.
|
||||
# Uncomment the following lines if you're not using Zero-Installs:
|
||||
# .yarn/cache
|
||||
# if you are NOT using Zero-installs, then:
|
||||
# comment the following lines
|
||||
!.yarn/cache
|
||||
|
||||
# and uncomment the following lines
|
||||
# .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
19
.prettierrc
Normal 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
11
.vscode/extension.json
vendored
Normal 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
17
.vscode/launch.json
vendored
Normal 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
70
.vscode/settings.json
vendored
Normal 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"
|
||||
]
|
||||
}
|
||||
17
LICENSE.md
17
LICENSE.md
@@ -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.
|
||||
|
||||
12
README.md
12
README.md
@@ -1,6 +1,8 @@
|
||||
# ⚡️ Redis Setup
|
||||
|
||||
[](https://github.com/glowingblue/flarum-ext-redis-setup/blob/master/LICENSE.md) [](https://packagist.org/packages/glowingblue/redis-setup) [](https://packagist.org/packages/glowingblue/redis-setup)
|
||||
[](https://github.com/glowingblue/flarum-ext-redis-setup/blob/master/LICENSE.md)
|
||||
[](https://packagist.org/packages/glowingblue/redis-setup)
|
||||
[](https://packagist.org/packages/glowingblue/redis-setup)
|
||||
|
||||
A [Flarum](http://flarum.org) extension.
|
||||
|
||||
@@ -10,15 +12,17 @@ Makes it easy to enable/disable Redis features:
|
||||
- Queue
|
||||
- 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
|
||||
REDIS_HOST=null # Required
|
||||
REDIS_HOST='127.0.0.1 # 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_QUEUE=2 # Optional, else uses default
|
||||
REDIS_DATABASE_SESSION=3 # Optional, else uses default
|
||||
REDIS_PREFIX='flarum_' # Optional, else uses default
|
||||
```
|
||||
|
||||
## 📥 Installation
|
||||
|
||||
@@ -2,7 +2,11 @@
|
||||
"name": "glowingblue/redis-setup",
|
||||
"description": "Makes it easy to enable/disable Redis features: Cache, Queue & Sessions",
|
||||
"keywords": [
|
||||
"flarum", "redis", "cache", "queue", "session"
|
||||
"flarum",
|
||||
"redis",
|
||||
"cache",
|
||||
"queue",
|
||||
"session"
|
||||
],
|
||||
"type": "flarum-extension",
|
||||
"license": "MIT",
|
||||
@@ -14,7 +18,7 @@
|
||||
},
|
||||
"homepage": "https://glowingblue.com",
|
||||
"require": {
|
||||
"flarum/core": "^1.0.0",
|
||||
"flarum/core": "^1.2.0",
|
||||
"blomstra/flarum-redis": "^0.4.0"
|
||||
},
|
||||
"authors": [
|
||||
@@ -22,6 +26,15 @@
|
||||
"name": "IanM",
|
||||
"homepage": "https://discuss.flarum.org/u/ianm",
|
||||
"role": "Developer"
|
||||
},
|
||||
{
|
||||
"name": "Glowing Blue AG",
|
||||
"homepage": "https://glowingblue.com",
|
||||
"role": "Developer"
|
||||
},
|
||||
{
|
||||
"name": "Rafael Horvat",
|
||||
"role": "Developer"
|
||||
}
|
||||
],
|
||||
"autoload": {
|
||||
@@ -37,7 +50,13 @@
|
||||
"name": "fas fa-tasks",
|
||||
"backgroundColor": "#00a7e3",
|
||||
"color": "#fff"
|
||||
}
|
||||
},
|
||||
"optional-dependencies": [
|
||||
"blomstra/horizon"
|
||||
]
|
||||
},
|
||||
"extiverse": {
|
||||
"discuss": "https://discuss.flarum.org/d/27455"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
10
extend.php
10
extend.php
@@ -3,7 +3,8 @@
|
||||
/*
|
||||
* 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
|
||||
* file that was distributed with this source code.
|
||||
@@ -12,7 +13,7 @@
|
||||
namespace GlowingBlue\RedisSetup;
|
||||
|
||||
use Flarum\Extend;
|
||||
use GlowingBlue\RedisSetup\Extend\EnableRedis;
|
||||
use GlowingBlue\RedisSetup\Extend as GBExtend;
|
||||
use GlowingBlue\RedisSetup\Provider\QueueProvider;
|
||||
|
||||
return [
|
||||
@@ -21,8 +22,9 @@ return [
|
||||
|
||||
new Extend\Locales(__DIR__ . '/resources/locale'),
|
||||
|
||||
new GBExtend\ConfigureHorizon(),
|
||||
new GBExtend\EnableRedis(),
|
||||
|
||||
(new Extend\ServiceProvider())
|
||||
->register(QueueProvider::class),
|
||||
|
||||
new EnableRedis()
|
||||
];
|
||||
|
||||
2
js/dist/admin.js
vendored
2
js/dist/admin.js
vendored
@@ -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"])}}))}))}]);
|
||||
(()=>{var e={n:t=>{var r=t&&t.__esModule?()=>t.default:()=>t;return e.d(r,{a:r}),r},d:(t,r)=>{for(var n in r)e.o(r,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:r[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};(()=>{"use strict";e.r(t);const r=flarum.core.compat["admin/app"];var n=e.n(r);const o=flarum.core.compat["common/extend"],a=flarum.core.compat["admin/components/StatusWidget"];var i=e.n(a),l="glowingblue-redis-setup";function s(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 u=n().translator.trans.bind(n().translator),d=l+".admin.settings";n().initializers.add(l,(function(){n().extensionData.for(l).registerSetting({setting:"glowingblue-redis.enableCache",type:"boolean",label:u(d+".enable_cache")}).registerSetting({setting:"glowingblue-redis.redisSessions",type:"boolean",label:u(d+".enable_redis_sessions")}).registerSetting({setting:"glowingblue-redis.enableQueue",type:"boolean",label:u(d+".enable_queue")}),n().initializers.has("blomstra/horizon")&&n().extensionData.for(l).registerSetting({setting:"glowingblue-redis.horizonConfig",type:"textarea",label:u(d+".horizon_config"),help:u(d+".horizon_help_text")}),(0,o.extend)(i().prototype,"items",(function(e){var t=n().data.blomstraQueuesLoad;if(void 0!==t)for(var r,o=function(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){if("string"==typeof e)return s(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?s(e,t):void 0}}(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.")}(n().data.blomstraQueuesSeen);!(r=o()).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"])}}))}))})(),module.exports=t})();
|
||||
//# sourceMappingURL=admin.js.map
|
||||
2
js/dist/admin.js.map
vendored
2
js/dist/admin.js.map
vendored
File diff suppressed because one or more lines are too long
4953
js/package-lock.json
generated
4953
js/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -2,17 +2,20 @@
|
||||
"name": "@glowingblue/redis-setup",
|
||||
"version": "0.0.0",
|
||||
"private": true,
|
||||
"prettier": "@glowingblue-dev/prettier-config",
|
||||
"dependencies": {
|
||||
"flarum-webpack-config": "^0.1.0-beta.10",
|
||||
"webpack": "^4.26.0",
|
||||
"webpack-cli": "^3.0.7"
|
||||
"flarum-webpack-config": "^2.0.0",
|
||||
"webpack": "^5.72.0",
|
||||
"webpack-cli": "^4.9.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@glowingblue-dev/prettier-config": "^1.0.0",
|
||||
"prettier": "^2.6.1"
|
||||
},
|
||||
"scripts": {
|
||||
"dev": "webpack --mode development --watch",
|
||||
"build": "webpack --mode production",
|
||||
"lint": "prettier --single-quote --jsx-single-quote --trailing-comma es5 --print-width 100 --use-tabs --tab-width 4 --write src"
|
||||
},
|
||||
"devDependencies": {
|
||||
"prettier": "^2.3.0"
|
||||
"format": "prettier --write src",
|
||||
"format-check": "prettier --check src"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 { extend } from 'flarum/common/extend';
|
||||
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
|
||||
.for('glowingblue-redis-setup')
|
||||
.for(slug)
|
||||
.registerSetting({
|
||||
setting: 'glowingblue-redis.enableCache',
|
||||
type: 'boolean',
|
||||
label: app.translator.trans('glowingblue-redis-setup.admin.settings.enable_cache'),
|
||||
label: t(`${prfx}.enable_cache`),
|
||||
})
|
||||
.registerSetting({
|
||||
setting: 'glowingblue-redis.redisSessions',
|
||||
type: 'boolean',
|
||||
label: app.translator.trans(
|
||||
'glowingblue-redis-setup.admin.settings.enable_redis_sessions'
|
||||
),
|
||||
label: t(`${prfx}.enable_redis_sessions`),
|
||||
})
|
||||
.registerSetting({
|
||||
setting: 'glowingblue-redis.enableQueue',
|
||||
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) => {
|
||||
const loads = app.data.blomstraQueuesLoad;
|
||||
|
||||
|
||||
11
js/src/common/index.js
Normal file
11
js/src/common/index.js
Normal 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';
|
||||
2319
js/yarn.lock
Normal file
2319
js/yarn.lock
Normal file
File diff suppressed because it is too large
Load Diff
@@ -2,5 +2,8 @@ glowingblue-redis-setup:
|
||||
admin:
|
||||
settings:
|
||||
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
|
||||
horizon_config: "Horizon config (format: JSON)."
|
||||
horizon_help_text: This will be passed to <code>(new \Blomstra\Horizon\Extend\Horizon)->config(...))</code>
|
||||
|
||||
45
src/Extend/ConfigureHorizon.php
Normal file
45
src/Extend/ConfigureHorizon.php
Normal 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);
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,15 @@
|
||||
<?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;
|
||||
|
||||
use Blomstra\Redis\Extend\Redis;
|
||||
@@ -19,9 +29,9 @@ class EnableRedis implements ExtenderInterface
|
||||
{
|
||||
$config = $this->buildConfig();
|
||||
|
||||
if (Arr::hasAny($config, [self::CACHE_KEY, self::QUEUE_KEY, self::SESSION_KEY])) {
|
||||
(new Redis($config))->disable($this->getDisabledServices())->extend($container, $extension);
|
||||
}
|
||||
(new Redis($config))
|
||||
->disable($this->getDisabledServices())
|
||||
->extend($container, $extension);
|
||||
}
|
||||
|
||||
private function getDisabledServices(): array
|
||||
@@ -46,19 +56,14 @@ class EnableRedis implements ExtenderInterface
|
||||
return $disabled;
|
||||
}
|
||||
|
||||
private function buildConfig(): array
|
||||
private function buildConfig($config = []): array
|
||||
{
|
||||
if ($this->getHost() === null) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$config = [];
|
||||
|
||||
$cache = [
|
||||
'host' => $this->getHost(),
|
||||
'password' => $this->getPassword(),
|
||||
'port' => $this->getPort(),
|
||||
'database' => $this->getCacheDatabase(),
|
||||
'prefix' => $this->getPrefix(),
|
||||
];
|
||||
|
||||
$queue = [
|
||||
@@ -66,6 +71,7 @@ class EnableRedis implements ExtenderInterface
|
||||
'password' => $this->getPassword(),
|
||||
'port' => $this->getPort(),
|
||||
'database' => $this->getQueueDatabase(),
|
||||
'prefix' => $this->getPrefix(),
|
||||
];
|
||||
|
||||
$session = [
|
||||
@@ -73,6 +79,7 @@ class EnableRedis implements ExtenderInterface
|
||||
'password' => $this->getPassword(),
|
||||
'port' => $this->getPort(),
|
||||
'database' => $this->getSessionDatabase(),
|
||||
'prefix' => $this->getPrefix(),
|
||||
];
|
||||
|
||||
$config = Arr::add($config, self::CACHE_KEY, $cache);
|
||||
@@ -82,9 +89,9 @@ class EnableRedis implements ExtenderInterface
|
||||
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
|
||||
@@ -111,4 +118,9 @@ class EnableRedis implements ExtenderInterface
|
||||
{
|
||||
return (int) getenv('REDIS_DATABASE_SESSION') ? getenv('REDIS_DATABASE_SESSION') : 3;
|
||||
}
|
||||
|
||||
private function getPrefix(): string
|
||||
{
|
||||
return getenv('REDIS_PREFIX') ? getenv('REDIS_PREFIX') : 'flarum_';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,15 @@
|
||||
<?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;
|
||||
|
||||
use Flarum\Extend\Frontend;
|
||||
|
||||
Reference in New Issue
Block a user